Endpoint
Authentication
Requires JWT authentication viaAuthorization: Bearer <token> header.
Description
Starts an agent run to process a user prompt. The agent executes in the context of a thread, which can be new or existing. The API supports file uploads, custom models, optimistic creation, and background sandbox initialization. Key Features:- New or Existing Thread: Create a new thread or continue in an existing one
- File Upload: Upload files that are processed and added to the sandbox
- Optimistic Mode: Pre-create thread/project IDs on the client for instant UI updates
- Streaming: Real-time progress via Server-Sent Events (SSE)
- Billing & Limits: Automatic credit checks and concurrent run limits
Request Format
This endpoint usesmultipart/form-data to support file uploads.
Request Parameters
User message/task for the agent to execute. Required for new threads.
UUID of an existing thread to continue, or a new UUID in optimistic mode.
UUID of the project containing the thread. Required in optimistic mode.
UUID of the agent to use. If not provided, uses the user’s default agent.
Override the agent’s default model (e.g., “kortix/basic”, “openai/gpt-5-nano-2025-08-07”).Model access depends on subscription tier:
- Free:
kortix/minimax - Pro:
kortix/basic,openai/gpt-5-nano,anthropic/claude-3.5-sonnet - Enterprise: All models
Set to
"true" to enable optimistic mode. Client pre-generates thread_id and project_id for instant UI updates.When enabled, thread_id and project_id must be provided as valid UUIDs.Set to
"true" or "false" to enable/disable memory for this run.Execution mode (e.g., “code”, “chat”). Used for specialized agent behaviors.
Array of files to upload. Files are parsed, uploaded to the project’s sandbox, and made available to the agent.Supported formats: text files, code files, PDFs, images, etc.
Response
Returns immediately with run metadata. The agent executes in the background.UUID of the thread (new or existing)
Unique identifier for this agent run (UUID)
UUID of the project containing the thread
UUID of the sandbox where files are uploaded. Only returned if files were uploaded or sandbox was created.
Initial run status, always
"running"Performance timing information (only if
X-Emit-Timing: true header set by super admin)Examples
Response Example
Streaming Progress
Agent runs stream real-time events via Server-Sent Events (SSE):Error Responses
Billing or limit issuesInsufficient Credits:Model Access Denied:Concurrent Run Limit:Thread Limit:
Invalid request parametersOr optimistic mode validation:
Thread not found (when using existing thread)
Missing or invalid authentication token
Server error during run startup
Optimistic Mode
Optimistic mode allows instant UI updates by pre-generating IDs on the client:File Upload Details
File Processing:- Files are parsed on the server
- Sandbox is created/resolved for the project
- Files are uploaded to sandbox storage
- Agent can access files via
/workspacedirectory
- Maximum file size: Varies by tier
- Supported formats: Text, code, PDFs, images, documents
Concurrent Run Limits
Limits based on subscription tier:- Free: 1 concurrent run
- Pro: 3 concurrent runs
- Enterprise: 10+ concurrent runs
Background Execution
The/agent/start endpoint returns immediately while the agent executes in the background:
- Immediate Response: Returns
agent_run_id,thread_id,status: "running" - Background Task: Agent execution runs asynchronously
- Streaming: Progress streamed via SSE to
/agent-run/{agent_run_id}/stream - Completion: Status updated to
completed,failed, orstopped
Notes
- Fast Response: API returns in less than 100ms by using background execution
- Sandbox Creation: Sandboxes are created on-demand; with files (blocking), without files (background)
- Cache Warming: Credits and user context are prewarmed in background
- Model Override: Free tier users requesting
kortix/basicare auto-downgraded tokortix/minimax - Slot Reservation: Concurrent slot is reserved before execution to enforce limits
- Cleanup: Slots are automatically released on completion, failure, or timeout
Related Endpoints
- Stream Agent Run - Stream real-time progress
- Stop Agent Run - Cancel a running agent
- Get Agent Run Status - Check run status
- List Agent Runs - View run history