Docs

API Reference

Responses & Usage

Responses & Usage

What a successful request returns, and how to read the usage it reports.

Response fields

FieldDescription
idIdentifier of this run. Quote it, with request_id, when you contact support.
request_idIdentifier of this request. The same value comes back in the X-Request-Id response header.
answerThe synthesized answer. With JSON Schema (Strict), the compact JSON of structured: the same value, serialized.
usageTokens and credits for this run. See below.
latency_msTime taken, in milliseconds.
finish_reasonWhy the answer ended: stop for a normal finish, length when it hit max_tokens or was cut short on Aivana's side.
noticesWhat you or your user may need to know about the answer, each a code and a message you can show as it is. Always present; empty when there is nothing to say.
structuredThe answer as a parsed JSON object, when you asked for structured output. With JSON Schema (Strict) it is the object validated against your schema, never null on a success. With prompt-defined JSON it is null if the answer wasn't a JSON object. See Structured output on Parameters.
structured_errorWhy the answer couldn't be parsed as a JSON object. null when parsing worked.
traceThe Intelligence Trace, only when you asked for it.

Usage

FieldDescription
input_tokensTokens in your request, including your history and any attached files.
cached_tokensThe part of input_tokens the run reused from cache. It is billed at the cached-input rate, and is 0 when nothing was reused.
output_tokensTokens in the answer.
creditsWhat the run was charged. See Pricing & Billing.

With JSON Schema (Strict), your schema counts once toward input_tokens, at about four characters a token of the schema as compact JSON, however Aivana produces the answer. A request that fails with structured_output_failed, or is refused for its schema, isn't charged. See Structured Outputs.

cached_tokens is part of input_tokens, not in addition to it. Cache reuse is automatic and may expire after inactivity, so identical follow-ups aren't guaranteed a cached part.

The usage and credits an API response returns are your actual Aivana usage and charge. Comparisons with external benchmarks are calculated separately in Usage & Insights and are not part of an individual Generate response.

Notices

Today there is one notice code, web_search_off: the question asked for the web (for example "search the web for…" or a link to read), but web search was off for the request, so the answer was written without searching. Set web_search to true to allow a search. A streamed response carries the same notices in its done event.

Example

json
{
  "id": "gen_...",
  "request_id": "req_...",
  "answer": "...",
  "usage": { "input_tokens": 5000, "output_tokens": 2000, "cached_tokens": 0, "credits": 0.013 },
  "latency_ms": 6120,
  "finish_reason": "stop",
  "notices": [
    { "code": "web_search_off", "message": "..." }
  ]
}

Learn more

Parameters

Every option the Generate API accepts.

View in Docs

Quickstart Guide

Get your key and make your first request in minutes.

Managing API Keys

Learn how to create and revoke API keys in Aivana AI Studio.

Create KeyView in Docs

Still have questions? We are here to help!

Try live

Run chat interactively in the Playground without any setup.

On this page

Responses & UsageResponse fieldsUsageNoticesExample

Helpful links

Aivana Status

Was this helpful?

Still have questions? We are here to help!