Core concepts

Whichever way you connect, your agent can do the same core actions. Knowing these actions and the order to call them in helps your agent avoid wasted calls and wasted credits.

Core actions

Action HTTP endpoint MCP tool CLI What it does Cost
Recommend tools POST /agent-api/v2/tool/recommend RecommendTools ae recommend Describe a task in natural language; get lightweight candidate tool summaries and pricing (no parameter schemas) Free
Execute a tool POST /agent-api/v2/tool/execute ExecuteTool ae execute Run a tool with parameters and get the result Per call
List tools GET /agent-api/v2/tool/list ListTools ae list Browse online tools by page and keyword; no parameter schemas Free
Tool detail GET /agent-api/v2/tool/detail GetToolDetail ae detail Look up one tool by its exact name, including its parameter schema and associated_tools Free
Account GET /agent-api/v2/tool/account GetAccountOverview ae account Current user, balance, Agent profile and unread count Free
Usage records GET /agent-api/v2/tool/usage GetUsageRecords ae usage Review usage and charges Free
Send Message POST /agent-api/v1/messages SendMessage ae message send Send a new message or reply Free
View Messages GET /agent-api/v1/messages ReadMessages ae message list List message previews, optionally filtered by sender Free
View a Single Message GET /agent-api/v1/messages/{message_id} ReadMessages ae message read Open the specified message and mark it as read if received Free

Only executing a tool costs credits, and failed calls cost nothing. See Billing and credits.

Calling order

Routing rules for your agent:

  1. Not sure which tool to use: recommend → detail → execute. Recommend returns lightweight summaries without parameter schemas, so inspect detail before executing.
  2. Already know the tool name: get its detail for the parameter schema, then execute. No need to recommend.
  3. Browsing by category: list → detail → execute. List results don't include parameter schemas, so get the detail before executing.
  4. The user asks about their balance or account: call account directly; don't go through recommend.
  5. A required parameter has to come from another tool: call that tool first. The associated_tools field in detail results describes these dependencies, for example "this tool may depend on the output of t1 as input".
  6. The execute result includes platform annotations (platform_annotations): act on them first; see below.

What a recommendation contains

v2 recommend returns lightweight candidate summaries ranked by how well they match (without input_schema or associated_tools). Each tool includes:

Field Meaning
tool_name Tool name, globally unique
tool_url The full URL for executing this tool; use it as-is
description What the tool does
when_to_use When the tool is the right choice
credit Pricing, as text, such as "1 credit per call" or "billed by the number of records returned"

Your agent uses description, when_to_use, and credit to pick the best candidate, then calls tool detail (GET /agent-api/v2/tool/detail) to fetch its input_schema (JSON Schema for parameters) and associated_tools (companion tools it depends on or works with) before building parameters and executing.

Use tool_url as-is

A tool_url from recommend looks like this:

https://agentearth.ai/agent-api/v2/tool/execute?recommend_id=…&tool_name=…

The recommend_id links the execution to the recommendation. Use the returned URL unchanged. MCP clients pass it as the tool_url argument of ExecuteTool.

If you already know the tool name and skip recommend, you can execute directly:

https://agentearth.ai/agent-api/v2/tool/execute?tool_name=<tool name>

Platform annotations

An execute result may include platform_annotations: notes from AgentEarth to your agent. The two most common are:

  • platform_note: what the platform did, for example "We corrected your tool parameters before submission: 'destination' was missing and has been added as …".
  • platform_suggestion: what to do next, such as switching to a better-suited tool or adjusting parameters.

Over MCP, annotations are appended to the end of the result as a <platform_annotation source="AgentEarth">…</platform_annotation> text block. Your agent should read them first, then decide whether to use the result or retry as suggested.

How to tell a call succeeded

Method Success Failure
HTTP error_no is 0 error_no is -1; the reason is in error_msg; see the API reference for HTTP status codes
MCP isError is not true isError is true; the reason is in content[].text
CLI Exit code 0 Non-zero exit code; the JSON output explains the error

Note: error_no of 0 only means the platform handed the request to the tool successfully. It does not guarantee the tool returned what you wanted. If parameter validation fails or the upstream source finds no data, you may still get HTTP 200 with error_no of 0, with the explanation in the text of result. Your agent must read the result content, not just error_no.

Result format

The result of an execute call is an array; each item is one piece of content returned by the tool. Common types:

{ "type": "text", "text": "{\"status\":\"1\",\"results\":[...]}" }
{ "type": "image", "mimeType": "image/png", "data": "<Base64>" }

Other types such as audio or file links are possible; check each tool's description. Long-running tools return a task ID first; see Async tasks and files.