Quick start
Mythos Gateway speaks both the OpenAI and the Anthropic APIs. Use the official SDKs and change only base_url and api_key.
| Protocol | Base URL | Endpoints |
|---|---|---|
| OpenAI | https://mythoskey.com/v1 | POST /v1/chat/completions · POST /v1/responses · GET /v1/models |
| Anthropic | https://mythoskey.com | POST /v1/messages |
- Sign up, then top up.
- Create a key under API keys (it is shown once; store it right away).
- Make your first call:
from openai import OpenAI client = OpenAI(base_url="https://mythoskey.com/v1", api_key="mgc-…") resp = client.chat.completions.create( model="mythos-fast", max_tokens=1024, temperature=0.7, messages=[ {"role": "system", "content": "You are concise."}, {"role": "user", "content": "Hello"}, ], ) print(resp.choices[0].message.content) print(resp.usage) # prompt_tokens / completion_tokens / total_tokens
import anthropic client = anthropic.Anthropic( base_url="https://mythoskey.com", # the SDK appends /v1/messages api_key="mgc-…", ) msg = client.messages.create( model="mythos-fast", max_tokens=1024, system="You are concise.", messages=[{"role": "user", "content": "Hello"}], ) print(msg.content[0].text, msg.usage)
curl https://mythoskey.com/v1/chat/completions \ -H "Authorization: Bearer $MYTHOS_API_KEY" \ -H "Content-Type: application/json" \ -d '{"model": "mythos-fast", "max_tokens": 512, "messages": [{"role": "user", "content": "hi"}]}'
Authentication
Every endpoint authenticates with an API key starting with mgc- . Send it in either header:
Authorization: Bearer mgc-…
# or (Anthropic style)
x-api-key: mgc-…- Only a hash of the key is stored; a lost key cannot be shown again — delete it and create a new one.
- Each key can have a name, a lifetime spend limit and a model allowlist; disable or delete it any time, effective immediately.
- Never ship a key in front-end code or a public repo; use an environment variable such as
MYTHOS_API_KEY.
Models
Use the model names below as the model parameter. Prices in CNY per 1M tokens; live prices on the model market. You can also call GET /v1/models.
| model | Name | Context | Input | Output |
|---|---|---|---|---|
mythos-fast | mythos-fast | — | ¥1.00 – ¥13.00 | ¥3.33 – ¥68.00 |
mythos-glm-live | mythos-glm-live | — | ¥1.00 | ¥3.33 |
mythos-kimi-live | mythos-kimi-live | — | ¥13.00 | ¥68.00 |
curl https://mythoskey.com/v1/models -H "Authorization: Bearer $MYTHOS_API_KEY"OpenAI-compatible API
POSThttps://mythoskey.com/v1/chat/completions
Supports messages (system / user / assistant / tool), max_tokens, temperature, top_p, stop, stream, tools / tool_choice, image input (image_url) and reasoning_content passthrough. The usage field holds the tokens you are billed for.
from openai import OpenAI client = OpenAI(base_url="https://mythoskey.com/v1", api_key="mgc-…") resp = client.chat.completions.create( model="mythos-fast", max_tokens=1024, temperature=0.7, messages=[ {"role": "system", "content": "You are concise."}, {"role": "user", "content": "Hello"}, ], ) print(resp.choices[0].message.content) print(resp.usage) # prompt_tokens / completion_tokens / total_tokens
curl https://mythoskey.com/v1/chat/completions \ -H "Authorization: Bearer $MYTHOS_API_KEY" \ -H "Content-Type: application/json" \ -d '{"model": "mythos-fast", "max_tokens": 512, "messages": [{"role": "user", "content": "hi"}]}'
POSThttps://mythoskey.com/v1/responses — a common subset of the OpenAI Responses API (text, streaming, tools).
Anthropic-compatible API
POSThttps://mythoskey.com/v1/messages
Same as the Anthropic Messages API: send the anthropic-version header; system, tools, images, thinking / redacted_thinking blocks and streaming events (message_start … message_stop) are supported.
import anthropic client = anthropic.Anthropic( base_url="https://mythoskey.com", # the SDK appends /v1/messages api_key="mgc-…", ) msg = client.messages.create( model="mythos-fast", max_tokens=1024, system="You are concise.", messages=[{"role": "user", "content": "Hello"}], ) print(msg.content[0].text, msg.usage)
curl https://mythoskey.com/v1/messages \ -H "x-api-key: $MYTHOS_API_KEY" \ -H "anthropic-version: 2023-06-01" \ -H "Content-Type: application/json" \ -d '{"model": "mythos-fast", "max_tokens": 512, "messages": [{"role": "user", "content": "hi"}]}'
Streaming
Set stream: true to receive Server-Sent Events. With the OpenAI protocol the usage arrives in [DONE] just before choices in a chunk with empty choices; with Anthropic it is in message_delta events.
from openai import OpenAI client = OpenAI(base_url="https://mythoskey.com/v1", api_key="mgc-…") stream = client.chat.completions.create( model="mythos-fast", max_tokens=1024, stream=True, stream_options={"include_usage": True}, messages=[{"role": "user", "content": "Hello"}], ) for chunk in stream: if chunk.choices and chunk.choices[0].delta.content: print(chunk.choices[0].delta.content, end="", flush=True) if chunk.usage: # the last chunk carries usage print("\n", chunk.usage)
import anthropic client = anthropic.Anthropic(base_url="https://mythoskey.com", api_key="mgc-…") with client.messages.stream( model="mythos-fast", max_tokens=1024, messages=[{"role": "user", "content": "Hello"}], ) as stream: for text in stream.text_stream: print(text, end="", flush=True)
curl -N https://mythoskey.com/v1/chat/completions \ -H "Authorization: Bearer $MYTHOS_API_KEY" \ -H "Content-Type: application/json" \ -d '{"model": "mythos-fast", "stream": true, "max_tokens": 256, "messages": [{"role": "user", "content": "hi"}]}'
data: {"id":"chatcmpl-…","object":"chat.completion.chunk","choices":[{"index":0,"delta":{"content":"你"}}]}
data: {"id":"chatcmpl-…","object":"chat.completion.chunk","choices":[{"index":0,"delta":{},"finish_reason":"stop"}]}
data: {"id":"chatcmpl-…","object":"chat.completion.chunk","choices":[],"usage":{"prompt_tokens":9,"completion_tokens":21,"total_tokens":30}}
data: [DONE]Tools & vision
Send OpenAI or Anthropic tools as usual. The gateway routes to an upstream that supports the capability; if none does it returns 400 capability_not_supported.
resp = client.chat.completions.create(
model="mythos-fast",
max_tokens=1024,
tools=[{
"type": "function",
"function": {
"name": "get_weather",
"description": "Get the weather for a city",
"parameters": {"type": "object", "properties": {"city": {"type": "string"}}, "required": ["city"]},
},
}],
messages=[{"role": "user", "content": "Weather in Shanghai?"}],
)
print(resp.choices[0].message.tool_calls)Billing & balance
- Cost = input × input price + cached input × cached price + output × output price (CNY per 1M tokens), to 0.000001 CNY.
- A hold for the maximum output is placed first (without max_tokens: 4096 tokens), then settled to the real usage. Always send max_tokens to use a small balance.
- Without max_tokens, if the balance cannot cover the default hold, the output is clamped to what you can afford (at least 256), reported in X-Mythos-Max-Tokens-Clamped; below that you get 402.
- Every call's charge is listed under Usage & billing (by x-request-id) and exportable as CSV. This page does not promise unbilled unsuccessful calls.
Response headers
| Header | Meaning |
|---|---|
x-request-id | Unique id of the call; matches the per-call record in the console |
X-Mythos-Max-Tokens-Clamped | The max_tokens used when you sent none and the balance could not cover the default |
X-Mythos-Cost-Warning | Cost warning, e.g. identical requests repeated in a short window |
Retry-After | Seconds to wait after a 429 |
Error codes
Errors follow the protocol you call (OpenAI error object or Anthropic type: error). The code field is stable for programmatic handling:
{
"error": {
"message": "Insufficient balance for this request; top up your account.",
"type": "insufficient_quota",
"code": "insufficient_balance",
"param": null
}
}| HTTP | code | Meaning |
|---|---|---|
400 | invalid_request | The body is not valid JSON or a field is invalid |
400 | missing_anthropic_version | /v1/messages without the anthropic-version header |
400 | capability_not_supported | No upstream of the model supports images or tools |
400 | upstream_bad_request | The upstream rejected the request (e.g. a parameter beyond the model limit) |
401 | missing_api_key | No API key was sent |
401 | invalid_api_key | Unknown or deleted key, or the account is suspended |
401 | key_disabled | You disabled this key in the console |
402 | insufficient_balance | Available balance cannot cover the request's maximum cost |
402 | key_quota_exceeded | The key reached its spending limit |
403 | model_not_allowed | This key is not allowed to use the model |
403 | model_not_billable | The model is not offered or not priced |
404 | model_not_found | No such model |
413 | request_too_large | The request body is too large |
429 | rate_limit_exceeded | Requests-per-minute limit; retry after Retry-After |
429 | concurrency_limit_exceeded | Too many concurrent requests on one key |
502 | upstream_error | Every upstream failed after retries and failover; retry later |
503 | no_available_provider | No upstream is available right now (circuit open or maintenance) |
500 | internal_error | Gateway error; contact support with the x-request-id |
Rate limits
By default each key may send 60 requests per minute with at most 8 concurrent requests. Beyond that you get 429 with Retry-After.