Launch Week 02 wrapped — explore all five launches

Query Ad Hoc Widget

POSThttps://api.confident-ai.com/v2/widgets/query

Computes the data for a widget you define inline, without saving it to a dashboard. Use it to chart your observability data on demand. Branch on data.kind to read the result: the widget's type and mode say how it is drawn, not how the payload is shaped. A query accepts at most 20 lines, a topK.limit of at most 100, and a range no longer than 366 days.

POST/v2/widgets/query
curl -X POST "https://api.confident-ai.com/v2/widgets/query" \
  -H "CONFIDENT_API_KEY: <PROJECT-API-KEY>" \
  -H "Content-Type: application/json" \
  -d '{
  "widget": {
    "name": "Trace volume",
    "description": "Traces served per day across production.",
    "type": "LINE",
    "unit": "COUNT",
    "mode": "TIME_SERIES",
    "bucketMode": "SERIES",
    "dimension": "model",
    "topK": {
      "limit": 10,
      "orderBy": "p90_latency",
      "direction": "desc"
    },
    "startTime": "2025-01-01T00:00:00.000Z",
    "endTime": "2025-01-31T23:59:59.999Z",
    "layout": {
      "x": 0,
      "y": 0,
      "w": 6,
      "h": 2
    },
    "lines": [
      {
        "name": "Traces",
        "color": "BLUE",
        "dataModel": "TRACE",
        "aggregation": "COUNT",
        "filters": {
          "operator": "AND",
          "groups": [
            {
              "operator": "AND",
              "filters": [
                {
                  "category": "User Id",
                  "condition": "Is less than",
                  "value": "string",
                  "key": "string"
                }
              ]
            }
          ]
        },
        "extraQueryParams": {
          "metricMetadataKey": "tokenCount"
        }
      }
    ]
  },
  "startTime": "2025-01-01T00:00:00.000Z",
  "endTime": "2025-01-31T23:59:59.999Z",
  "granularity": "thirty_minutes"
}'
200
{
  "success": true,
  "data": {
    "type": "LINE",
    "mode": "TIME_SERIES",
    "data": {
      "kind": "BIG_NUMBER",
      "unit": "COUNT",
      "values": [
        {
          "key": "Traces",
          "name": "Traces",
          "color": "AMBER",
          "lineId": "<LINE-ID>",
          "value": 3814
        }
      ]
    }
  },
  "deprecated": false
}

Headers

  • CONFIDENT_API_KEYstringRequired

    The API key of your Confident AI project.

Request body

  • widgetobjectRequired

    A widget to add to a dashboard: the chart to draw, the time range and breakdown to draw it over, and the lines to plot on it.

    Show 12 propertiesHide 12 properties
    • namestringRequired

      The name shown as the widget's title.

    • descriptionstring | null

      What the widget shows. Send null to leave it unset.

    • typeenum | null

      The visualization a widget is drawn as. It is how the widget is displayed and does not by itself decide the shape of a query response — a TABLE widget returns tabular data whatever its mode is.

      Show 7 enum valuesHide 7 enum values
      • LINE
      • AREA
      • BAR
      • STACKED_BAR
      • GROUPED_BAR
      • TABLE
      • BIG_NUMBER
    • unitenum | null

      The unit a widget's values are measured in.

      Show 6 enum valuesHide 6 enum values
      • COUNT
      • PERCENT
      • SCORE
      • SECONDS
      • USD
      • MILLISECONDS
    • modeenum | null

      How a widget aggregates its lines. TIME_SERIES plots each configured line over time; DIMENSION_SERIES takes a single metric and splits it into one series per value of the widget's dimension. This is the widget's saved configuration — the shape of a query response is given by kind on the result.

      Show 2 enum valuesHide 2 enum values
      • TIME_SERIES
      • DIMENSION_SERIES
    • bucketModeenum | null

      How a widget's data is bucketed over the query time range. SERIES splits the range into one bucket per granularity interval; RANGE aggregates the whole range into a single bucket, as a BIG_NUMBER widget wants. Defaults to SERIES.

      Show 2 enum valuesHide 2 enum values
      • SERIES
      • RANGE
    • dimensionenum | null

      The property a widget breaks its data down by, one series or table row per distinct value.

      Show 26 enum valuesHide 26 enum values
      • project
      • trace_name
      • span_name
      • model
      • type
      • thread_id
      • test_case_id
      • test_run_id
      • end_user
      • source
      • annotator
      • name
      • error
      • prompt_alias
      • tag
      • label
      • evaluation_model
      • prompt_version
      • prompt_label
      • prompt_commit_hash
      • metadata
      • hyperparameter
      • classifier
      • polarity
      • classifier_label
      • version
    • topKobject | null

      Caps a dimension breakdown at the most interesting values, so a dimension with thousands of values still plots.

      Show 3 propertiesHide 3 properties
      • limitinteger

        The number of series or rows to keep, taking the highest or lowest by orderBy. Defaults to 10.

      • orderByenum | enum

        The metric or column the dimension values are ranked by. Defaults to count.

        Show 2 variantsHide 2 variants
        • enum

          Show 28 enum valuesHide 28 enum values
          • count
          • avg_latency
          • p50_latency
          • p90_latency
          • p99_latency
          • error_rate
          • pass_rate
          • failure_rate
          • input_cost
          • output_cost
          • total_cost
          • avg_cost
          • input_tokens
          • output_tokens
          • total_tokens
          • count_distinct_endUserId
          • count_distinct_threadId
          • count_distinct_model
          • count_distinct_projectId
          • count_distinct_error
          • count_distinct_metadata
          • error_count
          • pass_count
          • avg_score
          • stddev_score
          • median_score
          • avg_rating
          • score_histogram
        • OR
        • enum

          Show 3 enum valuesHide 3 enum values
          • created_at
          • start_time
          • dimension
      • directionenum

        Whether to keep the highest ranked values or the lowest. Defaults to desc.

        Show 2 enum valuesHide 2 enum values
        • asc
        • desc
    • startTimestring | null

      The start of the widget's own time range, as an ISO 8601 datetime. Send null to let the query decide the range.

    • endTimestring | null

      The end of the widget's own time range, as an ISO 8601 datetime. Send null to let the query decide the range.

    • layoutobject | null

      A widget's position and size on the dashboard's 12-column grid. Omit it when creating a widget and Confident AI packs it into the first free space.

      Show 4 propertiesHide 4 properties
      • xnumberRequired

        The widget's left edge, as a column index on the 12-column grid.

      • ynumberRequired

        The widget's top edge, as a row index on the grid.

      • wnumberRequired

        The widget's width in grid columns.

      • hnumberRequired

        The widget's height in grid rows.

    • linesarray | null

      The series the widget plots.

      Show 6 propertiesHide 6 properties
      • namestringRequired

        The name the line is labelled with in the legend.

      • colorenum | null

        The colour a line is drawn in, from the Confident AI palette. A line you create without one is assigned the next colour in the palette.

        Show 10 enum valuesHide 10 enum values
        • AMBER
        • VIOLET
        • EMERALD
        • BLUE
        • PINK
        • CYAN
        • ROSE
        • LIME
        • TEAL
        • ORANGE
      • dataModelenum | null

        The entity a widget line aggregates over. It decides which aggregations, filters and extraQueryParams the line accepts.

        Show 12 enum valuesHide 12 enum values
        • TRACE
        • SPAN
        • LLM_SPAN
        • AGENT_SPAN
        • RETRIEVER_SPAN
        • TOOL_SPAN
        • CUSTOM_SPAN
        • THREAD
        • END_USER
        • METRIC_DATA
        • ANNOTATION
        • CLASSIFICATION
      • aggregationenum | null

        The aggregation a line computes, given as its token. Which tokens apply depends on the line's dataModelAVG_RATING belongs to ANNOTATION lines, TOTAL_TOKENS to span lines — and a token that does not apply to the line's data model is rejected with the list of the ones that do.

        Show 26 enum valuesHide 26 enum values
        • AVG_COST
        • AVG_COST_PER_USER
        • AVG_LATENCY
        • AVG_RATING
        • AVG_SCORE
        • COUNT
        • ERROR_COUNT
        • ERROR_RATE
        • FAILURE_RATE
        • INPUT_COST
        • INPUT_TOKENS
        • MEDIAN_SCORE
        • NEW_USERS
        • OUTPUT_COST
        • OUTPUT_TOKENS
        • P50_LATENCY
        • P90_LATENCY
        • P99_LATENCY
        • PASS_RATE
        • RETENTION
        • TOTAL_COST
        • TOTAL_TOKENS
        • UNIQUE_END_USERS
        • UNIQUE_METADATA_VALUES
        • UNIQUE_THREADS
        • UNIQUE_USERS
      • filtersobject | null

        A set of filter groups combined by a top-level operator. Each group combines its filter rows by its own operator, and each row matches one property, such as Name or User Id, against a value with a condition such as Is or Contains.

        Show 2 propertiesHide 2 properties
        • operatorenumRequired

          Show 2 enum valuesHide 2 enum values
          • AND
          • OR
        • groupslist of objectsRequired

          Show 2 propertiesHide 2 properties
          • operatorenumRequired

            Show 2 enum valuesHide 2 enum values
            • AND
            • OR
          • filterslist of objectsRequired

            Show 4 propertiesHide 4 properties
            • categoryenumRequired

              Show 80 enum valuesHide 80 enum values
              • User Id
              • Thread Id
              • Trace Uuid
              • Trace Name
              • Trace Version
              • Trace Status
              • Trace Tags
              • Trace
              • Span Uuid
              • Name
              • Span Name
              • Span Type
              • Span Status
              • Metrics Status
              • Error Status
              • Name
              • Model
              • Provider
              • Integration
              • Embedder
              • Chunk Size
              • Top-K
              • Hyperparameter
              • Dataset
              • Dataset Name
              • Test Run ID
              • Identifier
              • Test File
              • Status
              • Official
              • Evals Mode
              • Tests Passed
              • Tests Failed
              • Pass Rate
              • Fail Rate
              • Star Rating
              • Thumbs Rating
              • Explanation
              • Expected Output
              • Expected Outcome
              • Annotator
              • End User
              • Annotation Type
              • Annotation Name
              • Criteria
              • Annotation Date
              • Metric Score
              • Metric Status
              • Name
              • Metadata
              • Classifier
              • Metric
              • Metric Name
              • Trace Count
              • Test Case ID
              • Requested review from
              • Assigned to
              • Tags
              • Labels
              • Tools Called
              • Finalized
              • Golden ID
              • Ingestion Task
              • Latency
              • Environment
              • Review flag
              • Vulnerability
              • Vulnerability Type
              • Attack Method
              • Risk Category
              • Framework
              • Assessment ID
              • Prompt Alias
              • Prompt Version
              • Prompt Label
              • Prompt Commit Hash
              • Prompt
              • Annotations
              • Status Code
              • Actor Type
            • conditionenum | enum | enum | enum | enum | enum | enum | enum | enum | enumRequired

            • valuestring | number | list of stringsRequired

            • keystring

      • extraQueryParamsobject | null

        Advanced per-line query parameters, whose recognised keys depend on the line's dataModel. spanType restricts a SPAN line to one span type; metricMetadataKey names the metadata field a span, trace or thread line aggregates; category and metricName pick out the metric a METRIC_DATA line reads; dataType and source say which annotations an ANNOTATION line counts. Unrecognised keys are ignored, and most lines send none of these.

  • startTimestring

    The start of the range to compute over, as an ISO 8601 datetime. Must be sent together with endTime, and overrides a range set on the widget itself.

  • endTimestring

    The end of the range to compute over, as an ISO 8601 datetime. Must be sent together with startTime, and must be later than it.

  • granularityenum

    The size of each bucket in computed widget data. Left unset, Confident AI picks one from the length of the query range.

    Show 5 enum valuesHide 5 enum values
    • thirty_minutes
    • hour
    • day
    • week
    • month

Response

Query Ad Hoc Widget succeeded.

  • successboolean

    Indicates if the request was successful.

  • dataobject

    The computed data for a widget that was defined inline rather than saved, so it carries no widget id.

    Show 3 propertiesHide 3 properties
    • typeenum | null

      The visualization a widget is drawn as. It is how the widget is displayed and does not by itself decide the shape of a query response — a TABLE widget returns tabular data whatever its mode is.

      Show 7 enum valuesHide 7 enum values
      • LINE
      • AREA
      • BAR
      • STACKED_BAR
      • GROUPED_BAR
      • TABLE
      • BIG_NUMBER
    • modeenum | null

      How a widget aggregates its lines. TIME_SERIES plots each configured line over time; DIMENSION_SERIES takes a single metric and splits it into one series per value of the widget's dimension. This is the widget's saved configuration — the shape of a query response is given by kind on the result.

      Show 2 enum valuesHide 2 enum values
      • TIME_SERIES
      • DIMENSION_SERIES
    • dataobject | object | object | object

      A widget's computed data. Branch on kind to read it: Confident AI derives the shape from the widget's type and mode, so a DIMENSION_SERIES widget drawn as a TABLE returns TABLE data.

      Show 4 variantsHide 4 variants
      • Widget Big Number Dataobject

        The whole query range aggregated to one figure per line, as a BIG_NUMBER widget draws it.

        Show 3 propertiesHide 3 properties
        • kindenum

          Marks the result as a set of headline figures.

          Show 1 enum valueHide 1 enum value
          • BIG_NUMBER
        • unitenum | null

          The unit a widget's values are measured in.

          Show 6 enum valuesHide 6 enum values
          • COUNT
          • PERCENT
          • SCORE
          • SECONDS
          • USD
          • MILLISECONDS
        • valueslist of objects

          One figure per line on the widget.

          Show 5 propertiesHide 5 properties
          • keystring

            A key that identifies this series within the result, unique across the result and stable between queries. Use it as a render key, or to line results up across queries.

          • namestring

            The label to show for the series.

          • colorenum

            The colour a line is drawn in, from the Confident AI palette. A line you create without one is assigned the next colour in the palette.

            Show 10 enum valuesHide 10 enum values
            • AMBER
            • VIOLET
            • EMERALD
            • BLUE
            • PINK
            • CYAN
            • ROSE
            • LIME
            • TEAL
            • ORANGE
          • lineIdstring

            The id of the widget line this series was computed from, when one line produced it.

          • valuenumber | null

            The aggregated value over the whole query range, or null when there was nothing to aggregate.

      • OR
      • Widget Time Series Dataobject

        Values bucketed over the query range, each point's x the start of its time bucket.

        Show 3 propertiesHide 3 properties
        • kindenum

          Marks the result as series plotted against time.

          Show 1 enum valueHide 1 enum value
          • TIME_SERIES
        • unitenum | null

          The unit a widget's values are measured in.

          Show 6 enum valuesHide 6 enum values
          • COUNT
          • PERCENT
          • SCORE
          • SECONDS
          • USD
          • MILLISECONDS
        • serieslist of objects

          One series per line, or per dimension value when the widget breaks its single line down.

          Show 5 propertiesHide 5 properties
          • keystring

            A key that identifies this series within the result, unique across the result and stable between queries. Use it as a render key, or to line results up across queries.

          • namestring

            The label to show for the series.

          • colorenum

            The colour a line is drawn in, from the Confident AI palette. A line you create without one is assigned the next colour in the palette.

            Show 10 enum valuesHide 10 enum values
            • AMBER
            • VIOLET
            • EMERALD
            • BLUE
            • PINK
            • CYAN
            • ROSE
            • LIME
            • TEAL
            • ORANGE
          • lineIdstring

            The id of the widget line this series was computed from, when one line produced it.

          • pointslist of objects

            The series' points, ordered by time for TIME_SERIES data and by the order the dimension values were ranked in for DIMENSION data.

            Show 2 propertiesHide 2 properties
            • xstring

              The point's position along the x axis: the start of the time bucket for TIME_SERIES data, the dimension value for DIMENSION data.

            • ynumber | null

              The aggregated value at this point, or null when the bucket held nothing to aggregate.

      • OR
      • Widget Dimension Dataobject

        The whole query range aggregated per dimension value, as a DIMENSION_SERIES widget draws it.

        Show 3 propertiesHide 3 properties
        • kindenum

          Marks the result as series plotted against a dimension.

          Show 1 enum valueHide 1 enum value
          • DIMENSION
        • unitenum | null

          The unit a widget's values are measured in.

          Show 6 enum valuesHide 6 enum values
          • COUNT
          • PERCENT
          • SCORE
          • SECONDS
          • USD
          • MILLISECONDS
        • serieslist of objects

          One series per line, each point's x a value of the widget's dimension.

          Show 5 propertiesHide 5 properties
          • keystring

            A key that identifies this series within the result, unique across the result and stable between queries. Use it as a render key, or to line results up across queries.

          • namestring

            The label to show for the series.

          • colorenum

            The colour a line is drawn in, from the Confident AI palette. A line you create without one is assigned the next colour in the palette.

            Show 10 enum valuesHide 10 enum values
            • AMBER
            • VIOLET
            • EMERALD
            • BLUE
            • PINK
            • CYAN
            • ROSE
            • LIME
            • TEAL
            • ORANGE
          • lineIdstring

            The id of the widget line this series was computed from, when one line produced it.

          • pointslist of objects

            The series' points, ordered by time for TIME_SERIES data and by the order the dimension values were ranked in for DIMENSION data.

            Show 2 propertiesHide 2 properties
            • xstring

              The point's position along the x axis: the start of the time bucket for TIME_SERIES data, the dimension value for DIMENSION data.

            • ynumber | null

              The aggregated value at this point, or null when the bucket held nothing to aggregate.

      • OR
      • Widget Table Dataobject

        The whole query range aggregated into a table, as a TABLE widget draws it.

        Show 3 propertiesHide 3 properties
        • kindenum

          Marks the result as columns and rows.

          Show 1 enum valueHide 1 enum value
          • TABLE
        • columnslist of objects

          The table's columns: the widget's dimension first, under the key dimension, then one column per line.

          Show 2 propertiesHide 2 properties
          • keystring

            The key each row holds this column's value under.

          • labelstring

            The label to show in the column header.

        • rowslist of objects

          One row per dimension value. Each row holds its values under the key of the column they belong to, and a value is null where the row had nothing to aggregate.

  • deprecatedboolean

    Indicates if this endpoint is deprecated.

Built byConfident AI