Grok is xAI's family of large language models, built into the X (formerly Twitter) app and also accessible to developers through a standalone xAI API. It ranks #10 in usage share at roughly 11.1%. Grok is known for two things most competitors don't offer: real-time access to live X posts as a data source, and a more unfiltered, casual conversational personality than most mainstream assistants.
The xAI API is OpenAI-compatible โ you can use the standard OpenAI Python SDK and just point base_url at xAI's endpoint.
from openai import OpenAI
client = OpenAI(
api_key="YOUR_XAI_API_KEY",
base_url="https://api.x.ai/v1"
)
response = client.chat.completions.create(
model="grok-3",
messages=[{"role": "user", "content": "What are people on X saying about today's tech news?"}]
)
print(response.choices[0].message.content)
Create an xAI account, generate an API key from the developer console, and install the OpenAI SDK to call it.
# 1. sign up and get an API key at console.x.ai
# 2. install the OpenAI-compatible SDK
pip install openai
# 3. set your key
export XAI_API_KEY="your-key-here"