API
A complete Model Gate API reference in five minutes.
API
Model Gate exposes two compatible inference interfaces:
- Anthropic —
POST /v1/messagesfor the Anthropic SDK, Claude Code, and compatible clients. - OpenAI —
POST /v1/chat/completionsfor the OpenAI SDK and compatible clients.
One mg_live_... key works in both modes. Routing and billing are handled by Model Gate.
Base URL
https://api.model-gate.com
OpenAI-compatible clients normally use https://api.model-gate.com/v1.
Quick start
curl: Anthropic
curl https://api.model-gate.com/v1/messages \
-H "x-api-key: mg_live_..." \
-H "anthropic-version: 2023-06-01" \
-H "content-type: application/json" \
-d '{"model":"claude-opus-4.8","max_tokens":1024,"messages":[{"role":"user","content":"Hello"}]}'
curl: OpenAI
curl https://api.model-gate.com/v1/chat/completions \
-H "Authorization: Bearer mg_live_..." \
-H "content-type: application/json" \
-d '{"model":"claude-opus-4.8","messages":[{"role":"user","content":"Hello"}]}'
Python: OpenAI SDK
from openai import OpenAI
client = OpenAI(api_key="mg_live_...", base_url="https://api.model-gate.com/v1")
response = client.chat.completions.create(model="claude-opus-4.8", messages=[{"role":"user","content":"Hello"}])
print(response.choices[0].message.content)
Python: Anthropic SDK
from anthropic import Anthropic
client = Anthropic(api_key="mg_live_...", base_url="https://api.model-gate.com")
response = client.messages.create(model="claude-opus-4.8", max_tokens=1024, messages=[{"role":"user","content":"Hello"}])
print(response.content[0].text)
Supported capabilities
Streaming, prompt caching, vision, tool use/function calling, extended thinking, and large-context models are passed through when supported by the selected model.
Limits
RPM and concurrency can be configured per account and per key. A key also has a resettable spending usage counter and a lifetime total_spent counter. Exceeding a rate limit returns 429 with Retry-After.