Intelligent execution

Introduction

Capability key: agent.execute. Send a task to an agent that can discover authorized capabilities, estimate costs, submit image/video tasks and check their results. Use a connection key; browser cookies do not authorize this API.

Dashboard conversations with the isolated runtime enabled can run workspace commands, download files, convert images to JPEG and inspect PNG, JPEG, WebP or GIF images with deepseek-flash. The runtime includes Lingtu CLI and its inspiration Skill. Image reads use up to four images per request and resize large images automatically. Available tools and files belong to the conversation workspace. Remote execution writes results back to the same conversation. Image input uses the same run budget.

Create a reusable Agent

BASH
curl https://api.anycap.io/v1/managed-agents \  -H "Authorization: Bearer $ANYCAP_API_KEY" \  -H "Content-Type: application/json" \  -d '{"name":"Content planner","role_description":"Plan practical TikTok Shop content in the user’s language."}' # Use the returned id for every turn. Your application stores sessions/history.curl https://api.anycap.io/v1/managed-agents/$AGENT_ID/runs \  -H "Authorization: Bearer $ANYCAP_API_KEY" \  -H "Idempotency-Key: $TURN_ID" \  -H "Content-Type: application/json" \  -d '{"input":"Draft three hooks for this product.","history":[],"max_credits":0,"stream":false}'

List definitions with GET /v1/managed-agents; update or delete one with PATCH/DELETE /v1/managed-agents/{id}. Ownership always comes from the connection key’s account and actor. Reuse an Idempotency-Key only for the identical turn. Anycap executes and bills the model/tools; the integrating server stores and authorizes its own end-user sessions.

Registered server applications can use the durable graphic-remake job profile: POST /v1/managed-agents/{id}/jobs returns 202; GET /jobs/{job_id} reads state, /events replays SSE with Last-Event-ID, POST /cancel stops later work, and POST /inputs supplies a stable input_id plus feedback when waiting_input. Every call requires the connection key, X-Anycap-App and a short-lived X-Anycap-Grant binding the application user, external job id, action and exact body hash. Keep these credentials on the integrating server. Completed steps and cumulative model budgets survive restarts; an unknown model/submission outcome is not automatically resubmitted. This profile must be enabled by an operator before use; see OpenAPI for its structured case/product/material input and separate business-compute ceiling.

Discover a model and execute

BASH
curl https://api.anycap.io/v1/models \  -H "Authorization: Bearer $ANYCAP_API_KEY" curl https://api.anycap.io/api/v1/capabilities/agent.execute/executions \  -H "Authorization: Bearer $ANYCAP_API_KEY" \  -H "Content-Type: application/json" \  -d '{"input":"List the image capabilities available to me and suggest a suitable option.","model":"deepseek-flash","max_credits":0,"max_turns":4,"stream":false}'

Replace model with an available authorized model from discovery. The request uses the same contract as POST /v1/agent/runs; existing clients can keep that endpoint. Paid tool execution requires an explicitly authorized positive max_credits.

ParameterMeaning
input
Required task instruction, 1–8000 UTF-8 bytes.
model
Optional model key from /v1/models; omission uses the configured default.
max_credits
Paid-tool budget in whole credits, default 0, maximum 1,000,000. Zero disables paid tools; model token calls are still billed separately. This is not an all-inclusive run spending cap.
max_turns
Model round limit, default 8, maximum 12.
history
Optional user/assistant messages; at most 20 messages and 40,000 UTF-8 bytes of content in total.
stream
Use true for SSE; false returns the final JSON. An explicit value takes precedence over Accept.

Read the result and continue

The response includes id, status, message, steps, budget, usage and messages. Inspect status even after HTTP 200: completed, budget_exceeded, limit_reached or failed. An image/video task may still be processing; use the returned task ID and its normal capability query API.

For SSE, send stream:true or Accept: text/event-stream. Events are run.started, tool.call, tool.result, assistant, run.completed, run.failed. run.failed also represents budget and round-limit stops. Assistant text arrives per model round, not token by token.

Keep conversation history on your side, append returned messages, and send it as history on the next call. Direct agent.execute calls remain stateless; /v1/managed-agents/{id}/runs additionally loads an owned reusable role definition, but still does not create a dashboard browser session or file workspace. Send a stable Idempotency-Key so an identical retry derives the same billable execution ids; never reuse it with changed input/history.

HTTP statusHandling
400Check input and history bounds.
401 / 403Check key validity and model/tool permissions.
429Respect key/IP rate limits; do not retry a potentially submitted paid action blindly.
503Execution is unavailable. Do not assume an earlier ambiguous request was free or safe to repeat.