openai SDK with the OpenRouter base URL (https://openrouter.ai/api/v1). TraceRoot captures these calls through the existing OpenAI instrumentation — no new OpenRouter-specific instrumentor or enum is required.
Setup
- Python
- TypeScript
Usage
- Python
- TypeScript
What Gets Captured
| Attribute | Description |
|---|---|
| Model | Any OpenRouter model string, such as openai/gpt-4o-mini, anthropic/claude-sonnet-4, or meta-llama/llama-4-maverick |
| Messages | Input messages array |
| Response | Completion content |
| Tool calls | Function/tool call inputs and outputs when using the OpenAI SDK tool-calling API |
| Tokens | Prompt, completion, and total tokens when returned by the provider |
| Latency | Request duration |
Run the example
Clone the repo and run a complete OpenRouter agent end-to-end.Python
Run the Python OpenRouter tool-agent example
TypeScript
Run the TypeScript OpenRouter example