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
  }'
Output
{
  "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

NameTypeRequiredDescription
modeltextNoThe id or alias of the model. Leave it out to use the current default.
messagesarrayYesRequiredThe conversation, oldest message first.
roletextYesRequired"user", "assistant" or "tool".
contenttext or arrayYesRequiredPlain 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_idtextNoThe 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_thinkingbooleanNoSet 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.
systemtextNoInstructions that apply to the whole conversation.
max_output_tokensnumberNoThe most tokens the reply may hold. The reply stops there if it reaches the limit.
streambooleanNoSet to true to receive server-sent events. The default is false.
toolsarrayNoFunctions she may ask you to call. Each has a name, a description and an input_schema.
tool_choiceobjectNoHow 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_formatobjectNoA 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.
metadataobjectNoYour 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

NameTypeRequiredDescription
idtextYesRequiredThe id of this reply.
modeltextYesRequiredThe model that wrote the reply.
contentarrayYesRequiredThe reply, as a list of parts.
typetextYesRequired"text" or "tool_call".
texttextNoThe words of a text part.
stop_reasontextYesRequiredWhy the reply ended. See the table below.
thinkingarrayNoOnly when `include_thinking` is true. A list of notes, each with a `step`, a `stage` (a short label) and a `summary`.
usageobjectYesRequiredWhat the request used.
input_tokensnumberYesRequiredTokens in everything you sent.
output_tokensnumberYesRequiredTokens 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)

Next steps