Skip to main content
Opik Documentation

Search documentation

Type to search this documentation.

Get workspace span metric

POST/v1/private/workspaces/metrics/spansGet workspace span metric

Gets a span metric time series aggregated across the workspace. When project_ids is empty, all projects in the workspace are included; otherwise only the given projects.

Request body

application/json
objectWorkspaceSpanMetricRequest
breakdownobject
Show child attributes
fieldstring

one of "none", "tags", "metadata", "name", "error_info", "error_type", "model", "provider", "type", "guardrail_name"

metadata_keystring
sub_metricstring
filtersarray of object
Show child attributes
Show array items
fieldstring
keystring
operatorstring

one of "contains", "not_contains", "starts_with", "ends_with", "=", "!=", ">", ">=", "<", "<=", "is_empty", "is_not_empty", "in", "not_in"

valuestring
intervalstring

one of "HOURLY", "DAILY", "WEEKLY", "TOTAL"

interval_endstring · date-time
interval_startstring · date-timerequired
metric_typestring

one of "FEEDBACK_SCORES", "TRACE_COUNT", "TOKEN_USAGE", "DURATION", "COST", "GUARDRAILS_FAILED_COUNT", "THREAD_COUNT", "THREAD_DURATION", "THREAD_FEEDBACK_SCORES", "SPAN_FEEDBACK_SCORES", "SPAN_COUNT", "SPAN_DURATION", "SPAN_TOKEN_USAGE", "TRACE_AVERAGE_DURATION", "TRACE_ERROR_RATE", "SPAN_AVERAGE_DURATION", "SPAN_COST", "SPAN_ERROR_RATE", "THREAD_AVERAGE_DURATION", "THREAD_COST"

project_idsarray of string · uuid

uniqueItems true

Show child attributes

uniqueItems true

start_before_endboolean
Example request
{
  "breakdown": {
    "field": "error_info",
    "metadata_key": "string",
    "sub_metric": "string"
  },
  "filters": [
    {
      "field": "string",
      "key": "string",
      "operator": "!=",
      "value": "string"
    }
  ],
  "interval": "DAILY",
  "interval_end": "2026-06-09T00:00:00Z",
  "interval_start": "2026-06-09T00:00:00Z",
  "metric_type": "COST",
  "project_ids": [
    "00000000-0000-0000-0000-000000000000"
  ],
  "start_before_end": true
}

Responses

200Workspace span metricapplication/json
objectWorkspaceMetricResponse
resultsarray of object
Show child attributes
Show array items
currentnumber · double
namestring
previousnumber · double
Example response
{
  "results": [
    {
      "current": 0,
      "name": "string",
      "previous": 0
    }
  ]
}
400Bad Requestapplication/json
objectErrorMessage
codeinteger · int32
detailsstring
messagestring
Example response
{
  "code": 0,
  "details": "string",
  "message": "string"
}
Documentation menu