---
title: "Preview Genai Lens"
method: POST
path: "/genai-lens/v1/lenses/preview"
tags: ["genai-lens"]
---

# Preview Genai Lens

`POST /genai-lens/v1/lenses/preview`

## Request

- Base URL: `https://api.galileo.ai`
- URL: `https://api.galileo.ai/genai-lens/v1/lenses/preview`
- Auth: one of:
  - API key in header `Splunk-AO-API-Key`
  - API key in header `Galileo-API-Key`
  - OAuth 2
    - Password
    - Token URL: `https://api.galileo.ai/login`
  - HTTP basic

## Request body

- GenaiLensPreviewRequest: A draft lens from the builder, possibly incomplete.
  - `name` string, nullable
  - `description` string, nullable
  - `start_date` string, date, nullable
  - `end_date` string, date, nullable
  - `group_id` string, uuid4, nullable
  - `match` 'all' | 'any': How a lens combines its criteria when it counts a root trace.
  - `criteria` union[]
    - union
      - GenaiLensAgentCriterion: Counts a root trace that involves this inventory agent.
        - `kind` 'agent', required
        - `agent_id` string, required
      - GenaiLensEvalCriterion: Counts a root trace whose evaluation has this result.
        - `kind` 'eval', required
        - `evaluation_name` string, required
        - `result` 'success' | 'failure', required
      - GenaiLensMetadataCriterion: Counts a root trace whose tag or metadata value matches.
        - `kind` 'metadata', required
        - `key` string, required
        - `operator` 'equals' | 'not_equals', required
        - `value` string, required
  - `supporting_agents` GenaiLensSupportingAgent[]
    - `agent_id` string, required
    - `cost_allocation_pct` number
  - `value_rules` union[]
    - union
      - GenaiLensAgentValueRule: A value for each matched root trace that involves this inventory agent.
        - `source_kind` 'agent', required
        - `agent_id` string, required
        - `value_per_result_cents` integer, required
      - GenaiLensEvalValueRule: A value for each true result of a boolean evaluation.
        - `source_kind` 'eval', required
        - `evaluation_name` string, required
        - `value_per_result_cents` integer, required
      - GenaiLensMetricValueRule: A value for each unit of a numeric evaluation.
        - `source_kind` 'metric', required
        - `evaluation_name` string, required
        - `value_per_result_cents` integer, required

## Response `200`

Successful Response

- GenaiLensPreviewResponse: Raw stats for a draft lens, in request order. The UI applies allocations and values per result.
  - `matching_trace_count` integer, required
  - `value_sources` union[], required
    - union
      - GenaiLensCountStats: True and false counts of an agent or boolean evaluation source over the matched root traces.
        - `source_kind` 'agent' | 'eval', required
        - `true_count` integer, required
        - `false_count` integer, required
      - GenaiLensSumStats: Sum of a numeric evaluation source over the matched root traces.
        - `source_kind` 'metric', required
        - `sum` number, required
        - `unit` string, nullable
  - `supporting_agents` GenaiLensPreviewAgent[], required
    - `agent_id` string, required
    - `name` string, nullable
    - `ai_spend_cents` integer, required

## Other responses

- `422`: Validation Error

## Changes

> 35 revisions in range; 2 not diffed.

- **2026-10-28** `4cf49e96b632`: 1 info
  - endpoint added

[Operation history](https://skmtc.dev/galileo/apis/galileo-api-server/changes/genai-lens/v1/lenses/preview/post.md)

---

[API](https://skmtc.dev/galileo/apis/galileo-api-server.md) - [All operations](https://skmtc.dev/galileo/apis/galileo-api-server/llms.txt) - [OpenAPI document](https://skmtc.dev/galileo/apis/galileo-api-server/revisions/4cf49e96b632?raw)
