Async tasks and files
Async tasks
Long-running tools (mostly video and image generation) switch to async mode automatically: instead of the result, the execute call returns a task ID.
{
"task_id": "…",
"status": "created",
"query_tool": "ae_get_result",
"description": "task accepted; poll the result via query_tool with this task_id"
}Getting the result
Use the same Agent that submitted the task. You can still retrieve the result after renaming the Agent. If you delete it, a new Agent with the same name cannot retrieve its tasks.
Call the ae_get_result tool with the task ID:
curl --request POST \
--url 'https://agentearth.ai/agent-api/v2/tool/execute?tool_name=ae_get_result' \
--header "X-Api-Key: $AGENTEARTH_API_KEY" \
--header 'Content-Type: application/json' \
--data-raw '{"params":{"task_id":"<task ID>"}}'- Not finished yet: you get an in-progress status; check again a little later.
- Finished: you get the original tool's result, in the same format as a synchronous call.
ae_get_resultis free and does not count toward rate limits, so polling is safe.
Over MCP, call ae_get_result through ExecuteTool; with the CLI, use ae execute. The parameters are the same.
Things to keep in mind
- Don't resubmit. Once you have a task ID, only poll for the result. Running the original tool again creates a new task and charges again.
- Tasks are kept for 24 hours. After 24 hours, or for an unknown task ID, the response is always
{"status": "not_found"}. Fetch and save results within 24 hours. - Images and videos in results are usually file links; download them promptly if you need to keep them.
Uploading files
Tools that take files (images, audio, documents and so on) accept them in one of two ways; check each tool's parameter description:
Option 1: upload first, then pass the URL
Call the free tool
ae_file_service_get_upload_addrto get an upload URL. Parameters:Parameter Description extFile extension without the dot, letters and digits only, such as pngsize_bytesFile size in bytes, up to 524,288,000 (500 MiB) ttl_minutesHow long the upload URL stays valid, in minutes, up to 43,200 (30 days) It returns
uploadURL(where to upload) anddownloadURL(the file's address).Upload the file content to
uploadURLwith a PUT request:curl --request PUT --upload-file ./photo.png "<uploadURL>"Pass
downloadURLto the target tool as a parameter.
Anyone with the downloadURL link can access the file, so don't upload sensitive files this way.
Option 2: pass base64 directly
Some tools accept the file base64-encoded as a parameter. This suits small files; for larger files, prefer option 1.
