---
title: "Chat Completion"
method: POST
path: "/engines/{model}/chat/completions"
tags: ["chat/completions"]
---

# Chat Completion

`POST /engines/{model}/chat/completions`

Follows the exact same API spec as `OpenAI's Chat API https://platform.openai.com/docs/api-reference/chat`

```bash
curl -X POST http://localhost:4000/v1/chat/completions 
-H "Content-Type: application/json" 
-H "Authorization: Bearer sk-1234" 
-d '{
    "model": "gpt-4o",
    "messages": [
        {
            "role": "user",
            "content": "Hello!"
        }
    ]
}'
```

## Path parameters

- `model` string, nullable, required

## Request body

- object
  - `model` string, required
  - `messages` union[], required
    - union
      - ChatCompletionUserMessage
        - `role` 'user', required
        - `content` union, required
          - string
          - union[]
            - union
              - …
        - `cache_control` ChatCompletionCachedContent
          - `type` 'ephemeral', required
      - ChatCompletionAssistantMessage
        - `role` 'assistant', required
        - `content` union
          - string
          - union[]
            - union
              - …
        - `name` string, nullable
        - `tool_calls` ChatCompletionAssistantToolCall[], nullable
          - `id` string, nullable, required
          - `type` 'function', required
          - `function` ChatCompletionToolCallFunctionChunk, required
            - `name` string, nullable
            - `arguments` string
            - `provider_specific_fields` object, nullable
        - `function_call` ChatCompletionToolCallFunctionChunk
          - `name` string, nullable
          - `arguments` string
          - `provider_specific_fields` object, nullable
        - `reasoning_content` string, nullable
        - `cache_control` ChatCompletionCachedContent
          - `type` 'ephemeral', required
        - `thinking_blocks` union[], nullable
          - union
            - ChatCompletionThinkingBlock
              - …
            - ChatCompletionRedactedThinkingBlock
              - …
        - `reasoning_items` ChatCompletionReasoningItem[], nullable
          - `type` 'reasoning', required
          - `id` string
          - `encrypted_content` string, nullable
          - `summary` ChatCompletionReasoningSummaryTextBlock[]
            - `type` 'summary_text', required
            - `text` string
      - ChatCompletionToolMessage
        - `role` 'tool', required
        - `content` union, required
          - string
          - ChatCompletionTextObject[]
            - `type` 'text', required
            - `text` string, required
            - `cache_control` ChatCompletionCachedContent
              - …
        - `tool_call_id` string, required
      - ChatCompletionSystemMessage
        - `role` 'system', required
        - `content` union, required
          - string
          - unknown[]
            - unknown
        - `name` string
        - `cache_control` ChatCompletionCachedContent
          - `type` 'ephemeral', required
      - ChatCompletionFunctionMessage
        - `role` 'function', required
        - `content` union, required
          - string
          - ChatCompletionTextObject[]
            - `type` 'text', required
            - `text` string, required
            - `cache_control` ChatCompletionCachedContent
              - …
        - `name` string, required
        - `tool_call_id` string, nullable, required
      - ChatCompletionDeveloperMessage
        - `role` 'developer', required
        - `content` union, required
          - string
          - unknown[]
            - unknown
        - `name` string
        - `cache_control` ChatCompletionCachedContent
          - `type` 'ephemeral', required
  - `frequency_penalty` number, nullable
  - `logit_bias` object, nullable
  - `logprobs` boolean, nullable
  - `top_logprobs` integer, nullable
  - `max_tokens` integer, nullable
  - `n` integer, nullable
  - `presence_penalty` number, nullable
  - `response_format` object, nullable
  - `seed` integer, nullable
  - `service_tier` string, nullable
  - `stop` union
    - string
    - string[]
  - `stream_options` object, nullable
  - `temperature` number, nullable
  - `top_p` number, nullable
  - `tools` object[], nullable
  - `tool_choice` union
    - string
    - object
  - `parallel_tool_calls` boolean, nullable
  - `function_call` union
    - string
    - object
  - `functions` object[], nullable
  - `user` string, nullable
  - `stream` boolean, nullable
  - `metadata` object, nullable
  - `guardrails` string[], nullable
  - `caching` boolean, nullable
  - `num_retries` integer, nullable
  - `context_window_fallback_dict` object, nullable
  - `fallbacks` string[], nullable

## Response `200`

Successful Response

- unknown

## Other responses

- `422` — Validation Error

---

[API](https://skmtc.net/flock/apis/litellm-api.md) · [All operations](https://skmtc.net/flock/apis/litellm-api/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/flock/litellm-api/revisions/8fbaab4fc7c5/schema)
