Quickstart
- Sign in with your wallet.
- Sign in with a BNB Smart Chain wallet and top up your balance with USDC (see Top-ups).
- Create an agent, set its limits and copy its key. The key is shown once.
- Point your SDK at
https://agesic.space/v1with that key.
import OpenAI from "openai";
const client = new OpenAI({
baseURL: "https://agesic.space/v1",
apiKey: process.env.AGESIC_AGENT_KEY,
});
const res = await client.chat.completions.create({
model: "agesic/auto",
messages: [{ role: "user", content: "Hello" }],
});The full API is described in an OpenAPI 3.1 file at /openapi.json, for code generators, API clients and agents.
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.space/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. Non-streaming responses also carry an X-Agesic-Charged-Micro header with the amount charged in micro-dollars (1,000,000 = $1). Streams report the same amount in their last chunk, below.
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.
Once the call is settled, Agesic sends one more chunk right before data: [DONE]. It has no choices, so OpenAI SDKs pass over it, and it carries the amount charged:
data: {"id":"gen-…","object":"chat.completion.chunk","choices":[],"agesic":{"charged_micro":2140,"charged_usd":0.00214}}
data: [DONE]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. IDs must match exactly, so a name without its provider prefix, such as gpt-5-mini, returns 404 model_not_found.
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/codeandagesic/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.space/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_tokensso the call can't exceed the cap, your balance or what's left of the daily cap. Foragesic/autothe 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.
If the wallet you sign in with holds 1,000,000 $AGESIC or more, the fee drops to 3%. The balance is read from BNB Smart Chain and re-checked every hour; Billing shows whether the discount is active.
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" } }| Status | Code | Meaning |
|---|---|---|
| 400 | invalid_request | The body isn't JSON or messages is empty. |
| 401 | missing_api_key | No Authorization header was sent. |
| 401 | invalid_api_key | The key is wrong or was rotated. |
| 402 | insufficient_balance | Your account balance is empty. Top up. |
| 402 | daily_cap_reached | This agent hit its daily cap. It resets at 00:00 UTC. |
| 402 | project_cap_reached | The agent's project hit its daily or monthly budget. Daily resets at 00:00 UTC, monthly on the 1st. |
| 402 | budget_exceeded | The prompt alone would exceed the per-call cap or what's left. |
| 403 | agent_paused | The agent is paused in the dashboard. |
| 403 | model_not_allowed | The model isn't on the agent's allowlist. |
| 404 | model_not_found | Unknown model ID. Check GET /v1/models. |
| 429 | rate_limited | Too many calls in the last minute (loop breaker). |
| 502 | upstream_error | The model provider couldn't be reached. Not charged. |
Top-ups
Top-ups are made from Billing with the BNB Smart Chain wallet you signed in with, on BNB Smart Chain mainnet.
- USDC (
EPjF…Dt1v) is credited one-to-one: 1 USDC = $1.00. - Credits appear once the transfer is finalized, usually about 15 seconds. Each transaction is credited once.
- Only USDC transfers signed by your signed-in wallet to the Agesic treasury count. You pay the BNB Smart Chain network fee in SOL.
- Credit from top-ups can be spent but not withdrawn.
If your page closed before a top-up was credited, paste the transaction signature under "Already sent a transfer?" in Billing.
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.space/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-IdandX-Agesic-Signature, which issha256=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>orapi:*. Paid calls count toward daily and per-call caps and appear in Records asapi:<slug>. - Move earnings to your balance instantly, or request a payout in USDC on BNB Smart Chain to your wallet (minimum $10, sent manually).