openrouter:openai/gpt-6-luna is the suggested model. It’s cheap (about $0.10 per million input
tokens and $0.50 per million output tokens) and works well for trace analysis.
Model strings
Use a gateway prefix (openrouter:, portkey:, typesafe:), or name a provider directly.
- Portkey: the part before the
/is your Model Catalog provider slug. Writingportkey:@openai-prod/gpt-5means the same thing. SetPORTKEY_BASE_URLto use a self-hosted gateway. - Colons in model names: a colon after a
/is part of the model name, so strings likeollama_chat/llama3:8bwork as written. - Options: wrap a model string in
tp.LMto set options such as temperature or an endpoint, e.g.tp.LM("openrouter:openai/gpt-6-luna", temperature=0.0). It takes the same options asdspy.LM.
.env file in the working directory.
Jev
Jev, TypeSafe’s System One model, can be a cheaper option for stages that only make decisions, such as flagging steps or picking a category. It doesn’t write text: it answers yes/no (Noul) or picks among fixed options (Choice), with probabilities. Each output needs a desc,
which Jev reads as the question:
failed comes back with Jev’s probability, and kind as the chosen option. For example (values
made up to show the shape):
Local models
Any locally hosted model works, so your traces never leave your machine.-
Ollama: use
ollama_chat/<model>, e.g.tp.configure(lm="ollama_chat/llama3.1"). It talks to Ollama onlocalhost:11434by default. -
vLLM, llama.cpp, LM Studio, or any other OpenAI-compatible server: point a
tp.LMat it:
unpriced_calls in tp.last_run(). Add a
price with tp.configure(prices=...) if you want a cost estimate.
Cost and caching
Every call is cached on disk, so rerunning a pipeline only pays for prompts that changed. After a run,tp.last_run() shows what it did:
prompt_tokens or completion_tokens. What those calls used when they were first made is
counted in cached_prompt_tokens and cached_completion_tokens: the tokens the cache saved you.
by_model and by_op break the totals down by model and by operator. latency() gives
per-call percentiles. status is running, completed, failed or cancelled, and error
holds what ended a run that didn’t complete. During a live run, tp.last_run() shows the totals so far.
Cost is estimated from token counts. Prices come from a bundled price table, plus
built-in entries for the suggested model and Jev. When a provider reports a call’s cost (OpenRouter
does for models with no listed price), that’s used instead. Add your own prices, in USD per
million input and output tokens, keyed by the model name:
unpriced_calls instead of being guessed.
Next steps
- Optimization: improve a step against your labels.
- Live pipelines: run a model on traces as they arrive.