Skip to main content
The Agent Brain is FlareHQ’s autonomous reasoning layer for ERC-8004 agents. Send a natural-language message and the brain runs a Groq-powered loop (up to 4 iterations) that can autonomously invoke tools such as paying another agent, creating and settling ERC-8183 jobs, running payroll, generating invoices, routing USDC cross-chain via CCTP V2, recording on-chain reputation, and fetching external data. Each call is gated by the x402 protocol and costs $0.002 USDC.
This endpoint is protected by x402, not an API key. You must attach a valid payment-signature header (a base64-encoded x402 payment payload for exactly $0.002 USDC on Arc Mainnet) or the API returns HTTP 402 Payment Required. Paying the fee is handled by your x402/Gateway client — see x402 overview.

Endpoint

Request

Headers

Body Parameters

string
required
The instruction or question for the agent, in natural language (e.g. "Pay Agent B 5 USDC for the data processing job"). Must be a non-empty string — omitted or empty values return HTTP 400.
string
default:"session_{timestamp}"
A stable identifier for this conversation. The brain persists up to 20 prior messages per sessionId in its Postgres memory, so subsequent calls with the same value retain context across calls. Defaults to session_<Date.now()> when omitted.
string
default:""
Optional extra context injected into the system prompt for this call, e.g. the current user, an account ID, or instructions that should steer the agent’s tool selection.

Response

boolean
true when the reasoning loop completed. Note that tool calls inside the loop can still fail; their failures are reported in results.
string
The agent’s final text answer or summary. If the reasoning engine was unreachable, this contains a fallback message such as "I couldn't reach my reasoning engine right now. Please try again shortly."
array
Names of the tools the agent invoked during the loop (e.g. ["agent_pay_agent"]). Empty if the agent answered without calling any tool.
array
One entry per tool call, in execution order. Each entry has the shape { "tool": "<name>", "result": { ... } }. The result shape depends on the tool — for example agent_pay_agent returns { success, txHash, explorerUrl, amount, from, to }.
string
The session ID used for this call — either the one you supplied or the generated default. Pass it back to continue the same conversation.
object
Identity metadata for the brain’s host agent.

Examples

Success Response

Error Responses

When the x402 payment is missing or invalid, the API returns HTTP 402 with an empty JSON body {} and a base64-encoded PAYMENT-REQUIRED header describing the resource requirements (x402Version: 2, amount $0.002, network eip155:5042).

Notes

The brain can call the following tools: agent_pay_agent, create_agent_job, submit_job_deliverable, complete_or_reject_job, run_agent_payroll, setup_agent_subscription, generate_agent_invoice, route_cross_chain, record_agent_reputation, fetch_agent_data, and check_agent_status. The agent will not retry a tool that reports a setup/configuration error (e.g. “not found in registry”) — it explains the issue and suggests the fix instead.
Reuse the same sessionId across calls to give the agent memory of previous turns. Memory is capped at the last 20 messages and is stored per sessionId.
Each brain call settles a separate $0.002 x402 payment on-chain via Circle Gateway. Repeated calls accumulate micropayments — budget accordingly for long-running agent workflows. If the payment cannot be verified or settled, the call fails with HTTP 402.
A GET https://flarehq.xyz/api/agent/brain (no payment required) returns the agent’s metadata and the full list of capabilities, protocols (ERC-8004, ERC-8183, x402, Circle CCTP V2), and pricing.