Dynamiq
A I Gateway

Create a chat completion

OpenAI-compatible chat completions endpoint. The `model` is a Dynamiq router model slug; the gateway resolves it to the configured upstream provider and relays the request. Set `stream: true` to receive Server-Sent Events of `chat.completion.chunk` objects. Unknown request fields are passed through to the upstream provider.

POST
/v1/chat/completions

Authorization

accessKey
AuthorizationBearer <token>

Organization or project Access Key created in the Dynamiq console. Used for deployed-app (Runs API), AI Gateway, traces collector, and management API requests. Send as Authorization: Bearer <access-key>.

In: header

Request Body

application/json

TypeScript Definitions

Use the request body type in TypeScript.

OpenAI-compatible chat completion request. Additional provider-specific fields are passed through to the upstream provider.

Response Body

application/json

application/json

application/json

curl -X POST "https://example.com/v1/chat/completions" \  -H "Content-Type: application/json" \  -d '{    "model": "gpt-4o-mini",    "messages": [      {        "role": "system",        "content": "You are a support-triage assistant. Classify tickets."      },      {        "role": "user",        "content": "Customer says they were charged twice for the June invoice."      }    ],    "temperature": 0.2,    "max_tokens": 256  }'
{
  "id": "chatcmpl-9x1YzAbC",
  "object": "chat.completion",
  "created": 1781430921,
  "model": "gpt-4o-mini",
  "choices": [
    {
      "index": 0,
      "message": {
        "role": "assistant",
        "content": "{\"category\":\"billing\",\"priority\":\"high\"}"
      },
      "finish_reason": "stop"
    }
  ],
  "usage": {
    "prompt_tokens": 64,
    "completion_tokens": 18,
    "total_tokens": 82
  }
}
{
  "error": {
    "code": "bad_request",
    "message": "Bad Request",
    "details": {
      "input": "cannot be blank"
    }
  }
}
{
  "error": {
    "code": "unauthorized",
    "message": "Unauthorized"
  }
}
{
  "error": {
    "code": "bad_request",
    "message": "Failed to parse data",
    "details": {
      "error": "1 validation error for LLMRequest"
    }
  }
}