xAI Grok routing

xAI Grok router for API-key authorized agents

Use Sage Router as the policy layer around xAI Grok API routes. Keep XAI_API_KEY under your custody, expose one OpenAI-compatible endpoint to agents, and fail over to other authorized coding, frontier, local, or multimodal routes when a key, model, or provider path is unhealthy.

Create API key Read quickstart OpenAI-compatible setup Browse models

xAI API key custody

Configure Grok as an authorized provider route using your own XAI_API_KEY. Sage Router supports API-key mode; it does not proxy xAI SSO sessions or grant unauthorized Grok access.

OpenAI-compatible setup

Point OpenAI SDKs, Codex, Cursor, Aider, Continue, OpenHands, and gateway-compatible clients at https://api.sagerouter.dev/v1 while the router chooses Grok, OpenAI, Anthropic, Gemini, Ollama, NVIDIA NIM, or private routes by policy.

429 failover

When a Grok key, model route, or fallback provider rate-limits, Sage Router can choose another eligible authorized route instead of making every agent own retry and fallback logic.

60-second xAI Grok setup

export OPENAI_BASE_URL=https://api.sagerouter.dev/v1
export OPENAI_API_KEY=sk_sage_your_generated_key
export XAI_API_KEY=xai-your_authorized_key

curl "$OPENAI_BASE_URL/chat/completions" \
  -H "Authorization: Bearer $OPENAI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "sage-router/frontier",
    "messages": [{"role": "user", "content": "Use Grok if it is the best healthy authorized route"}]
  }'

Credential load balancing

Credential pools can distribute traffic across authorized xAI keys and fail over when one key is exhausted, revoked, rate-limited, or unhealthy.

Multimodal safeguards

Image, audio, video, and document inputs route only to capable models, so auto and agentic profiles do not send multimodal work to incompatible routes.

Provider boundary

Public Sage Router plans sell routing, generated keys, quotas, and telemetry. They do not include bundled xAI resale or xAI SSO proxying.

Why route Grok traffic?

Grok is another useful frontier route, but production agents still need provider policy, 429 failover, key rotation, route observability, multimodal capability gates, and local escape hatches. Sage Router keeps Grok in the matrix without making it the only path.

Next steps

Create an API key, copy the hosted quickstart, use the OpenAI-compatible setup, or estimate routing fit.