Skip to main content

GET /v1/traces

List and search traces.

Request

curl "https://api.anyway.sh/v1/traces?limit=50" \
  -H "Authorization: Bearer YOUR_API_KEY"

Query Parameters

limit
integer
default:"50"
Number of traces to return (max 100).
cursor
string
Pagination cursor for the next page.
start_time
string
Filter traces starting after this ISO 8601 timestamp.
end_time
string
Filter traces ending before this ISO 8601 timestamp.
model
string
Filter by LLM model name.
min_latency_ms
integer
Filter traces with latency above this threshold.
min_cost
number
Filter traces with cost above this threshold.
status
string
Filter by status: ok, error.

Example

curl "https://api.anyway.sh/v1/traces?model=gpt-4&min_latency_ms=1000&limit=20" \
  -H "Authorization: Bearer YOUR_API_KEY"

Response

{
  "data": [
    {
      "trace_id": "4bf92f3577b34da6a3ce929d0e0e4736",
      "start_time": "2024-01-15T10:30:00.000Z",
      "end_time": "2024-01-15T10:30:01.234Z",
      "duration_ms": 1234,
      "span_count": 3,
      "root_span": {
        "name": "user-query",
        "attributes": {
          "user_id": "user-123"
        }
      },
      "llm_summary": {
        "model": "gpt-4",
        "tokens_input": 150,
        "tokens_output": 200,
        "cost": 0.0135
      },
      "status": "ok"
    }
  ],
  "pagination": {
    "limit": 50,
    "has_more": true,
    "next_cursor": "abc123"
  }
}

GET /v1/traces/:trace_id

Get a single trace with all spans.

Request

curl https://api.anyway.sh/v1/traces/4bf92f3577b34da6a3ce929d0e0e4736 \
  -H "Authorization: Bearer YOUR_API_KEY"

Path Parameters

trace_id
string
required
The trace ID to retrieve.

Response

{
  "data": {
    "trace_id": "4bf92f3577b34da6a3ce929d0e0e4736",
    "start_time": "2024-01-15T10:30:00.000Z",
    "end_time": "2024-01-15T10:30:01.234Z",
    "duration_ms": 1234,
    "spans": [
      {
        "span_id": "00f067aa0ba902b7",
        "parent_span_id": null,
        "name": "user-query",
        "start_time": "2024-01-15T10:30:00.000Z",
        "end_time": "2024-01-15T10:30:01.234Z",
        "duration_ms": 1234,
        "attributes": {
          "user_id": "user-123"
        },
        "status": {
          "code": "OK"
        }
      },
      {
        "span_id": "00f067aa0ba902b8",
        "parent_span_id": "00f067aa0ba902b7",
        "name": "openai.chat.completions",
        "start_time": "2024-01-15T10:30:00.010Z",
        "end_time": "2024-01-15T10:30:01.220Z",
        "duration_ms": 1210,
        "attributes": {
          "llm.vendor": "openai",
          "llm.model": "gpt-4",
          "llm.tokens.input": 150,
          "llm.tokens.output": 200,
          "llm.cost": 0.0135
        },
        "status": {
          "code": "OK"
        }
      }
    ]
  }
}

Errors

CodeDescription
not_foundTrace does not exist