Insights
Computed live from your spans.
9 actionable recommendations
Projected from the last 24h × 30 days
Cost / latency / quality drift
What to fix this week
1 trace in 24h · up to 45 "openai.chat.completions.create" calls in one trace (avg 45) · ~$33/mo on these calls
45× openai.chat.completions.create
~1 batched call
One "rag.answer" produces ~45 "openai.chat.completions.create" calls — almost always a per-retrieved-item LLM call. Batch them into one request, or cap the loop. 45 completions for a single answer is a retrieval/ranking bug, not a model problem.
# One operation made N LLM calls in a single trace.
# Batch the per-item calls into one request:
inputs = [c.text for c in retrieved[:TOP_K]] # e.g. TOP_K = 8
client.embeddings.create(model="text-embedding-3-small", input=inputs)
# Or collapse a per-chunk loop into a single completion:
context = "\n\n".join(c.text for c in retrieved[:TOP_K])
client.chat.completions.create(messages=[{"role": "user", "content": context}])110 of 124 support_bot calls in 24h were under 600 input tokens on claude-opus-4-7.
Short prompts don't need a frontier model. Add a length check at the dispatcher: if tokens_input < 600, use gpt-4o-mini; otherwise fall back. Quality drop is typically negligible at this length.
# Route short prompts to cheaper model
model = "gpt-4o-mini" if tokens < 600 else "gpt-4o"
client.chat.completions.create(model=model, ...)124 support_bot calls in 24h, 100% on premium models.
At this volume a fine-tuned smaller model typically reaches ≥95% of frontier quality on a constrained task. Sample 5k spans, fine-tune gpt-4o-mini, A/B against current. Training cost recovers in ~5 days at current spend.
# Export training data from Peekr spans
# then fine-tune gpt-4o-mini on your task84 calls share a 2.4k-token system prompt on claude-opus-4-7.
Anthropic prompt caching cuts repeated system-prompt cost by ~90% after the first hit. Set cache_control: {"type":"ephemeral"} on the system block — no code path change required on Peekr's side.
# Anthropic — cache the system prompt
client.messages.create(
system=[{"type": "text", "text": prompt,
"cache_control": {"type": "ephemeral"}}],
...
)9 of 84 chat_summary calls scored below 0.5 faithfulness (mean 0.38) — $27/mo paid for output your eval flagged as unsupported.
A low-faithfulness answer costs the same to generate as a correct one — then costs you again in retries, support, and lost trust. Tighten grounding (better retrieval, require citations), or block-and-retry: Peekr's HallucinationBlock guard can withhold an answer scoring below your floor before it reaches the user.
# Stop serving (and paying for) unsupported answers
peekr.instrument(
evaluators=[peekr.eval.Hallucination()],
guards=[peekr.guard.HallucinationBlock(min_score=0.6)], # withhold + retry
)135 search_qa calls in 24h, 100% on premium models.
At this volume a fine-tuned smaller model typically reaches ≥95% of frontier quality on a constrained task. Sample 5k spans, fine-tune gpt-4o-mini, A/B against current. Training cost recovers in ~5 days at current spend.
# Export training data from Peekr spans
# then fine-tune gpt-4o-mini on your task5 traces were scored low-attention (e.g. "minimal") but still ran LLM calls — model spend on inputs your own router decided weren't worth the work.
Gate the expensive call on the triage score: if the router scores an input "minimal" or "ignore", short-circuit before the model call (a templated reply, a cached answer, or nothing). You're paying frontier-model rates to think about messages you already decided to skim.
# Gate the expensive call on the triage score
level = router.score_attention(message) # "full" | "minimal" | "ignore"
if level in ("minimal", "ignore"):
return cheap_reply(message) # template / cache — no model call
answer = client.chat.completions.create(...) # only when it's worth it4 of 57 code_assist calls scored below 0.5 faithfulness (mean 0.28) — $13/mo paid for output your eval flagged as unsupported.
A low-faithfulness answer costs the same to generate as a correct one — then costs you again in retries, support, and lost trust. Tighten grounding (better retrieval, require citations), or block-and-retry: Peekr's HallucinationBlock guard can withhold an answer scoring below your floor before it reaches the user.
# Stop serving (and paying for) unsupported answers
peekr.instrument(
evaluators=[peekr.eval.Hallucination()],
guards=[peekr.guard.HallucinationBlock(min_score=0.6)], # withhold + retry
)45 "openai.chat.completions.create" calls ran sequentially in 1 trace. Total: 42.3s, slowest single call: 1.2s.
42.3s
~1.2s
Each call waited for the previous one to finish. Running them concurrently (ThreadPoolExecutor in Python, Promise.all in JS) reduces wall-clock time from 42.3s to ~1.2s — a 35.8× speedup with no change to cost or output quality.
# Python — run LLM calls in parallel
from concurrent.futures import ThreadPoolExecutor
def process_all(items):
with ThreadPoolExecutor(max_workers=8) as pool:
return list(pool.map(process_one, items))When things changed without you noticing
Triggered when chat_summary defaulted back to claude-opus-4-7 on 2026-05-18. Volume held flat — the spike is purely model-mix.
Inspect a representative trace →p95 jumped from 480ms to 980ms after the 13:00 deploy. Hit rate on the downstream proxy dropped — likely cache invalidation.
Switched from claude-opus-4-7 to claude-sonnet-4-6 on the structured extraction prompt. Quality regressed; estimated $/correct-answer is actually higher.
Top spenders
| User | Share | Calls | Top feature | Models used | 24h | Projected /mo |
|---|---|---|---|---|---|---|
de u_demo | 4.3% | 57 | search_qa | 2 | $0.808 | $24.25 |
he u_heavy_19 | 3.5% | 40 | data_extraction | 3 | $0.652 | $19.57 |
he u_heavy_27 | 3.1% | 15 | chat_summary | 1 | $0.592 | $17.77 |
he u_heavy_37 | 2.6% | 25 | moderation | 3 | $0.493 | $14.78 |
he u_heavy_30 | 2.3% | 14 | support_bot | 1 | $0.430 | $12.90 |
he u_heavy_46 | 2.2% | 9 | code_assist | 1 | $0.421 | $12.64 |
he u_heavy_18 | 2.1% | 16 | search_qa | 2 | $0.399 | $11.98 |
he u_heavy_39 | 2.0% | 19 | code_assist | 3 | $0.369 | $11.07 |
he u_heavy_23 | 1.8% | 14 | search_qa | 2 | $0.342 | $10.25 |
53 u_532 | 1.8% | 7 | chat_summary | 1 | $0.334 | $10.02 |
See these recommendations on your own traffic.
Get started free →