---
title: "POST /v1/chat/completions"
method: POST
path: "/v1/chat/completions"
---

# POST /v1/chat/completions

`POST /v1/chat/completions`

Apply changes from big models into your files. Find your [API key](https://morphllm.com/dashboard).

## Request body

- union
  - ChatCompletionRequest
    - `model` 'morph-v3-fast' | 'morph-v3-large' | 'auto', required — ID of the model to use
    - `messages` object[], required — Array containing a single user message with structured content using instruction-guided format
      - `role` 'user', required — The role of the message author
      - `content` string, required — Message content with required format: <instruction>First-person description</instruction><code>Complete original file content</code><update>Code snippet with // ... existing code ... markers</update>
    - `stream` boolean — Enable streaming response
    - `max_tokens` integer — Maximum number of tokens to generate
    - `temperature` number — Sampling temperature (0.0 for deterministic output)
  - WarpGrepRequest
    - `model` 'morph-warp-grep-v1', required — ID of the Warp Grep model
    - `messages` WarpGrepMessage[], required — Multi-turn conversation with system prompt, user queries, assistant tool calls, and tool results
      - `role` 'system' | 'user' | 'assistant', required — The role of the message author
      - `content` string, required — Message content. User messages use <repo_structure> and <search_string> XML. Assistant messages contain <think> reasoning and XML tool calls (<grep>, <read>, <list_directory>, <finish>).
    - `temperature` number — Sampling temperature (0.0 recommended for deterministic search)
    - `max_tokens` integer — Maximum tokens per response

## Response `200`

Chat completion response

- ChatCompletionResponse
  - `id` string, required — Unique identifier for the completion
  - `object` string, required — Object type
  - `created` integer, required — Unix timestamp of when the completion was created
  - `choices` Choice[], required — List of completion choices
    - `index` integer, required — Index of the choice in the list
    - `message` object, required — The message generated by the model
      - `role` string — The role of the message author
      - `content` string — The content of the message
    - `finish_reason` string, required — The reason the model stopped generating tokens
  - `usage` ResponseUsage, required — Usage statistics for the completion request
    - `prompt_tokens` integer — Number of tokens in the prompt
    - `completion_tokens` integer — Number of tokens in the completion
    - `total_tokens` integer — Total number of tokens used

## Other responses

- `400` — Bad request error
- `401` — Authentication error

---

[API](https://skmtc.net/morphllm/apis/morph-api.md) · [All operations](https://skmtc.net/morphllm/apis/morph-api/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/morphllm/morph-api/versions/9e3d888071b5/schema)
