otelopenai middleware.
Setup
You will need an OpenRouter API key from your OpenRouter settings.Installation
Usage
Set
LANGWATCH_API_KEY and OPENROUTER_API_KEY environment variables before running.anthropic/claude-sonnet-4-20250514). OpenRouter has no registered gen_ai.provider.name, so pass a custom value:
The middleware captures input and output content by default. Pass
otelopenai.WithDataCapture(langwatch.DataCaptureNone) to opt out.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.