Skip to main content
POST

Body

application/json
model
string
required

Model name

messages
object[]
required

Chat history as an array of message objects (each with a role and content)

tools
object[]

Optional list of function tools the model may call during the chat

format

Format to return a response in. Can be json or a JSON schema

Available options:
json
options
object

Runtime options that control text generation

stream
boolean
default:true
think

Controls a model's thinking output. Use /api/show to discover the supported values and default for the selected model. true requests thinking, false requests no thinking output, and null uses the model default. String values are model-defined; supported names must match /api/show exactly. Numbers are not supported.

keep_alive

Model keep-alive duration (for example 5m or 0 to unload immediately)

logprobs
boolean

Whether to return log probabilities of the output tokens

top_logprobs
integer

Number of most likely tokens to return at each token position when logprobs are enabled

Response

Chat response

model
string

Model name used to generate this message

created_at
string<date-time>

Timestamp of response creation (ISO 8601)

message
object
done
boolean

Indicates whether the chat response has finished

done_reason
string

Reason the response finished

total_duration
integer

Total time spent generating in nanoseconds

load_duration
integer

Time spent loading the model in nanoseconds

prompt_eval_count
integer

Number of tokens in the prompt

prompt_eval_cached_count
integer

Number of prompt tokens read from the cache

prompt_eval_duration
integer

Time spent evaluating uncached prompt tokens in nanoseconds

eval_count
integer

Number of tokens generated in the response

eval_duration
integer

Time spent generating tokens in nanoseconds

logprobs
object[]

Log probability information for the generated tokens when logprobs are enabled