Assistant turns
One question and its answer: every step the assistant took, the tools it read the account with, and the words, written as they arrive. :stream follows a turn as it happens; :cancel stops it.
List assistant turns
The turns of a conversation, the first asked first.
path Parameters
account_idId of the parent account.
assistant_conversation_idId of the parent assistant_conversation.
query Parameters
page_sizeRows per page. Over the maximum is clamped, not rejected.
page_tokenOpaque token from a previous next_page_token. A token minted under a different order_by/filter is rejected.
skipRows to skip before the page (AIP-158). skip + page_size is capped at 10000; beyond that is OUT_OF_RANGE.
order_byComma-separated field [asc|desc], at most 3 keys. Default: create_time asc. Sortable: create_time.
filterAIP-160 subset (§8). Filterable: create_time. A field outside the list is INVALID_ARGUMENT.
List assistant turns › Responses
One page of turns.
This page of turns, in the requested order.
next_page_tokenOpaque. Absent or empty means this was the last page.
total_sizeRows in the whole filtered collection, not in this page.
Create assistant turn
Asks the assistant: answers at once with the turn, QUEUED, and the assistant works on it in the background — follow it with :stream, or read it until state is final. After the person applied, stopped, rejected or reverted a change set the assistant made, a turn of input.kind CHANGE_SET_RESULT naming the set in input.change_set tells the assistant how it ended, and it answers that.
Refused before anything is written or spent: FAILED_PRECONDITION ASSISTANT_DISABLED while the account has the assistant off; INVALID_ARGUMENT for an empty message or one longer than 8 000 characters, and for a CHANGE_SET_RESULT turn with a text, or naming a change set that is not this conversation's or is not yet applied, stopped, rejected or reverted; FAILED_PRECONDITION TURN_IN_PROGRESS while the conversation's last turn is still answering; RESOURCE_EXHAUSTED while the assistant answers as many turns as it runs at once; and the AI platform's own refusals — no connection the settings allow (NO_USABLE_CONNECTION), a balance or a limit that does not admit the call (INSUFFICIENT_BALANCE, DAILY_LIMIT_REACHED, MONTHLY_LIMIT_REACHED, CONCURRENCY_LIMIT_REACHED, MODEL_NOT_PRICED).
path Parameters
account_idId of the parent account.
assistant_conversation_idId of the parent assistant_conversation.
Create assistant turn › Request Body
inputWhat the turn answers. kind USER_MESSAGE (the default): text, the person's message (at most 8 000 characters). kind CHANGE_SET_RESULT: change_set, the name of a change set of this conversation that was applied, stopped, rejected or reverted — the assistant is told how it ended, and no text is sent. Either kind takes context, the screen the person was on — route, resource, website_id, locale: context for the model, never a grant.
Create assistant turn › Responses
The created resource.
nameThe resource name (§5) — the identity of this resource, and the path that addresses it: websites/{website}/cms_pages/{cms_page}. It is the handle to store, not a human label.
idThe last segment of name on its own, for a client that needs to build a child URL. Unique inside its parent, never across the platform.
create_timeWhen the resource was created (RFC 3339, UTC).
update_timeWhen the resource last changed (RFC 3339, UTC).
etagVersion of the persisted state. Send it back in If-Match on Update or Delete and the write is rejected with ABORTED if anyone else changed the resource meanwhile (§14).
inputWhat the turn answers. kind USER_MESSAGE (the default): text, the person's message (at most 8 000 characters). kind CHANGE_SET_RESULT: change_set, the name of a change set of this conversation that was applied, stopped, rejected or reverted — the assistant is told how it ended, and no text is sent. Either kind takes context, the screen the person was on — route, resource, website_id, locale: context for the model, never a grant.
stateQUEUED, RUNNING, then SUCCEEDED, FAILED, CANCELLED, or INTERRUPTED — a turn whose process stopped before it ended reads so once its deadline_time has passed.
outputThe answer so far, {text}, written as it arrives; absent until the first word.
stepsEach call of the model and of a tool, in order: kind (MODEL_CALL, TOOL_CALL), name, a summary line, status, duration once it ended, on the step a limit of the turn ended, limit (MODEL_CALLS, TOOL_CALLS, DURATION, INPUT_LENGTH), and on the call that made a change set, change_set — its name, state as the step left it (APPLIED, FAILED, AWAITING_CONFIRMATION) and item_count.
intentsWhat the turn asks the admin to do for the person, in order: {kind, target} — OPEN and the name of a resource, a collection or a setting to show; PREVIEW and the name of a theme, with url — a link to the website drawn with that theme, for the person to open — and expire_time, when the link stops working; IMAGE and the name of a file of the media library the turn drew, with generation — the image_generations run that drew it — to show the person.
usageThe tokens of the turn's model calls summed — input, output, cache reads and writes — and image_count, the pictures the turn drew; with cost when the platform's key paid — for the calls and the pictures — and connection_kind, BYOK or MANAGED, of the model's calls.
model_idThe ai_models entry the turn runs on, fixed when it was created from the account's assistant settings.
errorWhy a FAILED turn stopped, in the shape of an API error: code, status, message and its details.
sequenceThe number of the turn's latest change — 0 before the first. Every event of :stream carries the next one; pass the last you applied as after_sequence to resume.
deadline_timeWhen the turn must have ended (RFC 3339, UTC): it answers in words before it, and reads INTERRUPTED if its process stopped first.
end_timeWhen the turn reached its final state (RFC 3339, UTC); absent while it runs.
Get assistant turn
One exchange of a conversation: the person's message and the screen they were on, every step the assistant took to answer — the model's calls and the tools it read and changed the account with — and the answer, written as it arrives. A change is always a change set: applied at once, or waiting for the person to apply it — then the turn ends, and a turn of kind CHANGE_SET_RESULT tells the assistant how the set ended. Create starts it; :stream follows it as it happens, and :cancel stops it.
path Parameters
account_idId of the parent account.
assistant_conversation_idId of the parent assistant_conversation.
turn_idId of the parent turn.
Headers
If-None-MatchA matching etag answers 304 with no body (§16).
Get assistant turn › Responses
The resource.
nameThe resource name (§5) — the identity of this resource, and the path that addresses it: websites/{website}/cms_pages/{cms_page}. It is the handle to store, not a human label.
idThe last segment of name on its own, for a client that needs to build a child URL. Unique inside its parent, never across the platform.
create_timeWhen the resource was created (RFC 3339, UTC).
update_timeWhen the resource last changed (RFC 3339, UTC).
etagVersion of the persisted state. Send it back in If-Match on Update or Delete and the write is rejected with ABORTED if anyone else changed the resource meanwhile (§14).
inputWhat the turn answers. kind USER_MESSAGE (the default): text, the person's message (at most 8 000 characters). kind CHANGE_SET_RESULT: change_set, the name of a change set of this conversation that was applied, stopped, rejected or reverted — the assistant is told how it ended, and no text is sent. Either kind takes context, the screen the person was on — route, resource, website_id, locale: context for the model, never a grant.
stateQUEUED, RUNNING, then SUCCEEDED, FAILED, CANCELLED, or INTERRUPTED — a turn whose process stopped before it ended reads so once its deadline_time has passed.
outputThe answer so far, {text}, written as it arrives; absent until the first word.
stepsEach call of the model and of a tool, in order: kind (MODEL_CALL, TOOL_CALL), name, a summary line, status, duration once it ended, on the step a limit of the turn ended, limit (MODEL_CALLS, TOOL_CALLS, DURATION, INPUT_LENGTH), and on the call that made a change set, change_set — its name, state as the step left it (APPLIED, FAILED, AWAITING_CONFIRMATION) and item_count.
intentsWhat the turn asks the admin to do for the person, in order: {kind, target} — OPEN and the name of a resource, a collection or a setting to show; PREVIEW and the name of a theme, with url — a link to the website drawn with that theme, for the person to open — and expire_time, when the link stops working; IMAGE and the name of a file of the media library the turn drew, with generation — the image_generations run that drew it — to show the person.
usageThe tokens of the turn's model calls summed — input, output, cache reads and writes — and image_count, the pictures the turn drew; with cost when the platform's key paid — for the calls and the pictures — and connection_kind, BYOK or MANAGED, of the model's calls.
model_idThe ai_models entry the turn runs on, fixed when it was created from the account's assistant settings.
errorWhy a FAILED turn stopped, in the shape of an API error: code, status, message and its details.
sequenceThe number of the turn's latest change — 0 before the first. Every event of :stream carries the next one; pass the last you applied as after_sequence to resume.
deadline_timeWhen the turn must have ended (RFC 3339, UTC): it answers in words before it, and reads INTERRUPTED if its process stopped first.
end_timeWhen the turn reached its final state (RFC 3339, UTC); absent while it runs.
Cancel (assistant turn)
Stops a turn. One that has not started is CANCELLED at once; a running one stops at its next checkpoint — between two steps, or within about a second of a call of the model or of a read in flight — and reads RUNNING until then, keeping what it already wrote. A turn that has ended answers FAILED_PRECONDITION (TURN_FINISHED). Safe to repeat.
path Parameters
account_idId of the parent account.
assistant_conversation_idId of the parent assistant_conversation.
turn_idId of the parent turn.
Cancel (assistant turn) › Request Body optional
Cancel (assistant turn) › Responses
The affected resource, or the method’s own response object (§10).
Stream (assistant turn)
Follows a turn as it happens, as server-sent events (text/event-stream, §17 «Streamed responses»): first snapshot — the turn whole, as a Get answers it — then each change of it, each with its sequence, until turn.completed ends the stream; change_set tells a change set a step made, with its name, state and number of items. A turn that has already ended is its snapshot alone. While nothing changes, a : keep-alive comment every 15 seconds.
Pass after_sequence — the last sequence you applied — to resume after a dropped connection: the snapshot still comes first, and nothing at or below it is sent again. Read it with fetch and this call's Authorization; closing the connection does not stop the turn — :cancel does.
path Parameters
account_idId of the parent account.
assistant_conversation_idId of the parent assistant_conversation.
turn_idId of the parent turn.
query Parameters
after_sequenceThe last sequence the client applied, to resume a stream that dropped: the snapshot still comes first, and no event at or below it is sent again. A negative value is INVALID_ARGUMENT.
Stream (assistant turn) › Responses
Server-sent events (§17, «Streamed responses»): each an event: line with its name and one data: line with a JSON object that carries the sequence of the change, then a blank line. While nothing changes, a : keep-alive comment. The server ends the stream after the last event; a client ignores an event it does not know.
snapshot—turn— the turn whole, as a Get answers it, and thesequenceof the last change it holds. First on every connection; a turn that has already ended is the whole stream.text.delta—text— the next piece of the answer, appended tooutput.text.step.started—indexandstep— a call of the model or of a tool began, assteps[index]. The first one is the turn leavingQUEUEDforRUNNING.step.completed—indexandstep—steps[index]ended: itsstatus, itsduration, and on the last step a limit of the turn ended, itslimit.intent—intent—{kind, target}, added tointents: something to open for the person — withurlandexpire_timeon aPREVIEW, a theme's preview link.change_set—indexandchange_set—{name, state, item_count}: the call ofsteps[index]made a change set, applied at once (APPLIED,FAILED) or waiting for the person to apply it (AWAITING_CONFIRMATION). Set on that step; read the set by its name.usage—usage— the turn's wholeusageafter a call of the model, not the call's part.turn.completed—turn— the turn in its final state, as a Get answers it:SUCCEEDED,FAILEDwith itserror,CANCELLEDorINTERRUPTED. The last event of the stream.error—error— the Status of §13: the stream failed after it began, and this is its last event. Read the resource to know where it stands.
The events, one after another, as they happen.