API reference
Chat
Create a reply
POST https://antarya.ai/v1/chat
Send the conversation so far. Antarya returns the next reply. Pass session_id to continue a stored session, which is covered in sessions. The guides cover the larger features one at a time: conversations, streaming, structured output, tool use and files and images.
Headers
| Header | Value |
|---|---|
Authorization |
Bearer $ANTARYA_API_KEY |
Content-Type |
application/json |
curl https://antarya.ai/v1/chat \
-H "Authorization: Bearer $ANTARYA_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "antarya",
"system": "Answer in plain English.",
"messages": [
{"role": "user", "content": "Summarise this contract'"'"'s termination clause."}
],
"max_output_tokens": 400
}'{
"id": "req_01",
"model": "antarya",
"content": [
{"type": "text", "text": "Either side can end the agreement with 30 days of written notice."}
],
"stop_reason": "end_turn",
"usage": {"input_tokens": 24, "output_tokens": 17}
}Request body
| Name | Type | Required | Description |
|---|---|---|---|
model | text | No | The id or alias of the model. Leave it out to use the current default. |
messages | array | YesRequired | The conversation, oldest message first. |
role | text | YesRequired | "user", "assistant" or "tool". |
content | text or array | YesRequired | Plain text, or a list of parts. A part is text, an image, a file, a tool_call or a tool_result. The parts are listed under [message parts](#parts), and [files and images](/docs/guides/files-and-images) shows them in use. |
session_id | text | No | The id of a [stored session](/docs/guides/sessions). Its saved turns go before `messages`, and on success the new turns and the reply are saved to it. A failed or refused request saves nothing. |
include_thinking | boolean | No | Set to true to get short thinking notes with the reply. The default is false. A whole reply carries them as `thinking`, and a stream sends them as `thinking` events. |
system | text | No | Instructions that apply to the whole conversation. |
max_output_tokens | number | No | The most tokens the reply may hold. The reply stops there if it reaches the limit. |
stream | boolean | No | Set to true to receive server-sent events. The default is false. |
tools | array | No | Functions she may ask you to call. Each has a name, a description and an input_schema. |
tool_choice | object | No | How freely she may use tools. `auto` lets her decide and is the default, `none` stops her using tools, `any` makes her use one, and {"type": "tool", "name": "..."} makes her use that tool. |
response_format | object | No | A JSON schema the reply must follow, as {"type": "json_schema", "schema": {...}}. The schema may use the keywords type, properties, required, items, enum, description and additionalProperties. |
metadata | object | No | Your own labels for the request, up to 16 string pairs, with keys up to 64 characters and values up to 512 characters. They are kept with the usage record. They are never sent to the model. |
Message parts
| Part | Shape | Limits |
|---|---|---|
| Text | {"type": "text", "text": "..."} |
|
| File, by id | {"type": "file", "file_id": "file_..."} |
A file uploaded to /v1/files. |
| File, inline | {"type": "file", "source": {"type": "base64", "filename": "agreement.pdf", "media_type": "application/pdf", "data": "..."}} |
Up to 10 MB decoded. Read for this request only and not stored. |
| Image | {"type": "image", "source": {"type": "base64", "media_type": "image/png", "data": "..."}} |
PNG, JPEG or WebP, up to 10 MB each and 20 a request. |
Response
| Name | Type | Required | Description |
|---|---|---|---|
id | text | YesRequired | The id of this reply. |
model | text | YesRequired | The model that wrote the reply. |
content | array | YesRequired | The reply, as a list of parts. |
type | text | YesRequired | "text" or "tool_call". |
text | text | No | The words of a text part. |
stop_reason | text | YesRequired | Why the reply ended. See the table below. |
thinking | array | No | Only when `include_thinking` is true. A list of notes, each with a `step`, a `stage` (a short label) and a `summary`. |
usage | object | YesRequired | What the request used. |
input_tokens | number | YesRequired | Tokens in everything you sent. |
output_tokens | number | YesRequired | Tokens in the reply. |
stop_reason |
Meaning |
|---|---|
end_turn |
Antarya finished the reply. |
max_output_tokens |
The reply reached max_output_tokens and stopped. |
tool_call |
The reply asks you to run a function. Send the result back. |
A reply cut off at max_output_tokens ends with that value, including a JSON reply, which is then not complete.
Streaming
With stream set to true, the response is a stream of server-sent events. The events are reply.start, content.delta, reply.done and error, and thinking when include_thinking is true. The streaming guide shows each one and the data it carries.
event: reply.start
data: {"id": "req_03", "model": "antarya"}
event: content.delta
data: {"index": 0, "type": "text", "text": "Thank you for the invitation. "}
event: reply.done
data: {"stop_reason": "end_turn", "usage": {"input_tokens": 14, "output_tokens": 19}}
Not yet available
system, tools and response_format are not available on this model yet. Each turns on when the model object's capabilities flag (system, tools, structured_output) is true.
Limits
The model reports a longest reply of 2,048 tokens.
| Limit | Value |
|---|---|
| Longest reply | 2,048 tokens (max_output_tokens on the antarya model) |