Skip to main content
Use the Agents API when you want first-class, reusable agent objects instead of building a Responses request from scratch every time. An agent stores model choice, instructions, and tool configuration. Each run persists the input plus the upstream Responses API result. API Reference:

Create an agent

Create an agent once, then reuse its saved behavior across multiple runs. The example below stores instructions and a web_search tool so later runs can call external tools when needed.
On success, the API returns 201 Created with an agent object with a stable id such as agt_.... See the Create an agent API reference for the full schema.

List and retrieve agents

Use the collection endpoint to list saved agents for the current caller. Use the item endpoint when you already know the agent ID.
See the List agents API reference and Retrieve an agent API reference for the complete response shapes.

Execute a saved agent

Run the agent by sending only the per-run input and optional metadata. The service combines this with the saved agent configuration and forwards the request into the Responses API through mkllm-gateway. Runs start asynchronously: the create call returns a queued run record. Use run retrieval to poll status, or stream progress via the run events endpoint.
The run response includes:
  • the persisted run ID
  • the run status
  • gateway_response_id from the upstream Responses call
  • gateway_response, which contains the stored assistant output and any tool activity
If the run used web_search, the persisted gateway_response will include the corresponding tool call entries. See the Execute a saved agent API reference for the full run request and response schema.

Inspect run history

Use the runs collection to list prior executions for one agent. Use the run detail endpoint to retrieve one stored result again later.
To retrieve one run directly:
See the List runs for an agent API reference and Retrieve an agent run API reference for the complete run-history schema.

Update or delete an agent

Use POST /api/v1/agents/{agent_id} to update stored configuration. Use DELETE /api/v1/agents/{agent_id} to delete the agent when it should no longer accept new runs.
On success, delete returns 200 OK with a deletion result object:
See the Update an agent API reference and Delete an agent API reference for the endpoint details. An agent with connectors cannot be deleted: the call returns 409 until they are gone. Schedules do not block deletion, but they are only reachable through the agent, and deleting it does not delete them, so delete them first. See Connect agents to chat apps and schedules.

Versions and rollback

Every create, update, and rollback appends a version, an immutable copy of the agent’s configuration: name, description, model, instructions, tools, tool_choice, parallel_tool_calls, max_tool_calls, text, reasoning, and metadata. Creation writes version 1, and the agent object’s version is the number of the current one. Each run records agent_version, the version it executed against. A continuation such as an MCP approval keeps using that version, so the agent can change underneath it without changing the run. Rolling back to version N copies N’s configuration into the agent as a new version. Version N itself is untouched, and the new version carries restored_from_version: N, so history never loses an entry. The mka1 CLI reference does not list version commands, so this section has no CLI tab.
A version object holds the configuration fields above plus: The list is paginated with limit and order (desc by default, so the newest version comes first). Asking for a version number that does not exist returns 404. Rollback needs write:agents and returns the agent object, whose version is the new number. Like update and delete, rollback requires the same X-On-Behalf-Of the agent was created with: a caller sending the header gets 404 on an agent created without it. See the List agent versions, Retrieve an agent version, and Roll back an agent to a version API references. Review the Responses API guide if you want to compare saved-agent execution with one-off response requests. To run an agent from a chat app or on a timer, see Connect agents to chat apps and schedules.