This is a convenience, not the product. TokenPath attribution works with any model.
/v1/generate exists so demos and prototypes can produce an answer with a TokenPath key alone, without setting up a second provider. If you already have a model, skip this endpoint.attributions:write scope.
Request body
array of object
required
The conversation, oldest first. Each message is
{"role": "system" | "user" | "assistant", "content": "..."}. You can send 1 to 50 messages, and the last one must have role user. Total content across all messages is capped at 420,000 characters.integer
default:"512"
The maximum number of tokens to generate, from 16 to 2048.
422 validation_error, both at the top level and inside each message. There is no model, temperature, tools, or stream parameter. TokenPath chooses the model and sampling settings. Reasoning, tools, web search, images, and structured output are all off. The message shape looks like OpenAI’s chat format, but this is not an OpenAI-compatible endpoint.
The endpoint is stateless. To continue a conversation, send the whole transcript again each turn, just as you would with any chat API.
Response
A successful request returns200 with Content-Type: text/event-stream. Each server-sent event has a name and a single-line JSON payload:
delta
string
The next piece of the answer. Joining every
delta gives exactly the done answer.done
string
The complete answer. Attribute this string. Stream chunks can split in the middle of a Unicode character, but this field is always whole.
string
The model that actually ran. It can change over time, so read it instead of assuming.
object
input_tokens and output_tokens are the generation provider’s own counts, shown for transparency. billed_tokens is what you were charged.integer | null
Your available balance after this call, or
null if it could not be read.error
Sent instead of done when generation fails after the stream has started:
Billing
Generation uses the same prepaid credits as attribution, at the same $1 per million tokens.- You are billed for input only, estimated as
ceil(total message characters / 4). Output is free. - Credits are held before the model is called. If your balance is too low, you get
402 insufficient_creditsand nothing is spent. - The charge becomes final once the model accepts the request. Disconnecting afterwards does not refund it.
- If the request fails before the model accepts it, the hold is released in full.
- Each turn re-sends the whole conversation, so each turn pays for it again, including any document in the system message.
GET /v1/me/usage with generation_-prefixed reasons.
Generate, then attribute
Keep the document separate from the prompt you wrap it in. Send the bare document to/v1/attributions together with the done answer:
Errors
In addition to the authentication errors. The generation errors can arrive either as an HTTP status before the stream starts or as anerror event after it has started.
