Skip to Content
APIAgents API

Agents API

Agents are configurable AI entities that execute tasks within threads. Each agent has a model, system instructions, and optional MCP server configurations.

The Agent Object

{ "id": "agent_qP5Hz2jwHsj5oVoCPIx71", "userId": "user_abc123", "name": "Code Assistant", "agentType": "llm", "model": "gpt-5.1", "instructions": "You are a helpful coding assistant. Write clean, well-documented code.", "mcpServers": [ { "type": "stdio", "name": "filesystem", "command": "npx", "args": ["@modelcontextprotocol/server-filesystem", "/workspace"] } ], "execution": { "debug": false, "timeout": 600000 }, "createdAt": "2025-01-15T10:30:00.000Z", "updatedAt": "2025-01-15T14:22:00.000Z" }

Attributes

AttributeTypeDescription
idstringUnique identifier (agent_*)
userIdstringOwner user ID
namestringHuman-readable agent name
agentTypestringAgent type: llm or computer
modelstringModel identifier (for LLM agents)
workspacestringWorkspace path (for computer agents)
instructionsstringSystem prompt / instructions
mcpServersarrayMCP server configurations
executionobjectExecution configuration
handoffsarraySub-agents for delegation
metadataobjectCustom key-value metadata
createdAtstringISO 8601 timestamp
updatedAtstringISO 8601 timestamp

Agent Types

TypeDescriptionUse Case
llmLLM-based agent using OpenAI APIReasoning, planning, reviewing, chat
computerComputer-use agent via Codex SDKCode changes, file operations, terminal commands

Agent type is auto-inferred: providing model infers llm, providing workspace infers computer.

Supported Models

ModelDescriptionBest For
gpt-5.2Most advanced model (recommended)Complex reasoning, advanced coding
gpt-5.1High-performance modelGeneral tasks, coding, analysis
gpt-5.1-codexLatest Codex modelCode generation, code editing
gpt-5-codexOptimized for computer useCode generation, file operations
gpt-5Balanced general-purposeConversations, content generation
gpt-5-miniFast and cost-effectiveQuick tasks, simple queries
gpt-5-nanoUltra-efficientBasic tasks, rapid responses

List Agents

GET /v1/agents

Query Parameters

ParameterTypeDefaultDescription
appIdstring-Filter by application
limitnumber50Max results (1-100)
offsetnumber0Pagination offset

Example

curl https://api.computer-agents.com/v1/agents \ -H "Authorization: Bearer $API_KEY"

Response

{ "object": "list", "data": [ { "id": "agent_qP5Hz2jwHsj5oVoCPIx71", "name": "Code Assistant", "agentType": "llm", "model": "gpt-5.1", "createdAt": "2025-01-15T10:30:00.000Z" }, { "id": "agent_rQ6Ia3kxIsj6pWpDQJy82", "name": "Code Executor", "agentType": "computer", "workspace": "/projects/my-app", "createdAt": "2025-01-10T08:00:00.000Z" } ], "has_more": false, "total_count": 2 }

Create Agent

POST /v1/agents

Request Body

ParameterTypeRequiredDescription
namestringYesAgent name
agentTypestringNollm or computer (auto-inferred)
modelstringNo*Model identifier (required for LLM agents)
workspacestringNo*Workspace path (required for computer agents)
instructionsstringNoSystem prompt
mcpServersarrayNoMCP server configurations
executionobjectNoExecution settings
handoffsarrayNoSub-agents for delegation
metadataobjectNoCustom metadata

Either model or workspace must be provided. The agent type is inferred from which one you specify.

Example: LLM Agent

curl -X POST https://api.computer-agents.com/v1/agents \ -H "Authorization: Bearer $API_KEY" \ -H "Content-Type: application/json" \ -d '{ "name": "Code Planner", "model": "gpt-5.1", "instructions": "You are an expert software architect. Create detailed implementation plans with file structures, function signatures, and testing considerations." }'

Example: Computer Agent

curl -X POST https://api.computer-agents.com/v1/agents \ -H "Authorization: Bearer $API_KEY" \ -H "Content-Type: application/json" \ -d '{ "name": "Code Executor", "workspace": "/projects/my-app", "instructions": "You are a developer. Execute code changes as requested. Write clean, well-documented code.", "execution": { "debug": true, "timeout": 300000 } }'

Response

{ "agent": { "id": "agent_sR7Jb4lyJtk7qXqERKz93", "userId": "user_abc123", "name": "Code Planner", "agentType": "llm", "model": "gpt-5.1", "instructions": "You are an expert software architect...", "mcpServers": [], "createdAt": "2025-01-20T12:00:00.000Z" } }

Get Agent

GET /v1/agents/:agentId

Example

curl https://api.computer-agents.com/v1/agents/agent_xyz789 \ -H "Authorization: Bearer $API_KEY"

Response

{ "agent": { "id": "agent_xyz789", "userId": "user_abc123", "name": "Code Planner", "agentType": "llm", "model": "gpt-5.1", "instructions": "You are an expert software architect...", "mcpServers": [], "createdAt": "2025-01-20T12:00:00.000Z" } }

Update Agent

PATCH /v1/agents/:agentId

Request Body

ParameterTypeDescription
namestringNew agent name
modelstringNew model (LLM agents only)
workspacestringNew workspace (computer agents only)
instructionsstringNew instructions
mcpServersarrayUpdated MCP servers
executionobjectUpdated execution settings
metadataobjectUpdated metadata

Example

curl -X PATCH https://api.computer-agents.com/v1/agents/agent_xyz789 \ -H "Authorization: Bearer $API_KEY" \ -H "Content-Type: application/json" \ -d '{ "instructions": "You are a senior software architect with 10 years of experience..." }'

Delete Agent

DELETE /v1/agents/:agentId

Existing threads using this agent will continue to work but won’t use the agent’s configuration for new messages.

Example

curl -X DELETE https://api.computer-agents.com/v1/agents/agent_xyz789 \ -H "Authorization: Bearer $API_KEY"

Response

{ "success": true }

Execution Configuration

Configure how agents execute tasks:

{ "execution": { "debug": false, "timeout": 600000 } }
ParameterTypeDefaultDescription
debugbooleanfalseEnable debug logging
timeoutnumber600000Execution timeout in ms (10 min default)

MCP Server Configuration

Agents can use MCP (Model Context Protocol) servers to extend their capabilities:

Stdio Server

Local process-based MCP server:

{ "mcpServers": [ { "type": "stdio", "name": "filesystem", "command": "npx", "args": ["@modelcontextprotocol/server-filesystem", "/workspace"], "env": {}, "allowedTools": ["read_file", "write_file"] } ] }
ParameterTypeRequiredDescription
typestringYesMust be stdio
namestringYesUnique server name
commandstringYesCommand to execute
argsarrayNoCommand arguments
envobjectNoEnvironment variables
cwdstringNoWorking directory
allowedToolsarrayNoFilter available tools

HTTP Server

Remote HTTP-based MCP server:

{ "mcpServers": [ { "type": "http", "name": "notion", "url": "https://notion-mcp.example.com/mcp", "bearerToken": "your-token", "headers": {} } ] }
ParameterTypeRequiredDescription
typestringYesMust be http
namestringYesUnique server name
urlstringYesMCP endpoint URL
bearerTokenstringNoBearer token for auth
headersobjectNoAdditional headers
allowedToolsarrayNoFilter available tools

Multi-Agent Handoffs

Agents can delegate tasks to other agents using handoffs:

curl -X POST https://api.computer-agents.com/v1/agents \ -H "Authorization: Bearer $API_KEY" \ -H "Content-Type: application/json" \ -d '{ "name": "Planner", "model": "gpt-5.1", "instructions": "Create implementation plans. Delegate execution to the Executor agent.", "handoffs": ["agent_executor_id"] }'

Use handoffs to create multi-agent workflows where a planner agent creates plans and an executor agent implements them.


Writing Effective Instructions

Write clear, specific instructions:

You are a Python backend developer specializing in FastAPI. Guidelines: - Follow PEP 8 style guidelines - Use type hints for all function parameters and return values - Include docstrings for all public functions - Write unit tests for new functionality - Use async/await for I/O operations When creating APIs: - Use Pydantic models for request/response validation - Implement proper error handling with HTTPException - Add OpenAPI documentation with examples

Good instructions are specific, actionable, and include examples of expected behavior.


Errors

StatusErrorDescription
400Bad RequestInvalid model or configuration
404Not FoundAgent not found
422Validation ErrorInvalid instructions or parameters

Model Validation Error

{ "error": "Bad Request", "message": "Invalid model 'invalid-model'. Supported models: gpt-5.2, gpt-5.1, gpt-5.1-codex, gpt-5-codex, gpt-5, gpt-5-mini, gpt-5-nano" }

Missing Required Fields

{ "error": "Validation Error", "message": "Either 'model' or 'workspace' must be provided" }

Last updated on