Create a chat completion
Create a chat completion, optionally grounded in the caller's stores.
Supports the OpenAI Chat Completions API subset: a message list, function tools, streaming via server-sent events, and persistence via store. The caller sends the full conversation on every call; previous_completion_id groups stored turns into a conversation and restores the full model context — when the request's messages extend the stored conversation unchanged, the model also sees the previous turns' hosted tool calls and results, while an edited history is honored exactly as sent. Retrieval is opt-in: declare the hosted store tools (store_search, store_grep, store_list_chunks, store_metadata_facets, list_stores) in tools to let the model search, grep, filter, and read the caller's stores server-side, scoped by each declaration. Those executions are reported in the hosted_tool_calls extension field (and as extra streaming chunks), with chunk results included only for the requested include keys. A model call to a caller-declared function tool ends the completion with tool_calls on the choice message (finish_reason tool_calls); execute the functions and continue the conversation by appending the assistant message and the matching tool messages to the next request.
Request body
Example request
{
"tools": [
{
"filters": {
"all": [
{
"key": "price",
"operator": "gt",
"value": "100"
},
{
"key": "color",
"operator": "eq",
"value": "red"
}
],
"any": [
{
"key": "price",
"operator": "gt",
"value": "100"
},
{
"key": "color",
"operator": "eq",
"value": "red"
}
],
"none": [
{
"key": "price",
"operator": "gt",
"value": "100"
},
{
"key": "color",
"operator": "eq",
"value": "red"
}
]
}
}
]
}Response
The generated chat completion, or a server-sent event stream of completion chunks