You can query data within 3 years
Today
Today's Quota Status
Syncing today's request limits, token limits, and credit card status.
Card Usage Progress
Total Cost
\$0.00
Total Requests
0
Web Searches
0
Images
0
Total Tokens
0
Input Tokens
0
Output Tokens
0
Cache R/W
0
Model Cost Distribution
Model Request Distribution
Model Usage Details
| Model | Requests | Searches | Input Tokens | Output Tokens | Cache R/W | Images | Cost | Percentage |
|---|
Daily Usage Statistics
| Date | Requests | Cost | Tokens | Images | Primary Model |
|---|
My Account
Profile
Update the alias shown in the top-right corner, your login email, and billing notifications
API Key Security
Regenerating your key immediately invalidates the current API Key. Copy the new key and update your local tool configuration.
-
Supported format: XAI API Keys starting with sk-Xvs... Only verified active Keys are retained; abnormal Keys are shown once and then removed.
Query Results
Supported AI Service Providers
The XAI platform is compatible with virtually all major AI providers and model ecosystems, supporting unified integration and flexible switching.
How It Works
One entrypoint handles auth, routing, and normalization before reaching model providers.
Single entrypoint
Use one XAI API key and a unified base_url.
Smart routing
Policies, model mapping, rate limits, and observability live in the router.
Provider fan-out
Requests go to OpenAI, Claude, Gemini, and more, then normalize on the way back.
SDK Examples
OpenAI SDK Example
import os
from openai import OpenAI
XAI_API_KEY = os.getenv("XAI_API_KEY")
client = OpenAI(
api_key=XAI_API_KEY,
base_url="",
)
completion = client.chat.completions.create(
model="gpt-5",
messages=[
{"role": "system", "content": "You are AI"},
{"role": "user", "content": "What is the meaning of life, the universe, and everything?"},
],
)
print(completion.choices[0].message)
Anthropic SDK Example
import os
from anthropic import Anthropic
XAI_API_KEY = os.getenv("XAI_API_KEY")
client = Anthropic(
api_key=XAI_API_KEY,
base_url="",
)
message = client.messages.create(
model="claude-sonnet-5",
max_tokens=128,
system="You are AI.",
messages=[
{
"role": "user",
"content": "What is the meaning of life, the universe, and everything?",
},
],
)
print(message.content)
cURL Examples
OpenAI /responses
curl /responses \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $XAI_API_KEY" \
-d '{
"model": "gpt-5.6-sol",
"input": "Explain what the Responses API does in one sentence."
}'
OpenAI /chat/completions
curl /chat/completions \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $XAI_API_KEY" \
-d '{
"model": "gpt-5.2",
"messages": [
{
"role": "developer",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Hello!"
}
]
}'
Images API /v1/images/generations
curl /v1/images/generations \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $XAI_API_KEY" \
-d '{
"model": "gpt-image-2.5-sunburst",
"prompt": "Generate a polished square portrait of a professional XAI AI assistant in a bright futuristic control room. No text, no logos, no watermark.",
"size": "1024x1024",
"quality": "high",
"output_format": "png"
}' | jq -r '.data[0].b64_json' | base64 -d > xai-image.png
Images API /v1/images/edits
curl /v1/images/edits \
-H "Authorization: Bearer $XAI_API_KEY" \
-F "model=gpt-image-2.5-sunburst" \
-F "[email protected]" \
-F "prompt=Keep the same assistant identity and pose, but make the lighting brighter and add subtle floating interface panels. No text, no logos, no watermark." \
-F "size=1024x1024" \
-F "quality=high" \
-F "output_format=png" \
| jq -r '.data[0].b64_json' | base64 -d > xai-image-edited.png
Anthropic /messages
curl /v1/messages \
-H 'Content-Type: application/json' \
-H 'anthropic-version: 2023-06-01' \
-H "X-Api-Key: $XAI_API_KEY" \
-d '{
"max_tokens": 1024,
"messages": [
{
"content": "Hello, world",
"role": "user"
}
],
"model": "claude-sonnet-5"
}'
Create New Sub-account
API Call Examples
cURL
Python
JavaScript
Fund/Deduct Sub-account
API Call Examples
cURL
Python
JavaScript
Recharge History
No recharge records
Digital Goods Orders
No digital goods orders
Configuration Guide
Unified setup notes for Codex CLI / Codex App / Claude Code / OpenCode.
Unified prerequisite: all examples use the XAI Router gateway.
The page fills the compatible endpoint and current login key for each tool, so
users do not need to choose between OpenAI and Anthropic endpoints manually. Codex
writes to ~/.codex/auth.json, Claude Code uses
ANTHROPIC_AUTH_TOKEN, and OpenCode uses
XAI_API_KEY.
Codex CLI / Codex App
We recommend gpt-6-astra with wire_api = "responses" over HTTP
for compatibility with common network environments.
On Linux / macOS, copy the one-shot command below first: the page
inserts the current XAI API Key automatically, so the user only needs to paste it into a terminal.
Both regular and plan modes use xhigh reasoning effort. The context window
is set to 872000, and Codex calculates the automatic compaction threshold
from the context window.
Manual setup only needs two files: ~/.codex/config.toml and
~/.codex/auth.json. On Windows, use
%USERPROFILE%\.codex\config.toml and
%USERPROFILE%\.codex\auth.json.
Recommended: Linux / macOS one-shot setup
[ -e ~/.codex ] && mv ~/.codex ~/.codex.bk;mkdir -p ~/.codex
cat > ~/.codex/config.toml <<'EOF'
model_provider = "xai"
model = "gpt-6-astra"
model_context_window = 872000
model_reasoning_effort = "xhigh"
plan_mode_reasoning_effort = "xhigh"
model_reasoning_summary = "none"
approval_policy = "never"
sandbox_mode = "danger-full-access"
suppress_unstable_features_warning = true
[model_providers.xai]
name = "OpenAI"
base_url = ""
wire_api = "responses"
experimental_bearer_token = "sk-Xvs..."
requires_openai_auth = false
stream_idle_timeout_ms = 900000
supports_websockets = false
[features]
image_generation = true
goals = true
EOF
cat > ~/.codex/auth.json <<'EOF'
{
"OPENAI_API_KEY": "sk-Xvs..."
}
EOF
chmod 600 ~/.codex/auth.json
When copying the command above, the page automatically inserts the current
XAI API Key into both the config.toml
experimental_bearer_token field and auth.json. If
auth.json is later overwritten by Codex login, model requests still go
through XAI Router.
Fallback: copy ~/.codex/config.toml only
model_provider = "xai"
model = "gpt-6-astra"
model_context_window = 872000
model_reasoning_effort = "xhigh"
plan_mode_reasoning_effort = "xhigh"
model_reasoning_summary = "none"
approval_policy = "never"
sandbox_mode = "danger-full-access"
suppress_unstable_features_warning = true
[model_providers.xai]
name = "OpenAI"
base_url = ""
wire_api = "responses"
experimental_bearer_token = "sk-Xvs..."
requires_openai_auth = false
stream_idle_timeout_ms = 900000
supports_websockets = false
[features]
image_generation = true
goals = true
Fallback: copy ~/.codex/auth.json only
{
"OPENAI_API_KEY": "sk-Xvs..."
}
Windows CMD (create the directory and open files)
if not exist "%USERPROFILE%\.codex" mkdir "%USERPROFILE%\.codex"
notepad "%USERPROFILE%\.codex\config.toml"
notepad "%USERPROFILE%\.codex\auth.json"
codex
Windows PowerShell (create the directory and open files)
New-Item -ItemType Directory -Force "$env:USERPROFILE\.codex" | Out-Null
notepad "$env:USERPROFILE\.codex\config.toml"
notepad "$env:USERPROFILE\.codex\auth.json"
codex
On Windows, paste the TOML and JSON blocks above into the two files Notepad opens,
save them, then run codex.
Claude Code
Claude Code integration is primarily environment-variable based:
set ANTHROPIC_AUTH_TOKEN to the current XAI API Key and
ANTHROPIC_BASE_URL to the gateway address
.
Order: copy the environment variables for your shell first, then
run claude.
Environment variables (Linux / macOS)
export ANTHROPIC_AUTH_TOKEN="sk-Xvs..."
export ANTHROPIC_BASE_URL=""
Environment variables (Windows CMD)
set ANTHROPIC_AUTH_TOKEN=sk-Xvs...
set ANTHROPIC_BASE_URL=
Environment variables (Windows PowerShell)
$env:ANTHROPIC_AUTH_TOKEN="sk-Xvs..."
$env:ANTHROPIC_BASE_URL=""
Launch and verify
claude
Verify with: claude
OpenCode (Responses: gpt-5.6-sol)
OpenCode should use the global config file
~/.config/opencode/opencode.jsonc (Windows:
%USERPROFILE%\.config\opencode\opencode.jsonc).
Write the JSONC below into the config file, then set
XAI_API_KEY in your shell and run the
verification command.
Order: copy the Responses API config first, then copy the shell command for your OS.
Profile A: put this in opencode.jsonc (Responses API)
{
"$schema": "https://opencode.ai/config.json",
"model": "openai/gpt-5.6-sol",
"small_model": "openai/gpt-5.6-sol",
"provider": {
"openai": {
"options": {
"baseURL": "",
"apiKey": "{env:XAI_API_KEY}"
},
"models": {
"gpt-5.6-sol": {
"headers": {
"originator": "opencode"
}
}
}
}
},
"agent": {
"title": {
"options": {
"reasoningEffort": "none"
}
},
"build": {
"variant": "xhigh",
"options": {
"reasoningSummary": "detailed",
"textVerbosity": "high"
}
},
"plan": {
"variant": "xhigh",
"options": {
"reasoningSummary": "detailed",
"textVerbosity": "high"
}
}
},
"permission": {
"*": "allow",
"external_directory": "allow",
"doom_loop": "allow"
}
}
Linux / macOS (set key and verify)
export XAI_API_KEY="sk-Xvs..."
opencode debug config
opencode run "hello"
Windows CMD (set key and verify)
set XAI_API_KEY=sk-Xvs...
opencode debug config
opencode run "hello"
Windows PowerShell (set key and verify)
$env:XAI_API_KEY="sk-Xvs..."
opencode debug config
opencode run "hello"
Verify with: opencode debug config (config) and opencode run "hello" (request)
View Sub-account Information
API Call Examples
cURL
Python
JavaScript
Update Sub-account Information
API Call Examples
cURL
Python
JavaScript
Sub-account List
0 sub-accountsNo sub-accounts yet
This account has no sub-accounts
Delete Sub-account
This action cannot be undone. The sub-account Key will be immediately invalidated.
API Call Examples
cURL
Python
JavaScript
Sub-account Insights
Loading billing data...
Failed to load billing data
Please verify network access and API permissions, then retry
Total Cost
$0.00
Total Requests
0
Web Searches
0
Images
0
Total Tokens
0
Input Tokens
0
Output Tokens
0
Cache R/W
0
Model Cost Distribution
Model Request Distribution
Cost Trend Analysis
Daily Trend
Sub-account Overview
Compare sub-account request and spend distribution to flag anomalies quickly.
| ID | User | Requests | Searches | Input Tokens | Output Tokens | Cache R/W | Images | Highest-Cost Model | Most Requested Model | Spend | Spend Share | Request Share |
|---|
Model Spend & Requests
Summarize request share and cost structure to pinpoint primary cost drivers.
| Model | Requests | Searches | Input | Output | Spend | Request Share | Spend Share |
|---|
Daily Timeline
Review daily totals, model share, and cache activity across the selected range.
Activity Logs
| Time | Action | Target | Details | IP |
|---|
Loading logs...
No activity logs available