Developer Quickstart

Get Started in 3 Minutes

Replace your OpenAI base URL and API key. Your existing code works instantly — zero rewrites, drop-in compatible.

Three Steps

You are three steps away from running inference on 200+ models.

1

Create your API key

Visit the API Keys page and click Create Key. Copy it immediately — it is shown only once. Set it as an environment variable:
$export SEVENXAI_API_KEY="sk-..."
2

Replace your base URL

Change the base URL in your OpenAI SDK client from https://api.openai.com/v1 to https://api.7xai.com/v1. That is the only code change required.
3

Make your first request

Run any of the examples below. The response format is identical to OpenAI — every field is in the same place.

Code Examples

Drop-in replacement for the OpenAI SDK. Same client, same methods, different base URL.

bashcURL
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?"}
    ]
  }'
pythonPython (openai SDK)
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)
javascriptNode.js (openai SDK)
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);
bashStreaming (cURL)
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
  }'
pythonStreaming (Python)
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="")

Available Models

All models are accessible through the same /v1/chat/completions endpoint. Change the model field to switch.

DeepSeek V3

deepseek-chat

128K

General-purpose chat with excellent reasoning and coding capabilities.

Provider: DeepSeek

DeepSeek R1

deepseek-reasoner

128K

Advanced reasoning model with chain-of-thought. Ideal for math, logic, and analysis.

Provider: DeepSeek

Qwen Max

qwen-max

32K

Top-tier multilingual model with strong Chinese and English performance.

Provider: Alibaba

Qwen Plus

qwen-plus

128K

Balanced performance and speed for everyday tasks.

Provider: Alibaba

GPT-4o

gpt-4o

128K

Flagship multimodal model with vision, fast response times.

Provider: OpenAI

Claude 3.5 Sonnet

claude-3-5-sonnet

200K

Best-in-class coding, writing, and nuanced instruction following.

Provider: Anthropic

Gemini 2.0 Flash

gemini-2.0-flash

1M

Fast, efficient model with strong multimodal capabilities.

Provider: Google

Doubao Pro

doubao-pro

128K

Cost-effective Chinese-English model for production workloads.

Provider: ByteDance

Llama 4

llama-4

128K

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.

Embeddings

Generate vector embeddings for semantic search, clustering, and RAG pipelines.

bashEmbeddings (cURL)
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"
  }'
pythonEmbeddings (Python)
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. 1536

Error Codes Reference

The API uses standard HTTP status codes. Errors return a JSON body with code and message fields.

HTTP StatusCodeDescription
200OKRequest succeeded.
400BAD_REQUESTMalformed request body or invalid parameters.
401UNAUTHORIZEDMissing or invalid API key. Check your Authorization header.
402INSUFFICIENT_CREDITSYour account balance is too low for this request. Top up in the console.
403FORBIDDENYour API key does not have permission for this resource.
404NOT_FOUNDThe requested model, agent, or endpoint does not exist.
413PAYLOAD_TOO_LARGERequest body exceeds the maximum size limit.
429RATE_LIMITEDToo many requests. Check the Retry-After header and back off.
500INTERNAL_ERRORAn unexpected server error occurred. 7XAI is alerted automatically.
503SERVICE_UNAVAILABLEService is temporarily overloaded or under maintenance. Retry with exponential backoff.

Rate Limits

Rate limits ensure fair usage across all tenants. Limits apply per API key.

Free

Requests60/min
Concurrency5 concurrent

Pro

Requests600/min
Concurrency25 concurrent

Team

Requests3,000/min
Concurrency100 concurrent

Enterprise

RequestsCustom
ConcurrencyCustom

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.

Ready to build?

Create your free API key and start making requests in under three minutes. No credit card required.