Chat Completions API
Sample requests and responses for building with the Agentaus API.
Body Parameters
stream
true—The response is sent via Server-Sent Events as tokens are generated (default).false—The full response is returned in a single JSON payload.
temperature
What sampling temperature to use, between 0 and 2. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic. We generally recommend altering this or top_p but not both. Valid values: [0, 2].
top_p
An alternative to sampling with temperature, called nucleus sampling, where the model considers the results of the tokens with top_p probability mass. So 0.1 means only the tokens comprising the top 10% probability mass are considered. We generally recommend altering this or temperature but not both. Valid values: (0, 1].
tool_choice
"none"—The model will not call any tools and will generate a response directly."auto"—The model decides whether to invoke one or more tools or generate a response directly. This is the default when tools are provided."required"—Behaves identically to "auto". Full enforcement of required tool calls is a known limitation and is planned for a future release.Any other string—Treated as "none". The model will not call any tools.(omitted)—Defaults to "auto" behaviour.Object — Restricts the model to a subset of the provided tools. Only tools present in both the allowlist and the
toolsarray are visible to the model. Useful when you want to vary available tools across requests without changing thetoolspayload, preserving prompt cache. Constraints:typemust be"allowed_tools"modemust be"auto"- Each entry in
toolsmust includetypeandname
json{ "type": "allowed_tools", "mode": "auto", "tools": [ {"type": "function", "name": "get_weather"}, {"type": "function", "name": "get_horoscope"} ] }
tools
- If omitted, the model has access to both
agentaus_web_searchandagentaus_web_fetchby default. - Two built-in tools are available:
agentaus_web_search—Searches the web for current information using a query string. Returns up to 10 results with titles, URLs, and content snippets.agentaus_web_fetch—Fetches and extracts the full text content of a specific URL. Designed to be used afteragentaus_web_searchto read a discovered page.- Each built-in tool is an object with a
typefield set to either"agentaus_web_search"or"agentaus_web_fetch". Example:
{"type": "agentaus_web_fetch"}- Custom tools must set
typeto"function"and include afunctionobject containingname,description,parameters, andrequired. Example:
{
"type": "function",
"function": {
"name": "get_exchange_rate",
"description": "Get the exchange rate between two currencies",
"parameters": {
"type": "object",
"properties": {
"from": {"type": "string", "description": "Source currency code"},
"to": {"type": "string", "description": "Target currency code"}
},
"required": ["from", "to"]
}
}
}- When the model responds with a tool call, only one tool call is returned per response.
- Mixing built-in and custom tools in the same request is not yet supported.
Response
agentaus).chat.completion.choices
stop (final answer) or tool_calls (model wants to call a tool).message
tool_calls.assistant.tool_calls.function.usage
Two response shapes
finish_reason first — it tells you which of the two payloads you are holding. No tool call triggered, or built-in tools were used. The answer is final.
- content
- The response text
- tool_calls
[]
A custom function tool was invoked by the model. Run it and send the result back.
- content
null- tool_calls
- Function name and arguments