v1

latestOpenAPI 3.1.02026-07-26157321426.3 KB
Chat Completions

Create a chat completion

Creates a chat completion for the provided conversation. This endpoint is fully compatible with the OpenAI Chat Completions API, allowing you to use standard OpenAI SDKs by changing only the base URL and API key.

post/v1/chat/completions

Request body

modelstring required

The model slug to use for completion, such as deepseek-ai/DeepSeek-V4-Pro. Find available models at Model APIs.

frequency_penaltynumber

Penalizes tokens based on how frequently they appear in the text so far. Positive values decrease repetition. Support varies by model.

logit_biasobject

A map of token IDs to bias values (-100 to 100). Use this to increase or decrease the likelihood of specific tokens appearing in the output.

logprobsboolean

If true, returns log probabilities of the output tokens. Log probability support varies by model.

top_logprobsinteger

Number of most likely tokens to return at each position (0-20). Requires logprobs: true. Log probability support varies by model.

max_tokensinteger

Maximum number of tokens to generate. If your request input plus max_tokens exceeds the model's context length, max_tokens is truncated. If your request exceeds the context length by more than 16k tokens or if max_tokens signals no preference, context reservation is throttled to 49512 tokens. Higher max_tokens values slightly deprioritize request scheduling.

ninteger

Number of completions to generate. Only 1 is supported.

presence_penaltynumber

Penalizes tokens based on whether they have appeared in the text so far. Positive values encourage the model to discuss new topics. Support varies by model.

seedinteger

Random seed for deterministic generation. Determinism is not guaranteed across different hardware or model versions.

streamboolean

If true, responses are streamed back as server-sent events (SSE) as they are generated.

temperaturenumber

Controls randomness in the output. Lower values like 0.2 produce more focused and deterministic responses. Higher values like 1.5 produce more creative and varied output.

top_pnumber

Nucleus sampling: only consider tokens with cumulative probability up to this value. Lower values like 0.1 produce more focused output.

parallel_tool_callsboolean

If true, the model can call multiple tools in a single response.

userstring

A unique identifier for the end-user, useful for tracking and abuse detection.

best_ofinteger

Number of candidate sequences to generate and return the best from. Only a value of 1 is supported.

top_kinteger

Limits token selection to the top K most probable tokens at each step. Lower values like 10 produce more focused output. Set to -1 to disable.

top_p_minnumber

Minimum value for dynamic top_p. When set, top_p dynamically adjusts but does not go below this value.

min_pnumber

Minimum probability threshold for token selection. Filters out tokens with probability below min_p * max_probability.

repetition_penaltynumber

Multiplicative penalty for repeated tokens. Values greater than 1.0 discourage repetition, values less than 1.0 encourage it.

length_penaltynumber

Exponential penalty applied to sequence length during beam search. Values greater than 1.0 favor longer sequences.

early_stoppingboolean

If true, stops generation when at least n complete candidates are found.

bad_token_idsinteger[]

Token IDs to avoid in the output. Support varies by model.

stop_token_idsinteger[]

List of token IDs that cause generation to stop when encountered.

include_stop_str_in_outputboolean

If true, includes the matched stop string in the output.

ignore_eosboolean

If true, continues generating past the end-of-sequence token.

min_tokensinteger

Minimum number of tokens to generate before stopping. Useful for ensuring responses are not too short.

skip_special_tokensboolean

If true, removes special tokens from the generated output.

spaces_between_special_tokensboolean

If true, adds spaces between special tokens in the output.

truncate_prompt_tokensinteger

If set, truncates the prompt to this many tokens. Useful for handling inputs that may exceed context limits.

echoboolean

If true and the last message role matches the generation role, prepends that message to the output.

add_generation_promptboolean

If true, adds the generation prompt from the chat template, such as <|assistant|>. Set to false for completion-style generation.

add_special_tokensboolean

If true, adds special tokens like BOS to the prompt beyond what the chat template adds. For most models, the chat template handles special tokens, so this should be false.

documentsobject[]

A list of documents for RAG (retrieval-augmented generation). Each document is a dict with string keys and values that the model can reference.

chat_templatestring

A custom Jinja template for formatting the conversation. If not provided, uses the model's default template.

chat_template_argsobject

Additional arguments to pass to the chat template renderer.

Response

Successful response

idstring

A unique identifier for the chat completion.

object'chat.completion.chunk'

The object type, always chat.completion or chat.completion.chunk for streaming.

createdinteger

The Unix timestamp (in seconds) of when the completion was created.

modelstring required

The model used for the completion.