> ## Documentation Index
> Fetch the complete documentation index at: https://docs.budecosystem.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Calling agents

> Call an agent through the Responses API, pin a version, and run it in the background.

Agents are called on `/v1/responses` with the agent's name as `prompt.id`. Pin a version with `prompt.version` in the request body (it is not a header); without it the agent's default version answers. Agent variables go in `prompt.variables`. The `model` field is optional for agents. The agent must belong to the key's project.

```bash theme={null}
# Request
curl $BUD_BASE_URL/v1/responses \
  -H "Authorization: Bearer $BUD_API_KEY" -H "Content-Type: application/json" \
  -d '{"prompt": {"id": "claims-assistant", "version": "3",
                  "variables": {"customer_tier": "gold"}},
       "input": "Where is claim 4471?"}'

# Response (abbreviated)
{"id": "resp_...", "object": "response", "status": "completed",
 "output": [{"type": "message", "role": "assistant",
             "content": [{"type": "output_text", "text": "Claim 4471 is awaiting review..."}]}],
 "usage": {"input_tokens": 212, "output_tokens": 64, "total_tokens": 276}}
```

```python theme={null}
# Python, with a recent OpenAI SDK
resp = client.responses.create(
    prompt={"id": "claims-assistant", "version": "3", "variables": {"customer_tier": "gold"}},
    input="Where is claim 4471?")
print(resp.output_text)
```

| Request field | Meaning |
| - | - |
| `prompt.id` | The agent's name. Required for an agent call. |
| `prompt.version` | The version to run, for example `"3"`. Omit it to use the agent's default version. An unknown version returns 404. |
| `prompt.variables` | Values for the agent's input variables. |
| `input` | A string, or an array of content items. |
| `stream` | `true` streams the response as events. |
| `background` | `true` returns at once with a response in `queued` or `in_progress`; collect it later. Needs background mode enabled on the deployment. |
| `previous_response_id` | Continues a stored conversation (the response must have been stored). |
| `store` | Whether to keep the response so it can be retrieved or chained. |

A response `status` is one of `queued`, `in_progress`, `completed`, `failed`, `incomplete`, `cancelled` or `requires_action`. The last means a governance rule is holding the run for human approval.

```bash theme={null}
# Collect, cancel or delete a stored response. Send x-model-name: the agent or deployment name.
curl $BUD_BASE_URL/v1/responses/resp_... -H "Authorization: Bearer $BUD_API_KEY" -H "x-model-name: claims-assistant"
curl -X POST $BUD_BASE_URL/v1/responses/resp_.../cancel -H "Authorization: Bearer $BUD_API_KEY" -H "x-model-name: claims-assistant"
curl -X DELETE $BUD_BASE_URL/v1/responses/resp_... -H "Authorization: Bearer $BUD_API_KEY" -H "x-model-name: claims-assistant"
```

> [!TIP]
>
> A long agent run belongs in background mode: send `"background": true`, keep the `id`, and poll `GET /v1/responses/{id}` until `status` is no longer `queued` or `in_progress`. `GET /v1/responses/{id}/input_items` lists the inputs a response was given.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.