Query AI Observability
Search AI spans, chart token usage and costs, and retrieve or manage model pricing.
AI observability queries operate on AI spans. The API automatically restricts searches to protocol_type:gen_ai, and free-text queries search AI input/output messages where collected.
Endpoints
Search AI spans
POST /api/gen-ai/search
Query a time series
POST /api/gen-ai/search-time-series
List effective model pricing
GET /api/gen-ai/pricing
Read custom pricing status — Admin required
GET /api/gen-ai/pricing/custom
Replace custom price file — Admin required
PUT /api/gen-ai/pricing/custom
Remove custom pricing — Admin required
DELETE /api/gen-ai/pricing/custom
Download custom price file — Admin required
GET /api/gen-ai/pricing/custom/file
Authentication
Send an API key in Authorization: Bearer <YOUR_API_KEY> and select the backend with X-Backend-Id: <YOUR_BACKEND_ID>. Self-hosted deployments use their own API base URL. Custom-pricing operations require Admin permissions; uploads and deletion also require an authenticated user identity.
Search Request
start, end
string
Time range in RFC3339 format.
query
string
gcQL query.
sources
array
Optional structured scope conditions.
filters
string
Optional additional filters.
enableStream
boolean
Optional; true returns Server-Sent Events. Defaults to false.
bucketDuration
string
Required for time series, for example 5m.
valueField
string
Numeric result alias to chart.
fillValue
number
Optional replacement for empty time buckets; defaults to null.
Example: Token Usage
The response contains data rows and valueFieldHints for numeric columns. For example:
The values above are illustrative. When enableStream is true, consume SSE events named gen_ai_search through the final done: true event. Events contain data, valueFieldHints, estimate, and done; handle streamed errors as described in Search v3 and Streaming.
Example: Model Cost over Time
The response is an array of series with metric labels and velocity points. Input cost is one cost component; output, cache-read, and cache-write costs have separate fields. See Time-Series Queries.
List Model Pricing
The optional query parameter accepts gcQL filters only, without pipes or aggregations. Omit it to list all prices. The response contains a pricing array with provider, model, modelId, displayName, inputPrice, outputPrice, cacheReadPrice, cacheWritePrice, source, and fetchedAt.
Manage Custom Pricing
Admin required for every custom-pricing operation, including reading status and downloading the file. The AI queries and effective model-pricing lookup above do not require Admin permissions.
The custom-pricing API uses the file formats described in Custom Model Pricing. Upload CSV or supported JSON as multipart field file; prices use USD per token. The maximum file size is 10 MiB.
For example, save this synthetic configuration as model-prices.csv, replacing the model identity and rates with your own:
Use an Admin user credential that supplies a user identity for this operation. An API key without an associated user identity cannot upload or delete pricing and receives HTTP 401.
GET, PUT and DELETE return file, savedRevision, activeRevision, status (applying or active), and an optional error. Poll GET /api/gen-ai/pricing/custom until the saved revision is active. Download the original file with GET /api/gen-ai/pricing/custom/file. DELETE /api/gen-ai/pricing/custom removes the custom file and restores shared prices for new spans.
Errors
Invalid gcQL or time-series selection returns HTTP 400. An unsupported backend returns 404. Custom-pricing operations can also return 403 for missing Admin permissions, 413 for oversized uploads, or 503 when storage or activation services are unavailable.
Last updated
