Integrations / OpenRouter
To trace OpenRouter with Tracify, point the OpenAI client at OpenRouter's base URL and wrap it with the Tracify SDK. Each request is recorded with the model you chose, tokens, latency and any error.
Your code
OpenRouter
Tracify
One run.
Setup
OpenRouter uses the OpenAI library.
npm install tracify-sdk openaiCreate a project in Tracify, copy its API key and put it in the environment where your code runs. The SDK reads it from there, so nothing is hard-coded.
export TRACIFY_API_KEY="tracify_sk_live_..."Set OpenRouter's base URL and your OpenRouter key, then wrap the client.
import OpenAI from "openai";
import { wrapOpenAI } from "tracify-sdk";
const openrouter = wrapOpenAI(
new OpenAI({
apiKey: process.env.OPENROUTER_API_KEY,
baseURL: "https://openrouter.ai/api/v1",
}),
);
const reply = await openrouter.chat.completions.create({
model: "anthropic/claude-sonnet-4.5",
messages: [{ role: "user", content: "Hello" }],
});The same two lines in Python.
import os
import tracify
from openai import OpenAI
openrouter = tracify.wrap_openai(OpenAI(
api_key=os.environ["OPENROUTER_API_KEY"],
base_url="https://openrouter.ai/api/v1",
))
reply = openrouter.chat.completions.create(
model="anthropic/claude-sonnet-4.5",
messages=[{"role": "user", "content": "Hello"}],
)Run your code one time, then open the Tracing page of your project. Your OpenRouter call shows up as a run with its steps in order, plus the tokens, time and any error for each call.
Good to know
The wrapper reads the OpenAI call format, so calls are labeled as OpenAI-style in the trace. The model name you send is always the one shown, so you can still tell models apart.
Good to know
Because the model slug is recorded on every call, you can run the same agent on two models and compare their runs side by side in Tracify.
Good to know
Tracify records the tokens the provider returns. A dollar cost is shown when you give the wrapper your own rates with calculate_cost (Python) or calculateCost (TypeScript), so the number always matches your real price plan.
Full details in the documentation. All integrations are listed on the integrations page.
