Docs ChatGPT Chat /v1/completions
API reference

Creation completed

Given a hint, the model will return one or more predicted completions and can also return the probability of the surrogate marker for each position. Complete creation for the provided prompts and parameters…

POST/v1/completions

Body Parametersapplication/json

best_of integer

Defaults to 1 Generate best_of completions on the server side and return the "best" completion (the one with the highest log probability for each token). Unable to stream results. When used with n, best_of controls the number of candidate completions, and n specifies the number to return – best_of must be greater than n. Note: Because this parameter generates many completions, it can drain your token quota quickly. Please use with caution and make sure you have reasonable settings for max_tokens and stop.

echo boolean

The default is false. In addition to completion, prompts are also echoed.

frequency_penalty number

Defaults to 0 - a number between 2.0 and 2.0. Positive values ​​penalize new tokens based on the current existing frequency of the text, reducing the likelihood that the model will repeat the same line verbatim.

logit_bias object

Defaults to null The probability of occurrence of the specified token in modification completion. Accepts a JSON object that maps a token (specified by the token ID in the GPT tokenizer) to an associated bias value, -100 to 100. You can use this tokenizer tool (available for GPT-2 and GPT-3) to convert text into token IDs. Mathematically speaking, the bias is added to the resulting logit before sampling the model. The exact effect varies from model to model, but values ​​between -1 and 1 should reduce or increase the likelihood of selection; values ​​like -100 or 100 should result in a ban or exclusive selection of the token in question. For example, you can pass {"50256": -100} to prevent the <|endoftext|> token from being generated.

logprobs string nullable

Default is null Includes the log probabilities of the logprobs most likely tokens, as well as the selected token. For example, if logprobs is 5, the API will return a list of the 5 most likely tokens. The API always returns the logprob of the sampled token, so there may be at most logprobs+1 elements in the response. The maximum value of logprobs is 5.

max_tokens integer

Default is 16 The maximum number of tokens generated in completion. The hint's token count plus max_tokens cannot exceed the model's context length. Python code example for counting tokens.

model* string

The ID of the model to use. You can use the List models API to view all available models, or view our Model Overview for their descriptions.

n integer

Default is 1 The number of completions generated for each prompt. Note: Because this parameter generates many completions, it can drain your token quota quickly. Please use with caution and make sure you have reasonable settings for max_tokens and stop.

presence_penalty number

Defaults to 0 - a number between 2.0 and 2.0. Positive values ​​penalize new tokens based on whether they appear in the current text, increasing the likelihood that the model discusses new topics. For more information on frequency and presence penalties, see .

prompt* string

Generates a completed prompt, encoded as a string, an array of strings, an array of tokens, or an array of token arrays. Note that <|endoftext|> is the document delimiter that the model sees during training, so if no hints are specified, the model will generate the beginning of a new document.

seed integer

If specified, our system will do its best to sample deterministically so that repeated requests with the same seed and parameters should return the same results. Determinism is not guaranteed and you should refer to the system_fingerprint response parameter to monitor your backend for changes.

stop string

Defaults to null for a maximum of 4 sequences at which the API will stop generating more tokens. The text returned will not contain stop sequences.

stream boolean

The default is false whether to flow back part of the progress. If set, the token will be sent as a data-only server-sent event when available, and the stream is terminated by a data: [DONE] message. Object message. Python code examples.

suffix string

Defaults to null The suffix that appears after completion of inserted text.

temperature integer

Defaults to 1 The sampling temperature to use, between 0 and 2. Higher values ​​(like 0.8) will make the output more random, while lower values ​​(like 0.2) will make it more focused and deterministic. We generally recommend changing this or top_p, not both.

top_p integer

Represents a unique identifier for the end user, which can help OpenAI monitor and detect abuse. learn more.

user* string

End-user identifier (for risk control / billing)

Responses

200 application/json
response-200 object
properties
choices* array

List of candidate results

created* integer

Creation time (Unix timestamp)

id* string

Resource or task ID

model* string

Model name / model ID

object* string

Object type identifier, e.g. chat.completion

system_fingerprint* string

Backend configuration fingerprint

usage* object

Token usage statistics

400 Bad request or validation failed application/json
response-400 object
properties
error* object
401 Missing or invalid API Key application/json
response-401 object
Request Body Example
1{
2"max_tokens": 30,
3"model": "gpt-3.5-turbo-instruct",
4"prompt": "你好,",
5"temperature": 0,
6"user": "default-user"
7}
Code Sample cURL
1curl -X POST "https://api.digislash.com/v1/completions" \
2-H "Authorization: Bearer <API Key>" \
3-H "Content-Type: application/json" \
4-d '{
5"max_tokens": 30,
6"model": "gpt-3.5-turbo-instruct",
7"prompt": "你好,",
8"temperature": 0,
9"user": "default-user"
10}'
Response
1▼{
2▼"choices": [
3▶{ 4 keys }
4],
5"created": 1753859563,
6"id": "cmpl-ByvHP6AWeB1L5vWZSPNHsB12sU9db",
7"model": "gpt-3.5-turbo-instruct",
8"object": "text_completion",
9"system_fingerprint": "fp_abc123",
10▼"usage": {
11"completion_tokens": 30,
12"prompt_tokens": 3,
13"total_tokens": 33
14}
15}