---
title: "Create Chat Completion"
method: POST
path: "/agents/v1/chat/completions"
tags: ["AGENTS", "Chat"]
---

# Create Chat Completion

`POST /agents/v1/chat/completions`

Create a chat completion (OpenAI-compatible).

Uses litellm with provider fallback: Anthropic Sonnet 5 → Azure GPT-5.5.
The model in the request is ignored — provider selection is automatic.

## Headers

- `x-session-id` string, nullable — Optional opaque conversation identifier. When provided, the call's Langfuse trace is grouped under this session_id, letting a multi-turn agentic conversation appear as one timeline. Clients should pass the same value across every turn of a single conversation.

## Request body

- ChatRequest
  - `messages` union[], required
    - union
      - SystemMessage
        - `name` string, nullable
        - `role` 'system'
        - `content` union, required
          - string
          - TextContent[]
            - `type` 'text'
            - `text` string, required
            - `cache_control` object, nullable
      - UserMessage
        - `name` string, nullable
        - `role` 'user'
        - `content` union, required
          - string
          - union[]
            - union
              - …
      - AssistantMessage
        - `name` string, nullable
        - `role` 'assistant'
        - `content` union
          - string
          - union[]
            - union
              - …
        - `tool_calls` ToolCall[], nullable
          - `index` integer, nullable
          - `id` string, nullable
          - `type` 'function'
          - `function` ResponseFunction, required
            - `name` string, nullable
            - `arguments` string, required
      - ToolMessage
        - `role` 'tool'
        - `content` union, required
          - string
          - ToolContent[]
            - `type` 'text'
            - `text` string, required
          - object[]
        - `tool_call_id` string, required
  - `model` string
  - `frequency_penalty` number, nullable
  - `presence_penalty` number, nullable
  - `stream` boolean, nullable
  - `stream_options` StreamOptions
    - `include_usage` boolean
  - `temperature` number, nullable
  - `top_p` number, nullable
  - `user` string, nullable
  - `max_tokens` integer, nullable
  - `max_completion_tokens` integer, nullable
  - `reasoning_effort` 'low' | 'medium' | 'high', nullable
  - `n` integer, nullable
  - `tools` Tool[], nullable
    - `type` 'function'
    - `function` Function, required
      - `name` string, required
      - `description` string, nullable
      - `parameters` unknown, required
  - `tool_choice` union
    - string
    - unknown
  - `stop` union
    - string[]
    - string
  - `extra_body` object, nullable

## Response `200`

Successful Response

- unknown

## Other responses

- `422` — Validation Error

---

[API](https://skmtc.net/myaltimate/apis/fastapi.md) · [All operations](https://skmtc.net/myaltimate/apis/fastapi/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/myaltimate/fastapi/revisions/50769cbf05d5/schema)
