Run agents
Find an agent, give it inputs, credentials and files, start a run, wait for it, read its outputs, and handle reviews, failures and schedules.
Everything here works with any agent in your library: ones you built in the app, ones you added from the marketplace, and ones you created with the API.
How a run works
You start a run with POST /library/agents/{agent_id}/runs. The API answers 202 Accepted at once, before the agent does anything, and the run carries on in the background. You follow it by reading GET /runs/{run_id} until it reaches a final status.
status
Final?
Meaning
What your code should do
INCOMPLETE
No
Created but not handed to an executor yet.
Keep waiting.
QUEUED
No
Waiting for an executor.
Keep waiting.
RUNNING
No
Executing blocks.
Keep waiting.
REVIEW
No
Paused until a person approves or rejects something. It waits indefinitely.
Answer the review, or alert someone who can.
COMPLETED
Yes
Finished. This does not guarantee every block succeeded; see Check that a run succeeded.
Read outputs.
FAILED
Yes
Stopped by an error the run could not continue past.
Read the errors in node_executions.
TERMINATED
Yes
Stopped, by you or by the platform.
Nothing further happens.
Find the agent
You need the library agent ID, which is not the same as the graph ID. List your library (needs Read Library):
Each item has the id to run it with, its name, description, and the graph_id and graph_version it runs. The list leaves input_schema and output_schema empty; get the full agent with GET /library/agents/{agent_id} to read them. If you know an agent's graph ID, GET /graphs/{graph_id}/library-agent returns the full library agent directly.
There is no filter by name. To find an agent by name, read every page and match on name yourself. Names aren't unique, so handle more than one match, and once you've found the right agent, store its id and use that from then on:
Other ways to find agents:
GET /search?query=invoice&content_types=LIBRARY_AGENTsearches your library by meaning (needs Read Library). It's for discovery, not lookup: results depend on the instance's search index, which can lag behind your library or, on a new self-hosted instance, be empty.GET /marketplace/agents?search_query=invoicesearches the public marketplace. Add one to your library withPOST /marketplace/agents/{username}/{agent_name}/add-to-library(needs Write Library), then run the library agent it returns.
Work out its inputs
Read the agent's input_schema from GET /library/agents/{agent_id} (the list leaves it empty). It is a JSON Schema object. Each property is one input, its key is the name you pass in inputs, and required lists the inputs without a default:
So inputs for this agent is {"topic": "...", "document": "..."}, with max_words optional.
typeis present when the agent declares one. Inputs made with the general-purpose input block have none and accept any JSON value; send what the input'stitleanddescriptionask for."format": "file"marks an input that takes a file reference. Other formats, such aslong-text, are hints for the app's form: send a plain string.An input can be
requiredwhile its type also allowsnull, likedocumentabove. Send a value for it:nullcounts as missing.advanced: truemarks an optional input the app tucks away under advanced settings.secret: truemarks a value the app masks, such as a password. Neither changes how you send it.Starting a run or creating a schedule checks
inputsagainstinput_schema. A name the agent doesn't have, or arequiredinput left out ornull, is a422and nothing starts;details.errorshas one entry per input, up to 20, withloc["body", "inputs", "<name>"].
Turning on Advanced now makes a workflow input optional even without a default. This also applies to existing workflows. To require a value, turn off Advanced and clear the input's default.
When a run omits an optional input with no default, connected blocks use their own pin defaults. A block with a required input and no default may skip execution. A block that runs a child workflow can still start that workflow, allowing its other starting blocks to run. Keep a Google Drive picker required when a connected block needs its file and credentials.
Supply credentials it needs
Agents that call third-party services (an AI model provider, GitHub, Google, ...) need credentials from your account. Ask which ones (needs Read Integrations). An agent that needs none returns an empty list:
For each requirement, pick one of its matching_credentials and pass it under the requirement's field_name. When several match, let whoever owns the integration choose, for example by title, and store the choice; picking the first one silently can use the wrong account:
A requirement can be optional: the agent's builder may let some blocks run without their credentials. The graph's credentials_input_schema, from GET /graphs/{graph_id} (needs Read Graph), lists the requirements that must be filled under required.
If a requirement has no matching credentials, add one first:
API keys, passwords and custom headers:
POST /integrations/credentials(needs Manage Integrations), withtypeset toapi_key,user_passwordorhost_scoped:OAuth providers (Google, GitHub and the like): connect them in the app under Settings → Integrations. OAuth connections can't be created through the API. OAuth apps can send their users through the integration setup wizard instead.
On AutoGPT Cloud, some providers have platform-provided credentials ("is_managed": true), such as built-in AI model access. You can pass them like your own.
Start the run
Needs Run Agent. Limited to 60 run starts per minute per user.
Returns
202with the run ("status": "QUEUED"). Keep itsid.Always send an
Idempotency-Keyfrom code that retries. A retry with the same key gets the original run back instead of a second, paid run. See Idempotent runs.On AutoGPT Cloud,
402 payment_requiredmeans the account has no active plan or its credit balance is zero.
Wait for it to finish
Read the run until its status is COMPLETED, FAILED or TERMINATED. Poll every one to five seconds, back off on long runs, and keep everything inside one deadline: each request's timeout and each sleep are cut to the time that's left. (A requests timeout limits each wait for the server, not a whole slow response; if you need a hard limit, use a client with an overall timeout.) A run in REVIEW waits for a person and never finishes on its own.
Every poll counts toward the 200-requests-per-minute limit, which is shared by all your keys. If you follow many runs at once, list them in one request instead: GET /runs?statuses=QUEUED&statuses=RUNNING.
If your deadline passes and you no longer want the result, stop the run so it doesn't keep spending: POST /runs/{run_id}/stop.
Read the outputs
GET /runs/{run_id} includes outputs once the run finishes. It maps the name of each of the agent's outputs (the keys of its output_schema) to a list of values, because an output can be produced more than once in one run:
While the run is going, outputs and node_executions hold what has finished so far, and can be empty. Most agents produce each output once, so read outputs["name"][0], or the last element for the latest value. An output the run never produced is missing from outputs. Outputs that are files arrive as workspace:// references; see Get files back.
node_executions lists every block that ran, with its inputs and outputs, which is what you need to debug a run. The schema allows it to be null; treat that as no detail being available. cost_cents is what the run cost.
Check that a run succeeded
COMPLETED means the run reached its end. It doesn't mean every block succeeded. When a block fails it produces an error output instead of its normal outputs. If the agent doesn't route that error anywhere, the run still completes, just without the outputs that depended on the failed block:
So treat a run as successful only when it is COMPLETED and the outputs you need are present. When they aren't, collect the errors. If there are none, check that the run got every required input:
A FAILED run carries its errors the same way.
Human-in-the-loop reviews
Agents can include a human-in-the-loop block that pauses the run until someone approves or rejects a piece of data. The run then has status REVIEW and waits until it gets an answer.
List what's waiting (needs Read Run Review):
payload is the data under review and instructions says what it is. Leave out run_id to see waiting reviews across all your runs.
Answer every waiting review of the run in one request (needs Write Run Review). The request fails if it leaves one out.
approved: truesends the data (or youredited_payload, when the review iseditable) down the block's approved path, and the run continues.approved: falsesends the data down the block's rejected path instead, so the steps after an approval don't run. What happens next depends on what the agent's builder connected to the rejected path.auto_approve_future: trueapproves this block's future reviews automatically. It only applies to an approval, and ignoresedited_payload.
After you answer, the run moves back to RUNNING; keep waiting for it as usual. Reviews can also be answered in the AutoGPT app.
When your integration can't answer reviews
A run in REVIEW waits until someone answers, however long that takes. Decide up front what your integration does when it sees one:
Hand it to a person. Tell someone the run is waiting (the review shows up in the AutoGPT app for the account that owns the run), stop polling, and check back later. The run continues once they answer.
Answer it yourself, if your product has its own approval step: show the
payloadandinstructionsto your user and send their decision withPOST /runs/{run_id}/reviews.Give up.
POST /runs/{run_id}/stopends the run asTERMINATED.Don't ask at all. If the agent may run unattended, turn its reviews off with
PATCH /graphs/{graph_id}/settingsand{"human_in_the_loop_safe_mode": false}, and every review is approved automatically. See Build agents.
Pass files to an agent
Upload the file to your workspace (needs Write Files; 20 uploads per 5 minutes):
Pass file_uri as the value of the file input:
Uploads are virus-scanned and count toward your storage quota. A file can be up to 100 MB on AutoGPT Cloud; a larger one gets
413 payload_too_large.Uploading a file whose name is already in the workspace fails with
409 conflict. Add?overwrite=trueto replace it. The replacement gets a newidandfile_uri.GET /fileslists the workspace andDELETE /files/{file_id}removes a file (needs Read Files and Write Files).
Get files back
An output that is a file arrives as a workspace://<file_id>#<mime type> reference. Download it with the ID between workspace:// and # (needs Read Files):
Run on a schedule
Schedules run a graph on a cron expression (needs Write Schedule and Run Agent). Note that schedules take the graph ID, not the library agent ID:
crontakes the standard five fields: minute, hour, day of month, month, day of week. An invalid expression fails with400.timezoneis an IANA name. Without it, the schedule uses the account's time zone.graph_versiondefaults to the active version.GET /schedules?graph_id=...lists schedules andDELETE /schedules/{schedule_id}removes one. Each scheduled run shows up inGET /runslike any other run.
Manage runs
List runs, newest first
GET /runs?graph_id=...&statuses=FAILED&started_after=2026-10-01T00:00:00Z
Read Run
Get one run with outputs
GET /runs/{run_id}
Read Run
Stop a run
POST /runs/{run_id}/stop waits up to about 15 seconds for the run to stop, then returns it. If it still isn't TERMINATED, keep polling. A run that already finished (COMPLETED, FAILED or TERMINATED) answers 409 conflict.
Write Run
Delete a run
DELETE /runs/{run_id}
Write Run
Share a run publicly
POST /runs/{run_id}/share returns a share_url anyone with the link can open
Read Run + Share Run
Stop sharing
DELETE /runs/{run_id}/share
Read Run + Share Run
Repeat statuses to match several, e.g. ?statuses=COMPLETED&statuses=FAILED.
Costs
Every run reports cost_cents once it finishes. GET /credits returns your balance, and GET /credits/cost-summary breaks spending down by agent and by day (both need Read Credits). Self-hosted instances don't bill: runs cost nothing and the balance is a fixed placeholder.
Last updated
Was this helpful?