Copy this into your coding agent
Paste into Cursor, Codex, Claude Code, or another coding agent in your project.This is a preview. Use the installation command from Bench;
the public npm package is not released yet.
Record one interaction
Copy the installation command from SDK in your Bench account and run it in your server project. The command uses the SDK build available to your account. Create a repository-scoped key there and keep it in your server’s secret store.NEXT_PUBLIC_ or VITE_ for the key. Set BENCH_API_BASE_URL to the endpoint shown in your account.
Use the API address and installation command shown on the SDK page in your Bench account.
The example uses TypeScript. In JavaScript, remove the ! non-null assertions
and validate required environment variables when your server starts.
Wrap agents and tools
Replace the synthetic callback with an existing application operation. Nest tool calls withkind: 'TOOL'; awaited child calls keep their parent trace. Wrap the
complete invocation for Mastra, Vercel AI SDK, LangChain, LangGraph, Deep Agents,
OpenAI Agents or custom server code. These are manual wrappers. More automatic
framework adapters are coming soon.
For streams, keep the span open until the stream is fully consumed. Fire-and-forget
work may finish after the request and needs its own lifecycle handling.
captureContent defaults to false. When enabled, pass input and let the callback
return the output. Built-in filters run before sending. Add a redact(value)
callback for extra application fields. Read privacy and redaction.
Call await bench.flush() at serverless request boundaries. Reuse the client for
long-running servers and call await bench.shutdown() after active work finishes.
bench.stats and onError expose delivery failures without changing app results.
Set componentId to a real prompt component from Bench when linking events to
criteria. Never invent IDs. SDK setup keys cannot spend evaluation credits.
Test application behavior
This client includesevaluateSystem for individual cases and simulateSystem
for scripted customer conversations through your app. Both require your actual
application function and test dependencies. Read application testing
for complete examples, then production checks to evaluate
recorded interactions.
See SDK setup for connection status, environments and troubleshooting.

