Documentation Index
Fetch the complete documentation index at: https://laminar.sh/docs/llms.txt
Use this file to discover all available pages before exploring further.
LaminarClient
HTTP client for Laminar API operations.import { LaminarClient } from '@lmnr-ai/lmnr';
const client = new LaminarClient({
projectApiKey: process.env.LMNR_PROJECT_API_KEY,
});
// Tag a completed trace
await client.tags.tag(traceId, ['user-feedback-positive']);
Constructor parameters:| Name | Type | Default | Description |
|---|
projectApiKey | string | LMNR_PROJECT_API_KEY env | API key |
baseUrl | string | https://api.lmnr.ai | API base URL |
port | number | 443 | API port |
Resources:Add tags to a completed trace.await client.tags.tag('trace-uuid', ['positive-feedback', 'resolved']);
Example: Capture a trace ID and tag laterimport { Laminar, LaminarClient, observe } from '@lmnr-ai/lmnr';
Laminar.initialize();
const client = new LaminarClient();
const traceId = await observe({ name: 'chat_completion' }, async () => {
// ... your work ...
return Laminar.getTraceId();
});
await Laminar.flush();
if (traceId) {
await client.tags.tag(traceId, 'good');
}
Parameters:| Name | Type | Default | Description |
|---|
traceId | string | — | Trace UUID |
tags | string[] | string | — | Tag(s) to add |
Returns: Promise<any>Note: Call after Laminar.flush() to ensure trace exists.
Push a metadata patch to a finished trace. The patch is shallow-merged into the trace’s existing metadata server-side. Use it for post-hoc signals (quality scores, reviewer notes, edit counts) you compute after the trace ends.import { Laminar, LaminarClient, observe } from '@lmnr-ai/lmnr';
Laminar.initialize();
const client = new LaminarClient();
const traceId = await observe({ name: 'chat_completion' }, async () => {
// ... your work ...
return Laminar.getTraceId();
});
await Laminar.flush();
if (traceId) {
await client.traces.pushMetadata(traceId, {
score: 0.85,
reviewer: 'alice',
editsMade: 2,
});
}
Parameters:| Name | Type | Default | Description |
|---|
traceId | string | — | Trace UUID, or a 32-char OTel hex trace id |
metadata | Record<string, unknown> | — | Patch merged into existing trace metadata. Must be non-empty |
Returns: Promise<void>Note: Call after Laminar.flush() to ensure the trace exists. If the trace can’t be found at processing time, the call logs a warning and returns without raising. The patch increments the trace’s numSpans by 1 (the virtual span that carried the patch) but does not change endTime, tokens, cost, top span, tags, or span names.
client.rolloutSessions
Rollout session management and SSE connections for rollout debugging.const response = await client.rolloutSessions.connect({
sessionId: 'session-uuid',
name: 'generateStream',
params: [{ name: 'messages', required: true }],
});
client.rolloutSessions.connect(options)
Connect to a rollout session and return the SSE streaming response.Parameters:| Name | Type | Default | Description |
|---|
options.sessionId | string | — | Rollout session UUID |
options.name | string | — | Rollout entrypoint name |
options.params | RolloutParam[] | — | Entrypoint parameter metadata |
options.signal | AbortSignal | — | Abort signal for the request |
Returns: Promise<Response>
client.rolloutSessions.setStatus(options)
Update the rollout session status.Parameters:| Name | Type | Default | Description |
|---|
options.sessionId | string | — | Rollout session UUID |
options.status | 'PENDING' | 'RUNNING' | 'FINISHED' | 'STOPPED' | — | New status |
Returns: Promise<void>
client.rolloutSessions.sendSpanUpdate(options)
Stream span updates to the rollout session.Parameters:| Name | Type | Default | Description |
|---|
options.sessionId | string | — | Rollout session UUID |
options.span | object | — | Span payload (OTel IDs and attributes) |
Returns: Promise<void>Span payload:| Name | Type | Description |
|---|
name | string | Span name |
startTime | string | ISO timestamp |
spanId | string | OTel span ID |
traceId | string | OTel trace ID |
parentSpanId | string | undefined | Parent span ID |
attributes | Record<string, any> | Span attributes |
spanType | SpanType | Span type |
client.rolloutSessions.delete(options)
Delete a rollout session.Parameters:| Name | Type | Default | Description |
|---|
options.sessionId | string | — | Rollout session UUID |
Returns: Promise<void>
client.datasets
Dataset operations.// List datasets
const datasets = await client.datasets.listDatasets();
// Get by name
const dataset = await client.datasets.getDatasetByName('my-dataset');
// Push datapoints
await client.datasets.push({
name: 'my-dataset',
points: [{ data: { query: 'test' }, target: { answer: '42' } }],
createDataset: true,
});
// Pull datapoints
const points = await client.datasets.pull({
name: 'my-dataset',
limit: 100,
});
client.datasets.listDatasets()
Returns: Promise<Dataset[]>
client.datasets.getDatasetByName(name)
Parameters:| Name | Type | Default | Description |
|---|
name | string | — | Dataset name |
Returns: Promise<Dataset[]>
client.datasets.pull(options)
Pull datapoints from a dataset.Parameters:| Name | Type | Default | Description |
|---|
options.name | string | — | Dataset name |
options.id | string | — | Dataset ID |
options.limit | number | 100 | Max datapoints |
options.offset | number | 0 | Pagination offset |
Returns: Promise<GetDatapointsResponse<D, T>>
client.datasets.push(options)
Push datapoints to a dataset.Parameters:| Name | Type | Default | Description |
|---|
options.points | Datapoint<D, T>[] | — | Datapoints to push |
options.name | string | — | Dataset name |
options.id | string | — | Dataset ID |
options.batchSize | number | 100 | Batch size |
options.createDataset | boolean | false | Create dataset if missing |
Returns: Promise<PushDatapointsResponse | undefined>
client.evals
Evaluation operations.// Initialize evaluation
const eval = await client.evals.init('my-eval', 'default-group');
// Create datapoint
await client.evals.createDatapoint({
evalId: eval.id,
data: { query: 'test' },
target: { answer: '42' },
});
client.evals.init(name?, groupName?, metadata?)
Parameters:| Name | Type | Default | Description |
|---|
name | string | — | Evaluation name |
groupName | string | — | Group name |
metadata | Record<string, any> | — | Evaluation metadata |
Returns: Promise<InitEvaluationResponse>
client.evals.createDatapoint(options)
Parameters:| Name | Type | Default | Description |
|---|
options.evalId | string | — | Evaluation UUID |
options.data | any | — | Input data |
options.target | any | — | Target/expected output |
options.metadata | Record<string, any> | — | Datapoint metadata |
options.index | number | — | Dataset index |
options.traceId | string | — | Trace UUID |
Returns: Promise<string>
client.evaluators.score(options)
Attach evaluator score to a trace or span.await client.evaluators.score({
name: 'quality',
score: 0.95,
traceId: 'trace-uuid',
});
Parameters:Pass exactly one of traceId or spanId.| Name | Type | Default | Description |
|---|
options.name | string | — | Evaluator name |
options.score | number | — | Score value |
options.metadata | Record<string, any> | — | Score metadata |
options.traceId | string | — | Trace UUID |
options.spanId | string | — | Span UUID |
Returns: Promise<void>
client.agent.run(options)
Run a browser agent.const result = await client.agent.run({
prompt: 'Find the pricing on example.com',
maxSteps: 50,
returnScreenshots: true,
});
Parameters:| Name | Type | Default | Description |
|---|
prompt | string | — | Agent instruction (required) |
parentSpanContext | string | Current span | Parent trace context |
model | string | — | Model to use |
stream | boolean | false | Stream responses |
maxSteps | number | 100 | Maximum steps |
startUrl | string | — | Starting URL |
timeout | number | — | Timeout in ms |
returnScreenshots | boolean | false | Include screenshots |
returnAgentState | boolean | false | Return agent state |
returnStorageState | boolean | false | Return storage state |
disableGiveControl | boolean | false | Disable “give control” |
enableThinking | boolean | true | Enable thinking |
Returns:
Promise<AgentOutput> when stream is false
Promise<ReadableStream<RunAgentResponseChunk>> when stream is true
LaminarClient
Synchronous HTTP client for Laminar API operations.from lmnr import LaminarClient
client = LaminarClient()
# Tag a completed trace
client.tags.tag(trace_id, ["user-feedback-positive"])
Constructor parameters:| Name | Type | Default | Description |
|---|
project_api_key | str | LMNR_PROJECT_API_KEY env | API key |
base_url | str | https://api.lmnr.ai | API base URL |
port | int | From URL | API port |
timeout | int | 3600 | Request timeout (seconds) |
Resources:Add tags to a completed trace.from lmnr import Laminar, LaminarClient, observe
Laminar.initialize()
client = LaminarClient()
@observe()
def my_trace():
return Laminar.get_trace_id()
trace_id = my_trace()
Laminar.flush()
if trace_id:
client.tags.tag(trace_id, ["user-feedback-positive"])
Parameters:| Name | Type | Default | Description |
|---|
trace_id | str | int | uuid.UUID | — | Trace identifier |
tags | list[str] | str | — | Tag(s) to add |
Returns: list[dict] (returns [] on 404)Note: Call after the trace has ended (use Laminar.flush() for short-lived scripts).
Push a metadata patch to a finished trace. The patch is shallow-merged into the trace’s existing metadata server-side. Use it for post-hoc signals (quality scores, reviewer notes, edit counts) you compute after the trace ends.from lmnr import Laminar, LaminarClient, observe
Laminar.initialize()
client = LaminarClient()
@observe(name="chat_completion")
def chat_completion():
# ... your work ...
return Laminar.get_trace_id()
trace_id = chat_completion()
Laminar.flush()
if trace_id:
client.traces.push_metadata(
trace_id,
{"score": 0.85, "reviewer": "alice", "edits_made": 2},
)
Parameters:| Name | Type | Default | Description |
|---|
trace_id | str | int | uuid.UUID | — | Trace identifier |
metadata | dict[str, Any] | — | Patch merged into existing trace metadata. Must be non-empty |
Returns: NoneNote: Call after the trace has ended (use Laminar.flush() for short-lived scripts). If the trace can’t be found at processing time, the call logs a warning and returns without raising. The patch increments the trace’s num_spans by 1 (the virtual span that carried the patch) but does not change end_time, tokens, cost, top span, tags, or span names. The async client exposes the same method as await client.traces.push_metadata(...).
client.rollout
Rollout session management for rollout debugging.client.rollout.connect(session_id, function_name, params=None)
Connect to a rollout session and return the SSE streaming response.Parameters:| Name | Type | Default | Description |
|---|
session_id | uuid.UUID | — | Rollout session UUID |
function_name | str | — | Rollout entrypoint name |
params | list[RolloutParam] | None | Entrypoint parameter metadata |
Returns: Context manager yielding httpx.Response
client.rollout.update_span_info(session_id, span_data)
Stream a span update to the rollout session.Parameters:| Name | Type | Default | Description |
|---|
session_id | str | — | Rollout session UUID |
span_data | SpanStartData | — | Span payload (name, IDs, attributes, start time) |
Returns: None
client.rollout.update_status(session_id, status)
Update the rollout session status.Parameters:| Name | Type | Default | Description |
|---|
session_id | str | — | Rollout session UUID |
status | 'PENDING' | 'RUNNING' | 'FINISHED' | 'STOPPED' | — | New status |
Returns: None
client.rollout.delete_session(session_id)
Delete a rollout session.Parameters:| Name | Type | Default | Description |
|---|
session_id | str | — | Rollout session UUID |
Returns: NoneNote: AsyncLaminarClient.rollout exposes the same methods; update_span_info, update_status, and delete_session are awaitable.
client.close()
Close the underlying HTTP client.Returns: None
client.datasets.pull(name=None, id=None, limit=100, offset=0)
Pull datapoints from a dataset.Parameters:| Name | Type | Default | Description |
|---|
name | str | None | Dataset name |
id | uuid.UUID | None | Dataset ID |
limit | int | 100 | Max datapoints |
offset | int | 0 | Pagination offset |
Returns: GetDatapointsResponse
client.datasets.push(points, name=None, id=None, batch_size=100, create_dataset=False)
Push datapoints to a dataset.Parameters:| Name | Type | Default | Description |
|---|
points | list[Datapoint] | — | Datapoints to push |
name | str | None | Dataset name |
id | uuid.UUID | None | Dataset ID |
batch_size | int | 100 | Batch size |
create_dataset | bool | False | Create dataset if missing |
Returns: PushDatapointsResponse | None
client.evals.init(name=None, group_name=None, metadata=None)
Initialize an evaluation.Parameters:| Name | Type | Default | Description |
|---|
name | str | None | Evaluation name |
group_name | str | None | Group name |
metadata | dict | None | Evaluation metadata |
Returns: InitEvaluationResponse
client.evaluators.score(…)
Create a score for a trace or span.Parameters:Pass exactly one of trace_id or span_id.| Name | Type | Default | Description |
|---|
name | str | — | Evaluator name |
score | float | — | Score value |
trace_id | str | int | uuid.UUID | None | Trace identifier |
span_id | str | int | uuid.UUID | None | Span identifier |
metadata | dict | None | Score metadata |
Returns: None
AsyncLaminarClient
Async variant of LaminarClient.from lmnr import AsyncLaminarClient
client = AsyncLaminarClient()
await client.tags.tag(trace_id, ["feedback"])
await client.close()
Constructor parameters:| Name | Type | Default | Description |
|---|
project_api_key | str | None | API key (defaults to LMNR_PROJECT_API_KEY) |
base_url | str | None | API base URL (defaults to LMNR_BASE_URL or https://api.lmnr.ai) |
port | int | None | API port (defaults to 443) |
timeout | int | 3600 | Request timeout (seconds) |
await client.close()
Returns: None