Skip to main content

Chat Completion

POST 

https://knox.chat/v1/chat/completions

Send a chat generation/completion request to the selected model. The request must include a "messages" array. All advanced options from the base request are also supported.

Request

This endpoint requires an object.

Request Headers

NameTypeRequiredDescription
AuthorizationStringYesBearer authentication in the form of Bearer <token>, where token is your authentication token.

Request Body

NameTypeRequiredDescription
modelStringYesThe model ID to use. If not specified, the user's default setting will be used.
messagesList of ObjectsYesA list of message objects containing "role" and "content" properties.
modelsList of StringsNoAlternative model list for routing override.
providerObjectNoProvider routing preference settings.
reasoningObjectNoConfiguration for model reasoning/thought tokens.
usageObjectNoWhether to include usage information in the response.
transformsList of StringsNoA list of prompt transformations (Knox Chat only).
streamBooleanNoEnable result streaming. Defaults to false.
max_tokensIntegerNoMaximum number of tokens (range: [1, context_length)).
temperatureDoubleNoSampling temperature (range: [0, 2]).
seedIntegerNoSeed for deterministic output.
top_pDoubleNoTop-p sampling value (range: (0, 1]).
top_kIntegerNoTop-k sampling value (range: [1, Infinity)).
frequency_penaltyDoubleNoFrequency penalty (range: [-2, 2]).
presence_penaltyDoubleNoPresence penalty (range: [-2, 2]).
repetition_penaltyDoubleNoRepetition penalty (range: (0, 2]).
logit_biasMap of String to DoubleNoMapping from token IDs to bias values.
top_logprobsIntegerNoNumber of top log probabilities to return.
min_pDoubleNoMinimum probability threshold (range: [0, 1]).
top_aDoubleNoAlternative top sampling parameter (range: [0, 1]).

cURL Example

curl -X POST https://knox.chat/v1/chat/completions \
-H "Authorization: Bearer <token>" \
-H "Content-Type: application/json" \
-d '{
"model": "anthropic/claude-sonnet-4",
"messages": [
{
"role": "user",
"content": "生命的意义是什么?"
}
]
}'

Response

Success Response (200)

{
"id": "gen-12345",
"choices": [
{
"message": {
"role": "assistant",
"content": "生命的意义是一个复杂且主观的问题..."
}
}
]
}

Response Schema

NameTypeDescription
idstringUnique identifier for the completion
choicesarrayArray of completion choices
choices[].messageobjectThe generated message
choices[].message.rolestringRole of the message (typically "assistant")
choices[].message.contentstringContent of the generated message