API reference
Account and keys
The account, its balance, keys, limits, requests, analytics and statements.
On this page
- Read the account
- Read the balance
- List activity
- Read one request
- Read usage
- Read usage over time
- List keys
- Create a key
- Update a key
- Rotate a key
- Delete a key
- Set a key's controls
- Read a key's limits
- Read key safety
- Read limits
- Read a receipt
- List statements
- Download a statement
- Read a deposit receipt
- Buy USDF by card
- List card purchases
GET/
The signed-in account: its balance and what is held, the linked wallet, recent withdrawals, where to deposit, and the X and GitHub accounts it signed in with. Credits are in GET /v1/balance.
Auth: Session, not an API key: Authorization: Bearer <session token>. See Sign in.
No parameters.
GET /v1/account
curl https://api.usdf.fi/v1/account \
-H "Authorization: Bearer $SESSION"Response, trimmed
{
"account": {
"id": "<account id>",
"wallet_address": "<wallet address>",
"balance_units": "<units>",
"held_units": "<units>",
…
},
"x": { "user_id": "…", "username": "…", "name": "…", "avatar_url": "…" },
"github": null,
"withdrawals": { "pending_count": …, "pending_units": "<units>", "recent": [ … ], "note": "…" },
"deposit": { "network": "…", "chain_id": …, "token": "<USDF address>", "to": "<deposit address>", "note": "…" }
}GET/
USDF and credits as separate lines: USDF available, held and in all, and each credit grant with what is left and when it expires. With an API key, the key's view within its budget.
Auth: API key (Authorization: Bearer sk_) or a session
No parameters.
GET /v1/balance
curl https://api.usdf.fi/v1/balance \
-H "Authorization: Bearer $USDF_API_KEY"Response, trimmed
{
"object": "balance",
"scope": "account",
"usdf": { "available": { "units": "<units>", "usd": "<usd>", "usdf": "<usdf>" }, "held": { … }, "balance": { … }, "note": "…" },
"credits": {
"total": { … },
"grants": [{ "id": "…", "source": "<source>", "status": "active", "amount": { … }, "remaining": { … }, "expires_at": "<time>" }],
"note": "…"
},
"holder_rewards": { … },
"note": "USDF and credits are separate: credits are not USDF and cannot be withdrawn, sent or redeemed."
}GET/
The account's requests, newest first, each with its settlement, finish reason, routes tried, project and a link to its detail. Also as .csv with the same filters.
Auth: Session, not an API key: Authorization: Bearer <session token>. See Sign in.
| Name | Type | Required | Description |
|---|---|---|---|
key | string | No | Query. Only this key's (a key id). |
model | string | No | Query. Only this model's, or tool's. |
status | string | No | Query. ok, partial, failed_refunded or pending. |
provider | string | No | Query. Only rows served by this kind of route: hosted, network or private. |
project | string | No | Query. Only rows charged to this project (a project id), or none: keys in no project. |
from | string | No | Query. From this time, as an ISO time. |
to | string | No | Query. Up to this time, as an ISO time. |
min_ | string | No | Query. Only rows that cost at least this many base units. |
cursor | string | No | Query. The next_cursor of the previous page. |
limit | integer | No | Query. How many rows to return. |
before | string | No | Query. The page.next_before of the previous page. |
GET /v1/account/activity
curl https://api.usdf.fi/v1/account/activity \
-H "Authorization: Bearer $SESSION"GET/
One request in full: the route that served it and every route tried, the fallbacks, finish reason, latency, tokens, cost by who paid it, preset, settlement and receipt. A session reads the account's requests, with the logged prompt and response where they were kept; a key reads only its own, without the texts.
Auth: API key (Authorization: Bearer sk_) or a session
| Name | Type | Required | Description |
|---|---|---|---|
request_ | string | Yes | Path. The request's id: its answer's id or x-request-id. |
GET /v1/requests/{request_id}
curl https://api.usdf.fi/v1/requests/{request_id} \
-H "Authorization: Bearer $USDF_API_KEY"Response, trimmed
{
"object": "request",
"id": "<request_id>",
"model": "<model>",
"provider": "<provider>",
"status": "ok",
"finish_reason": "stop",
"route": { … },
"attempts": [{ "provider": "<provider>", "outcome": "served", … }],
"latency": { "total_ms": …, "ttft_ms": …, "generation_ms": …, "overhead_ms": … },
"usage": { "prompt_tokens": …, "completion_tokens": …, "cached_tokens": …, "total_tokens": … },
"cost": { "total": { "units": "<units>", "usd": "<usd>", "usdf": "<usdf>" }, "charged": { … }, "free_credit": { … }, … },
"settlement": { "status": "unsettled", … },
"bodies": { "available": false, "reason": "no_logs" },
"links": { "receipt": "…", "proof": "…", … }
}GET/
The account's usage rows.
Auth: Session, not an API key: Authorization: Bearer <session token>. See Sign in.
| Name | Type | Required | Description |
|---|---|---|---|
below | string | No | Query. Rows below this id. |
above | string | No | Query. Rows above this id. |
ids | string | No | Query. These row ids, comma-separated. |
limit | integer | No | Query. How many rows to return. |
GET /v1/account/usage
curl https://api.usdf.fi/v1/account/usage \
-H "Authorization: Bearer $SESSION"GET/
Requests, refunds, spend, tokens and latency by the hour or the day, overall or grouped. Also as .csv and .pdf with the same parameters. A key reads its own usage.
Auth: API key (Authorization: Bearer sk_) or a session
| Name | Type | Required | Description |
|---|---|---|---|
bucket | string | No | Query. hour or day. |
range | string | No | Query. A rolling window ending now: 1h, 24h, 7d, 30d or 90d. Or send from and to. |
from | string | No | Query. The window's start: a date or an ISO time. |
to | string | No | Query. The window's end (default now). |
group_ | string | No | Query. none, model, key, provider (the route type: hosted, network or private), member (with org) or project. |
key | string | No | Query. Only this key's. |
model | string | No | Query. Only this model's, or tool's. |
provider | string | No | Query. Only what this kind of route served: hosted, network or private. |
org | string | No | Query. A team the account is a member of: its usage. |
project | string | No | Query. Only this project's (a project id), or none: keys in no project. |
top | integer | No | Query. How many groups to keep, largest spend first; the rest are one group, _other. |
GET /v1/analytics/series
curl https://api.usdf.fi/v1/analytics/series \
-H "Authorization: Bearer $USDF_API_KEY"GET/
The account's API keys.
Auth: Session, not an API key: Authorization: Bearer <session token>. See Sign in.
| Name | Type | Required | Description |
|---|---|---|---|
state | string | No | Query. active (default) or revoked. |
before | string | No | Query. For revoked keys: the revoked_at of the last row of the previous page. |
count | string | No | Query. 1: only the number of revoked keys. |
limit | integer | No | Query. How many keys to return. |
GET /v1/account/keys
curl https://api.usdf.fi/v1/account/keys \
-H "Authorization: Bearer $SESSION"POST/
Creates an API key. It is shown once, in this answer.
Auth: Session, not an API key: Authorization: Bearer <session token>. See Sign in.
| Name | Type | Required | Description |
|---|---|---|---|
label | string | No | A name for the key. |
budget_ | string or integer | No | The most the key may spend in all, in USDF base units. |
rate_ | integer | No | Requests per minute. |
project_ | string | No | One of the account's live projects to make the key in. |
POST /v1/account/keys
curl -X POST https://api.usdf.fi/v1/account/keys \ -H "Authorization: Bearer $SESSION" \ -H "Content-Type: application/json" \ -d '{"label": "research", "budget_units": "<units>"}'
Response, trimmed
{
"object": "api_key",
"key_id": "<key_id>",
"api_key": "sk_…",
"prefix": "<prefix>",
"note": "Shown once: store the key now. It spends from this account's balance."
}PATCH/
Changes a key's label, budget or rate limit, or moves it to a project. project_id alone moves the key and changes nothing else.
Auth: Session, not an API key: Authorization: Bearer <session token>. See Sign in.
| Name | Type | Required | Description |
|---|---|---|---|
id | string | Yes | Path. The key id. |
label | string | No | A name for the key. |
budget_ | string or integer | No | The key's budget in all, in USDF base units. |
clear_ | boolean | No | true removes the budget. |
rate_ | integer | No | Requests per minute. |
project_ | string or null | No | A live project to move the key into; null takes it out of its project. |
PATCH /v1/account/keys/{id}
curl -X PATCH https://api.usdf.fi/v1/account/keys/{id} \
-H "Authorization: Bearer $SESSION" \
-H "Content-Type: application/json" \
-d '{"project_id": "<project_id>"}'POST/
A new key with the old one's label, scope and every control: the budget left, the rate limit, the caps, the model allowlist, the pause, the flags, the webhook, the guardrails and the project. The old key is revoked in the same step, unless grace_seconds keeps it serving beside the new one for a while. The new key is shown once.
Auth: Session, not an API key: Authorization: Bearer <session token>. See Sign in.
| Name | Type | Required | Description |
|---|---|---|---|
id | string | Yes | Path. The key id. |
grace_ | integer | No | Seconds the old key keeps serving beside the new one, 0 to 86,400; then it is refused key_expired. 0 or none revokes it at once. A key with a budget or a spending cap rotates at once only. |
POST /v1/account/keys/{id}/rotate
curl -X POST https://api.usdf.fi/v1/account/keys/{id}/rotate \
-H "Authorization: Bearer $SESSION"Response, trimmed
{
"object": "api_key",
"key_id": "<new key_id>",
"api_key": "sk_…",
"prefix": "<prefix>",
"rotated_from": "<key_id>",
"old_key_revoked": true,
"old_key_expires_at": null,
"grace_seconds": 0,
"kept": { … },
"note": "…"
}DELETE/
Revokes a key.
Auth: Session, not an API key: Authorization: Bearer <session token>. See Sign in.
| Name | Type | Required | Description |
|---|---|---|---|
id | string | Yes | Path. The key id. |
DELETE /v1/account/keys/{id}
curl -X DELETE https://api.usdf.fi/v1/account/keys/{id} \
-H "Authorization: Bearer $SESSION"PATCH/
Spend caps by the hour, day and month, the model allowlist, the pause, the privacy flags, the webhook, guardrails, an expiry and an IP allowlist. An unknown field refuses the whole request.
Auth: Session, not an API key: Authorization: Bearer <session token>. See Sign in.
| Name | Type | Required | Description |
|---|---|---|---|
id | string | Yes | Path. The key id. |
spend_ | string or null | No | Caps over the trailing hour, day and month, in USDF base units. Null clears one. |
allowed_ | array or null | No | Model ids, or prefixes ending in *. Null allows every listed model; an empty list allows none. |
paused | boolean | No | Pause or resume the key. |
no_ | boolean | No | Never keep the prompt or completion text. |
retain | boolean | No | true keeps the key's requests in the account's request logs; false keeps the key in no-logs mode. |
private_ | boolean | No | Run every request on attested routes. |
webhook_ | string or null | No | Where the key's pause and resume events go. |
guardrails | object or null | No | The key's own guardrails: allowed_providers, blocked_providers, max_price, zdr_only, redact, injection. Null removes them. |
expires_ | string or null | No | When the key stops serving, as an ISO time with its offset. Null: no expiry. |
ip_ | array or null | No | IPv4 or IPv6 addresses or CIDR blocks the key serves from. Null: any address. An empty list is refused. |
PATCH /v1/keys/{id}
curl -X PATCH https://api.usdf.fi/v1/keys/{id} \
-H "Authorization: Bearer $SESSION" \
-H "Content-Type: application/json" \
-d '{"expires_at": "<time>", "ip_allowlist": ["<address>", "<CIDR block>"]}'GET/
A key's caps, spend in each window, allowlist, pause, flags, webhook and safety.
Auth: Session, not an API key: Authorization: Bearer <session token>. See Sign in.
| Name | Type | Required | Description |
|---|---|---|---|
id | string | Yes | Path. The key id. |
GET /v1/keys/{id}/limits
curl https://api.usdf.fi/v1/keys/{id}/limits \
-H "Authorization: Bearer $SESSION"GET/
Every active key of the account: when it was made and last used, and from which address, its expiry and IP allowlist, the last request refused for either, and its flags (never_used, stale, old, expired, expiring_soon, no_expiry, no_ip_allowlist, no_spend_limit, paused, refused_recently). your_ip is your address as the gateway sees it.
Auth: Session, not an API key: Authorization: Bearer <session token>. See Sign in.
No parameters.
GET /v1/keys/safety
curl https://api.usdf.fi/v1/keys/safety \
-H "Authorization: Bearer $SESSION"GET/
The gateway's rate limits.
Auth: API key (Authorization: Bearer sk_) or a session
No parameters.
GET /v1/limits
curl https://api.usdf.fi/v1/limits \
-H "Authorization: Bearer $USDF_API_KEY"GET/
One request's receipt: with a key, a request that key made; with a session, any of the account's.
Auth: API key (Authorization: Bearer sk_) or a session
| Name | Type | Required | Description |
|---|---|---|---|
id | string | Yes | Path. The request id. |
GET /v1/receipts/{id}
curl https://api.usdf.fi/v1/receipts/{id} \
-H "Authorization: Bearer $USDF_API_KEY"GET/
Every month of the account, newest first, with its statement's number and state: open, closing, closed or issued. A closed month is issued on its first read and never changes after.
Auth: Session, not an API key: Authorization: Bearer <session token>. See Sign in.
No parameters.
GET /v1/statements
curl https://api.usdf.fi/v1/statements \
-H "Authorization: Bearer $SESSION"GET/
A month's statement as CSV, also as .pdf or .json: deposits, spend by model, settlements, withdrawals, refunds, credits and the opening and closing balances, with the statement's number and state.
Auth: Session, not an API key: Authorization: Bearer <session token>. See Sign in.
| Name | Type | Required | Description |
|---|---|---|---|
YYYY-MM | string | Yes | Path. The month. |
GET /v1/statements/{YYYY-MM}.csv
curl https://api.usdf.fi/v1/statements/{YYYY-MM}.csv \
-H "Authorization: Bearer $SESSION"GET/
A numbered receipt for one deposit credited to the account, also as .pdf: the amount, where it came from, the transaction, when it was credited and whether it is final.
Auth: Session, not an API key: Authorization: Bearer <session token>. See Sign in.
| Name | Type | Required | Description |
|---|---|---|---|
tx_ | string | Yes | Path. The deposit's transaction. |
log_ | string | Yes | Path. Its log index in that transaction. |
GET /v1/account/deposits/{tx_hash}/{log_index}/receipt.json
curl https://api.usdf.fi/v1/account/deposits/{tx_hash}/{log_index}/receipt.json \
-H "Authorization: Bearer $SESSION"Response, trimmed
{
"object": "deposit_receipt",
"number": "DR-…",
"tx_hash": "<transaction hash>",
"log_index": …,
"from_address": "<wallet address>",
"amount": { "units": "<units>", "usd": "<usd>", "usdf": "<usdf>" },
"source": "transfer",
"credited_at": "<time>",
"final": true,
…
}GET/
The card widget's settings for the signed-in account and the purchase the payment becomes, with its status link.
Auth: Session, not an API key: Authorization: Bearer <session token>. See Sign in.
No parameters.
GET /v1/account/deposit/card
curl https://api.usdf.fi/v1/account/deposit/card \
-H "Authorization: Bearer $SESSION"GET/
The account's card purchases, newest first: status, what was paid and delivered, the transactions and what was credited.
Auth: Session, not an API key: Authorization: Bearer <session token>. See Sign in.
No parameters.
GET /v1/account/deposit/card/history
curl https://api.usdf.fi/v1/account/deposit/card/history \
-H "Authorization: Bearer $SESSION"