Skip to main content
OpenRouter provides a unified API to access LLMs from many providers. LangWatch traces calls made through OpenRouter using its OpenAI-compatible endpoint.

Setup

You will need an OpenRouter API key from your OpenRouter settings. Set your OpenRouter API key as an environment variable:

Usage

Set LANGWATCH_API_KEY and OPENROUTER_API_KEY environment variables before running.
The key difference with OpenRouter is the model name, which is prefixed with the provider (e.g., anthropic/claude-sonnet-4-20250514).
The defer tp.Shutdown(ctx) call is essential. Without it, traces buffered in memory will be lost when your application exits.
Using OpenRouter is a great way to experiment with different models without changing your core instrumentation logic. All calls will be traced by LangWatch, regardless of the underlying model you choose.
Last modified on August 23, 2026