curl -X POST "$ATAI_API_URL/api/agents/instances" \
-H "Authorization: Bearer $ATAI_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"package_id": "pkg_01jcb2x7m4qv8n3h5t6rk9dzs0",
"connectors": {
"source": [
{"type": "file", "id": "file_abc123", "format": "csv"}
]
}
}'
curl -X POST "$ATAI_API_URL/api/agents/instances" \
-H "Authorization: Bearer $ATAI_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"package_id": "pkg_01jcb2x7m4qv8n3h5t6rk9dzs0",
"mode": "serving"
}'
import os
import requests
base_url = os.environ["ATAI_API_URL"]
api_key = os.environ["ATAI_API_KEY"]
response = requests.post(
f"{base_url}/api/agents/instances",
headers={
"Authorization": f"Bearer {api_key}",
"Content-Type": "application/json",
},
json={
"package_id": "pkg_01jcb2x7m4qv8n3h5t6rk9dzs0",
"connectors": {
"source": [{"type": "file", "id": "file_abc123", "format": "csv"}],
},
},
)
if response.status_code == 202:
agent = response.json()
print(f"Run accepted: {agent['id']} (status {agent['status']})")
else:
print(f"Error: {response.json()['errors']}")
const response = await fetch(`${process.env.ATAI_API_URL}/api/agents/instances`, {
method: 'POST',
headers: {
'Authorization': `Bearer ${process.env.ATAI_API_KEY}`,
'Content-Type': 'application/json'
},
body: JSON.stringify({
package_id: 'pkg_01jcb2x7m4qv8n3h5t6rk9dzs0',
connectors: {
source: [{ type: 'file', id: 'file_abc123', format: 'csv' }]
}
})
});
const body = await response.json();
if (response.status === 202) {
console.log(`Run accepted: ${body.id} (status ${body.status})`);
} else {
console.error('Error:', body.errors);
}
{
"id": "agt_01jcb3k8p5rw9t2bkz4dhs6fmq",
"name": "Pump line 3",
"org_id": "org_01jc8m5r2vq9xt4bn7h3kdzs6w",
"package_id": "pkg_01jcb2x7m4qv8n3h5t6rk9dzs0",
"blueprint": "osm",
"blueprint_id": "blp_01jc9n7k3xf8mbq2v5t0ary6de",
"mode": "batch",
"connectors": {
"source": [
{"type": "file", "id": "file_abc123", "format": "csv"}
],
"sink": null
},
"status": "running",
"project_id": null,
"created_at": "2026-10-21T15:20:00Z"
}
{
"errors": [
{
"code": "bad_request",
"message": "<reason>",
"suggestion": null,
"error_uid": "err-xxxxxxxx"
}
]
}
{
"errors": [
{
"code": "capability_locked",
"message": "Blueprint not available to the caller's organization.",
"suggestion": "Contact [email protected] to unlock it.",
"error_uid": "err-xxxxxxxx"
}
]
}
{
"errors": [
{
"code": "not_found",
"message": "Package 'pkg_01jcb2x7m4qv8n3h5t6rk9dzs0' not found",
"suggestion": null,
"error_uid": "err-xxxxxxxx"
}
]
}
{
"errors": [
{
"code": "conflict",
"message": "package 'pkg_01jcb2x7m4qv8n3h5t6rk9dzs0' is not ready to run; wait until its status is `ready`",
"suggestion": null,
"error_uid": "err-xxxxxxxx"
}
]
}
{
"errors": [
{
"code": "serving_limit_reached",
"message": "Your organization already has 5 serving agents running, the most it may run at once.",
"suggestion": "Cancel a running serving agent, then retry.",
"error_uid": "err-xxxxxxxx"
}
]
}
Instances
Create Agent
Run a ready package as a batch job or a serving agent, creating a new agent instance
POST
/
api
/
agents
/
instances
curl -X POST "$ATAI_API_URL/api/agents/instances" \
-H "Authorization: Bearer $ATAI_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"package_id": "pkg_01jcb2x7m4qv8n3h5t6rk9dzs0",
"connectors": {
"source": [
{"type": "file", "id": "file_abc123", "format": "csv"}
]
}
}'
curl -X POST "$ATAI_API_URL/api/agents/instances" \
-H "Authorization: Bearer $ATAI_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"package_id": "pkg_01jcb2x7m4qv8n3h5t6rk9dzs0",
"mode": "serving"
}'
import os
import requests
base_url = os.environ["ATAI_API_URL"]
api_key = os.environ["ATAI_API_KEY"]
response = requests.post(
f"{base_url}/api/agents/instances",
headers={
"Authorization": f"Bearer {api_key}",
"Content-Type": "application/json",
},
json={
"package_id": "pkg_01jcb2x7m4qv8n3h5t6rk9dzs0",
"connectors": {
"source": [{"type": "file", "id": "file_abc123", "format": "csv"}],
},
},
)
if response.status_code == 202:
agent = response.json()
print(f"Run accepted: {agent['id']} (status {agent['status']})")
else:
print(f"Error: {response.json()['errors']}")
const response = await fetch(`${process.env.ATAI_API_URL}/api/agents/instances`, {
method: 'POST',
headers: {
'Authorization': `Bearer ${process.env.ATAI_API_KEY}`,
'Content-Type': 'application/json'
},
body: JSON.stringify({
package_id: 'pkg_01jcb2x7m4qv8n3h5t6rk9dzs0',
connectors: {
source: [{ type: 'file', id: 'file_abc123', format: 'csv' }]
}
})
});
const body = await response.json();
if (response.status === 202) {
console.log(`Run accepted: ${body.id} (status ${body.status})`);
} else {
console.error('Error:', body.errors);
}
{
"id": "agt_01jcb3k8p5rw9t2bkz4dhs6fmq",
"name": "Pump line 3",
"org_id": "org_01jc8m5r2vq9xt4bn7h3kdzs6w",
"package_id": "pkg_01jcb2x7m4qv8n3h5t6rk9dzs0",
"blueprint": "osm",
"blueprint_id": "blp_01jc9n7k3xf8mbq2v5t0ary6de",
"mode": "batch",
"connectors": {
"source": [
{"type": "file", "id": "file_abc123", "format": "csv"}
],
"sink": null
},
"status": "running",
"project_id": null,
"created_at": "2026-10-21T15:20:00Z"
}
{
"errors": [
{
"code": "bad_request",
"message": "<reason>",
"suggestion": null,
"error_uid": "err-xxxxxxxx"
}
]
}
{
"errors": [
{
"code": "capability_locked",
"message": "Blueprint not available to the caller's organization.",
"suggestion": "Contact [email protected] to unlock it.",
"error_uid": "err-xxxxxxxx"
}
]
}
{
"errors": [
{
"code": "not_found",
"message": "Package 'pkg_01jcb2x7m4qv8n3h5t6rk9dzs0' not found",
"suggestion": null,
"error_uid": "err-xxxxxxxx"
}
]
}
{
"errors": [
{
"code": "conflict",
"message": "package 'pkg_01jcb2x7m4qv8n3h5t6rk9dzs0' is not ready to run; wait until its status is `ready`",
"suggestion": null,
"error_uid": "err-xxxxxxxx"
}
]
}
{
"errors": [
{
"code": "serving_limit_reached",
"message": "Your organization already has 5 serving agents running, the most it may run at once.",
"suggestion": "Cancel a running serving agent, then retry.",
"error_uid": "err-xxxxxxxx"
}
]
}
Requires version 2.0.0 or later of the Archetype platform.
Overview
This endpoint runs a package and returns the created agent. The package fixes everything about how the agent behaves: its blueprint, the blueprint’s values, and the model every slot resolved to when the package was built. The request only says how to run it and binds its I/O. To change anything else, build a new package.mode picks how the agent executes:
batch(the default) processes the input files inconnectors.sourceand finishes.servingstays up to answer queries over Query Agent and/api/agents/instances/{agent_id}/connect. A serving run takes its input from each query, so it must not sendconnectors.
running. A serving run is returned deploying, before it is placed:
poll Get Agent until it is running before you query
it. Follow either kind through its events, logs, and results, exactly as a run of a bundle.
The run is owned by the caller, or by the project’s creator when the package is in a project.
Other members of the organization cannot see it unless they are org admins.
Request
string
required
The
pkg_ id of the package to run. It must be ready, built for the platform target, and
hold exactly one blueprint.string
default:"batch"
How the agent executes:
batch processes the inputs and finishes; serving stays up to answer
queries.object
The run’s input files and optional output file. A
batch run must list at least one file
ref in source. A serving run must omit connectors.array
One or more input refs. Each entry is a data ref.
object
Optional output ref; omit it or send
null for the default. It must not name an output that
already exists. Omitted: the runner writes one output per input, named after the input.
Provided: for concatenable formats (for example CSV) all output folds into this single file.Data ref
string
required
Storage kind, for example
file.string
required
Identifier within that storage kind, for example
file_abc123.string
Optional format hint, for example
csv.Response
Returns202 Accepted with the created agent.
string
required
TypeID-encoded agent identifier (
agt_ prefix).string
required
The run’s name. For a run of a package, this is the package’s name.
string
required
Organization the agent belongs to.
string
The package this agent was run from (provenance). Absent for a run of a bundle, which carries
bundle_id instead.string
required
Human-readable blueprint reference (its key), for example
osm.string
required
Immutable blueprint id the package holds.
string
required
How the agent executes:
batch or serving.string
required
Agent lifecycle status. A new run is
running, or deploying for a serving run.string
The project the run is in, which is its package’s project.
null outside any project.object
The I/O binding this run was started with.
string
The executor’s job id for this run. Present once the run has been dispatched.
string
required
When the run was created (date-time).
string
When the run began executing. Absent until it has been dispatched.
string
When the run reached a terminal status. Absent while it is unfinished.
string
Why the run failed. Present only when
status is failed.curl -X POST "$ATAI_API_URL/api/agents/instances" \
-H "Authorization: Bearer $ATAI_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"package_id": "pkg_01jcb2x7m4qv8n3h5t6rk9dzs0",
"connectors": {
"source": [
{"type": "file", "id": "file_abc123", "format": "csv"}
]
}
}'
curl -X POST "$ATAI_API_URL/api/agents/instances" \
-H "Authorization: Bearer $ATAI_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"package_id": "pkg_01jcb2x7m4qv8n3h5t6rk9dzs0",
"mode": "serving"
}'
import os
import requests
base_url = os.environ["ATAI_API_URL"]
api_key = os.environ["ATAI_API_KEY"]
response = requests.post(
f"{base_url}/api/agents/instances",
headers={
"Authorization": f"Bearer {api_key}",
"Content-Type": "application/json",
},
json={
"package_id": "pkg_01jcb2x7m4qv8n3h5t6rk9dzs0",
"connectors": {
"source": [{"type": "file", "id": "file_abc123", "format": "csv"}],
},
},
)
if response.status_code == 202:
agent = response.json()
print(f"Run accepted: {agent['id']} (status {agent['status']})")
else:
print(f"Error: {response.json()['errors']}")
const response = await fetch(`${process.env.ATAI_API_URL}/api/agents/instances`, {
method: 'POST',
headers: {
'Authorization': `Bearer ${process.env.ATAI_API_KEY}`,
'Content-Type': 'application/json'
},
body: JSON.stringify({
package_id: 'pkg_01jcb2x7m4qv8n3h5t6rk9dzs0',
connectors: {
source: [{ type: 'file', id: 'file_abc123', format: 'csv' }]
}
})
});
const body = await response.json();
if (response.status === 202) {
console.log(`Run accepted: ${body.id} (status ${body.status})`);
} else {
console.error('Error:', body.errors);
}
{
"id": "agt_01jcb3k8p5rw9t2bkz4dhs6fmq",
"name": "Pump line 3",
"org_id": "org_01jc8m5r2vq9xt4bn7h3kdzs6w",
"package_id": "pkg_01jcb2x7m4qv8n3h5t6rk9dzs0",
"blueprint": "osm",
"blueprint_id": "blp_01jc9n7k3xf8mbq2v5t0ary6de",
"mode": "batch",
"connectors": {
"source": [
{"type": "file", "id": "file_abc123", "format": "csv"}
],
"sink": null
},
"status": "running",
"project_id": null,
"created_at": "2026-10-21T15:20:00Z"
}
{
"errors": [
{
"code": "bad_request",
"message": "<reason>",
"suggestion": null,
"error_uid": "err-xxxxxxxx"
}
]
}
{
"errors": [
{
"code": "capability_locked",
"message": "Blueprint not available to the caller's organization.",
"suggestion": "Contact [email protected] to unlock it.",
"error_uid": "err-xxxxxxxx"
}
]
}
{
"errors": [
{
"code": "not_found",
"message": "Package 'pkg_01jcb2x7m4qv8n3h5t6rk9dzs0' not found",
"suggestion": null,
"error_uid": "err-xxxxxxxx"
}
]
}
{
"errors": [
{
"code": "conflict",
"message": "package 'pkg_01jcb2x7m4qv8n3h5t6rk9dzs0' is not ready to run; wait until its status is `ready`",
"suggestion": null,
"error_uid": "err-xxxxxxxx"
}
]
}
{
"errors": [
{
"code": "serving_limit_reached",
"message": "Your organization already has 5 serving agents running, the most it may run at once.",
"suggestion": "Cancel a running serving agent, then retry.",
"error_uid": "err-xxxxxxxx"
}
]
}
Important Notes
- A
400means the package was built for a target other thanplatformor holds more than one blueprint, or the request does not fit the mode: abatchrun sent nofileref inconnectors.source, or aservingrun sentconnectors. It also covers aservingrun whose blueprint cannot be served, which creates no agent. - When the package is in a project, the run may only read
sourcefiles the project’s creator can see. Any other file returns400. - A
403with codecapability_lockedmeans the package’s blueprint is not available to your organization. A403without that code means you can see the package’s project but cannot modify it. - A
409means the package is notreadyyet, or thesinknames an output that already exists. - A
429with codeserving_limit_reachedmeans your organization already runs as many serving agents as it may. Cancel one, then retry. - A
501meansservingwas requested in an environment where serving is not enabled. - A serving run that cannot be placed or started ends
failedwith the reason inerror. Create another instance to retry. - A package cannot be deleted while runs from it exist. Find them with List Agents and
package_id.
Was this page helpful?