# SDK reference · Agent Dev Labs

> Every function, option, report field and environment setting of the Agent Dev Labs JavaScript and Python SDKs.

Source: https://www.agentdevlabs.com/docs/reference

# SDK reference

Describes the JavaScript SDK 0.3.0 and the Python SDK 0.3.0.

- [adl](#adl)
- [init](#init)
- [trace](#trace)
- [CallReport](#callreport)
- [Mode](#mode)
- [Environment settings](#environment-settings)

## adl

Wraps your OpenAI or Anthropic client so a call is replayed from a recording or captured, with your code and prompts unchanged.

JavaScript

import OpenAI from 'openai'
import { adl } from 'agentdevlabs'

const client = adl(new OpenAI(), {
 onCall: (report) => console.log(report.outcome, report.mode, report.modeFrom),
})

Python

import openai
from agentdevlabs import adl

client = adl(
    openai.OpenAI(),
    on\_call=lambda report: print(report.outcome, report.mode, report.mode\_from),
)

`onCall` / `on_call`

A listener called once per provider call with its report. A request that raises gets no report: your app gets the error. It sends nothing anywhere, and a listener that throws is ignored.

`http_client`

The HTTP client your provider client already uses, so the SDK keeps its own apart from it.Python only: A Python provider client keeps its HTTP client apart from the SDK's, so the app passes the one it already uses.

## init

Records every OpenAI and Anthropic call in the process, including those made through LangChain, LangGraph and Deep Agents, and in JavaScript the Vercel AI SDK and Mastra, which build their own clients. Call it once, first in your entry file in JavaScript and at startup in Python. Every strict-replay failure answers 400, so a library around the provider does not retry it.

JavaScript

import { init } from 'agentdevlabs'

init({
 onCall: (report) => console.log(report.outcome, report.mode, report.modeFrom),
})

Python

from agentdevlabs import init

init(on\_call=lambda report: print(report.outcome, report.mode, report.mode\_from))

`onCall` / `on_call`

A listener called once per provider call with its report. A request that raises gets no report: your app gets the error. It sends nothing anywhere, and a listener that throws is ignored.

## trace

Makes the calls inside it one trace, which ends when its last call finishes. Its name is sent with each capture, cut to 100 characters, and shown to your workspace as plain text: use a fixed name, never user data.

JavaScript

import { trace } from 'agentdevlabs'

await trace('checkout', async () => {
 await client.chat.completions.create({ model: 'gpt-4o', messages })
})

Python

from agentdevlabs import trace

with trace("checkout"):
    client.chat.completions.create(model="gpt-4o", messages=messages)

## CallReport

What the listener receives for each provider call: the mode in effect, where it came from and what happened.

`outcome`

What happened to the call.

`replayed`

A stored capture answered.

`captured`

The provider answered and the call is recorded.

`passed-through`

The provider answered and nothing was recorded.

`failed`

Strict replay had no capture, so the provider was not called.

`not-stored`

The server did not store the capture of a call reported as captured; the reason follows.

`mode`

The mode this call ran in.

`modeFrom` / `mode_from`

Where the mode came from.

`env`

The AGENT\_DEV\_LABS\_MODE setting.

`server`

The console or devkit toggle, the environment's default, or the token.

`default`

The server could not be reached or rejected the token.

`disabled`

AGENT\_DEV\_LABS\_DISABLED is set, or there is no token.

`pin`

Set when the environment's pinned trace answered the call.

`traceId` / `trace_id`

The trace of the capture the call matched or made.

`step`

The step within that trace.

`cacheKey` / `cache_key`

The key of the capture the call matched or made.

`reason`

Why a call failed or went unrecorded.

`pin.traceId` / `pin.trace_id`

The pinned trace.

`pin.setAt` / `pin.set_at`

When the trace was pinned.

## Mode

The mode a call runs in. AGENT\_DEV\_LABS\_MODE overrides the server's mode, except a server off for production or the plan limit.

`auto`

The default: replays on a hit and captures on a miss.

`capture`

Set explicitly: calls are recorded.

`replay`

Set explicitly: calls are answered from recordings.

`off`

Calls pass through to the provider and nothing is recorded.

## Environment settings

Settings are environment variables only, the same in both SDKs.

Environment settings, the same in both SDKs

Variable

Values

Description

`AGENT_DEV_LABS_TOKEN`

a workspace token

Your workspace token. Without it the SDK warns once and records nothing: each call passes through, and its report says passed-through, off and disabled.

`AGENT_DEV_LABS_MODE`

auto, capture, replay, off

Overrides the server's mode, except a server off for production or the plan limit, which always wins. Any case; any other value runs as auto, with one warning naming it.

`AGENT_DEV_LABS_DISABLED`

1, true, yes, on; 0, false, no, off or empty

The first set turns the SDK off and the second leaves it on. Any other value turns it off, with one warning naming it. Beats every other setting.

`AGENT_DEV_LABS_VERBOSE`

1, true, yes, on; 0, false, no, off or empty

The first set prints one line per call to standard error: \[agentdevlabs\] captured, replayed, passed-through, failed or not-stored, the last three with their reason. The second leaves it off, and any other value leaves it off too, with one warning naming it. Sends nothing.

`AGENT_DEV_LABS_API_URL`

a URL

The API to talk to.

`AGENT_DEV_LABS_REPLAY_SPEED`

realtime, fast, instant, or a number

How fast a replayed stream plays: realtime is the default, fast is 10x, a number divides the recorded pace by it. Non-streamed replies are instant unless this is set.

`AGENT_DEV_LABS_GROUP`

a group name

Names a trace group: calls are captured into it and replays use only its recordings. Letters, digits,., \_, / and -, up to 100.

`AGENT_DEV_LABS_CACHE_DIR`

a directory

Where replayed captures are cached, encrypted. Defaults to your OS cache directory.
