Documentation

Connect an agent to Agesic

Agesic exposes the OpenAI Chat Completions API. Any SDK or framework that talks to OpenAI works by changing the base URL and the key.

Quickstart

  1. Sign in with your wallet.
  2. Top up your balance with USDG or ETH on Robinhood Chain.
  3. Create an agent, set its limits and copy its key. The key is shown once.
  4. Point your SDK at https://agesic.app/v1 with that key.
import OpenAI from "openai";

const client = new OpenAI({
  baseURL: "https://agesic.app/v1",
  apiKey: process.env.AGESIC_AGENT_KEY,
});

const res = await client.chat.completions.create({
  model: "agesic/auto",
  messages: [{ role: "user", content: "Hello" }],
});

Running Agesic yourself? Use your own host, for example http://localhost:3000/v1.

Authentication

Send the agent's key as a bearer token. Keys start with agk_. Agesic stores only a SHA-256 hash, so a lost key can't be recovered; rotate it from the agent's page instead.

Authorization: Bearer agk_…

Chat Completions

POST /v1/chat/completions accepts the standard OpenAI request body: model, messages, temperature, max_tokens, tools, response_format and so on. Parameters are passed through to the provider.

curl https://agesic.app/v1/chat/completions \
  -H "Authorization: Bearer $AGESIC_AGENT_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "openai/gpt-5-mini",
    "messages": [{ "role": "user", "content": "Say hi in five words" }],
    "max_tokens": 50
  }'

Successful responses include a usage object and an X-Agesic-Charged-Micro header with the amount charged in micro-dollars (1,000,000 = $1).

Streaming

Set "stream": true to receive server-sent events exactly as OpenAI sends them. Usage is reported in the final chunk and billed the same way. If the client disconnects mid-stream, the tokens reported so far are billed.

Models

Use any OpenRouter model ID, such as anthropic/claude-haiku-4.5 or openai/gpt-5-mini, or one of the router models to let Agesic choose per request.

GET /v1/models returns every model with its input and output price per million tokens. The dashboard has a searchable version.

Routing

Four router models pick a vetted model for each request from the last user message and the length of the conversation:

  • agesic/auto: simple prompts go to a fast tier, code to a code tier, step-by-step questions to a reasoning tier, and complex or long work to a frontier tier.
  • agesic/cheap: the lowest-cost tier, one step up only for complex requests.
  • agesic/code and agesic/reason: pin the tier, moving to the frontier tier for hard problems.

Every tier has a primary model and two fallbacks. If the primary is unavailable, the provider tries the next one, and you are billed for the model that actually answered (shown in the response's model field).

Preview a decision without calling a model or storing anything:

curl https://agesic.app/v1/route/preview \
  -H "Content-Type: application/json" \
  -d '{ "prompt": "Fix this failing unit test", "mode": "auto" }'

Limits

Each agent has its own limits. They are checked before a request reaches the provider.

  • Daily cap. Total spend per UTC day.
  • Per-call cap. When a model's price is known, Agesic lowers max_tokens so the call can't exceed the cap, your balance or what's left of the daily cap. For agesic/auto the price is budgeted against the most expensive model in its tier.
  • Model allowlist. Exact IDs, or a provider wildcard like anthropic/*.
  • Requests per minute. A rolling one-minute ceiling that stops runaway loops.
  • Pause. Refuses every call until you resume the agent.

Billing

Each call costs what the provider reports for it, plus a 5% Agesic fee, deducted from your balance. Refused and failed calls cost nothing. Every call appears in Usage with its tokens, provider cost, fee and latency, and can be exported as CSV.

Errors

Errors use the OpenAI shape, so SDKs raise them normally:

{ "error": { "message": "This agent has reached its daily spending cap.", "type": "daily_cap_reached", "code": "daily_cap_reached" } }
StatusCodeMeaning
400invalid_requestThe body isn't JSON or messages is empty.
401missing_api_keyNo Authorization header was sent.
401invalid_api_keyThe key is wrong or was rotated.
402insufficient_balanceYour account balance is empty. Top up.
402daily_cap_reachedThis agent hit its daily cap. It resets at 00:00 UTC.
402budget_exceededThe prompt alone would exceed the per-call cap or what's left.
403agent_pausedThe agent is paused in the dashboard.
403model_not_allowedThe model isn't on the agent's allowlist.
404model_not_foundUnknown model ID. Check GET /v1/models.
429rate_limitedToo many calls in the last minute (loop breaker).
502upstream_errorThe model provider couldn't be reached. Not charged.

Top-ups

Top-ups are made from the dashboard with the wallet you signed in with, on Robinhood Chain (chain ID 4663).

  • USDG (0x5fc5…d168) is credited one-to-one: 1 USDG = $1.00.
  • ETH is credited at a USD price locked for five minutes when you start the transfer. If it lands later, you get the lower of the locked price and the live price.
  • Credits appear after 30 block confirmations, usually a few seconds. Each transaction is credited once.
  • Only direct transfers from your signed-in wallet to the treasury count. USDG-funded credit can be withdrawn as USDG from Billing; ETH-bought credit can only be spent.

If your page closed before a top-up was credited, paste the transaction hash on the Top up page. Need funds on Robinhood Chain? See the official bridging guide.

Earn: sell your API to agents

List any HTTPS API in the dashboard's Earn tab with a price per call. Agents call it through Agesic with their own key, and you earn the price minus a 5% fee for every call that doesn't fail with a 5xx error.

curl https://agesic.app/v1/apis/<slug>/<path> \
  -H "Authorization: Bearer $AGESIC_AGENT_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "query": "Paris" }'
  • Method, path, query and body are forwarded to your base URL. The agent's key and cookies are not.
  • Each request carries X-Agesic-Timestamp, X-Agesic-Call-Id and X-Agesic-Signature, which is sha256= plus the HMAC-SHA256 of <timestamp>.<raw body> with your signing secret. Reject requests that don't match or are older than five minutes.
  • Responses are capped at 5 MB and 30 seconds. Redirects aren't followed.
  • Agents with a model allowlist need api:<slug> or api:*. Paid calls count toward daily and per-call caps and appear in Records as api:<slug>.
  • Move earnings to your balance instantly, or request a USDG payout to your wallet (minimum $10, sent manually).