---
title: "Create a chat completion"
method: POST
path: "/v1/chat/completions"
tags: ["Models"]
---

# Create a chat completion

`POST /v1/chat/completions`

## Request

- Base URL: `https://api.dexto.ai`
- URL: `https://api.dexto.ai/v1/chat/completions`
- Auth: HTTP bearer

Creates an OpenAI-compatible chat completion. Set stream to true to receive server-sent events ending with data: [DONE].

## Request body

- object
  - `access_method` 'anthropic-api-key' | 'dexto' | 'openai-api-key' | 'openai-chatgpt'
  - `frequency_penalty` number
  - `include_reasoning` boolean
  - `max_completion_tokens` integer
  - `max_tokens` integer
  - `messages` union[], required
    - union
      - object
        - `content` union, required
          - string
          - object[]
            - `text` string, required
            - `type` 'text', required
        - `role` 'developer' | 'system', required
      - object
        - `content` union, required
          - string
          - union[]
            - union
              - …
        - `role` 'user', required
      - object
        - `content` union
          - string
          - union[]
            - union
              - …
        - `reasoning` string
        - `reasoning_content` string
        - `role` 'assistant', required
        - `tool_calls` object[]
          - `function` object, required
            - `arguments` string, required
            - `name` string, required
          - `id` string, required
          - `type` 'function', required
      - object
        - `content` union, required
          - string
          - union[]
            - union
              - …
        - `name` string
        - `role` 'tool', required
        - `tool_call_id` string, required
  - `model` string, required
  - `presence_penalty` number
  - `parallel_tool_calls` boolean
  - `prompt_cache_key` string
  - `reasoning` object
  - `reasoning_effort` string
  - `response_format` union
    - object
      - `type` 'text', required
    - object
      - `type` 'json_object', required
    - object
      - `json_schema` object, required
        - `description` string
        - `name` string, required
        - `schema` object, required
        - `strict` true
      - `type` 'json_schema', required
  - `seed` integer
  - `service_tier` 'auto' | 'default' | 'fast' | 'priority'
  - `stop` union
    - string
    - string[]
  - `stream` boolean
  - `stream_options` object
    - `include_usage` boolean
  - `temperature` number
  - `tool_choice` union
    - 'auto' | 'none' | 'required'
    - object
      - `function` object, required
        - `name` string, required
      - `type` 'function', required
  - `tools` object[]
    - `function` object, required
      - `description` string
      - `name` string, required
      - `parameters` object
    - `type` 'function', required
  - `top_p` number
  - `usage` object
  - `user` string
  - `verbosity` 'low' | 'medium' | 'high'

## Response `200`

Successful response.

- object
  - `choices` object[], required
    - `finish_reason` 'content_filter' | 'length' | 'stop' | 'tool_calls', nullable, required
    - `index` integer, required
    - `message` object, required
      - `content` string, nullable, required
      - `reasoning` string
      - `reasoning_content` string
      - `role` 'assistant', required
      - `tool_calls` object[]
        - `function` object, required
          - `arguments` string, required
          - `name` string, required
        - `id` string, required
        - `index` integer
        - `type` 'function', required
  - `created` integer, required
  - `id` string, required
  - `model` string, required
  - `object` 'chat.completion', required
  - `service_tier` 'default' | 'priority'
  - `usage` object, required
    - `completion_tokens` integer, required
    - `completion_tokens_details` object
      - `reasoning_tokens` integer, required
    - `cost` number
    - `prompt_tokens` integer, required
    - `prompt_tokens_details` object
      - `cache_write_tokens` integer
      - `cached_tokens` integer, required
    - `total_tokens` integer, required

## Other responses

- `400`: Invalid JSON or request fields.
- `401`: Missing or invalid API key.
- `402`: The account has insufficient credits.
- `403`: The account cannot perform this operation.
- `404`: The requested resource was not found.
- `409`: The request conflicts with existing resource state.
- `429`: The account exceeded this operation's request rate.
- `500`: Unexpected Dexto failure.
- `502`: The upstream model provider failed.
- `503`: A required Dexto service is temporarily unavailable.

---

[API](https://skmtc.dev/dexto/apis/dexto-api.md) - [All operations](https://skmtc.dev/dexto/apis/dexto-api/llms.txt) - [OpenAPI document](https://skmtc.dev/dexto/apis/dexto-api/revisions/47eb880cffa5?raw)
