Documentation
Everything you need to route your first request through the gateway. One line to switch, full control from request one.
01 · Quickstart
Change one line
SwitchGate speaks the OpenAI API. Point any OpenAI-compatible SDK at https://api.switchgate.ai/v1, use your SwitchGate key, and every model in the catalog becomes available.
from openai import OpenAI
client = OpenAI(
base_url="https://api.switchgate.ai/v1", # the only change
api_key="sg-live-…",
)
r = client.chat.completions.create(
model="anthropic/claude-sonnet-4-6",
messages=[{"role": "user", "content": "Bonjour!"}],
)
print(r.choices[0].message.content)
import OpenAI from "openai";
const client = new OpenAI({
baseURL: "https://api.switchgate.ai/v1", // the only change
apiKey: "sg-live-…",
});
const r = await client.chat.completions.create({
model: "anthropic/claude-sonnet-4-6",
messages: [{ role: "user", content: "Bonjour!" }],
});
console.log(r.choices[0].message.content);
curl https://api.switchgate.ai/v1/chat/completions \
-H "Authorization: Bearer sg-live-…" \
-H "Content-Type: application/json" \
-d '{
"model": "anthropic/claude-sonnet-4-6",
"messages": [{"role": "user", "content": "Bonjour!"}]
}'
02 · Authentication
API keys
Keys are created in the console and passed as a bearer token. Two kinds exist: standard keys (sg-live-…) that draw from your account balance, and burnable prepaid keys backed by a fixed credit allocation; when the credits are gone, the key stops working. Burnable keys are ideal for contractors, hackathons, and untrusted agents.
03 · Model IDs
provider/model
Model IDs are namespaced by provider: anthropic/claude-sonnet-4-6, openai/gpt-5.2, groq/llama-4-scout. The same underlying model can be reached through different providers (for example anthropic/… vs bedrock/…) with identical pass-through pricing. Browse the full list on the models page.
04 · Governance & security
Budgets, locks, and the kill switch
Model locks restrict which models a user or key may call. Budgets cap spend per key, per user, or per project, enforced before the request is routed, not reconciled after. The runaway-agent kill switch is a velocity breaker: if a key exceeds your configured request or spend rate, the gateway halts it instantly and notifies you.
All three are configured in the console or via the management API, and every enforcement decision appears in the request trace.
05 · Reliability
Cross-provider fallbacks
Declare fallback models and the gateway retries across providers on outages or rate limits, turning individual provider failures into one measured effective success rate, visible on the status page.
r = client.chat.completions.create(
model="anthropic/claude-sonnet-4-6",
extra_body={
"fallback_models": ["bedrock/claude-sonnet-4-6", "openai/gpt-5.2"],
"max_budget_usd": 0.25, # hard cap for this request
},
messages=[…],
)
06 · Cost tracing
Exact cost per call
Every response includes the exact cost of the call, and every request lands in one ledger across all providers, filterable by key, user, project, and model. Semantic cache hits under token economy mode are billed 0 credits and marked as such in the trace.
07 · User-assigned keys
Every key belongs to someone
Assign each API key to a specific user or service account when you create it. The assignment travels with every request: budgets and model locks apply per person, revocation is per person, and the ledger reports spend per person, so "who burned the credits" stops being a forensic exercise.
curl https://api.switchgate.ai/v1/keys \
-H "Authorization: Bearer sg-admin-…" \
-d '{
"assigned_to": "[email protected]",
"monthly_budget_usd": 40,
"allowed_models": ["anthropic/claude-haiku-4-5", "google/gemini-3-flash"],
"burnable": false
}'
Set "burnable": true with a credit_balance instead of a monthly budget to issue a prepaid key that simply stops working when the credits are gone: ideal for contractors, classrooms and hackathons.
08 · Local models
Connect your own model with the device agent
The SwitchGate device agent is not an AI: it's a small piece of software you install on your own server, next to whatever serves your model (vLLM, Ollama, llama.cpp or any OpenAI-compatible runtime). On start it opens an outbound tunnel to the gateway, no inbound ports, no public IP, and your model appears in your catalog as local/<model>, callable through the same API as every cloud model, with the same per-user budgets, locks and cost tracing (your own calls bill 0 credits).
Once the tunnel is up you can keep the model private to your org or wire it into your own website or product through our API, and, once the marketplace opens, you'll be able to resell it on SwitchGate: publish a public listing, set your per-token price, and let the gateway meter, bill and pay you out.
# one-line install
curl -fsSL https://get.switchgate.ai/agent | sh
# bridge your Ollama models into your catalog
switchgate agent up --ollama http://localhost:11434
# then call it like any other model
# model="local/llama-4-maverick"