API reference

Account and keys

The account, its balance, keys, limits, requests, analytics and statements.

On this page

GET/v1/account

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
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/v1/balance

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
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/v1/account/activity

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.

NameTypeRequiredDescription
keystringNoQuery. Only this key's (a key id).
modelstringNoQuery. Only this model's, or tool's.
statusstringNoQuery. ok, partial, failed_refunded or pending.
providerstringNoQuery. Only rows served by this kind of route: hosted, network or private.
projectstringNoQuery. Only rows charged to this project (a project id), or none: keys in no project.
fromstringNoQuery. From this time, as an ISO time.
tostringNoQuery. Up to this time, as an ISO time.
min_cost_unitsstringNoQuery. Only rows that cost at least this many base units.
cursorstringNoQuery. The next_cursor of the previous page.
limitintegerNoQuery. How many rows to return.
beforestringNoQuery. The page.next_before of the previous page.

GET /v1/account/activity

curl
curl https://api.usdf.fi/v1/account/activity \
  -H "Authorization: Bearer $SESSION"

GET/v1/requests/{request_id}

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

NameTypeRequiredDescription
request_idstringYesPath. The request's id: its answer's id or x-request-id.

GET /v1/requests/{request_id}

curl
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/v1/account/usage

The account's usage rows.

Auth: Session, not an API key: Authorization: Bearer <session token>. See Sign in.

NameTypeRequiredDescription
belowstringNoQuery. Rows below this id.
abovestringNoQuery. Rows above this id.
idsstringNoQuery. These row ids, comma-separated.
limitintegerNoQuery. How many rows to return.

GET /v1/account/usage

curl
curl https://api.usdf.fi/v1/account/usage \
  -H "Authorization: Bearer $SESSION"

GET/v1/analytics/series

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

NameTypeRequiredDescription
bucketstringNoQuery. hour or day.
rangestringNoQuery. A rolling window ending now: 1h, 24h, 7d, 30d or 90d. Or send from and to.
fromstringNoQuery. The window's start: a date or an ISO time.
tostringNoQuery. The window's end (default now).
group_bystringNoQuery. none, model, key, provider (the route type: hosted, network or private), member (with org) or project.
keystringNoQuery. Only this key's.
modelstringNoQuery. Only this model's, or tool's.
providerstringNoQuery. Only what this kind of route served: hosted, network or private.
orgstringNoQuery. A team the account is a member of: its usage.
projectstringNoQuery. Only this project's (a project id), or none: keys in no project.
topintegerNoQuery. How many groups to keep, largest spend first; the rest are one group, _other.

GET /v1/analytics/series

curl
curl https://api.usdf.fi/v1/analytics/series \
  -H "Authorization: Bearer $USDF_API_KEY"

GET/v1/account/keys

The account's API keys.

Auth: Session, not an API key: Authorization: Bearer <session token>. See Sign in.

NameTypeRequiredDescription
statestringNoQuery. active (default) or revoked.
beforestringNoQuery. For revoked keys: the revoked_at of the last row of the previous page.
countstringNoQuery. 1: only the number of revoked keys.
limitintegerNoQuery. How many keys to return.

GET /v1/account/keys

curl
curl https://api.usdf.fi/v1/account/keys \
  -H "Authorization: Bearer $SESSION"

POST/v1/account/keys

Creates an API key. It is shown once, in this answer.

Auth: Session, not an API key: Authorization: Bearer <session token>. See Sign in.

NameTypeRequiredDescription
labelstringNoA name for the key.
budget_unitsstring or integerNoThe most the key may spend in all, in USDF base units.
rate_limit_rpmintegerNoRequests per minute.
project_idstringNoOne of the account's live projects to make the key in.

POST /v1/account/keys

curl
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/v1/account/keys/{id}

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.

NameTypeRequiredDescription
idstringYesPath. The key id.
labelstringNoA name for the key.
budget_unitsstring or integerNoThe key's budget in all, in USDF base units.
clear_budgetbooleanNotrue removes the budget.
rate_limit_rpmintegerNoRequests per minute.
project_idstring or nullNoA live project to move the key into; null takes it out of its project.

PATCH /v1/account/keys/{id}

curl
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/v1/account/keys/{id}/rotate

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.

NameTypeRequiredDescription
idstringYesPath. The key id.
grace_secondsintegerNoSeconds 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
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/v1/account/keys/{id}

Revokes a key.

Auth: Session, not an API key: Authorization: Bearer <session token>. See Sign in.

NameTypeRequiredDescription
idstringYesPath. The key id.

DELETE /v1/account/keys/{id}

curl
curl -X DELETE https://api.usdf.fi/v1/account/keys/{id} \
  -H "Authorization: Bearer $SESSION"

PATCH/v1/keys/{id}

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.

NameTypeRequiredDescription
idstringYesPath. The key id.
spend_limit_hour_units, spend_limit_day_units, spend_limit_month_unitsstring or nullNoCaps over the trailing hour, day and month, in USDF base units. Null clears one.
allowed_modelsarray or nullNoModel ids, or prefixes ending in *. Null allows every listed model; an empty list allows none.
pausedbooleanNoPause or resume the key.
no_logsbooleanNoNever keep the prompt or completion text.
retainbooleanNotrue keeps the key's requests in the account's request logs; false keeps the key in no-logs mode.
private_tierbooleanNoRun every request on attested routes.
webhook_urlstring or nullNoWhere the key's pause and resume events go.
guardrailsobject or nullNoThe key's own guardrails: allowed_providers, blocked_providers, max_price, zdr_only, redact, injection. Null removes them.
expires_atstring or nullNoWhen the key stops serving, as an ISO time with its offset. Null: no expiry.
ip_allowlistarray or nullNoIPv4 or IPv6 addresses or CIDR blocks the key serves from. Null: any address. An empty list is refused.

PATCH /v1/keys/{id}

curl
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/v1/keys/{id}/limits

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.

NameTypeRequiredDescription
idstringYesPath. The key id.

GET /v1/keys/{id}/limits

curl
curl https://api.usdf.fi/v1/keys/{id}/limits \
  -H "Authorization: Bearer $SESSION"

GET/v1/keys/safety

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
curl https://api.usdf.fi/v1/keys/safety \
  -H "Authorization: Bearer $SESSION"

GET/v1/limits

The gateway's rate limits.

Auth: API key (Authorization: Bearer sk_…) or a session

No parameters.

GET /v1/limits

curl
curl https://api.usdf.fi/v1/limits \
  -H "Authorization: Bearer $USDF_API_KEY"

GET/v1/receipts/{id}

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

NameTypeRequiredDescription
idstringYesPath. The request id.

GET /v1/receipts/{id}

curl
curl https://api.usdf.fi/v1/receipts/{id} \
  -H "Authorization: Bearer $USDF_API_KEY"

GET/v1/statements

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
curl https://api.usdf.fi/v1/statements \
  -H "Authorization: Bearer $SESSION"

GET/v1/statements/{YYYY-MM}.csv

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.

NameTypeRequiredDescription
YYYY-MMstringYesPath. The month.

GET /v1/statements/{YYYY-MM}.csv

curl
curl https://api.usdf.fi/v1/statements/{YYYY-MM}.csv \
  -H "Authorization: Bearer $SESSION"

GET/v1/account/deposits/{tx_hash}/{log_index}/receipt.json

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.

NameTypeRequiredDescription
tx_hashstringYesPath. The deposit's transaction.
log_indexstringYesPath. Its log index in that transaction.

GET /v1/account/deposits/{tx_hash}/{log_index}/receipt.json

curl
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/v1/account/deposit/card

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
curl https://api.usdf.fi/v1/account/deposit/card \
  -H "Authorization: Bearer $SESSION"

GET/v1/account/deposit/card/history

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
curl https://api.usdf.fi/v1/account/deposit/card/history \
  -H "Authorization: Bearer $SESSION"
Foundry documentation

Confirm it's you

Confirm to continue the action you started.

Checking confirmation options…