BrowserStack AI Evals

Traces API

Create, list, retrieve, and delete execution traces.

Traces API

Traces represent a single end-to-end execution of your AI pipeline. Each trace can contain multiple observations (spans, generations, events).

List Traces

GET /api/public/traces

Returns a paginated list of traces for the current project.

Query Parameters

ParameterTypeDescription
pageintegerPage number (default: 1)
limitintegerItems per page (default: 50, max: 100)
namestringFilter by trace name
userIdstringFilter by user ID
sessionIdstringFilter by session ID
tagsstring | string[]Filter by tags
environmentstring | string[]Filter by environment
versionstringFilter by version
releasestringFilter by release
fromTimestampISO 8601Filter traces at or after this time
toTimestampISO 8601Filter traces at or before this time
orderBystringSort: e.g., timestamp.asc, timestamp.desc

Response

{
  "data": [
    {
      "id": "trace-uuid-1",
      "externalId": null,
      "timestamp": "2026-04-03T10:00:00.000Z",
      "name": "rag-pipeline",
      "userId": "user-123",
      "sessionId": "session-abc",
      "metadata": { "env": "production" },
      "tags": ["production", "v2"],
      "release": "2026-04-01",
      "version": "2.0.0",
      "projectId": "proj-xyz",
      "environment": "production",
      "public": false,
      "bookmarked": false,
      "input": { "query": "What is quantum computing?" },
      "output": { "answer": "Quantum computing is..." },
      "observations": ["obs-uuid-1", "obs-uuid-2"],
      "scores": ["score-uuid-1"],
      "totalCost": 0.00042,
      "latency": 1523,
      "htmlPath": "/project/proj-xyz/traces/trace-uuid-1",
      "createdAt": "2026-04-03T10:00:00.000Z",
      "updatedAt": "2026-04-03T10:00:01.000Z"
    }
  ],
  "meta": {
    "page": 1,
    "limit": 50,
    "totalItems": 243,
    "totalPages": 5
  }
}

cURL Example

curl "https://evals-api.browserstack.com/api/public/traces?page=1&limit=10&userId=user-123" \
  -u "pk-lf-...:sk-lf-..."

Get Trace

GET /api/public/traces/{traceId}

Returns a single trace with all its observations and scores.

Path Parameters

ParameterTypeDescription
traceIdstringTrace ID

Response

{
  "id": "trace-uuid-1",
  "timestamp": "2026-04-03T10:00:00.000Z",
  "name": "rag-pipeline",
  "userId": "user-123",
  "sessionId": "session-abc",
  "metadata": { "env": "production" },
  "tags": ["production"],
  "projectId": "proj-xyz",
  "environment": "default",
  "public": false,
  "bookmarked": false,
  "input": { "query": "What is quantum computing?" },
  "output": { "answer": "Quantum computing is..." },
  "totalCost": 0.00042,
  "latency": 1523,
  "htmlPath": "/project/proj-xyz/traces/trace-uuid-1",
  "createdAt": "2026-04-03T10:00:00.000Z",
  "updatedAt": "2026-04-03T10:00:01.000Z",
  "observations": [
    {
      "id": "obs-uuid-1",
      "type": "GENERATION",
      "name": "llm-call",
      "model": "gpt-4o",
      "input": [{ "role": "user", "content": "What is quantum computing?" }],
      "output": { "role": "assistant", "content": "Quantum computing is..." },
      "usage": { "input": 20, "output": 80, "total": 100, "unit": "TOKENS" },
      "latency": 1400
    }
  ],
  "scores": [
    {
      "id": "score-uuid-1",
      "name": "correctness",
      "value": 0.9,
      "dataType": "NUMERIC",
      "source": "API"
    }
  ]
}

cURL Example

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

Create Trace

POST /api/public/traces

Creates a single trace. For bulk ingestion, prefer the batch ingestion endpoint.

Authentication: Accepts write-only keys.

Request Body

FieldTypeRequiredDescription
idstringNoTrace ID (auto-generated if omitted)
namestringNoTrace name
userIdstringNoUser identifier
sessionIdstringNoSession identifier
inputanyNoInput data
outputanyNoOutput data
metadataobjectNoArbitrary metadata
tagsstring[]NoTags
versionstringNoApplication version
releasestringNoRelease identifier
publicbooleanNoWhether publicly accessible
environmentstringNoEnvironment name

Response

{ "id": "trace-uuid-1" }

cURL Example

curl -X POST https://evals-api.browserstack.com/api/public/traces \
  -u "pk-lf-...:sk-lf-..." \
  -H "Content-Type: application/json" \
  -d '{
    "name": "rag-pipeline",
    "userId": "user-123",
    "sessionId": "session-abc",
    "input": { "query": "What is quantum computing?" },
    "tags": ["production"]
  }'

Delete Trace

DELETE /api/public/traces/{traceId}

Deletes a single trace and all its associated observations and scores.

Path Parameters

ParameterTypeDescription
traceIdstringTrace ID

Response

{ "message": "Traces deleted successfully" }

cURL Example

curl -X DELETE "https://evals-api.browserstack.com/api/public/traces/trace-uuid-1" \
  -u "pk-lf-...:sk-lf-..."

Bulk Delete Traces

DELETE /api/public/traces

Deletes multiple traces by ID in a single request.

Request Body

FieldTypeRequiredDescription
traceIdsstring[]YesList of trace IDs to delete (at least 1)

cURL Example

curl -X DELETE https://evals-api.browserstack.com/api/public/traces \
  -u "pk-lf-...:sk-lf-..." \
  -H "Content-Type: application/json" \
  -d '{ "traceIds": ["trace-uuid-1", "trace-uuid-2"] }'

Response

{ "message": "Traces deleted successfully" }