---
title: "Chat Completions (OpenAI-compatible)"
method: POST
path: "/api/v1/gateway/chat/completions"
tags: ["LLM"]
---

# Chat Completions (OpenAI-compatible)

`POST /api/v1/gateway/chat/completions`

## Request

- Base URL: `http://dobby-ai.com`
- URL: `http://dobby-ai.com/api/v1/gateway/chat/completions`
- Auth: HTTP bearer

Proxy chat completion requests to configured LLM providers. Supports streaming. Recommended "Single Key + Headers" pattern: send the gateway key as the Bearer token AND set `X-Org-Id` + `X-Tenant-Id`. Bearer-only key resolution can fail with 403 "Missing organization context".

## Headers

- `X-Org-Id` string
- `X-Tenant-Id` string

## Request body

- ChatCompletionRequest
  - `model` string, required
  - `messages` object[], required
    - `role` 'system' | 'user' | 'assistant'
    - `content` string
  - `stream` boolean
  - `max_tokens` integer
  - `temperature` number

## Response `200`

Completion response (or SSE stream if stream=true)

- ChatCompletionResponse
  - `id` string
  - `object` string
  - `model` string
  - `choices` object[]
    - `index` integer
    - `message` object
      - `role` string
      - `content` string
    - `finish_reason` string
  - `usage` object
    - `prompt_tokens` integer
    - `completion_tokens` integer
    - `total_tokens` integer

## Other responses

- `401`: 401 — Missing or invalid gateway key
- `403`: 403 — Request blocked by policy
- `429`: 429 — Rate limit exceeded
- `503`: 503 — Upstream provider error

---

[API](https://skmtc.dev/dobby-ai/apis/dobby-gateway-api.md) · [All operations](https://skmtc.dev/dobby-ai/apis/dobby-gateway-api/llms.txt) · [OpenAPI document](https://skmtc.dev/dobby-ai/apis/dobby-gateway-api/revisions/c189542f9647?raw)
