AI executions
The execution — one persistent run, with its model, its attempts, its tokens and its output. Runs are carried out in the background; :cancel stops one and :retry runs it again.
List AI executions
One run of an agent in an account: what was asked, which model and connection ran it, what came back, what it consumed, and every attempt in between. Runs are carried out in the background — create one, then read it until state is final.
path Parameters
account_idId of the parent account.
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 desc. Sortable: create_time, expire_time.
filterAIP-160 subset (§8). Filterable: agent_id, connection_id, connection_mode, create_time, end_time, expire_time, model_id, provider, source_id, source_module, start_time, state. A field outside the list is INVALID_ARGUMENT.
List AI executions › Responses
One page of ai_executions.
This page of ai_executions, 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 AI execution
Starts a run of an agent and answers at once with the run, QUEUED: the work happens in the background, so read the run until state is SUCCEEDED, FAILED, CANCELLED or EXPIRED. The run uses the agent's current version and its instruction's active (or pinned) version, and keeps using them even if either changes before it starts.
Refused before anything is queued: an input that does not fill exactly the variables the instruction uses, a model_id the agent cannot run on, an agent that is switched off, and an account with no connection the agent may use (FAILED_PRECONDITION, NO_USABLE_CONNECTION). Send a request_id to make the call safe to repeat: a repeat returns the first run.
path Parameters
account_idId of the parent account.
Create AI execution › Request Body
agent_idThe id of the account's ai_agents entry this run executes. Set on create and fixed afterwards.
inputWhat the run works on: variables, an object filling every {{variable}} the instruction uses (strings, integers or booleans), and optionally text — material for the instruction to act on, such as a page to translate.
model_idThe ai_models entry the run uses. Leave it out to use the agent's preferred_model_id; when the agent lists allowed_model_ids, only those can be named.
source_moduleWho started the run, in the caller's own words — editorial, import. Stored and filterable, never interpreted. Fixed after create.
source_idThe caller's own reference for what the run is for, within source_module, which it requires. Filter by it together with source_module.
metadataAny other correlation the caller wants back with the run, as an object of at most 16 KB. Returned as sent; not filterable.
expire_timeA deadline for starting: a run not started by then becomes EXPIRED without calling the provider (RFC 3339, UTC). Sort by it together with a state filter.
request_idAn idempotency key you choose, at most 64 characters. Creating with a key already used returns the run that key created instead of starting another.
Create AI execution › 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).
agent_idThe id of the account's ai_agents entry this run executes. Set on create and fixed afterwards.
agent_versionThe version of the agent this run uses, resolved when the run was created. Its settings are kept under the agent's versions, so the run can be reproduced after the agent changes.
instruction_versionThe version of the agent's instruction whose text this run uses, resolved when the run was created.
model_idThe ai_models entry the run uses. Leave it out to use the agent's preferred_model_id; when the agent lists allowed_model_ids, only those can be named.
providerThe AI provider of the run's model, by the platform's name for it.
inputWhat the run works on: variables, an object filling every {{variable}} the instruction uses (strings, integers or booleans), and optionally text — material for the instruction to act on, such as a page to translate.
stateQUEUED, RUNNING, then SUCCEEDED, FAILED, CANCELLED or EXPIRED. A retryable failure puts the run back to QUEUED until its attempts run out.
connection_idThe ai_connections entry the latest attempt was authorized through. Absent until an attempt was routed.
connection_modeWhose key the latest attempt used: BYOK (the account's own) or MANAGED (the platform's, paid from the AI balance).
usageWhat the run consumed, summed over every attempt that reported it: input_tokens, output_tokens, cache_read_input_tokens, cache_creation_input_tokens, and for an IMAGE run image_count and megapixels_milli (thousandths of a megapixel).
costWhat the run was charged to the AI balance, summed over its attempts, as Money. Present once an attempt on the platform's key (MANAGED) was charged; a run on the account's own key has no cost here, because the provider bills the account directly.
outputThe result of a SUCCEEDED run: text, or json for an agent with output_format JSON, or artifacts for an IMAGE agent — each with its storage_key, mime_type, width, height and byte_size, the bytes living in the platform's store — and output_truncated, true when a text answer stopped at max_tokens.
errorWhy a FAILED or EXPIRED run stopped, in the same shape as an API error: code, status, message and, where there is one, a PRECONDITION_FAILURE whose type says why.
attemptsEvery attempt, in order: number, start_time, end_time, http_status (0 when no response arrived), error_code, message, and usage when the attempt's usage is known.
source_moduleWho started the run, in the caller's own words — editorial, import. Stored and filterable, never interpreted. Fixed after create.
source_idThe caller's own reference for what the run is for, within source_module, which it requires. Filter by it together with source_module.
metadataAny other correlation the caller wants back with the run, as an object of at most 16 KB. Returned as sent; not filterable.
expire_timeA deadline for starting: a run not started by then becomes EXPIRED without calling the provider (RFC 3339, UTC). Sort by it together with a state filter.
start_timeWhen the first attempt started (RFC 3339, UTC).
end_timeWhen the run reached the state it is in, if that state is final (RFC 3339, UTC).
Get AI execution
One run of an agent in an account: what was asked, which model and connection ran it, what came back, what it consumed, and every attempt in between. Runs are carried out in the background — create one, then read it until state is final.
path Parameters
account_idId of the parent account.
ai_execution_idId of the parent ai_execution.
Headers
If-None-MatchA matching etag answers 304 with no body (§16).
Get AI execution › 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).
agent_idThe id of the account's ai_agents entry this run executes. Set on create and fixed afterwards.
agent_versionThe version of the agent this run uses, resolved when the run was created. Its settings are kept under the agent's versions, so the run can be reproduced after the agent changes.
instruction_versionThe version of the agent's instruction whose text this run uses, resolved when the run was created.
model_idThe ai_models entry the run uses. Leave it out to use the agent's preferred_model_id; when the agent lists allowed_model_ids, only those can be named.
providerThe AI provider of the run's model, by the platform's name for it.
inputWhat the run works on: variables, an object filling every {{variable}} the instruction uses (strings, integers or booleans), and optionally text — material for the instruction to act on, such as a page to translate.
stateQUEUED, RUNNING, then SUCCEEDED, FAILED, CANCELLED or EXPIRED. A retryable failure puts the run back to QUEUED until its attempts run out.
connection_idThe ai_connections entry the latest attempt was authorized through. Absent until an attempt was routed.
connection_modeWhose key the latest attempt used: BYOK (the account's own) or MANAGED (the platform's, paid from the AI balance).
usageWhat the run consumed, summed over every attempt that reported it: input_tokens, output_tokens, cache_read_input_tokens, cache_creation_input_tokens, and for an IMAGE run image_count and megapixels_milli (thousandths of a megapixel).
costWhat the run was charged to the AI balance, summed over its attempts, as Money. Present once an attempt on the platform's key (MANAGED) was charged; a run on the account's own key has no cost here, because the provider bills the account directly.
outputThe result of a SUCCEEDED run: text, or json for an agent with output_format JSON, or artifacts for an IMAGE agent — each with its storage_key, mime_type, width, height and byte_size, the bytes living in the platform's store — and output_truncated, true when a text answer stopped at max_tokens.
errorWhy a FAILED or EXPIRED run stopped, in the same shape as an API error: code, status, message and, where there is one, a PRECONDITION_FAILURE whose type says why.
attemptsEvery attempt, in order: number, start_time, end_time, http_status (0 when no response arrived), error_code, message, and usage when the attempt's usage is known.
source_moduleWho started the run, in the caller's own words — editorial, import. Stored and filterable, never interpreted. Fixed after create.
source_idThe caller's own reference for what the run is for, within source_module, which it requires. Filter by it together with source_module.
metadataAny other correlation the caller wants back with the run, as an object of at most 16 KB. Returned as sent; not filterable.
expire_timeA deadline for starting: a run not started by then becomes EXPIRED without calling the provider (RFC 3339, UTC). Sort by it together with a state filter.
start_timeWhen the first attempt started (RFC 3339, UTC).
end_timeWhen the run reached the state it is in, if that state is final (RFC 3339, UTC).
Cancel (AI execution)
Stops a run. A QUEUED run is CANCELLED at once. A RUNNING run cannot be interrupted mid-call — the provider finishes what it was sent — so the cancel is recorded and the run becomes CANCELLED as soon as that call returns, without its output; until then it still reads RUNNING. A run that has already finished answers FAILED_PRECONDITION (EXECUTION_FINISHED). Safe to repeat.
path Parameters
account_idId of the parent account.
ai_execution_idId of the parent ai_execution.
Cancel (AI execution) › Request Body optional
Cancel (AI execution) › Responses
The affected resource, or the method’s own response object (§10).
Retry (AI execution)
Runs a FAILED run again: it goes back to QUEUED with a fresh set of the agent's max_attempts, and the new attempts are added to attempts after the old ones, numbered on. It runs with the same agent version, instruction version, model and input. Any other state answers FAILED_PRECONDITION (EXECUTION_NOT_FAILED), as does a run past its expire_time.
path Parameters
account_idId of the parent account.
ai_execution_idId of the parent ai_execution.
Retry (AI execution) › Request Body optional
Retry (AI execution) › Responses
The affected resource, or the method’s own response object (§10).