B2BB2B LLM

POST /v1/chat/completions

OpenAI-compatible chat completions with streaming, tools, vision, and model aliases.

POST /v1/chat/completions

Request

curl https://api.model-gate.com/v1/chat/completions \
  -H "Authorization: Bearer mg_live_..." \
  -H "Content-Type: application/json" \
  -d '{
    "model": "ch-47",
    "messages": [
      {"role": "user", "content": "Explain this API in one sentence."}
    ],
    "stream": false
  }'

The model can be a canonical ID or an enabled alias. Model Gate resolves aliases before pricing and sends the canonical ID upstream.

Response

{
  "id": "chatcmpl_example",
  "object": "chat.completion",
  "model": "claude-opus-4.7",
  "choices": [
    {
      "index": 0,
      "message": {"role": "assistant", "content": "Model Gate provides one compatible API for multiple AI models."},
      "finish_reason": "stop"
    }
  ],
  "usage": {
    "prompt_tokens": 14,
    "completion_tokens": 17,
    "total_tokens": 31
  }
}

Streaming request

Set "stream": true. The upstream Server-Sent Events are passed through without rewriting successful event payloads.

Asynchronous request

For supported endpoints, add "async": true with "stream": false. The immediate response is HTTP 202 and contains request_id and a Partner API result URL.

Errors

Provider non-2xx status, body, and content type are passed through unchanged. Locally generated validation errors use the Model Gate error envelope.

StatusMeaningAction
400Invalid requestCheck the request body and model ID.
401Invalid or frozen keyVerify or rotate the API key.
429Rate or concurrency limit exceededRespect Retry-After and retry with backoff.
5xxTemporary upstream or gateway errorRetry idempotent requests with exponential backoff.