Create a Text Completion
[Legacy] Create a Text Completion.
The Text Completions API is a legacy API. We recommend using the Messages API going forward.
Future models and features will not be compatible with Text Completions. See our migration guide for guidance in migrating from Text Completions to Messages.
Headers
The version of the Claude API you want to use.
Read more about versioning and our version history here.
The version of the Claude API you want to use.
Read more about versioning and our version history here.
Optional header to specify the beta version(s) you want to use.
To use multiple betas, use a comma separated list like beta1,beta2 or specify the header multiple times for each beta.
Optional header to specify the beta version(s) you want to use.
To use multiple betas, use a comma separated list like beta1,beta2 or specify the header multiple times for each beta.
Request body
Example request
{
"max_tokens_to_sample": 256,
"model": "claude-2.1",
"prompt": "\n\nHuman: Hello, world!\n\nAssistant:"
}Response
Text Completion object.
Example response
{
"completion": " Hello! My name is Claude.",
"id": "compl_018CKm6gsux7P8yMcwZbeCPw",
"model": "claude-2.1",
"stop_reason": "stop_sequence",
"type": "completion"
}