Agent tracing API
This page documents the 17 gateway endpoints tagged agent tracing in the gateway's OpenAPI document. Every example targets a gateway on http://localhost:4000 and authenticates with the SPANWAY_API_KEY environment variable, which holds the master key or a virtual key that has access to the route. Request and response fields are taken from the schema the running gateway publishes at /openapi.json, and the same document is bundled with this site as openapi.json.
| Method | Path | Summary |
|---|---|---|
| GET | /v1/traces/search | Search the text of agent traces |
| GET | /v1/traces/sessions | List conversation sessions |
| GET | /v1/traces/sessions/{session_id} | Read one session as a thread |
| GET | /v1/traces/{trace_id}/graph | Read the agent graph of one trace |
| GET | /v1/traces/{trace_id}/comments | List the comments on a trace |
| POST | /v1/traces/{trace_id}/comments | Comment on a trace |
| PATCH | /v1/traces/{trace_id}/comments/{comment_id} | Edit a comment on a trace |
| DELETE | /v1/traces/{trace_id}/comments/{comment_id} | Delete a comment on a trace |
| GET | /v1/traces | List agent traces |
| POST | /v1/traces | Send OTLP traces from your app |
| POST | /v1/logs | Send OTLP logs from your app |
| GET | /v1/traces/agents | List the agents seen in traces |
| POST | /v1/traces/query | Run a read only SQL query over traces |
| GET | /v1/traces/query/help | Describe the tables a trace query may use |
| GET | /v1/traces/{trace_id} | Read one trace as a page of spans |
| GET | /v1/traces/{trace_id}/spans/{span_id} | Read one span in full |
| GET | /v1/traces/{trace_id}/spans/{span_id}/error | Page through a span's error details |
Endpoints
GET /v1/traces/search
Search the text of agent traces
Find the agent runs whose steps contain every word of q, newest first, with the first matching step and a short snippet around the match. Words are matched anywhere and ignore case, and a "quoted phrase" is matched as written. The search looks inside step inputs, outputs and error messages only when your role may see them (searched_fields says which), and always in trace ids, step names, agent names and models. The window defaults to the last 7 days and may be at most 31 days. A search that looks inside content is written to the audit log as a read, with a hash of the search text, never the text. Docs (https://docs.spanway.ai/docs/proxy/lens/explore#search)
Parameters:
| Name | In | Type | Required | Description |
|---|---|---|---|---|
q | query | string | Yes | Words or quoted phrases to find |
start_ms | query | integer or null | No | Window start, unix ms. Default: 7 days ago |
end_ms | query | integer or null | No | Window end, unix ms. Default: now |
limit | query | integer | No | Most traces to return |
Example request:
curl -X GET "http://localhost:4000/v1/traces/search?q=string" \
-H "Authorization: Bearer $SPANWAY_API_KEY"
Responses:
| Status | Description | Body |
|---|---|---|
| 200 | The matching traces, newest first | application/json TraceSearchResult |
| 400 | The window or the search text is not valid | application/json ErrorDetail |
| 401 | No valid key or Admin UI session was presented | application/json ErrorDetail |
| 403 | The caller may not read agent traces | application/json ErrorDetail |
| 422 | Validation Error | application/json HTTPValidationError |
| 501 | Lens is not set up on this gateway | application/json ErrorDetail |
| 503 | Lens did not answer or the query ran past the reader limits, or the gateway has no master key | application/json ErrorDetail |
Response fields (200):
| Field | Type | Required | Description |
|---|---|---|---|
query | string | Yes | Query |
terms | array of string | Yes | Terms |
searched_fields | array of enum: "input", "output", "error", "name" | Yes | The fields your role lets the search look inside |
start_ms | integer | Yes | Start Ms |
end_ms | integer | Yes | End Ms |
hits | array of TraceSearchHit | Yes | Hits |
truncated | boolean | Yes | True when more traces matched than the limit returned |
GET /v1/traces/sessions
List conversation sessions
List the sessions seen in your traces, most recently active first. A session groups the runs that carry the same session.id attribute (on the span or its resource) or OpenTelemetry gen_ai.conversation.id, for example every turn of one chat. Each row counts its runs, error steps and tokens and names up to 10 agents. contains keeps sessions whose id contains that text. The window defaults to the last 7 days. Nothing changes. Docs (https://docs.spanway.ai/docs/proxy/lens/explore#sessions)
Parameters:
| Name | In | Type | Required | Description |
|---|---|---|---|---|
contains | query | string | No | Keep sessions whose id contains this |
start_ms | query | integer or null | No | Window start, unix ms. Default: 7 days ago |
end_ms | query | integer or null | No | Window end, unix ms. Default: now |
limit | query | integer | No | Most sessions to return |
Example request:
curl -X GET "http://localhost:4000/v1/traces/sessions" \
-H "Authorization: Bearer $SPANWAY_API_KEY"
Responses:
| Status | Description | Body |
|---|---|---|
| 200 | The sessions in the window | application/json TraceSessionList |
| 400 | The window or the search text is not valid | application/json ErrorDetail |
| 401 | No valid key or Admin UI session was presented | application/json ErrorDetail |
| 403 | The caller may not read agent traces | application/json ErrorDetail |
| 422 | Validation Error | application/json HTTPValidationError |
| 501 | Lens is not set up on this gateway | application/json ErrorDetail |
| 503 | Lens did not answer or the query ran past the reader limits, or the gateway has no master key | application/json ErrorDetail |
Response fields (200):
| Field | Type | Required | Description |
|---|---|---|---|
start_ms | integer | Yes | Start Ms |
end_ms | integer | Yes | End Ms |
sessions | array of TraceSession | Yes | Sessions |
truncated | boolean | Yes | Truncated |
GET /v1/traces/sessions/{session_id}
Read one session as a thread
Read every run of one session in the order they started, as a conversation: each turn has the run's first input, its final output (each cut to 4,000 characters), the agents that took part, its steps, errors and tokens, and the trace id to open it. Pass the session_ref from the session list to keep sessions of other keys that reuse the same id apart. Inputs and outputs your role hides come back as null and are listed in hidden_fields. The window defaults to the trace retention (14 days). Reading a thread is written to the audit log as a content read. Docs (https://docs.spanway.ai/docs/proxy/lens/explore#sessions)
Parameters:
| Name | In | Type | Required | Description |
|---|---|---|---|---|
session_id | path | string | Yes | |
session_ref | query | string | No | |
start_ms | query | integer or null | No | Window start, unix ms. Default: 14 days ago |
end_ms | query | integer or null | No | Window end, unix ms. Default: now |
limit | query | integer | No | Most turns to return |
Example request:
curl -X GET "http://localhost:4000/v1/traces/sessions/session_id-123" \
-H "Authorization: Bearer $SPANWAY_API_KEY"
Responses:
| Status | Description | Body |
|---|---|---|
| 200 | The session's runs as turns, oldest first | application/json SessionThread |
| 400 | The window or the search text is not valid | application/json ErrorDetail |
| 401 | No valid key or Admin UI session was presented | application/json ErrorDetail |
| 403 | The caller may not read agent traces | application/json ErrorDetail |
| 404 | No session with that id is visible to the caller | application/json ErrorDetail |
| 422 | Validation Error | application/json HTTPValidationError |
| 501 | Lens is not set up on this gateway | application/json ErrorDetail |
| 503 | Lens did not answer or the query ran past the reader limits, or the gateway has no master key | application/json ErrorDetail |
Response fields (200):
| Field | Type | Required | Description |
|---|---|---|---|
session_id | string | Yes | Session Id |
session_ref | string | Yes | Session Ref |
start_ms | integer | Yes | Start Ms |
end_ms | integer | Yes | End Ms |
turns | array of SessionTurn | Yes | Turns |
hidden_fields | array of string | Yes | Content your role hides, such as prompts or responses |
truncated | boolean | Yes | Truncated |
GET /v1/traces/{trace_id}/graph
Read the agent graph of one trace
Draw one run as a graph: a node for the run, for every agent, every tool and every model, and an edge for each hand-off from one agent to another and for each tool or model an agent called, with call, error, time and token totals. It reads at most the first 5,000 steps (truncated says when a trace had more). The caller must be able to see the trace, otherwise it answers 404. No prompt or response text is returned, and nothing changes. Docs (https://docs.spanway.ai/docs/proxy/lens/explore#agent-graph)
Parameters:
| Name | In | Type | Required | Description |
|---|---|---|---|---|
trace_id | path | string | Yes | |
trace_ref | query | string | No |
Example request:
curl -X GET "http://localhost:4000/v1/traces/trace_id-123/graph" \
-H "Authorization: Bearer $SPANWAY_API_KEY"
Responses:
| Status | Description | Body |
|---|---|---|
| 200 | The trace's agents, tools and models and how they called each other | application/json AgentGraph |
| 401 | No valid key or Admin UI session was presented | application/json ErrorDetail |
| 403 | The caller may not read agent traces | application/json ErrorDetail |
| 404 | No trace with that id is visible to the caller | application/json ErrorDetail |
| 409 | The trace changed while it was read, so try again | application/json ErrorDetail |
| 422 | Validation Error | application/json HTTPValidationError |
| 501 | Lens is not set up on this gateway | application/json ErrorDetail |
| 503 | Lens did not answer, retry after Retry-After seconds | application/json ErrorDetail |
Response fields (200):
| Field | Type | Required | Description |
|---|---|---|---|
trace_id | string | Yes | Trace Id |
trace_ref | string | Yes | Trace Ref |
span_count | integer | Yes | Span Count |
nodes | array of GraphNode | Yes | Nodes |
edges | array of GraphEdge | Yes | Edges |
truncated | boolean | Yes | True when the trace had more steps than the graph reads |
GET /v1/traces/{trace_id}/comments
List the comments on a trace
List the comments people left on one trace, oldest first, with who wrote each and whether you may edit it. Anyone who may read the trace may read its comments. Pass the trace_ref from the trace list so comments of another key that reuses the trace id stay apart. Nothing changes. Docs (https://docs.spanway.ai/docs/proxy/lens/explore#comments)
Parameters:
| Name | In | Type | Required | Description |
|---|---|---|---|---|
trace_id | path | string | Yes | |
trace_ref | query | string | No |
Example request:
curl -X GET "http://localhost:4000/v1/traces/trace_id-123/comments" \
-H "Authorization: Bearer $SPANWAY_API_KEY"
Responses:
| Status | Description | Body |
|---|---|---|
| 200 | The trace's comments | application/json TraceCommentList |
| 401 | No valid key or Admin UI session was presented | application/json ErrorDetail |
| 403 | The caller may not read agent traces | application/json ErrorDetail |
| 404 | No trace with that id is visible to the caller | application/json ErrorDetail |
| 422 | Validation Error | application/json HTTPValidationError |
| 500 | The gateway runs without a database | application/json ErrorDetail |
| 501 | Lens is not set up on this gateway | application/json ErrorDetail |
| 503 | Lens did not answer, retry after Retry-After seconds | application/json ErrorDetail |
Response fields (200):
| Field | Type | Required | Description |
|---|---|---|---|
trace_id | string | Yes | Trace Id |
trace_ref | string | Yes | Trace Ref |
comments | array of TraceComment | Yes | Comments |
POST /v1/traces/{trace_id}/comments
Comment on a trace
Leave a note on a trace, or on one step of it with span_id, for example why a run went wrong or who is looking into it. Anyone who may read the trace may comment, except the read only roles. The text may be up to 4,000 characters and a trace holds at most 500 comments. The new comment is written to the audit log with a hash and the length of its text. Docs (https://docs.spanway.ai/docs/proxy/lens/explore#comments)
Parameters:
| Name | In | Type | Required | Description |
|---|---|---|---|---|
trace_id | path | string | Yes |
Request body (application/json, schema NewTraceComment):
| Field | Type | Required | Description |
|---|---|---|---|
body | string | Yes | Body |
span_id | string or null | No | Span Id |
trace_ref | string | No | The trace_ref from the trace list, if known |
Example request:
curl -X POST "http://localhost:4000/v1/traces/trace_id-123/comments" \
-H "Authorization: Bearer $SPANWAY_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"body": "The refund tool timed out here, the retry picked the wrong order. Filed SUP-812.",
"span_id": "00f067aa0ba902b7",
"trace_ref": "9D3C1E0B7A4F2E6D8C5B1A0F3E2D4C6B8A9F7E5D3C1B0A2F4E6D8C0B2A4F6E8D"
}'
Responses:
| Status | Description | Body |
|---|---|---|
| 201 | The new comment | application/json TraceComment |
| 401 | No valid key or Admin UI session was presented | application/json ErrorDetail |
| 403 | The caller may not read the trace or has a read only role | application/json ErrorDetail |
| 404 | No trace with that id is visible to the caller | application/json ErrorDetail |
| 409 | The trace already holds the most comments allowed | application/json ErrorDetail |
| 422 | Validation Error | application/json HTTPValidationError |
| 500 | The gateway runs without a database | application/json ErrorDetail |
| 501 | Lens is not set up on this gateway | application/json ErrorDetail |
| 503 | Lens did not answer, retry after Retry-After seconds | application/json ErrorDetail |
PATCH /v1/traces/{trace_id}/comments/{comment_id}
Edit a comment on a trace
Replace the text of a comment. Only its author or a proxy admin may edit it, and read only roles never can. The change is written to the audit log with a hash and the length of the text before and after. Docs (https://docs.spanway.ai/docs/proxy/lens/explore#comments)
Parameters:
| Name | In | Type | Required | Description |
|---|---|---|---|---|
trace_id | path | string | Yes | |
comment_id | path | string | Yes | |
trace_ref | query | string | No |
Request body (application/json, schema EditTraceComment):
| Field | Type | Required | Description |
|---|---|---|---|
body | string | Yes | Body |
Example request:
curl -X PATCH "http://localhost:4000/v1/traces/trace_id-123/comments/comment_id-123" \
-H "Authorization: Bearer $SPANWAY_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"body": "Root cause found: the order lookup used the wrong customer id."
}'
Responses:
| Status | Description | Body |
|---|---|---|
| 200 | The edited comment | application/json TraceComment |
| 401 | No valid key or Admin UI session was presented | application/json ErrorDetail |
| 403 | The caller may not read the trace, has a read only role, or did not write the comment | application/json ErrorDetail |
| 404 | No trace or no comment with that id is visible to the caller | application/json ErrorDetail |
| 422 | Validation Error | application/json HTTPValidationError |
| 500 | The gateway runs without a database | application/json ErrorDetail |
| 501 | Lens is not set up on this gateway | application/json ErrorDetail |
| 503 | Lens did not answer, retry after Retry-After seconds | application/json ErrorDetail |
Response fields (200):
| Field | Type | Required | Description |
|---|---|---|---|
comment_id | string | Yes | Comment Id |
trace_id | string | Yes | Trace Id |
trace_ref | string | Yes | Trace Ref |
span_id | string or null | Yes | Span Id |
body | string | Yes | Body |
author_user_id | string or null | Yes | Author User Id |
author_key_alias | string or null | Yes | Author Key Alias |
created_at | string | Yes | Created At |
updated_at | string | Yes | Updated At |
can_edit | boolean | No | Whether the caller may edit or delete this comment |
DELETE /v1/traces/{trace_id}/comments/{comment_id}
Delete a comment on a trace
Remove a comment for good and return it one last time. Its author or a proxy admin may delete it, read only roles never can. The removal is written to the audit log with a hash and the length of the text. Docs (https://docs.spanway.ai/docs/proxy/lens/explore#comments)
Parameters:
| Name | In | Type | Required | Description |
|---|---|---|---|---|
trace_id | path | string | Yes | |
comment_id | path | string | Yes | |
trace_ref | query | string | No |
Example request:
curl -X DELETE "http://localhost:4000/v1/traces/trace_id-123/comments/comment_id-123" \
-H "Authorization: Bearer $SPANWAY_API_KEY"
Responses:
| Status | Description | Body |
|---|---|---|
| 200 | The comment that was deleted | application/json TraceComment |
| 401 | No valid key or Admin UI session was presented | application/json ErrorDetail |
| 403 | The caller may not read the trace, has a read only role, or did not write the comment | application/json ErrorDetail |
| 404 | No trace or no comment with that id is visible to the caller | application/json ErrorDetail |
| 422 | Validation Error | application/json HTTPValidationError |
| 500 | The gateway runs without a database | application/json ErrorDetail |
| 501 | Lens is not set up on this gateway | application/json ErrorDetail |
| 503 | Lens did not answer, retry after Retry-After seconds | application/json ErrorDetail |
Response fields (200):
| Field | Type | Required | Description |
|---|---|---|---|
comment_id | string | Yes | Comment Id |
trace_id | string | Yes | Trace Id |
trace_ref | string | Yes | Trace Ref |
span_id | string or null | Yes | Span Id |
body | string | Yes | Body |
author_user_id | string or null | Yes | Author User Id |
author_key_alias | string or null | Yes | Author Key Alias |
created_at | string | Yes | Created At |
updated_at | string | Yes | Updated At |
can_edit | boolean | No | Whether the caller may edit or delete this comment |
GET /v1/traces
List agent traces
List the agent runs the gateway recorded, one summary per trace with its agents, models, tokens, spend and status, newest first. A key with a user sees the traces of its own requests and of the teams where it is a team admin or holds the spend logs permission, proxy admins and admin viewers see every trace, and a key with no user answers 403. The window defaults to the last 24 hours, start_ms and end_ms are unix milliseconds and cursor continues a page. Nothing changes. Docs (https://docs.spanway.ai/docs/proxy/agent_tracing)
Parameters:
| Name | In | Type | Required | Description |
|---|---|---|---|---|
cursor | query | string or null | No | |
end_ms | query | integer or null | No | Window end, unix ms. Default: now |
start_ms | query | integer or null | No | Window start, unix ms. Default: 24h ago |
Example request:
curl -X GET "http://localhost:4000/v1/traces" \
-H "Authorization: Bearer $SPANWAY_API_KEY"
Responses:
| Status | Description | Body |
|---|---|---|
| 200 | One page of trace summaries | application/json TracePage |
| 400 | A parameter or the cursor is not valid | application/json ErrorDetail |
| 401 | No valid key or Admin UI session was presented | application/json ErrorDetail |
| 403 | The caller may not read agent traces | application/json ErrorDetail |
| 404 | No trace or span with that id is visible to the caller | application/json ErrorDetail |
| 409 | The trace changed while it was paged, so start again without a cursor | application/json ErrorDetail |
| 413 | The trace is too large for this view | application/json ErrorDetail |
| 422 | Validation Error | application/json HTTPValidationError |
| 501 | Lens is not set up on this gateway | application/json ErrorDetail |
| 503 | Lens did not answer, retry after Retry-After seconds | application/json ErrorDetail |
Response fields (200):
| Field | Type | Required | Description |
|---|---|---|---|
data | array of TraceSummary | Yes | Data |
next_cursor | string or null | Yes | Next Cursor |
POST /v1/traces
Send OTLP traces from your app
Accept an OTLP/HTTP trace export from your own application, authenticated with a virtual key, and store the spans in Lens next to the gateway's request records, so one trace shows your app's steps and the model calls they made through the gateway. Send application/x-protobuf or application/json, optionally gzip compressed. The spans are stored under the key's team and user, never under ids the spans claim. Uploads above OTLP_MAX_BODY_BYTES (16 MiB by default, before and after decompression) are refused with 413. Docs (https://docs.spanway.ai/docs/proxy/otlp_intake)
Request body (application/x-protobuf, string):
Request body (application/json, object):
Example request:
curl -X POST "http://localhost:4000/v1/traces" \
-H "Authorization: Bearer $SPANWAY_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"resourceSpans": [
{
"resource": {
"attributes": [
{
"key": "service.name",
"value": {
"stringValue": "research-service"
}
}
]
},
"scopeSpans": [
{
"spans": [
{
"traceId": "4bf92f3577b34da6a3ce929d0e0e4736",
"spanId": "00f067aa0ba902b7",
"name": "plan step",
"startTimeUnixNano": "1795000000000000000",
"endTimeUnixNano": "1795000001200000000"
}
]
}
]
}
]
}'
Responses:
| Status | Description | Body |
|---|---|---|
| 200 | Lens stored the batch. The body is an empty OTLP export response | application/json object |
| 400 | The body or its encoding is not valid OTLP | application/json object |
| 401 | No valid virtual key was sent | application/json object |
| 413 | The upload is larger than the gateway accepts | application/json object |
| 501 | Lens is not set up on this gateway, so there is nowhere to store spans | application/json object |
| 503 | The gateway or Lens is busy or unreachable, retry after Retry-After seconds | application/json object |
POST /v1/logs
Send OTLP logs from your app
Accept an OTLP/HTTP log export, such as the event logs coding agents emit, authenticated with a virtual key, and store the records in Lens next to the gateway's request records. Encoding, size limit and tenant rules are the same as POST /v1/traces. Docs (https://docs.spanway.ai/docs/proxy/otlp_intake)
Request body (application/x-protobuf, string):
Request body (application/json, object):
Example request:
curl -X POST "http://localhost:4000/v1/logs" \
-H "Authorization: Bearer $SPANWAY_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"resourceSpans": [
{
"resource": {
"attributes": [
{
"key": "service.name",
"value": {
"stringValue": "research-service"
}
}
]
},
"scopeSpans": [
{
"spans": [
{
"traceId": "4bf92f3577b34da6a3ce929d0e0e4736",
"spanId": "00f067aa0ba902b7",
"name": "plan step",
"startTimeUnixNano": "1795000000000000000",
"endTimeUnixNano": "1795000001200000000"
}
]
}
]
}
]
}'
Responses:
| Status | Description | Body |
|---|---|---|
| 200 | Lens stored the batch. The body is an empty OTLP export response | application/json object |
| 400 | The body or its encoding is not valid OTLP | application/json object |
| 401 | No valid virtual key was sent | application/json object |
| 413 | The upload is larger than the gateway accepts | application/json object |
| 501 | Lens is not set up on this gateway, so there is nowhere to store spans | application/json object |
| 503 | The gateway or Lens is busy or unreachable, retry after Retry-After seconds | application/json object |
GET /v1/traces/agents
List the agents seen in traces
List the agent names that appear in the caller's traces in the window, with how often each ran and failed, for filters and pickers. The same scoping as the trace list applies, and nothing changes. Docs (https://docs.spanway.ai/docs/proxy/agent_tracing)
Parameters:
| Name | In | Type | Required | Description |
|---|---|---|---|---|
start_ms | query | integer or null | No | |
end_ms | query | integer or null | No |
Example request:
curl -X GET "http://localhost:4000/v1/traces/agents" \
-H "Authorization: Bearer $SPANWAY_API_KEY"
Responses:
| Status | Description | Body |
|---|---|---|
| 200 | The agents seen in the window | application/json TraceAgentList |
| 400 | A parameter or the cursor is not valid | application/json ErrorDetail |
| 401 | No valid key or Admin UI session was presented | application/json ErrorDetail |
| 403 | The caller may not read agent traces | application/json ErrorDetail |
| 404 | No trace or span with that id is visible to the caller | application/json ErrorDetail |
| 409 | The trace changed while it was paged, so start again without a cursor | application/json ErrorDetail |
| 413 | The trace is too large for this view | application/json ErrorDetail |
| 422 | Validation Error | application/json HTTPValidationError |
| 501 | Lens is not set up on this gateway | application/json ErrorDetail |
| 503 | Lens did not answer, retry after Retry-After seconds | application/json ErrorDetail |
Response fields (200):
| Field | Type | Required | Description |
|---|---|---|---|
agents | array of TraceAgent | Yes | Agents |
POST /v1/traces/query
Run a read only SQL query over traces
Run a read only SQL query over the caller's traces and spend logs for ad hoc analysis, for example the slowest agents of the week. Any key that may read traces may call it, and rows are limited to what the caller may read. GET /v1/traces/query/help lists the tables and columns the query may use. A custom role that hides prompts, responses or tool arguments may not run it, because SQL could read them. A query that writes, reads outside the caller's scope or exceeds the reader limits is refused, and nothing changes. Docs (https://docs.spanway.ai/docs/proxy/agent_tracing#reading-traces)
Request body (application/json, schema TraceQueryRequest):
| Field | Type | Required | Description |
|---|---|---|---|
sql | string | Yes | Sql |
Example request:
curl -X POST "http://localhost:4000/v1/traces/query" \
-H "Authorization: Bearer $SPANWAY_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"sql": "SELECT agent, count() AS traces FROM traces WHERE start_ms > now() - 86400000 GROUP BY agent"
}'
Responses:
| Status | Description | Body |
|---|---|---|
| 200 | The rows the query returned | application/json TraceSQLResponse |
| 400 | The SQL is not a single read only query the reader accepts | application/json ErrorDetail |
| 401 | No valid key or Admin UI session was presented | application/json ErrorDetail |
| 403 | The caller may not read agent traces, or a custom role hides prompts, responses or tool arguments | application/json ErrorDetail |
| 404 | No trace or span with that id is visible to the caller | application/json ErrorDetail |
| 409 | The trace changed while it was paged, so start again without a cursor | application/json ErrorDetail |
| 413 | The trace is too large for this view | application/json ErrorDetail |
| 422 | Validation Error | application/json HTTPValidationError |
| 501 | Lens is not set up on this gateway | application/json ErrorDetail |
| 503 | The query failed or ran past the reader limits, or the gateway has no master key to sign it with | application/json ErrorDetail |
Response fields (200):
| Field | Type | Required | Description |
|---|---|---|---|
data | array of object | Yes | Data |
GET /v1/traces/query/help
Describe the tables a trace query may use
Describe what POST /v1/traces/query may read: the tables and columns, how they join, the attribute and metadata keys seen in the caller's data, example queries and the limits. Any key that may read traces may call it, and nothing changes. Docs (https://docs.spanway.ai/docs/proxy/agent_tracing#reading-traces)
Example request:
curl -X GET "http://localhost:4000/v1/traces/query/help" \
-H "Authorization: Bearer $SPANWAY_API_KEY"
Responses:
| Status | Description | Body |
|---|---|---|
| 200 | The query reference for the caller | application/json TraceQueryHelp |
| 401 | No valid key or Admin UI session was presented | application/json ErrorDetail |
| 403 | The caller may not read agent traces | application/json ErrorDetail |
| 501 | Lens is not set up on this gateway | application/json ErrorDetail |
| 503 | Lens did not answer, or the gateway has no master key to sign the query with | application/json ErrorDetail |
Response fields (200):
| Field | Type | Required | Description |
|---|---|---|---|
access | string | Yes | Access |
attributes | array of TraceQueryAttributes | Yes | Attributes |
dialect | string | Yes | Dialect |
examples | array of TraceQueryExample | Yes | Examples |
gotchas | array of string | Yes | Gotchas |
guide | string | Yes | Guide |
metadata | TraceQueryMetadata | Yes | |
normalized_fields | array of TraceQueryNormalizedField | Yes | Normalized Fields |
relationships | array of TraceQueryRelationship | Yes | Relationships |
response | string | Yes | Response |
tables | array of TraceQueryTable | Yes | Tables |
GET /v1/traces/{trace_id}
Read one trace as a page of spans
Read one agent run as its summary, the agents that took part and a page of its spans, the steps such as model calls and tool calls in the order they ran. The caller must be able to see the trace, otherwise it answers 404. cursor continues a long trace, and a trace that changed while it was paged answers 409 so the client starts again. Input previews and error text read [hidden by your role] when a custom role hides prompts or tool arguments. Nothing changes. Docs (https://docs.spanway.ai/docs/proxy/agent_tracing)
Parameters:
| Name | In | Type | Required | Description |
|---|---|---|---|---|
trace_id | path | string | Yes | |
cursor | query | string or null | No | |
page_size | query | integer or null | No | |
trace_ref | query | string | No |
Example request:
curl -X GET "http://localhost:4000/v1/traces/trace_id-123" \
-H "Authorization: Bearer $SPANWAY_API_KEY"
Responses:
| Status | Description | Body |
|---|---|---|
| 200 | The trace summary, its agents and one page of spans | application/json Trace |
| 400 | A parameter or the cursor is not valid | application/json ErrorDetail |
| 401 | No valid key or Admin UI session was presented | application/json ErrorDetail |
| 403 | The caller may not read agent traces | application/json ErrorDetail |
| 404 | No trace or span with that id is visible to the caller | application/json ErrorDetail |
| 409 | The trace changed while it was paged, so start again without a cursor | application/json ErrorDetail |
| 413 | The trace is too large for this view | application/json ErrorDetail |
| 422 | Validation Error | application/json HTTPValidationError |
| 501 | Lens is not set up on this gateway | application/json ErrorDetail |
| 503 | Lens did not answer, retry after Retry-After seconds | application/json ErrorDetail |
Response fields (200):
| Field | Type | Required | Description |
|---|---|---|---|
agents | array of AgentNode | Yes | Agents |
next_cursor | string or null | No | Next Cursor |
spans | array of Span | Yes | Spans |
summary | TraceSummary | Yes |
GET /v1/traces/{trace_id}/spans/{span_id}
Read one span in full
Read one step of a trace in full: its attributes and, when the content policy keeps them, its input and output. The caller must be able to see the trace, otherwise it answers 404. When a custom role hides prompts, responses or tool arguments, the hidden parts and the attributes that can quote them read [hidden by your role]. Nothing changes. Docs (https://docs.spanway.ai/docs/proxy/agent_tracing#what-spans-keep)
Parameters:
| Name | In | Type | Required | Description |
|---|---|---|---|---|
trace_id | path | string | Yes | |
span_id | path | string | Yes | |
trace_ref | query | string | No |
Example request:
curl -X GET "http://localhost:4000/v1/traces/trace_id-123/spans/span_id-123" \
-H "Authorization: Bearer $SPANWAY_API_KEY"
Responses:
| Status | Description | Body |
|---|---|---|
| 200 | The span with its attributes, input and output | application/json SpanDetail |
| 400 | A parameter or the cursor is not valid | application/json ErrorDetail |
| 401 | No valid key or Admin UI session was presented | application/json ErrorDetail |
| 403 | The caller may not read agent traces | application/json ErrorDetail |
| 404 | No trace or span with that id is visible to the caller | application/json ErrorDetail |
| 409 | The trace changed while it was paged, so start again without a cursor | application/json ErrorDetail |
| 413 | The trace is too large for this view | application/json ErrorDetail |
| 422 | Validation Error | application/json HTTPValidationError |
| 501 | Lens is not set up on this gateway | application/json ErrorDetail |
| 503 | Lens did not answer, retry after Retry-After seconds | application/json ErrorDetail |
Response fields (200):
| Field | Type | Required | Description |
|---|---|---|---|
attributes | object | Yes | Attributes |
input | string | Yes | Input |
input_ui | UIMessages or UIFields or UIText | Yes | Input Ui |
output | string | Yes | Output |
output_ui | UIMessages or UIFields or UIText | Yes | Output Ui |
span_id | string | Yes | Span Id |
GET /v1/traces/{trace_id}/spans/{span_id}/error
Page through a span's error details
Read the error message recorded on a failed step, paged with cursor when it is long. The caller must be able to see the trace, otherwise it answers 404. Nothing changes. Docs (https://docs.spanway.ai/docs/proxy/agent_tracing)
Parameters:
| Name | In | Type | Required | Description |
|---|---|---|---|---|
trace_id | path | string | Yes | |
span_id | path | string | Yes | |
cursor | query | string or null | No | |
trace_ref | query | string | No |
Example request:
curl -X GET "http://localhost:4000/v1/traces/trace_id-123/spans/span_id-123/error" \
-H "Authorization: Bearer $SPANWAY_API_KEY"
Responses:
| Status | Description | Body |
|---|---|---|
| 200 | One page of the span's error message | application/json SpanErrorPage |
| 400 | A parameter or the cursor is not valid | application/json ErrorDetail |
| 401 | No valid key or Admin UI session was presented | application/json ErrorDetail |
| 403 | The caller may not read agent traces | application/json ErrorDetail |
| 404 | No trace or span with that id is visible to the caller | application/json ErrorDetail |
| 409 | The trace changed while it was paged, so start again without a cursor | application/json ErrorDetail |
| 413 | The trace is too large for this view | application/json ErrorDetail |
| 422 | Validation Error | application/json HTTPValidationError |
| 501 | Lens is not set up on this gateway | application/json ErrorDetail |
| 503 | Lens did not answer, retry after Retry-After seconds | application/json ErrorDetail |
Response fields (200):
| Field | Type | Required | Description |
|---|---|---|---|
message | string | Yes | Message |
next_cursor | string or null | Yes | Next Cursor |
span_id | string | Yes | Span Id |
total_chars | integer | Yes | Total Chars |