POST /events
Ingest an event from your agent — the core endpoint of AgentFlare.
POST /events
This is the primary endpoint your agent calls on every LLM call, tool use, or lifecycle event. The backend calculates cost, updates the 24h total, checks the threshold, and returns a pause signal.
Rate limit: 120 requests per minute per API key.
Request
Body
Fields
| Field | Type | Required | Description |
|---|---|---|---|
agent_id | string | Yes | Identifies which agent this event belongs to. |
event_type | string | Yes | "llm_call" | "tool_call" | "agent_start" | "agent_end" |
model | string | For llm_call | The LLM model name. Used for cost lookup. |
input_tokens | integer | No (default 0) | Number of prompt/input tokens used. |
output_tokens | integer | No (default 0) | Number of completion/output tokens used. |
tool_name | string | For tool_call | Name of the tool invoked. |
metadata | object | No | Arbitrary key-value pairs stored with the event. |
Response
| Field | Type | Description |
|---|---|---|
ok | boolean | Always true on success. |
cost_usd | float | Cost of this single event in USD. 0.0 for non-LLM events. |
paused | boolean | If true, stop your agent immediately. The budget has been exceeded. |
total_cost_24h | float | Cumulative cost for this agent in the last 24 hours. |
How cost is calculated
Cost is only calculated for event_type = "llm_call" events with a known model. The formula is:
Prices are looked up from a hardcoded table (see Supported models). Unknown models fall back to GPT-4o pricing.
What happens on threshold breach
When the 24h total crosses the configured cost_threshold_usd:
- The backend sets
is_paused = trueonagent_configsin Supabase. "paused": trueis returned in this response.- A Slack message is sent (if
slack_webhook_urlis configured). - The SDK sets its internal
_pausedflag and all futuresend_eventcalls returnFalse.