---
title: "Create chat completion"
method: POST
path: "/chat/completions"
---

# Create chat completion

`POST /chat/completions`

## Request

- Base URL: `https://neo.character.ai/external`
- URL: `https://neo.character.ai/external/chat/completions`
- Auth: none declared. Required headers: `Application-Key`

Creates a model response for the given chat conversation.

## Headers

- `Application-Key` string, required
- `X-Routing-Key` string
- `X-External-User-Id` string

## Request body

- ChatCompletionRequest
  - `user_name` string: The username for which to generate the chat completion.
  - `character_id` string, required: The external character ID from c.ai, from whose perspective the chat completion will be generated.
  - `stream` boolean: If set, partial message deltas will be sent, like on c.ai. Response payloads will be sent as data-only server-sent events as they become available, with the stream terminated by `is_final: True`.
  - `messages` ChatCompletionRequestMessage[], required: A list of messages comprising the conversation so far.
    - `role` 'system' | 'user' | 'assistant', required: The role of the message's author.
    - `content` string, required: The contents of the message.
    - `name` string: (unused) An optional name for the participant.
  - `model` 'default' | 'safe'

## Response `200`

Successful operation

- ChatCompletionResponse
  - `response` string, required
  - `is_final` boolean, required

## Other responses

- `403`: Invalid API key
- `405`: Method Not Allowed
- `429`: Too Many Requests

## Changes

- **2024-12-12** `256c9f25f906`: 1 breaking, 1 info
  - the `stream` request property type changed from `bool` to `boolean`
  - added the new optional request property `model`

[Operation history](https://skmtc.dev/character/apis/external-character-ai-openapi-3-0/changes/chat/completions/post.md)

---

[API](https://skmtc.dev/character/apis/external-character-ai-openapi-3-0.md) - [All operations](https://skmtc.dev/character/apis/external-character-ai-openapi-3-0/llms.txt) - [OpenAPI document](https://skmtc.dev/character/apis/external-character-ai-openapi-3-0/revisions/256c9f25f906?raw)
