> For clean Markdown content of this page, append .md to this URL. For the complete documentation index, see https://buildwithfern.com/learn/llms.txt. # Post Chat Completion POST https://fai.buildwithfern.com/chat/{domain} Content-Type: application/json Reference: https://buildwithfern.com/learn/docs/scribe-api/chat/post-chat-completion ## Authentication - `Authorization` header (bearer token, required) — Bearer authentication of the form `Bearer `, where token is your auth token. ## Servers - `https://fai.buildwithfern.com` (Production, default) - `https://fai-dev.buildwithfern.com` (Development) - `http://localhost:8080` (Local) ## Request ### Path parameters - `domain` (string, required) ### Body (application/json) This endpoint expects an object. - `messages` (list of object, required) — The messages to use for the chat completion - `role` (enum, required) - Allowed values: `user`, `assistant` - `content` (string, required) - `model` (enum, optional, nullable) — The model to use for the chat completion - Allowed values: `claude-4-sonnet`, `claude-4.5-haiku`, `claude-4.5-sonnet`, `claude-4.6-sonnet` - `max_tokens` (integer, optional, nullable, default: 3000) — The maximum number of tokens to generate. Note: setting a token count lower than 2000 may result in incomplete responses. You can add a custom system prompt to control the verbosity of the response. - `system_prompt` (string, optional, nullable) — The system prompt to use for the chat completion - `rewrite_query` (boolean, optional, nullable, default: false) — Whether to rewrite the query using query decomposition ## Response ### 200 Successful Response - `turns` (list of object, required) — The conversation turns in the chat completion - `role` (enum, required) - Allowed values: `user`, `assistant` - `content` (string, required) - `citations` (list of string, required) — List of citation strings ## Errors ### 422 Unprocessable Entity Error Validation Error - `detail` (list of object, optional) - `loc` (list of string or integer, required) - `msg` (string, required) - `type` (string, required) ## Examples **Request** ```json { "messages": [ { "role": "user", "content": "string" } ] } ``` **Response** ```json { "turns": [ { "role": "user", "content": "string" } ], "citations": [ "string" ] } ```