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

# Create Chat Completion

`POST /api/v1/chat/completions`

Create a chat completion with automatic session creation if enabled.

Supports both streaming and non-streaming responses based on the 'stream' parameter.
Tool calling is supported but may work better with streaming enabled.

## Request body

- ChatCompletionRequest — Request payload for chat completions. Note: Field defaults and names must remain unchanged for API parity.
  - `model` string
  - `messages` ChatMessage[], required
    - `role` string, required
    - `content` string
    - `name` string
    - `tool_calls` object[]
    - `tool_call_id` string
  - `temperature` number
  - `top_p` number
  - `n` integer
  - `stream` boolean
  - `stop` union
    - string
    - string[]
  - `max_tokens` integer
  - `presence_penalty` number
  - `frequency_penalty` number
  - `tools` Tool[]
    - `type` string
    - `function` ToolFunction, required — Function definition for tool calling.
      - `name` string, required
      - `description` string
      - `parameters` object
  - `tool_choice` union
    - string
    - ToolChoice — Explicit tool selection for tool calling.
      - `type` string
      - `function` object
  - `session_id` string — Optional session ID to use for this request. If not provided, the system will use the session associated with the API key.

## Response `200`

Successful Response

- unknown

## Other responses

- `422` — Validation Error

---

[API](https://skmtc.dev/morpheusais/apis/morpheus-api-gateway.md) · [All operations](https://skmtc.dev/morpheusais/apis/morpheus-api-gateway/llms.txt) · [OpenAPI document](https://skmtc-service-production.skmtc.workers.dev/v1/apis/morpheusais/morpheus-api-gateway/revisions/061297d1593b/schema)
