Provider

Route xAI (Grok) through Stockyard

Add cost tracking, caching, failover, and 76 middleware modules to your xAI (Grok) requests. One URL change, no SDK swap.

Environment variable
XAI_API_KEY
Models
grok-3, grok-3-mini, grok-2
Failover to
OpenAI GPT-4o, Anthropic Claude, or Groq
API format
OpenAI-compatible

Why proxy xAI (Grok)?

xAI offers Grok models through an OpenAI-compatible API. Proxying through Stockyard adds the operational infrastructure that xAI does not provide: per-request cost tracking, response caching, audit trails, and automatic failover to other providers.

Grok models are competitive on reasoning and coding benchmarks. Using Stockyard, you can route specific workloads to Grok while keeping other requests on OpenAI or Anthropic.

Quick start

# Install Stockyard
curl -fsSL stockyard.dev/install.sh | sh

# Set your xAI (Grok) API key
export XAI_API_KEY=your-key-here

# Start the proxy
stockyard
# Provider: xai (from XAI_API_KEY)
# Proxy listening on :4200

# Send a request through the proxy
curl http://localhost:4200/v1/chat/completions \
  -H "Content-Type: application/json" \
  -d '{"model":"grok-3","messages":[{"role":"user","content":"hello"}]}'

Good to know

xAI uses standard OpenAI-compatible auth. Set XAI_API_KEY and Stockyard auto-detects the provider.

Try Grok alongside other models

Grok is competitive on reasoning and coding benchmarks but you might not want to commit to it as your primary model yet. Stockyard makes it easy to A/B test Grok against GPT-4o or Claude on your actual workload:

# Set up both providers
export XAI_API_KEY=xai-...
export OPENAI_API_KEY=sk-...
stockyard

# Send some traffic to Grok, some to OpenAI
# Compare cost, latency, and quality in the dashboard

Stockyard's cost dashboard shows per-model breakdowns so you can see exactly how Grok compares on your workload before switching.

Route xAI (Grok) through Stockyard in under 60 seconds.

Install Guide

All 16 providers · Proxy-only mode · What is an LLM proxy? · vs LiteLLM · Best self-hosted proxy

Explore: OpenAI · Anthropic · Groq · Install guide