API reference overview

Base URL, authentication, the error envelope, streaming and rate limits shared by every route.

Base URL

https://swarm.thundera.eu. All routes below are under /api/v1 unless shown. Bodies and responses are JSON.

Authentication

Routes marked Session or API key accept the swarm_session cookie or an API key (Authorization: Bearer, or x-api-key). Admin role routes additionally need the Thundera admin role. See Authentication and keys.

Errors

Errors use one envelope:

{"error":{"code":"INSUFFICIENT_CREDITS","message":"Your credit balance is too low to complete this request.","details":{}}}
CodeHTTPMeaning
UNAUTHENTICATED401No or invalid session/key.
SESSION_REVOKED401The Thundera session was revoked; sign in again.
FORBIDDEN403Missing role.
NOT_FOUND404Unknown resource.
VALIDATION_ERROR400details.fields lists each field and message.
INSUFFICIENT_CREDITS402Balance cannot cover the reservation.
MODEL_DISABLED422The model is not enabled.
RATE_LIMITED429Retry after Retry-After seconds.
UPSTREAM_ERROR502The provider failed; the reservation is refunded.
INTERNAL_ERROR500Unexpected failure.

Streaming

With stream: true the response is text/event-stream. The last event before [DONE] carries the swarm block with the real debit. If you disconnect, the call is aborted and refunded.

The swarm block

FieldMeaning
credits_debitedCredits charged for this call.
credit_balance_afterYour balance after settlement.
usage_event_idId of the ledger row; matches /usage.
token_sourceWhether token counts came from the provider or an estimate.
cached_tokensInput tokens served from the provider cache.
dropped_paramsPresent only if a parameter was removed for this model.
Source of truth: the Swarm repository