v1
latestOpenAPI 3.1.02026-07-26157321426.3 KBCreate 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.
Request body
The model slug to use for completion, such as deepseek-ai/DeepSeek-V4-Pro. Find available models at Model APIs.
Penalizes tokens based on how frequently they appear in the text so far. Positive values decrease repetition. Support varies by model.
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.
If true, returns log probabilities of the output tokens. Log probability support varies by model.
Number of most likely tokens to return at each position (0-20). Requires logprobs: true. Log probability support varies by model.
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.
Number of completions to generate. Only 1 is supported.
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.
Random seed for deterministic generation. Determinism is not guaranteed across different hardware or model versions.
If true, responses are streamed back as server-sent events (SSE) as they are generated.
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.
Nucleus sampling: only consider tokens with cumulative probability up to this value. Lower values like 0.1 produce more focused output.
If true, the model can call multiple tools in a single response.
A unique identifier for the end-user, useful for tracking and abuse detection.
Number of candidate sequences to generate and return the best from. Only a value of 1 is supported.
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.
Minimum value for dynamic top_p. When set, top_p dynamically adjusts but does not go below this value.
Minimum probability threshold for token selection. Filters out tokens with probability below min_p * max_probability.
Multiplicative penalty for repeated tokens. Values greater than 1.0 discourage repetition, values less than 1.0 encourage it.
Exponential penalty applied to sequence length during beam search. Values greater than 1.0 favor longer sequences.
If true, stops generation when at least n complete candidates are found.
Token IDs to avoid in the output. Support varies by model.
List of token IDs that cause generation to stop when encountered.
If true, includes the matched stop string in the output.
If true, continues generating past the end-of-sequence token.
Minimum number of tokens to generate before stopping. Useful for ensuring responses are not too short.
If true, removes special tokens from the generated output.
If true, adds spaces between special tokens in the output.
If set, truncates the prompt to this many tokens. Useful for handling inputs that may exceed context limits.
If true and the last message role matches the generation role, prepends that message to the output.
If true, adds the generation prompt from the chat template, such as <|assistant|>. Set to false for completion-style generation.
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.
A list of documents for RAG (retrieval-augmented generation). Each document is a dict with string keys and values that the model can reference.
A custom Jinja template for formatting the conversation. If not provided, uses the model's default template.
Additional arguments to pass to the chat template renderer.
Response
Successful response
A unique identifier for the chat completion.
The object type, always chat.completion or chat.completion.chunk for streaming.
The Unix timestamp (in seconds) of when the completion was created.
The model used for the completion.