Documentation
Tracing and exports
View .mdOpenAPI

Export your spans as OTLP JSON

GEThttps://weights.fyi/run/v1/tracesscope: read
text
GET https://weights.fyi/run/v1/traces[?from=<time>][&to=<time>][&after=<cursor>][&limit=<count>]
Authorization: Bearer <token>                    scope: read
Available since
2026-10-08, with the exports added that evening. Logged inputs and outputs never appear in this export.
Answer time
synchronous and streamed: the answer starts at once and is written as it is read, at most 512 spans per answer.

Downloads your account's ended spans and events that started in a window, oldest first, as one OpenTelemetry export request in OTLP's JSON encoding: the pull side of a trace destination, for an audit or for a tool you run now and then. It needs no switch and costs nothing. One answer carries at most 512 spans, the size of one delivery, so it can be posted as it is to any receiver of our deliveries, or fewer when you send limit; when more remain, X-Weights-Next-After is the after of the next call. What a span shows, and which names it has, is described in Tracing and exports; the export is always content-free, even for a destination that includes outputs.

A span still open is not in the answer, and the cursor moves past it, so ask for its window again once it has ended. The answer is streamed; a failure part way closes the connection without the final chunk, so a cut answer is an incomplete download, never a short one that looks whole.

Request

NameWhereRequiredMeaning
AuthorizationheaderyesBearer and your token. The token needs the read scope; reads do not count against the request rate.
fromquerynoThe window's start, included: a span is in it when it started at or after this time. ISO 8601 such as 2026-10-08T00:00:00Z; no zone means UTC, and a + offset is sent as %2B. Without from the answer starts at your oldest span.
toquerynoThe window's end, excluded. It must be later than from.
afterquerynoThe cursor from the previous answer's X-Weights-Next-After, a whole number. The default, 0, starts at the beginning of the window.
limitquerynoThe most spans this answer carries, a whole number from 1 to 512, which is also the default.

Return value

200 OK, application/json, a download named traces.json:

HeaderMeaning
X-Weights-Max-SpansThe most spans one answer can carry, today 512: the highest limit.
X-Weights-Next-AfterPresent only when more spans remain in the window: the after value for the next request.

The body is one OTLP ExportTraceServiceRequest:

FieldMeaning
resourceSpansA list with one entry, the service as the source of every span.
resource.attributesservice.name, which is weights.fyi. weights.model, the page classifier's model, is there only when the answer holds a job's spans: an answer of credit, fees or chat charges alone names no model, and a chat charge names its own in its model attribute.
scopeSpansA list with one entry, whose scope.name is weights.telemetry.
spansThe spans, oldest first. Each has the fields below.
traceId, spanIdThe span's trace and its own id, in hexadecimal, as in the job log.
parentSpanIdThe span it belongs under; absent for a root span such as job.
nameWhat the span records, such as job, job.queued or billing.charge.
kind3 (client) for a call to the model, 1 (internal) for everything else.
startTimeUnixNano, endTimeUnixNanoWhen it started and ended, in nanoseconds since 1970, as strings, as OTLP's JSON encoding writes them.
attributesThe span's details as OTLP key-value pairs, plus weights.span_kind, weights.account_id, weights.job_id and weights.attempt_id where they apply.
status.code1 when what the span records went well, 2 when it failed.

Errors

StatusCodeWhen it happensWhat to do
400invalid_parameterfrom or to is not an ISO 8601 time (expected shows one), or after is not a whole number; parameter names it.Fix the parameter; send a + as %2B.
400invalid_windowfrom is not earlier than to.Swap them, or widen the window.
400parameter_out_of_rangeafter is below 0, or limit is outside 1 to 512; parameter, low and high say which and its bounds.Send the value the header gave you, or a limit inside the bounds.
401unauthorized, invalid_token, token_revoked, token_expiredNo token, or one that does not work (any more).Use a valid token.
403scope_required, account_suspendedThe token lacks read, or the account is suspended.Use a token with read.

Examples

The start of an answer: a job queued while the model was not ready, its root span and first events (the rest of the day's spans left out):

sh
curl -s -D - "https://weights.fyi/run/v1/traces?from=2026-10-09T00:00:00Z&to=2026-10-10T00:00:00Z" \
  -H "Authorization: Bearer $WEIGHTS_API_KEY"
text
HTTP/1.1 200 OK
Content-Type: application/json
Transfer-Encoding: chunked
X-Weights-Max-Spans: 512
Content-Disposition: attachment; filename="traces.json"

{
  "resourceSpans": [{
    "resource": {"attributes": [
      {"key": "weights.model", "value": {"stringValue": "laya-page-role"}},
      {"key": "service.name", "value": {"stringValue": "weights.fyi"}}
    ]},
    "scopeSpans": [{
      "scope": {"name": "weights.telemetry"},
      "spans": [
        {
          "traceId": "54da3ec45d99eba84336021ad3e15853",
          "spanId": "136241e49ed6a735",
          "name": "job",
          "kind": 1,
          "startTimeUnixNano": "1791534489784000000",
          "endTimeUnixNano": "1791534489788000000",
          "attributes": [
            {"key": "attempts_not_metered_yet", "value": {"arrayValue": {"values": []}}},
            {"key": "caller_trace", "value": {"boolValue": false}},
            {"key": "cost_charged_usd_micros", "value": {"intValue": "0"}},
            {"key": "items_cancelled", "value": {"intValue": "1"}},
            {"key": "items_done", "value": {"intValue": "0"}},
            {"key": "items_failed", "value": {"intValue": "0"}},
            {"key": "items_total", "value": {"intValue": "1"}},
            {"key": "service_class", "value": {"stringValue": "flex"}},
            {"key": "status", "value": {"stringValue": "CANCELLED"}},
            {"key": "weights.account_id", "value": {"intValue": "1"}},
            {"key": "weights.job_id", "value": {"stringValue": "job_63a47e390e1b77237fbfeb4c"}},
            {"key": "weights.span_kind", "value": {"stringValue": "span"}}
          ],
          "status": {"code": 1}
        },
        {
          "traceId": "54da3ec45d99eba84336021ad3e15853",
          "spanId": "e651a3d57680e422",
          "name": "job.queued",
          "kind": 1,
          "startTimeUnixNano": "1791534489784000000",
          "endTimeUnixNano": "1791534489784000000",
          "attributes": [
            {"key": "items_total", "value": {"intValue": "1"}},
            {"key": "service_class", "value": {"stringValue": "flex"}},
            {"key": "weights.account_id", "value": {"intValue": "1"}},
            {"key": "weights.job_id", "value": {"stringValue": "job_63a47e390e1b77237fbfeb4c"}},
            {"key": "weights.span_kind", "value": {"stringValue": "event"}}
          ],
          "status": {"code": 1},
          "parentSpanId": "136241e49ed6a735"
        },
        {
          "traceId": "54da3ec45d99eba84336021ad3e15853",
          "spanId": "b6089caa5c6a09a4",
          "name": "job.cold_start",
          "kind": 1,
          "startTimeUnixNano": "1791534489784000000",
          "endTimeUnixNano": "1791534489784000000",
          "attributes": [
            {"key": "expected_ready_seconds", "value": {"intValue": "151"}},
            {"key": "model_state", "value": {"stringValue": "asleep"}},
            {"key": "weights.account_id", "value": {"intValue": "1"}},
            {"key": "weights.job_id", "value": {"stringValue": "job_63a47e390e1b77237fbfeb4c"}},
            {"key": "weights.span_kind", "value": {"stringValue": "event"}}
          ],
          "status": {"code": 1},
          "parentSpanId": "136241e49ed6a735"
        }
      ]
    }]
  }]
}

Patterns

Exporting a day of traces

Loop from the cursor until the header is gone, keeping each part; each is a complete OTLP request you can load or post as it is, with Content-Type: application/json, to a collector's /v1/traces. Export a day a few minutes after it ends, so its spans have ended:

sh
after=0
while :; do
  curl -s -D headers.txt -o "traces-$after.json" \
    "https://weights.fyi/run/v1/traces?from=2026-10-08T00:00:00Z&to=2026-10-09T00:00:00Z&after=$after" \
    -H "Authorization: Bearer $WEIGHTS_API_KEY"
  next=$(grep -i '^X-Weights-Next-After:' headers.txt | tr -dc '0-9')
  [ -z "$next" ] && break
  after=$next
done

History

  • 2026-10-08: live: OTLP JSON, a window by start time, 512 spans an answer and a cursor.
  • 2026-10-09: this export, the job log and your destinations show each span by one rule.
  • 2026-11-15 (built, live with the deploy that carries it): limit; weights.model only on an answer that holds a job's spans.

See also

GET /v1/jobs/{job_id}/logs, POST /v1/trace-sinks, Tracing and exports.