Pre-production environment · A real payment provider is configured; payment actions may move real money. Pricing configuration has not been approved.

Quick start

Mythos Gateway speaks both the OpenAI and the Anthropic APIs. Use the official SDKs and change only base_url and api_key.

ProtocolBase URLEndpoints
OpenAIhttps://mythoskey.com/v1POST /v1/chat/completions · POST /v1/responses · GET /v1/models
Anthropichttps://mythoskey.comPOST /v1/messages
  1. Sign up, then top up.
  2. Create a key under API keys (it is shown once; store it right away).
  3. Make your first call:
Python · OpenAI SDK
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
Python · Anthropic SDK
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
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:

HTTP
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.

modelNameContextInputOutput
mythos-fastmythos-fast—¥1.00 – ¥13.00¥3.33 – ¥68.00
mythos-glm-livemythos-glm-live—¥1.00¥3.33
mythos-kimi-livemythos-kimi-live—¥13.00¥68.00
curl
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.

Python
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
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.

Python · Anthropic SDK
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
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.

Python · OpenAI
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)
Python · Anthropic
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
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"}]}'
SSE response
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]
If you disconnect mid-stream you pay the usage the vendor reported, otherwise an estimate of what was streamed; nothing streamed means no charge.

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.

Python
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

HeaderMeaning
x-request-idUnique id of the call; matches the per-call record in the console
X-Mythos-Max-Tokens-ClampedThe max_tokens used when you sent none and the balance could not cover the default
X-Mythos-Cost-WarningCost warning, e.g. identical requests repeated in a short window
Retry-AfterSeconds 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:

HTTP 402
{
  "error": {
    "message": "Insufficient balance for this request; top up your account.",
    "type": "insufficient_quota",
    "code": "insufficient_balance",
    "param": null
  }
}
HTTPcodeMeaning
400invalid_requestThe body is not valid JSON or a field is invalid
400missing_anthropic_version/v1/messages without the anthropic-version header
400capability_not_supportedNo upstream of the model supports images or tools
400upstream_bad_requestThe upstream rejected the request (e.g. a parameter beyond the model limit)
401missing_api_keyNo API key was sent
401invalid_api_keyUnknown or deleted key, or the account is suspended
401key_disabledYou disabled this key in the console
402insufficient_balanceAvailable balance cannot cover the request's maximum cost
402key_quota_exceededThe key reached its spending limit
403model_not_allowedThis key is not allowed to use the model
403model_not_billableThe model is not offered or not priced
404model_not_foundNo such model
413request_too_largeThe request body is too large
429rate_limit_exceededRequests-per-minute limit; retry after Retry-After
429concurrency_limit_exceededToo many concurrent requests on one key
502upstream_errorEvery upstream failed after retries and failover; retry later
503no_available_providerNo upstream is available right now (circuit open or maintenance)
500internal_errorGateway 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.