For AI agents: a documentation index is available at the root level at /llms.txt and /llms-full.txt. Append /llms.txt to any URL for a page-level index, or .md for the markdown version of any page.
Contact usJoin the Discord
ManualAPI GuideAPI Reference
  • Overview
    • API Reference
    • Client libraries
  • API Reference
      • POSTCreate a Text Completion
LogoLogo
Contact usJoin the Discord
API ReferenceCompletions

Create a Text Completion

POST
https://host.com/v1/complete
POST
/v1/complete
$curl -X POST https://host.com/v1/complete \
> -H "Content-Type: application/json" \
> -d '{
> "model": "model",
> "prompt": "prompt",
> "max_tokens_to_sample": 1
>}'
1{
2 "id": "id",
3 "type": "completion",
4 "completion": "completion",
5 "model": "model",
6 "stop_reason": "stop_reason"
7}
Create a Text Completion
Was this page helpful?
Previous

List Models

Next
Built with

Request

This endpoint expects an object.
modelstringRequired
Model identifier or alias.
promptstringRequired=1 character

Legacy completion prompt in Human/Assistant format.

max_tokens_to_sampleintegerRequired>=1
Maximum number of tokens to sample.
metadataobjectOptional
Metadata object for request attribution.
stop_sequenceslist of stringsOptional
Stop generation if any sequence is encountered.
streambooleanOptional
Whether to stream the response.
temperaturedoubleOptional0-1
Sampling temperature between 0 and 1.
top_kintegerOptional>=0

Top-k sampling parameter.

top_pdoubleOptional0-1

Top-p sampling parameter.

Response

This endpoint returns an object.
idstring
Completion identifier
type"completion"
Object type. Always "completion".
completionstring
Generated completion text.
modelstring
Resolved model identifier.
stop_reasonstring
Reason the generation stopped.

Errors

401
Unauthorized
422
Unprocessable Entity