Skip to main content

Docs

Point your OpenAI-compatible SDK at https://api.xmaxgate.com/v1 with Authorization: Bearer <key>, or point your Anthropic SDK / Claude Code at https://api.xmaxgate.com/anthropic with x-api-key: <key>.

Authentication

OpenAI-compatible routes accept Authorization: Bearer xmg_.... Anthropic routes accept either x-api-key: xmg_... or Authorization: Bearer xmg_....

GET /v1/models

List model ids available through the gateway (chat and embedding models). Also available at GET /anthropic/v1/models.

Response shape follows standard list models format (object, data[] with id, object, owned_by).

curl https://api.xmaxgate.com/v1/models \
  -H "Authorization: Bearer xmg_xxx"

POST /v1/chat/completions

Chat completions with an OpenAI-compatible JSON body. Set model and a messages array (see messages).

curl https://api.xmaxgate.com/v1/chat/completions \
  -H "Authorization: Bearer xmg_xxx" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "claude-sonnet-4-6",
    "messages": [
      {"role":"system","content":"You are concise."},
      {"role":"user","content":"hello"}
    ]
  }'

messages (Chat Completions body)

On OpenAI-compatible chat completions, conversation turns are sent as the messages array inside POST /v1/chat/completions.

  • role: typically system, user, or assistant.
  • content: string content for that turn (multi-modal shapes follow upstream when enabled).

Order matters: older turns first; the latest user message is usually last before the model reply.

POST /anthropic/v1/messages

Native Anthropic Messages API endpoint supporting streaming SSE, tool use, and Claude Code. Set ANTHROPIC_BASE_URL=https://api.xmaxgate.com/anthropic and ANTHROPIC_API_KEY=xmg_....

Usage and prepaid wallet billing are tracked identically across both OpenAI and Anthropic endpoints.

curl https://api.xmaxgate.com/anthropic/v1/messages \
  -H "x-api-key: xmg_xxx" \
  -H "anthropic-version: 2023-06-01" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "claude-sonnet-4-6",
    "max_tokens": 512,
    "messages": [
      {"role": "user", "content": "Hello"}
    ]
  }'

POST /v1/embeddings

Create vector embeddings for semantic search, RAG, or classification. Use an embedding-capable model (for example one returned from GET /v1/models).

Request and response formats follow standard Embeddings API (model, input string or array; response includes data[].embedding).

curl https://api.xmaxgate.com/v1/embeddings \
  -H "Authorization: Bearer xmg_xxx" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "text-embedding-3-small",
    "input": "Semantic search example text."
  }'

Quick reference

MethodPathPurpose
GET/v1/modelsList available models
POST/v1/chat/completionsOpenAI-compatible chat with messages[]
POST/anthropic/v1/messagesAnthropic Messages API (Claude SDK / Claude Code)
GET/anthropic/v1/modelsList models (Anthropic prefix)
POST/v1/embeddingsEmbedding vectors