Completions
api/completions
Nearest release: v2.1.245, published an hour after this site recorded the change. Shown because the two are within 24 hours of each other. Nothing here says the release caused the edit.
api/completions Changed · +30 / -15 lines
### Headers ### Body parameters #### Response (200) ## Domain types ### Header Parameters ### Body Parameters #### Response ## Domain Types
---- -title: Completions -url: https://platform.claude.com/docs/en/api/completions ---- - # Completions ## Create a Text Completion -**post** `/v1/complete` +**POST** `/v1/complete` [Legacy] Create a Text Completion.
Future models and features will not be compatible with Text Completions. See our [migration guide](https://platform.claude.com/docs/en/build-with-claude/working-with-messages) for guidance in migrating from Text Completions to Messages. -### Header Parameters +### Headers - `"anthropic-beta": optional array of AnthropicBeta`
- `"mid-conversation-tool-changes-2026-07-01"` -### Body Parameters +### Body parameters - `max_tokens_to_sample: number`
Note that our models may stop _before_ reaching this maximum. This parameter only specifies the absolute maximum number of tokens to generate. + minimum: 1 + - `model: Model` The model that will complete your prompt.
See [prompt validation](https://platform.claude.com/docs/en/build-with-claude/working-with-messages) and our guide to [prompt design](https://platform.claude.com/docs/en/build-with-claude/prompt-engineering/overview) for more details. + minLength: 1 + - `metadata: optional Metadata` An object describing metadata about the request.
This should be a uuid, hash value, or other opaque identifier. Anthropic may use this id to help detect abuse. Do not include any identifying information such as name, email address, or phone number. + maxLength: 512 + - `stop_sequences: optional array of string` Sequences that will cause the model to stop generating.
- `temperature: optional number` + **Deprecated**: Deprecated. Models released after Claude Opus 4.6 do not support setting temperature. A value of 1.0 of will be accepted for backwards compatibility, all other values will be rejected with a 400 error. + Amount of randomness injected into the response. Defaults to `1.0`. Ranges from `0.0` to `1.0`. Use `temperature` closer to `0.0` for analytical / multiple choice, and closer to `1.0` for creative and generative tasks.
Note that even with `temperature` of `0.0`, the results will not be fully deterministic. + maximum: 1, minimum: 0 + - `top_k: optional number` + **Deprecated**: Deprecated. Models released after Claude Opus 4.6 do not accept top_k; any value will be rejected with a 400 error. + Only sample from the top K options for each subsequent token. Used to remove "long tail" low probability responses. [Learn more technical details here](https://towardsdatascience.com/how-to-sample-from-language-models-682bceb97277).
Recommended for advanced use cases only. + minimum: 0 + - `top_p: optional number` + **Deprecated**: Deprecated. Models released after Claude Opus 4.6 do not support setting top_p. A value >= 0.99 will be accepted for backwards compatibility, all other values will be rejected with a 400 error. + Use nucleus sampling. In nucleus sampling, we compute the cumulative distribution over all the options for each subsequent token in decreasing probability order and cut it off once it reaches a particular probability specified by `top_p`.
Recommended for advanced use cases only. + maximum: 1, minimum: 0 + ### Returns -- `Completion object { id, completion, model, 2 more }` +- `Completion object` - `id: string`
For Text Completions, this is always `"completion"`. - - `"completion"` + default: completion +- `Completion object` + ### Example -```http +```bash curl https://api.anthropic.com/v1/complete \ -H 'Content-Type: application/json' \ -H 'anthropic-version: 2023-06-01' \
}' ``` -#### Response +#### Response (200) ```json {
} ``` -## Domain Types +## Domain types ### Completion -- `Completion object { id, completion, model, 2 more }` +- `Completion object` - `id: string`
For Text Completions, this is always `"completion"`. - - `"completion"` + default: completion