Langfuse JS/TS SDKs
    Preparing search index...

    Interface GetObservationsV2Request

    {}
    
    interface GetObservationsV2Request {
        cursor?: string;
        environment?: string | string[];
        expandMetadata?: string;
        fields?: string;
        filter?: string;
        fromStartTime?: string;
        isRootObservation?: boolean;
        level?: ObservationLevel;
        limit?: number;
        name?: string;
        parentObservationId?: string;
        parseIoAsJson?: boolean;
        sessionId?: string;
        toStartTime?: string;
        traceId?: string;
        type?: string;
        userId?: string;
        version?: string;
    }
    Index

    Properties

    cursor?: string

    Base64-encoded cursor for pagination. Use the cursor from the previous response to get the next page.

    environment?: string | string[]

    Optional filter for observations where the environment is one of the provided values.

    expandMetadata?: string

    Comma-separated list of metadata keys to return non-truncated. By default, metadata values over 200 characters are truncated. Use this parameter to retrieve full values for specific keys. Example: "key1,key2"

    fields?: string

    Comma-separated list of field groups to include in the response. Available groups: core, basic, time, io, metadata, model, usage, prompt, metrics, trace_context. If not specified, core and basic field groups are returned. Example: "basic,usage,model"

    filter?: string

    JSON string containing an array of filter conditions. A condition on the same field as a query parameter filter (userId, name, type, level, environment, fromStartTime, ...) replaces that parameter. Query parameters for other fields still apply. A startTime condition replaces both fromStartTime and toStartTime.

    Each filter condition has the following structure:

    [
    {
    "type": string, // Required. One of: "datetime", "string", "number", "stringOptions", "arrayOptions", "stringObject", "boolean", "null"
    "column": string, // Required. Column to filter on (see available columns below)
    "operator": string, // Required. Operator based on type:
    // - datetime: ">", "<", ">=", "<="
    // - string: "=", "contains", "does not contain", "starts with", "ends with", "is not empty", "matches" (input/output only)
    // - stringOptions: "any of", "none of" (works on any string column except input/output)
    // - arrayOptions: "any of", "none of", "all of"
    // - number: "=", ">", "<", ">=", "<="
    // - stringObject: "=", "contains", "does not contain", "starts with", "ends with", "matches", "is set", "is not set"
    // - boolean: "=", "<>"
    // - null: "is null", "is not null"
    "value": any, // Required. Type depends on filter type: ISO 8601 string for datetime, JSON number for number (not a numeric string), array of strings for stringOptions/arrayOptions, boolean for boolean, and "" (empty string) for null
    "key": string // Required only for stringObject (the metadata key to filter on)
    }
    ]
    • id (string) - Observation ID
    • type (string) - Observation type (SPAN, GENERATION, EVENT)
    • name (string) - Observation name
    • traceId (string) - Associated trace ID
    • startTime (datetime) - Observation start time
    • endTime (datetime) - Observation end time
    • environment (string) - Environment tag
    • level (string) - Log level (DEBUG, DEFAULT, WARNING, ERROR)
    • statusMessage (string) - Status message
    • version (string) - Version tag
    • userId (string) - User ID
    • sessionId (string) - Session ID
    • isRootObservation (boolean) - Whether the observation is a logical root. Observations marked as app roots by the SDK may retain a non-null parentObservationId.
    • traceName (string) - Name of the parent trace
    • traceTags (arrayOptions) - Tags from the parent trace
    • tags (arrayOptions) - Alias for traceTags
    • latency (number) - Latency in seconds (calculated: end_time - start_time)
    • timeToFirstToken (number) - Time to first token in seconds
    • tokensPerSecond (number) - Output tokens per second
    • inputTokens (number) - Number of input tokens
    • outputTokens (number) - Number of output tokens
    • totalTokens (number) - Total tokens (alias: tokens)
    • inputCost (number) - Input cost in USD
    • outputCost (number) - Output cost in USD
    • totalCost (number) - Total cost in USD
    • model (string) - Provided model name (alias: providedModelName)
    • promptName (string) - Associated prompt name
    • promptVersion (number) - Associated prompt version
    • input (string) - Observation input. Supports accelerated indexed literal search with the matches operator.
    • output (string) - Observation output. Supports accelerated indexed literal search with the matches operator.
    • metadata (stringObject) - Metadata key-value pairs. Use the key parameter to filter on a specific metadata key. Metadata values are stored as strings, so match numbers and booleans by their string form with = (for example "value": "true" or "value": "42"); numeric comparisons such as > are not supported on metadata.

    The matches operator is only supported for input, output, and stringObject metadata filters. It performs indexed literal search with token-boundary pruning using the events table text indexes. Case sensitivity differs by target: input and output matches are case-insensitive, while metadata value matches are case-sensitive. Unlike SQL LIKE, % and _ are treated as literal characters. Use contains for legacy substring semantics where the API allows it. Any v2 input or output filter must be accompanied by at least one = or matches filter on input or output; standalone contains, starts with, ends with, and does not contain filters on these columns are rejected.

    [
    {
    "type": "string",
    "column": "type",
    "operator": "=",
    "value": "GENERATION"
    },
    {
    "type": "number",
    "column": "latency",
    "operator": ">=",
    "value": 2.5
    },
    {
    "type": "stringObject",
    "column": "metadata",
    "key": "environment",
    "operator": "=",
    "value": "production"
    },
    {
    "type": "string",
    "column": "output",
    "operator": "matches",
    "value": "needle"
    },
    {
    "type": "boolean",
    "column": "isRootObservation",
    "operator": "=",
    "value": true
    }
    ]
    fromStartTime?: string

    Retrieve only observations with a start_time on or after this datetime (ISO 8601).

    isRootObservation?: boolean

    Filter by whether an observation is a logical root. Root observations include observations without a physical parent and observations marked as app roots by the SDK. An app-root observation may have isRootObservation=true and a non-null parentObservationId.

    Optional filter for observations with a specific level (e.g. "DEBUG", "DEFAULT", "WARNING", "ERROR").

    limit?: number

    Maximum number of items to return per page. A page may contain fewer items, including zero items, while meta.cursor is present. Maximum 1000, default 50.

    name?: string
    parentObservationId?: string

    Filter by the physical parent observation ID. An empty value matches only observations without a physical parent. Use isRootObservation to include observations marked as app roots by the SDK, which may retain a non-null parentObservationId.

    parseIoAsJson?: boolean

    Deprecated. Setting this to true will return a 400 error. Input/output fields are always returned as raw strings. Remove this parameter or set it to false.

    sessionId?: string

    Filter by session ID.

    toStartTime?: string

    Retrieve only observations with a start_time before this datetime (ISO 8601).

    traceId?: string
    type?: string

    Filter by observation type (e.g., "GENERATION", "SPAN", "EVENT", "AGENT", "TOOL", "CHAIN", "RETRIEVER", "EVALUATOR", "EMBEDDING", "GUARDRAIL")

    userId?: string
    version?: string

    Optional filter to only include observations with a certain version.