BrowserStack AI Evals

Observations API

List and retrieve spans, generations, and events within traces.

Observations API

Observations are the individual steps within a trace: spans (arbitrary operations), generations (LLM calls), events (point-in-time logs), and tool calls.

List Observations

GET /api/public/observations

Returns a paginated list of observations across all traces.

Query Parameters

ParameterTypeDescription
pageintegerPage number (default: 1)
limitintegerItems per page (default: 50, max: 100)
typestringFilter by type: GENERATION, SPAN, EVENT, TOOL_CALL
namestringFilter by observation name
traceIdstringFilter by parent trace ID
userIdstringFilter by user ID
parentObservationIdstringFilter by parent observation ID
versionstringFilter by version
environmentstring | string[]Filter by environment
fromStartTimeISO 8601Filter observations starting at or after
toStartTimeISO 8601Filter observations starting at or before

Response

{
  "data": [
    {
      "id": "obs-uuid-1",
      "projectId": "proj-xyz",
      "traceId": "trace-uuid-1",
      "parentObservationId": null,
      "name": "llm-call",
      "type": "GENERATION",
      "environment": "production",
      "startTime": "2026-04-03T10:00:00.100Z",
      "endTime": "2026-04-03T10:00:01.100Z",
      "version": "2.0.0",
      "createdAt": "2026-04-03T10:00:01.200Z",
      "updatedAt": "2026-04-03T10:00:01.200Z",
      "input": [{ "role": "user", "content": "Explain quantum computing." }],
      "output": { "role": "assistant", "content": "Quantum computing..." },
      "metadata": null,
      "level": "DEFAULT",
      "statusMessage": null,
      "model": "gpt-4o",
      "modelParameters": { "temperature": 0.7 },
      "completionStartTime": "2026-04-03T10:00:00.500Z",
      "promptId": null,
      "promptName": null,
      "promptVersion": null,
      "usageDetails": { "input": 30, "output": 90, "total": 120 },
      "costDetails": { "input": 0.00009, "output": 0.00027, "total": 0.00036 },
      "usage": { "unit": "TOKENS", "input": 30, "output": 90, "total": 120 },
      "unit": "TOKENS",
      "promptTokens": 30,
      "completionTokens": 90,
      "totalTokens": 120,
      "modelId": "model-uuid-1",
      "inputPrice": 0.000003,
      "outputPrice": 0.000003,
      "totalPrice": 0.000012,
      "calculatedInputCost": 0.00009,
      "calculatedOutputCost": 0.00027,
      "calculatedTotalCost": 0.00036,
      "latency": 1000,
      "timeToFirstToken": 400
    }
  ],
  "meta": {
    "page": 1,
    "limit": 50,
    "totalItems": 10,
    "totalPages": 1
  }
}

cURL Example

curl "https://evals-api.browserstack.com/api/public/observations?traceId=trace-uuid-1&type=GENERATION" \
  -u "pk-lf-...:sk-lf-..."

Get Observation

GET /api/public/observations/{observationId}

Returns a single observation by ID.

Path Parameters

ParameterTypeDescription
observationIdstringObservation ID

Response

Same schema as the list response items.

cURL Example

curl "https://evals-api.browserstack.com/api/public/observations/obs-uuid-1" \
  -u "pk-lf-...:sk-lf-..."

Observation Types

TypeDescription
GENERATIONAn LLM API call. Includes model, modelParameters, token usage, and cost fields.
SPANA generic operation with a duration (start/end time).
EVENTA point-in-time log without a duration.
TOOL_CALLA tool/function call invocation.

Observation Fields

FieldTypeDescription
idstringObservation ID
traceIdstring | nullParent trace ID
parentObservationIdstring | nullParent observation ID (for nesting)
namestring | nullObservation name
typestringGENERATION, SPAN, EVENT, TOOL_CALL
startTimeISO 8601Start time
endTimeISO 8601 | nullEnd time
inputanyInput data
outputanyOutput data
metadataanyMetadata
levelstringDEFAULT, DEBUG, WARNING, ERROR
modelstring | nullModel name (GENERATION only)
modelParametersobject | nullModel parameters (GENERATION only)
usageobjectToken usage: {input, output, total, unit}
usageDetailsobjectDetailed usage breakdown
calculatedTotalCostnumber | nullCalculated cost in USD
latencynumber | nullDuration in milliseconds
timeToFirstTokennumber | nullTime to first token in ms (GENERATION only)

Creating Observations

Observations are created via the Ingestion API using event types span-create, generation-create, and event-create. Use the batch endpoint for SDK-level usage.