TypeScript
Python
Setup
Auto-instrumentation
Braintrust provides automatic tracing for OpenRouter calls. This is the recommended setup for most projects.node --import can run the file directly. The Braintrust APIs work the same in TypeScript projects — compile your TypeScript to JavaScript, then run the compiled file with the import hook.If you’re using a bundler, see Trace LLM calls for plugin and loader setup.
Manual instrumentation
Trace an OpenRouter client explicitly by wrapping it withwrapOpenRouter.What Braintrust traces
For the@openrouter/sdk package, Braintrust traces:- Chat completions via
chat.send(), including streaming - Embeddings via
embeddings.generate() - Reranking via
rerank.rerank(), withtopNand document count in metadata and each result captured as{ index, relevance_score } - Responses API via
beta.responses.send(), including streaming