OpenRouter
Trace OpenRouter in Python and TypeScript.
OpenRouter gives you 200+ models through one API. The Python SDK (openrouter) and the TypeScript agent SDK (@openrouter/agent) are both traced with provider="openrouter". In Python, system is set to the underlying model vendor (openai / anthropic / google / …) inferred from the vendor/model slug; in TypeScript, system is openrouter.
Prerequisites
pip install -U neatlogs openrouterUsage
import os
import neatlogs
from openrouter import OpenRouter
neatlogs.init(api_key=os.environ["NEATLOGS_API_KEY"], workflow_name="openrouter-demo")
client = neatlogs.wrap(OpenRouter(api_key=os.environ["OPENROUTER_API_KEY"]))
resp = client.chat.send(
model="openai/gpt-4o-mini",
messages=[{"role": "user", "content": "In one sentence, what is OpenRouter?"}],
temperature=0.3,
top_p=0.9,
max_tokens=256,
)
print(resp.choices[0].message.content)
neatlogs.flush()
neatlogs.shutdown()wrap() opens a WORKFLOW root for you, so this renders with no extra wrapper. The Python SDK traces Chat Completions (chat.send), the Responses API (beta.responses.send), embeddings, and rerank. The TypeScript @openrouter/agent LLM span is finalized when you consume the result (getText() / getResponse()). Sampling params are recorded as model settings, and streaming is supported.
Making several calls in one run? Group them into one trace with a
WORKFLOWroot.