Complete

complete

Methods

Create A Text Completion -> { id, completion, model, 2 more... }
post/v1/complete

[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.

header Parameters
anthropic-version: string
Optional

The version of the Anthropic API you want to use.

Read more about versioning and our version history here.

x-api-key: string
Optional

Your unique API key for authentication.

This key is required in the header of all API requests, to authenticate your account and access Anthropic's services. Get your API key through the Console. Each key is scoped to a Workspace.

Response fields
id: string

Unique object identifier.

The format and length of IDs may change over time.

completion: string

The resulting completion up to and excluding the stop sequences.

model: string

The model that handled the request.

stop_reason: string
Nullable

The reason that we stopped.

This may be one the following values:

  • "stop_sequence": we reached a stop sequence — either provided by you via the stop_sequences parameter, or a stop sequence built into the model
  • "max_tokens": we exceeded max_tokens_to_sample or the model's maximum
type: "completion"
(default: "completion")

Object type.

For Text Completions, this is always "completion".

Request example
200Example