Skip to main content
The chat completions endpoint is compatible with OpenAI’s API.

Endpoint

POST https://gateway.muxx.dev/v1/chat/completions

Request

curl https://gateway.muxx.dev/v1/chat/completions \
  -H "Content-Type: application/json" \
  -H "X-Muxx-Api-Key: muxx_sk_live_xxxxxxxxxxxx" \
  -d '{
    "model": "gpt-4o",
    "messages": [
      {"role": "system", "content": "You are a helpful assistant."},
      {"role": "user", "content": "Hello!"}
    ],
    "temperature": 0.7,
    "max_tokens": 1000
  }'

Parameters

ParameterTypeRequiredDescription
modelstringYesModel ID (e.g., gpt-4o)
messagesarrayYesConversation messages
temperaturenumberNoRandomness (0-2)
max_tokensintegerNoMax output tokens
streambooleanNoEnable streaming
toolsarrayNoFunction definitions

Response

{
  "id": "chatcmpl-abc123",
  "object": "chat.completion",
  "created": 1699000000,
  "model": "gpt-4o",
  "choices": [
    {
      "index": 0,
      "message": {
        "role": "assistant",
        "content": "Hello! How can I help you today?"
      },
      "finish_reason": "stop"
    }
  ],
  "usage": {
    "prompt_tokens": 20,
    "completion_tokens": 10,
    "total_tokens": 30
  }
}

Muxx Headers

Request Headers

HeaderDescription
X-Muxx-Api-KeyYour Muxx API key (required)
X-Muxx-MetadataCustom metadata JSON
X-Muxx-Cache-Controlno-cache to bypass cache
X-Muxx-User-IdUser ID for per-user rate limiting

Response Headers

HeaderDescription
X-Muxx-Request-IdUnique request ID
X-Muxx-CacheHIT or MISS
X-Muxx-CostCalculated cost in USD

Streaming

curl https://gateway.muxx.dev/v1/chat/completions \
  -H "Content-Type: application/json" \
  -H "X-Muxx-Api-Key: muxx_sk_live_xxxxxxxxxxxx" \
  -d '{
    "model": "gpt-4o",
    "messages": [{"role": "user", "content": "Hello!"}],
    "stream": true
  }'
Response is server-sent events:
data: {"id":"chatcmpl-abc","choices":[{"delta":{"content":"Hello"}}]}
data: {"id":"chatcmpl-abc","choices":[{"delta":{"content":"!"}}]}
data: [DONE]

Supported Models

  • gpt-4o
  • gpt-4o-mini
  • gpt-4-turbo
  • gpt-4
  • gpt-3.5-turbo