Replace your OpenAI base URL and API key. Your existing code works instantly — zero rewrites, drop-in compatible.
You are three steps away from running inference on 200+ models.
https://api.openai.com/v1 to https://api.7xai.com/v1. That is the only code change required.Drop-in replacement for the OpenAI SDK. Same client, same methods, different base URL.
curl https://api.7xai.com/v1/chat/completions \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "deepseek-chat",
"messages": [
{"role": "user", "content": "Hello! What can you do?"}
]
}'from openai import OpenAI
client = OpenAI(
base_url="https://api.7xai.com/v1",
api_key="YOUR_API_KEY",
)
response = client.chat.completions.create(
model="deepseek-chat",
messages=[
{"role": "user", "content": "Hello! What can you do?"}
],
)
print(response.choices[0].message.content)import OpenAI from 'openai';
const client = new OpenAI({
baseURL: 'https://api.7xai.com/v1',
apiKey: 'YOUR_API_KEY',
});
const response = await client.chat.completions.create({
model: 'deepseek-chat',
messages: [
{ role: 'user', content: 'Hello! What can you do?' },
],
});
console.log(response.choices[0].message.content);curl https://api.7xai.com/v1/chat/completions \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "deepseek-chat",
"messages": [{"role": "user", "content": "Tell me a short story"}],
"stream": true
}'from openai import OpenAI
client = OpenAI(
base_url="https://api.7xai.com/v1",
api_key="YOUR_API_KEY",
)
stream = client.chat.completions.create(
model="deepseek-chat",
messages=[{"role": "user", "content": "Tell me a short story"}],
stream=True,
)
for chunk in stream:
if chunk.choices[0].delta.content:
print(chunk.choices[0].delta.content, end="")All models are accessible through the same /v1/chat/completions endpoint. Change the model field to switch.
deepseek-chat
General-purpose chat with excellent reasoning and coding capabilities.
Provider: DeepSeek
deepseek-reasoner
Advanced reasoning model with chain-of-thought. Ideal for math, logic, and analysis.
Provider: DeepSeek
qwen-max
Top-tier multilingual model with strong Chinese and English performance.
Provider: Alibaba
qwen-plus
Balanced performance and speed for everyday tasks.
Provider: Alibaba
gpt-4o
Flagship multimodal model with vision, fast response times.
Provider: OpenAI
claude-3-5-sonnet
Best-in-class coding, writing, and nuanced instruction following.
Provider: Anthropic
gemini-2.0-flash
Fast, efficient model with strong multimodal capabilities.
Provider: Google
doubao-pro
Cost-effective Chinese-English model for production workloads.
Provider: ByteDance
llama-4
Open-weight model with strong general capabilities.
Provider: Meta
Browse the full catalog on the Models page for pricing, benchmarks, and availability. New models are added weekly.
Generate vector embeddings for semantic search, clustering, and RAG pipelines.
curl https://api.7xai.com/v1/embeddings \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "text-embedding-3-small",
"input": "The quick brown fox jumps over the lazy dog"
}'from openai import OpenAI
client = OpenAI(
base_url="https://api.7xai.com/v1",
api_key="YOUR_API_KEY",
)
response = client.embeddings.create(
model="text-embedding-3-small",
input="The quick brown fox jumps over the lazy dog",
)
print(len(response.data[0].embedding)) # e.g. 1536The API uses standard HTTP status codes. Errors return a JSON body with code and message fields.
| HTTP Status | Code | Description |
|---|---|---|
| 200 | OK | Request succeeded. |
| 400 | BAD_REQUEST | Malformed request body or invalid parameters. |
| 401 | UNAUTHORIZED | Missing or invalid API key. Check your Authorization header. |
| 402 | INSUFFICIENT_CREDITS | Your account balance is too low for this request. Top up in the console. |
| 403 | FORBIDDEN | Your API key does not have permission for this resource. |
| 404 | NOT_FOUND | The requested model, agent, or endpoint does not exist. |
| 413 | PAYLOAD_TOO_LARGE | Request body exceeds the maximum size limit. |
| 429 | RATE_LIMITED | Too many requests. Check the Retry-After header and back off. |
| 500 | INTERNAL_ERROR | An unexpected server error occurred. 7XAI is alerted automatically. |
| 503 | SERVICE_UNAVAILABLE | Service is temporarily overloaded or under maintenance. Retry with exponential backoff. |
Rate limits ensure fair usage across all tenants. Limits apply per API key.
Handling rate limits
When rate-limited, you will receive a 429 response with a Retry-After header. Implement exponential backoff in your client. For sustained high throughput, upgrade your plan or contact sales@7xai.com.
Create your free API key and start making requests in under three minutes. No credit card required.