SIGN IN SIGN UP

fix(ai-monitoring): Include token-priced specialized models.dev types (#126052)

Spans from models.dev "decision" models (for example Typesafe Jev,
`typesafe-ai/jev`) never get a `gen_ai.cost.*` value, even though
models.dev lists pricing for them.

The cause is that `https://models.dev/api.json` leaves out specialized
model types by default. You have to pass `?type=all` to get them. Right
now the only specialized type is `decision` (6 entries, all Jev, priced
per 1M tokens like general models). Because those models are missing
from the AI model metadata we send to Relay, `normalize_ai_costs` finds
no cost entry for them.

Changes:
- Fetch `api.json?type=all`.
- Keep models with no `type` (general models, same behavior as today)
plus an allowlist of specialized types that are priced per token
(`decision`). Types added later that we don't recognize are still
skipped, since their `cost` may not be per token.

I ran the updated `_fetch_models_dev_models` against the live `type=all`
response. It now produces `jev` / `*jev` entries at an input cost of
4.2e-8 per token and an output cost of 0. Relay's prefix-glob lookup
would match `*jev` against `typesafe-ai/jev`.

Tests: I added
`test_fetch_ai_model_metadata_models_dev_specialized_types`. I couldn't
run the Sentry test suite or prek locally, so this is relying on CI.

<!-- junior-request-attribution:start -->
via **sergical**.
<!-- junior-request-attribution:end -->

<!-- junior-session-footer:start -->
<!-- junior-conversation-id:slack%3AC062N2F39V4%3A1790789822.138069 -->

--

[View Junior
Session](https://junior-prod.sentry.dev/conversations/slack%3AC062N2F39V4%3A1790789822.138069)
[[Sentry]](https://sentry.sentry.io/explore/conversations/slack%3AC062N2F39V4%3A1790789822.138069/?project=4510944073809921)

<!-- junior-session-footer:end -->

Co-authored-by: sentry-junior[bot] <264270552+sentry-junior[bot]@users.noreply.github.com>
Co-authored-by: Sergiy Dybskiy <3760543+sergical@users.noreply.github.com>
S
sentry-junior[bot] committed
e2a66655a5731b1bee19544bc9e3cff00bdd3121
Parent: 1ff6d97
Committed by GitHub <noreply@github.com> on 10/1/2026, 12:13:29 PM