Files
zed/crates/language_models/src
Olivier Bonvalet 7fab4c0527 language_models: Detect OpenRouter Anthropic aliases (#66857)
## Summary

OpenRouter aliases are prefixed with `~` (e.g.
`~anthropic/claude-sonnet-latest`).
`into_open_router` only checked for the `anthropic/` prefix, so aliases
were
not treated as Anthropic models: no `cache_control` was sent (no prompt
caching), and `reasoning_details` was echoed back in requests.

Strip the leading `~` before checking the prefix.

Aliases are documented at
https://openrouter.ai/docs/guides/routing/routers/latest-resolution

## Testing

Added `test_anthropic_alias_model_uses_anthropic_request_handling`. It
fails
without the fix (`Alias should get cache_control`) and passes with it.
`cargo test -p language_models --lib open_router`, `cargo fmt --check`
and
`./script/clippy -p language_models` pass.

I did not test this manually against the OpenRouter API.

## Self-review

- [x] I've reviewed my diff for quality, security, reliability, and
performance.
- [x] UI changes follow the checklist. (N/A, no UI change)
- [x] Tests cover the new or changed behavior.

Release Notes:

- Fixed prompt caching for OpenRouter Anthropic aliases (e.g.
`~anthropic/...`)
2026-11-12 16:04:51 +00:00
..