Use this reference to look up Ampersand endpoints, parameters, and responses.
For a working example, start with the quickstart. If you are moving
an OpenAI integration, check OpenAI compatibility.
Authentication and requests
Use https://ampersand.humansand.ai/v1 as the base URL.
Include Authorization: Bearer <your-key>. All endpoints except the
model endpoints also require OpenAI-Beta: agents=v1.
JSON requests use Content-Type: application/json.
Your API key determines which tenant you can access. You cannot select another
tenant through headers or message metadata.
The hosted request-body limit is 16 MiB. Deployment or tenant settings can impose
smaller input limits. See input limits for token and
encoded-size limits. The API rejects unknown request fields. Strings in
the body, path, and query cannot contain the null character, U+0000.
To create a session, supply nonempty input, environment={"type":"none"}, and
either agent_id or agent.model. If you supply both, fields in agent override
the saved agent's settings for the new session.
Use ampersand-v0.1 or ampersand-tutor-v0.1 for model
when creating an agent or agent.model when creating a session with inline agent
settings. Check /models for availability; the tutor's supported features differ.
Endpoints
Append these paths to https://ampersand.humansand.ai/v1.
Successful JSON requests return 200.
Submitting events returns 202 with an empty body. Streams use
text/event-stream. Follow the type links for request and response fields.
You can send 1–256 events in one request. Include the original turn_id and
call_id with each tool result. To cancel work, send an event containing only
type="agent.session.input.cancel".
Event POSTs accept Idempotency-Key: repeating the same body and key creates no
new work, while reusing the key with a different body returns 409. Agent and
session creation reject this header.
You can update a session's metadata and agent.reasoning.effort. An effort update
applies to new turns. An active turn keeps its effort through steering, tool waits,
and recovery. Omitted effort is unchanged; null effort resets the model default.
Null agent or reasoning objects are rejected. Other session agent settings
cannot be updated. Updating or deleting the saved agent does not change existing sessions.
Deleting a session stops its work and frees a slot under the session limit.
The deleted session is no longer available through the API.
Models
GET /models lists the model IDs available to your tenant, sorted by ID.
The response contains object="list" and data. It returns the full list in
one response and does not use pagination.
GET /models/{model} returns one model. Use the full model ID in the path,
including any / characters. An unknown model, or one unavailable to your
tenant, returns 404.
Each model has id, object="model", created=0, and owned_by.
The created value is always zero because model IDs are aliases with no fixed
creation date. Neither endpoint accepts query parameters or requires the
OpenAI-Beta header. Both require your API key.
Pagination
When listing agents, sessions, items, or turns, use limit to set the page size
and order to choose the direction. limit accepts 1–100 and defaults to 20.
order accepts asc or desc and defaults to desc. To get the next page, pass
the last returned ID as after and keep the same order.
You can also filter sessions with agent_id. An unknown cursor or unsupported
query parameter returns 400.
Each page contains object="list", data, first_id, last_id, and has_more.
Keep requesting pages while has_more is true. An empty page has null first and
last IDs.
SSE streams do not use pagination. They accept no query parameters and reject
Last-Event-ID.
Read context usage
GET /agents/sessions/{session_id}/context returns
{"object":"agent.session.context","session_id":"sess_…","input_tokens":4291}.
input_tokens is the measured input usage of the latest completed model reply.
It is null if no reply has completed or that reply has no usage measurement. The
API does not return an older count in its place. Input and tool results added
since that reply are not included yet.
This count differs from turn usage, which adds up model calls, and from the
saved-history limit, which is measured in bytes.
This endpoint accepts no query parameters. You receive 404 for a deleted
session or one owned by another tenant. See the client example.
Account statements
GET /account/balance returns promotional credit, purchased credit, unsettled
usage, and available credit. Amounts are integer microdollars: 1,000,000 equals
one US dollar. Available credit already accounts for unsettled usage. This
endpoint accepts no query parameters.
GET /account/usage?start=YYYY-MM-DD&end=YYYY-MM-DD returns settled Agents API
usage for the account that owns your key. Supply both dates in UTC; the results
include both the start and end date. Token quantities are grouped by day, key,
model, and meter. Spend and billed requests are grouped by day and key.
Recent usage may appear in unsettled_micro before it appears in a usage
statement. Each statement can cover 1–92 days and up to 10,000 quantity rows.
Exceeding either limit returns 400. This endpoint has no cursor pagination and
rejects query fields other than start and end.
API keys without a linked account receive 404. If account statements are not
available for your key, contact Ampersand. If statements are
temporarily unavailable or too many reads are in progress, you may
receive 503 with Retry-After.
Validation and defaults
Agent and session metadata can contain up to 16 string pairs. Keys can be up to
64 characters and values up to 512 characters. Input message metadata is a
separate JSON object, limited to 8 KiB. Its reserved keys have specific types:
you can omit them, but cannot set them to null. See message details.
When you create an agent, omitted options use these defaults: no tools, disabled
multi-agent mode, null reasoning effort, text output with medium verbosity,
service tier auto, and compaction=auto. Silent completion defaults to true
for ampersand-v0.1; the tutor defaults it to false and rejects explicit true.
Setting these options to null at creation also uses their defaults.
ampersand-v0.1 supports reasoning.effort="low", "medium", "high", and
"max". The tutor supports "low", "high", and "max". Both models default
to high, which is the recommended setting.
Saved agents keep omitted/null effort as null. A new session captures its model's
default when the inherited or overridden effort is null. This lets saved agents
change models without carrying an effort the client did not select. Explicit
efforts are inherited and must be supported by the selected model.
Existing sessions with null effort follow the model's current endpoint defaults.
A release can change those defaults; the current Ampersand default output limit
is 16,384 tokens, including for these sessions.
The Ampersand presets use low with up to 8,192 generated tokens per model call,
medium or high with up to 16,384, or max with up to 32,768.
These limits include reasoning and the answer;
they do not limit the complete session or promise that each call uses the full limit.
Effort support is model-specific; unsupported selections return 400.
multi_agent turns on multi-agent mode; it does not change how effort is set.
reasoning.summary must remain null. See reasoning settings.
When you update an agent, omitted fields keep their current values.
instructions=null clears the instructions, while nullable settings reset to
their defaults. model=null is rejected. Ampersand options are updated one field
at a time; see agent settings. Responses omit
compaction when its value is the default, auto.
Give each tool a unique name and an object JSON Schema. The supported dialects
are draft 4, 6, 7, 2019-09, and 2020-12 (the default). Each schema can be up to
32 KiB, with at most 128 KiB across all tools and 32 levels of nesting. References
must resolve within the schema. The API rejects invalid references and reference
cycles that never reach a property. It also rejects schemas that would apply
more than 1,024 subschemas to a single value through references and schema
keywords. It does not fetch external schemas.
Ampersand checks function arguments before asking your application to run a tool,
but this check has limits:
It skips pattern and patternProperties, plus additionalProperties and
unevaluatedProperties checks that depend on pattern matching.
It skips not, oneOf, if, and contains with maxContains when their
subschemas depend on these skipped checks.
It rejects arguments nested more than 64 JSON levels. A call can pass unchecked
if validation exceeds 100,000 keyword evaluations.
The model receives the full schema. Your handler must check arguments and
permissions before running the function.
If a model reserves special control tokens, tool definitions cannot contain
those tokens. Ampersand escapes them in instructions, message text, metadata,
and tool results before sending that text to the model. Saved API resources
keep the original text.
When input moderation is enabled, Ampersand rejects flagged content before
saving it. It also rejects image input. If moderation cannot complete its check, the
request returns 503.
Multi-agent mode
Multi-agent mode lets one session work as a team: a main agent that can bring
in subagents of itself on its task. It is off by default. Set it with
agent.multi_agent when you create an agent or a session, or in a session's
inline agent override:
JSON
{
"agent": {
"model": "ampersand-v0.1",
"instructions": "Fix bugs in the checked-out repository.",
"tools": [{"type": "function", "name": "run_command", "parameters": {"type": "object"}}],
"reasoning": {"effort": "high"},
"multi_agent": {"enabled": true, "max_concurrent_subagents": 3}
},
"environment": {"type": "none"},
"input": "The parser test fails on empty lines. Fix it and run the tests."
}
Field
Values
Default
multi_agent.enabled
true or false
false
multi_agent.max_concurrent_subagents
1 to 7 when enabled; null when disabled
3 when enabled
Reasoning effort is set exactly as for a single session, and every subagent
runs at that effort. Effort values the model does not support return 400
whether multi-agent mode is on or off. ampersand-tutor-v0.1 rejects
multi-agent mode with 400.
With multi-agent mode enabled, internal team tools normally use start_group and
send_message. After the service enables collision fallback, a customer function with either
name makes that session use internal_team_start_group and internal_team_send_message for
internal coordination. The customer functions keep their supplied names. Sessions without a
conflict keep the original tool names and prompts.
Customer tools that also occupy a selected fallback name return 400 on agent create/update
and session create, including saved-agent overrides. Before collision fallback is enabled,
customer start_group or send_message functions also return 400 in multi-agent mode.
Single-agent sessions are unaffected. Internal function-call items in the main session's item
list and event stream expose the session's host tool names; they are not included in
required_actions. Existing sessions retain the names saved with their prompts.
The session behaves like any other:
With multi-agent mode on
required_actions
Function calls from the main agent and every subagent. Answer each on this session with its turn_id and call_id.
status
requires_action while any call waits for you, in_progress while any agent works, idle when every agent is done.
Items and turns
The main agent's conversation. Its final reply is the answer.
usage
Includes every agent.
Cancel and delete
Stop or delete every agent.
Guidelines:
Use multi-agent mode for long, multi-step tasks where parallel work and
cross-checking pay off, such as fixing bugs in a repository. Keep it off for
questions, chat, and short tasks.
Start with the default of 3 subagents. More subagents add parallel work, but
also more duplicated effort.
Calls from several agents can be pending at once and share one environment
(for example, one checkout), so make your tools safe to run concurrently.
Wait for agent.session.idle, not for one turn to complete: the main agent's
turn can end while subagents still work.
Every agent's model calls count toward your usage.
Each SSE event has an event_id and a JSON payload. Session events include the
session's state, and turn events include the turn's state. Item and text events
include session, turn, and item IDs. The field reference below describes each payload.
Text deltas are available when the provider supports streaming. When the done
event arrives, replace the text shown so far with its full text. Only completed
items become part of model history. Tool call IDs can repeat across turns, so
identify a call by its session, turn, and call IDs together. See
recovery for handling disconnects.
Session status is idle, in_progress, requires_action, or failed.
Turn status is queued, in_progress, waiting, completed, failed, or
cancelled. Check the turn's status even when the session is idle.
waiting means the turn is paused for tool results. Send a result for every
entry in required_actions; the turn resumes when none remain.
Usage is null when it is unknown. Token totals can change as more usage is recorded.
Webhooks send signed notifications to your HTTP endpoint. When webhook
management is enabled, register an endpoint in the developer console,
select its events, and save its one-time signing secret. New endpoints are
disabled until you enable them after receiver setup. Endpoint management is
available through the console; it is not a public API or OpenAI client operation.
Notifications use the envelope {id, object, created_at, type, data} and support
session created, in_progress, action_required, idle, and failed. See
webhook notifications for settings, recovery, and signature
verification, and WebhookEvent for payload fields.
Errors and limits
HTTP errors use {"error":{"message":"…","type":"…","param":null,"code":null}}.
Check code for a more specific cause when it is present. SSE error events also
contain an error object. The OpenAI client can raise APIError when it reads one.
HTTP status
Meaning
What to do
400
Invalid fields, unsupported features, saved-data limits, or content-policy rejection
Correct the request. At the session limit, delete a session or request a higher limit. For other storage limits, contact Ampersand.
401
Invalid or missing credential
Check the key.
402
Insufficient credit
Add credit. If an earlier request may have succeeded, check saved state before retrying.
403
Access denied
Check account eligibility and permissions.
404
Resource not found for your tenant
Check the ID and the tenant associated with your key.
408
The first 16 KiB of an events request did not arrive within 10 seconds, or a large upload did not finish within 30 seconds after crossing 16 KiB
Check the client connection.
409
A retry key or message ID conflicts with saved input, or the session is changing state
Read saved state and compare it with the request you are sending.
413
Request exceeds the configured body limit (hosted default: 16 MiB)
Reduce the request.
429
Request rate, work rate, or temporary capacity limit
Follow Retry-After; preserve the event request key and body.
503
The service or a required dependency is temporarily unavailable
Follow Retry-After when present, then check saved state.
An unexpected server failure can return 500. If you cannot tell whether a
write succeeded, check saved state before retrying it.
A turn that cannot finish has status failed and an error with code and
message. The message "Model output did not match the required response format"
means Ampersand could not use the model's output after its retries, for example
a call to a function the agent does not declare. Check whether your instructions
ask for actions as markup instead of function tools.
Rate limits can apply to both your key and your tenant. A request can count
toward the limit before its body is validated, its resource is found, or its
idempotency key is checked. Retries can therefore count toward the limit too.
Rate-limit responses may include retry-after-ms as well as Retry-After.
Session deletion and events requests containing only cancellations use a separate
control budget; the cancellation body must be no larger than 16 KiB. Saved-data
limits return 400 without Retry-After. Waiting and retrying the same request
will not free stored data.
Field reference
These tables list the request and response fields. You can also download the
JSON Schema definitions and select the relevant entry in
$defs to validate a payload. The validation rules and service limits above
still apply.
An optional field can be omitted. If no default is listed, do not assume
the value will be null; the API may calculate it. See
validation and defaults for create and update behavior, and
agent settings for older saved sessions.
Multi-agent mode: the session works as one agent that can bring in subagents of itself.
The main agent decides when to start up to max_concurrent_subagents subagents on its task;
they share its model, instructions, tools and reasoning effort. Clients see one session: every
agent's function calls arrive in its required_actions, and it is idle once all are done.
Field
Type
Presence
Rules
enabled
true
Required
—
max_concurrent_subagents
integer
Optional
The most subagents the main agent may run at once next to itself. Schema default: 3. minimum=1. maximum=7.
JSON Schema
JSON
{
"additionalProperties": false,
"description": "Multi-agent mode: the session works as one agent that can bring in subagents of itself.\n\nThe main agent decides when to start up to `max_concurrent_subagents` subagents on its task;\nthey share its model, instructions, tools and reasoning effort. Clients see one session: every\nagent's function calls arrive in its `required_actions`, and it is idle once all are done.",
"properties": {
"enabled": {
"const": true,
"title": "Enabled",
"type": "boolean"
},
"max_concurrent_subagents": {
"default": 3,
"description": "The most subagents the main agent may run at once next to itself.",
"maximum": 7,
"minimum": 1,
"title": "Max Concurrent Subagents",
"type": "integer"
}
},
"required": [
"enabled"
],
"title": "MultiAgentEnabled",
"type": "object"
}