All SDKs POST to the same set of endpoints underDocumentation Index
Fetch the complete documentation index at: https://docs.bitfab.ai/llms.txt
Use this file to discover all available pages before exploring further.
{serviceUrl}/api/sdk/. This page documents the wire protocol so you can integrate directly without using an SDK, or debug SDK behavior.
Base URL defaults to https://bitfab.ai.
Authentication
All endpoints require the API key in theAuthorization header:
401 Unauthorized.
Common Request Fields
The SDKs append these fields to most request bodies:| Field | Type | Description |
|---|---|---|
sdkVersion | string | The SDK package version |
source | string | Origin tag — "typescript-sdk", "python-sdk", etc. |
Endpoints
POST /api/sdk/functions/lookup
Look up a function by name. Blocking.
Request:
{ "id": null } — SDKs raise a typed error pointing users to /functions.
POST /api/sdk/functions/{functionId}/traces
Record a trace produced by a server-side function execution (e.g. client.call(...)). Fire-and-forget.
Request:
200 OK.
POST /api/sdk/externalSpans
Record a single span produced by withSpan / @span / Span / bitfab_span. Fire-and-forget.
Request:
200 OK.
POST /api/sdk/externalTraces
Record the completion of a root span’s trace. Sent once per trace when the outermost span ends. Fire-and-forget.
Request:
POST /api/sdk/replay/start
Begin a replay session. Blocking. Timeout: 30 s on the client side.
Request:
items[] entry carries metrics from the historical trace being replayed: durationMs is the end-to-end wall time (integer milliseconds), tokens is an object with input/output/cached/total counts, and model is the model id. Any field may be null when the underlying trace didn’t capture it.
POST /api/sdk/replay/complete
Signal that a replay session finished.
Request:
GET /api/sdk/externalSpans/{spanId}
Fetch a specific external span by ID. Used by replay internals. Returns the rawSpan object.
Serialization
- Inputs and outputs in
span_data.input/span_data.outputare serialized using superjson by the TypeScript SDK. Theinput_meta/output_metafields are the superjson meta descriptors. - Python, Ruby, and Go SDKs use JSON-compatible fallbacks. Objects that don’t round-trip through JSON are coerced to string via the SDK’s
serializehelper.
Error Responses
| Status | Meaning |
|---|---|
200 | Success |
400 | Malformed request body |
401 | Missing/invalid API key |
403 | API key valid but lacks access to the referenced resource |
404 | Function / span / trace ID not found |
429 | Rate limit exceeded |
5xx | Server error |
lookup, replay/start) raise typed errors.