Completions
Creates a model response for the given chat conversation.
Header Parameters |
---|
Authorization string — REQUIREDThis field can adopt either of the following two formats: Bearer Token format: Authorization: Bearer <your_token_here> API Key format: X-API-Key: <your_token_here> Note: You must choose one of the two formats exclusively. |
Request Body | |
---|---|
messages array — REQUIREDA list of messages comprising the conversation so far. | |
model string — REQUIREDID of the model to use. Possible values: [deepseek-chat, deepseek-reasoner] | |
frequency_penalty numberNumber between -2.0 and 2.0. Positive values penalize new tokens based on their existing frequency in the text so far, decreasing the model's likelihood to repeat the same line verbatim. Possible values: Default value: 0 | |
max_tokens integerInteger between 1 and 8192. The maximum number of tokens that can be generated in the chat completion.The total length of input tokens and generated tokens is limited by the model's context length.If max_tokens is not specified, the default value 4096 is used. Possible values: | |
presence_penalty numberNumber between -2.0 and 2.0. Positive values penalize new tokens based on whether they appear in the text so far, increasing the model's likelihood to talk about new topics.
Possible values: Default value: 0 | |
response_format objectAn object specifying the format that the model must output. Setting to { "type": "json_object" } enables JSON Output, which guarantees the message the model generates is valid JSON. Important: When using JSON Output, you must also instruct the model to produce JSON yourself via a system or user message. Without this, the model may generate an unending stream of whitespace until the generation reaches the token limit, resulting in a long-running and seemingly "stuck" request. Also note that the message content may be partially cut off if finish_reason="length", which indicates the generation exceeded max_tokens or the conversation exceeded the max context length.
| |
stream booleanIf set, partial message deltas will be sent. Tokens will be sent as data-only server-sent events (SSE) as they become available, with the stream terminated by a data: [DONE] message. | |
temperature numberWhat 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 altering this or top_p but not both. Possible values: Default value: 1 | |
top_p numberAn alternative to sampling with temperature, called nucleus sampling, where the model considers the results of the tokens with top_p probability mass. So 0.1 means only the tokens comprising the top 10% probability mass are considered. Possible values: Default value: 1 | |
tools arrayA list of tools the model may call. Currently, only functions are supported as a tool. Use this to provide a list of functions the model may generate JSON inputs for. A max of 128 functions are supported. View More | |
logprobs booleanWhether to return log probabilities of the output tokens or not. If true, returns the log probabilities of each output token returned in the content of message. | |
top_logprobs integerAn integer between 0 and 20 specifying the number of most likely tokens to return at each token position, each with an associated log probability. logprobs must be set to true if this parameter is used. Possible values: |
Responses |
---|
200 Returns a chat completion object, or a streamed sequence of chat completion chunk objects if the request is streamed. View More |