Create Chat Completion
Creates a model response for the given chat conversation.Request Body
string
required
The ID of the model to use. Must match a model available in Jan.Example:
llama3-8b-instruct, qwen2.5-7b-instructarray
required
A list of messages comprising the conversation so far.Each message has:
role(string, required): One ofsystem,user,assistant, ortoolcontent(string or array): The message content. Can be a string or an array of content parts (for multimodal messages)name(string, optional): The name of the message authortool_calls(array, optional): Tool calls made by the assistanttool_call_id(string, optional): The ID of the tool call this message is responding to
number
default:"0.7"
Sampling temperature between 0 and 2. Higher values make output more random, lower values more deterministic.
number
The maximum number of tokens to generate. Set to
null or omit for unlimited generation (up to context limit).number
default:"0.95"
Nucleus sampling: only tokens with cumulative probability up to
top_p are considered.number
default:"40"
Only the top K most likely tokens are considered for generation.
number
Minimum probability threshold for token selection.
boolean
default:false
If
true, returns a stream of Server-Sent Events (SSE) as the model generates tokens.string | array
Up to 4 sequences where the API will stop generating further tokens.
number
default:"0"
Number between -2.0 and 2.0. Positive values penalize new tokens based on whether they appear in the text so far.
number
default:"0"
Number between -2.0 and 2.0. Positive values penalize new tokens based on their existing frequency in the text.
number
default:"1.1"
Penalty for repeating tokens. Values > 1 discourage repetition.
number
default:"64"
Number of previous tokens to consider for repeat penalty.
number
Random seed for reproducible generation.
array
A list of tools the model may call. Each tool has:
type(string): Currently only"function"is supportedfunction(object): Function definition withname,description, andparameters
string | object
Controls which (if any) function is called by the model.
"none": Model will not call any function"auto": Model can pick between generating a message or calling a function"required": Model must call one or more functions{"type": "function", "function": {"name": "my_function"}}: Forces a specific function call
Advanced Parameters
number
Dynamic temperature range for sampling.
number
Dynamic temperature exponent.
number
Typical probability mass for sampling.
number
Enable Mirostat sampling.
0 = disabled, 1 = Mirostat, 2 = Mirostat 2.0.number
Mirostat target entropy.
number
Mirostat learning rate.
object
Modify the likelihood of specified tokens appearing. Maps token IDs to bias values (-100 to 100).
boolean
Enable KV cache for the prompt.
Response
string
A unique identifier for the chat completion.
string
The object type, always
chat.completion.number
Unix timestamp (in seconds) of when the completion was created.
string
The model used for the completion.
array
A list of chat completion choices. Can be more than one if
n is greater than 1.Each choice contains:index(number): The index of this choicemessage(object): The generated messagerole(string): Alwaysassistantcontent(string): The content of the messagetool_calls(array, optional): Tool calls made by the model
finish_reason(string): Why generation stopped (stop,length,tool_calls,content_filter)
object
Token usage information.
prompt_tokens(number): Number of tokens in the promptcompletion_tokens(number): Number of tokens in the completiontotal_tokens(number): Total tokens used
string
System fingerprint for the backend.
Example Response
Streaming
Whenstream is set to true, the API returns Server-Sent Events (SSE) as the model generates tokens.
Streaming Request
cURL
Streaming Response
Each chunk is a JSON object prefixed withdata: :
Streaming Response Fields
string
Unique identifier for the chat completion (consistent across all chunks).
string
Always
chat.completion.chunk.number
Unix timestamp.
string
The model used.
array
Array of choices.
index(number): Choice indexdelta(object): Content deltarole(string, optional): Set in first chunkcontent(string, optional): Incremental content
finish_reason(string | null): Reason for stopping (only in final chunk)
object
Jan-specific field showing prompt processing progress.
cache(number): Tokens already in KV cacheprocessed(number): Tokens processed so fartotal(number): Total prompt tokenstime_ms(number): Time spent processing
Multimodal Messages
Jan supports vision models that can process images alongside text.Image Input
cURL
Content Array Format
When using multimodal messages, thecontent field is an array of objects:
string
required
The type of content:
text, image_url, or input_audio.string
Text content (when type is
text).object
Image content (when type is
image_url).url(string): URL or base64-encoded data URI
Function Calling
Jan supports function calling for compatible models.Request with Tools
Response with Tool Call
Error Handling
Finish Reasons
stop: Natural stop point or stop sequence reachedlength: Maximum token limit reached (context overflow)tool_calls: Model called a functioncontent_filter: Content was filtered
Context Overflow
When the conversation exceeds the model’s context window, the API returnsfinish_reason: "length". You’ll need to truncate the conversation history or use a model with a larger context window.