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
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
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.
input
model
/v1/models; omission uses the configured default.max_credits
max_turns
history
stream
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 status | Handling |
|---|---|
| 400 | Check input and history bounds. |
| 401 / 403 | Check key validity and model/tool permissions. |
| 429 | Respect key/IP rate limits; do not retry a potentially submitted paid action blindly. |
| 503 | Execution is unavailable. Do not assume an earlier ambiguous request was free or safe to repeat. |