---
title: "Chat completions (LiteLLM - OpenAI format)"
method: POST
path: "/litellm/v1/chat/completions"
tags: ["LiteLLM Integration"]
---

# Chat completions (LiteLLM - OpenAI format)

`POST /litellm/v1/chat/completions`

Creates a chat completion using OpenAI-compatible format via LiteLLM.

## Request body

- OpenAIChatRequest
  - `model` string, required — Model identifier (e.g., gpt-4, gpt-3.5-turbo)
  - `messages` OpenAIMessage[], required — List of messages in the conversation
    - `role` 'system' | 'user' | 'assistant' | 'tool' | 'developer', required
    - `name` string
    - `content` union — Message content - can be a string or array of content blocks
      - string
      - object[]
        - `type` 'text' | 'image_url' | 'input_audio' | 'file' | 'refusal', required
        - `text` string
        - `refusal` string
        - `image_url` object
          - `url` string, required
          - `detail` 'low' | 'high' | 'auto'
        - `input_audio` object
          - `data` string, required
          - `format` string
        - `file` object
          - `file_data` string
          - `file_id` string
          - `filename` string
          - `file_type` string
        - `cache_control` CacheControl — Cache control settings for content blocks
          - `type` 'ephemeral'
          - `ttl` string — Time to live (e.g., "1m", "1h")
    - `tool_call_id` string — For tool messages
    - `refusal` string
    - `reasoning` string
    - `annotations` object[]
      - `type` string
      - `url_citation` object
        - `start_index` integer
        - `end_index` integer
        - `title` string
        - `url` string
        - `sources` object
        - `type` string
    - `tool_calls` object[]
      - `index` integer
      - `type` string
      - `id` string
      - `function` object, required
        - `name` string
        - `arguments` string
  - `stream` boolean — Whether to stream the response
  - `max_tokens` integer — Maximum tokens to generate (legacy, use max_completion_tokens)
  - `max_completion_tokens` integer — Maximum tokens to generate
  - `temperature` number
  - `top_p` number
  - `frequency_penalty` number
  - `presence_penalty` number
  - `logit_bias` object
  - `logprobs` boolean
  - `top_logprobs` integer
  - `n` integer
  - `stop` union
    - string
    - string[]
  - `seed` integer
  - `user` string
  - `tools` object[]
    - `type` 'function' | 'custom', required
    - `function` object
      - `name` string, required
      - `description` string
      - `parameters` object
        - `type` string
        - `description` string
        - `required` string[]
        - `properties` object
        - `enum` string[]
        - `additionalProperties` boolean
      - `strict` boolean
    - `custom` object
      - `format` object
        - `type` string, required
        - `grammar` object
          - `definition` string, required
          - `syntax` 'lark' | 'regex', required
    - `cache_control` CacheControl — Cache control settings for content blocks
      - `type` 'ephemeral'
      - `ttl` string — Time to live (e.g., "1m", "1h")
  - `tool_choice` union
    - 'none' | 'auto' | 'required'
    - object
      - `type` 'none' | 'any' | 'required' | 'function' | 'allowed_tools' | 'custom', required
      - `function` object
        - `name` string, required
      - `allowed_tools` object
        - `mode` 'auto' | 'required'
        - `tools` object[]
          - `type` string, required
          - `function` object
            - `name` string, required
  - `parallel_tool_calls` boolean
  - `response_format` object — Format for the response
  - `reasoning_effort` 'none' | 'minimal' | 'low' | 'medium' | 'high' | 'xhigh' — OpenAI reasoning effort level
  - `service_tier` string
  - `stream_options` object
    - `include_obfuscation` boolean
    - `include_usage` boolean
  - `fallbacks` string[] — Fallback models

## Response `200`

Successful response

- ChatCompletionResponse
  - `id` string
  - `choices` object[]
    - `index` integer
    - `finish_reason` string
    - `log_probs` object
      - `content` object[]
        - `bytes` integer[]
        - `logprob` number
        - `token` string
        - `top_logprobs` object[]
          - `bytes` integer[]
          - `logprob` number
          - `token` string
      - `refusal` object[]
        - `bytes` integer[]
        - `logprob` number
        - `token` string
      - `text_offset` integer[]
      - `token_logprobs` number[]
      - `tokens` string[]
      - `top_logprobs` object[]
    - `text` string — For text completions
    - `message` ChatMessage
      - `role` 'assistant' | 'user' | 'system' | 'tool' | 'developer', required
      - `name` string
      - `content` union — Message content - can be a string or array of content blocks
        - string
        - object[]
          - `type` 'text' | 'image_url' | 'input_audio' | 'file' | 'refusal', required
          - `text` string
          - `refusal` string
          - `image_url` object
            - `url` string, required
            - `detail` 'low' | 'high' | 'auto'
          - `input_audio` object
            - `data` string, required
            - `format` string
          - `file` object
            - `file_data` string
            - `file_id` string
            - `filename` string
            - `file_type` string
          - `cache_control` CacheControl — Cache control settings for content blocks
            - `type` 'ephemeral'
            - `ttl` string — Time to live (e.g., "1m", "1h")
      - `tool_call_id` string — For tool messages
      - `refusal` string
      - `audio` object
        - `id` string
        - `data` string
        - `expires_at` integer
        - `transcript` string
      - `reasoning` string
      - `reasoning_details` object[]
        - `id` string
        - `index` integer
        - `type` 'reasoning.summary' | 'reasoning.encrypted' | 'reasoning.text'
        - `summary` string
        - `text` string
        - `signature` string
        - `data` string
      - `annotations` object[]
        - `type` string
        - `url_citation` object
          - `start_index` integer
          - `end_index` integer
          - `title` string
          - `url` string
          - `sources` object
          - `type` string
      - `tool_calls` object[]
        - `index` integer
        - `type` string
        - `id` string
        - `function` object, required
          - `name` string
          - `arguments` string
    - `delta` object — For streaming chat completions
      - `role` string
      - `content` string
      - `refusal` string
      - `audio` object
        - `id` string
        - `data` string
        - `expires_at` integer
        - `transcript` string
      - `reasoning` string
      - `reasoning_details` object[]
        - `id` string
        - `index` integer
        - `type` 'reasoning.summary' | 'reasoning.encrypted' | 'reasoning.text'
        - `summary` string
        - `text` string
        - `signature` string
        - `data` string
      - `tool_calls` object[]
        - `index` integer
        - `type` string
        - `id` string
        - `function` object, required
          - `name` string
          - `arguments` string
  - `created` integer
  - `model` string
  - `object` string
  - `service_tier` string
  - `system_fingerprint` string
  - `usage` BifrostLLMUsage — Token usage information
    - `prompt_tokens` integer — Total input tokens including any prompt-cache tokens (read + write). Subtract prompt_tokens_details.cached_read_tokens and prompt_tokens_details.cached_write_tokens to get the non-cached portion.
    - `prompt_tokens_details` ChatPromptTokensDetails
      - `text_tokens` integer
      - `audio_tokens` integer
      - `image_tokens` integer
      - `cached_read_tokens` integer — Tokens served from the prompt cache (cache hit). These tokens are already included in prompt_tokens and are billed at the reduced cache-read rate. Populated for all providers that support prompt caching (Anthropic, Bedrock, OpenAI, Gemini, xAI, etc.).
      - `cached_write_tokens` integer — Tokens written to the prompt cache on this request (cache creation / write). These tokens are already included in prompt_tokens and are billed at the cache-creation rate. Populated for providers that separately report cache write tokens (Anthropic, Bedrock).
    - `completion_tokens` integer — Number of output/completion tokens generated.
    - `completion_tokens_details` ChatCompletionTokensDetails
      - `text_tokens` integer
      - `accepted_prediction_tokens` integer
      - `audio_tokens` integer
      - `citation_tokens` integer
      - `num_search_queries` integer
      - `reasoning_tokens` integer
      - `image_tokens` integer
      - `rejected_prediction_tokens` integer
    - `total_tokens` integer
    - `cost` BifrostCost — Cost breakdown for the request
      - `input_tokens_cost` number
      - `output_tokens_cost` number
      - `reasoning_tokens_cost` number — Cost for reasoning/thinking tokens (reasoning models)
      - `citation_tokens_cost` number — Cost for citation tokens
      - `search_queries_cost` number — Cost for web search queries
      - `request_cost` number
      - `total_cost` number
  - `extra_fields` BifrostResponseExtraFields — Additional fields included in responses
    - `request_type` string — Type of request that was made
    - `provider` 'openai' | 'azure' | 'anthropic' | 'bedrock' | 'cohere' | 'vertex' | 'vllm' | 'mistral' | 'ollama' | 'groq' | 'sgl' | 'parasail' | 'perplexity' | 'replicate' | 'cerebras' | 'deepseek' | 'gemini' | 'openrouter' | 'elevenlabs' | 'huggingface' | 'nebius' | 'xai' | 'runway' | 'fireworks' — AI model provider identifier
    - `model_requested` string — The model that was requested
    - `model_deployment` string — The actual model deployment used
    - `latency` integer — Request latency in milliseconds
    - `chunk_index` integer — Index of the chunk for streaming responses
    - `raw_request` object — Raw request if enabled
    - `raw_response` object — Raw response if enabled
    - `cache_debug` BifrostCacheDebug
      - `cache_hit` boolean
      - `cache_id` string
      - `hit_type` string
      - `requested_provider` string
      - `requested_model` string
      - `provider_used` string
      - `model_used` string
      - `input_tokens` integer
      - `threshold` number
      - `similarity` number
  - `search_results` PerplexitySearchResult[]
    - `title` string
    - `url` string
    - `date` string
    - `last_updated` string
    - `snippet` string
    - `source` string
  - `videos` PerplexityVideoResult[]
    - `url` string
    - `thumbnail_url` string
    - `thumbnail_width` integer
    - `thumbnail_height` integer
    - `duration` number
  - `citations` string[]

## Other responses

- `400` — Bad request
- `500` — Internal server error

---

[API](https://skmtc.net/getbifrost/apis/bifrost-api.md) · [All operations](https://skmtc.net/getbifrost/apis/bifrost-api/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/getbifrost/bifrost-api/versions/f8cab88f64ea/schema)
