Create Completion

Create Completion
Create a completion.

Given a prompt, this method lets you retrieve one or more predicted completions along with the probabilities of alternative tokens at each position.

To leverage the newest models and features, you should consider using use the Chat Completions API instead.

This method is compatible with the OpenAI endpoint for creating a completion.

Request
URI
POST
https://{api_host}/api/v1/compatibility/openai/v1/completions
COPY
Request Body
CompletionsRequestPayload of type(s) application/json
Required

Show optional properties

{
    "model": "model-to-use",
    "prompt": "hello"
}
{
    "temperature": "number",
    "n": 0,
    "stop": [
        "string"
    ],
    "max_tokens": 0,
    "stream": false,
    "stream_options": {
        "include_usage": false
    },
    "model": "string",
    "prompt": "string",
    "seed": 0
}
number
temperature
Optional
Constraints: minimum: 0 maximum: 2 default: 0

temperature

integer
n
Optional
Constraints: minimum: 1 default: 1

n

array of string
stop
Optional
Constraints: minItems: 1

stop

integer
max_tokens
Optional
Constraints: minimum: 1

max_tokens

boolean
stream
Optional

stream

stream_options
Optional

Options for streaming response. Only set this when you set stream: true.

string
model
Required

ID of the completions model to use.

string
prompt
Required

prompt

integer
seed
Optional

Seed to propagate to the LLM for making repeated requests with the same seed as deterministic as possible. Note that this feature is in beta for most inference servers.

Authentication
This operation uses the following authentication methods.
Responses
200

Successful Response

{
    "choices": [
        {
            "finish_reason": "length",
            "index": 0,
            "text": "Hello! I am an AI Assistant!"
        }
    ],
    "created": 1589478378,
    "id": "cmpl-123",
    "model": "gpt-4",
    "object": "text_completion",
    "usage": {
        "completion_tokens": 7,
        "prompt_tokens": 5,
        "total_tokens": 12
    }
}

400

Invalid model endpoint specified or model endpoint not ready.

Operation doesn't return any data structure

404

Unknown model endpoint requested.

Operation doesn't return any data structure

422

Validation Error

Returns HTTPValidationError of type(s) application/json
{
    "detail": [
        {
            "loc": [
                {}
            ],
            "msg": "string",
            "type": "string"
        }
    ]
}
array of object
detail
Optional

detail


Code Samples
COPY
                    curl -X POST -H 'Authorization: <value>' -H 'Content-Type: application/json' -d '{"model":"string","prompt":"string"}' https://{api_host}/api/v1/compatibility/openai/v1/completions