Skip to main content

parse_openrouter_models

Function parse_openrouter_models 

Source
pub fn parse_openrouter_models(
    json: &Value,
    model: &str,
) -> Option<ModelPricing>
Expand description

Parses an OpenRouter /api/v1/models response for model.

Matches the full model id case-insensitively first, then falls back to the leaf after the last / (so claude-3.5-sonnet matches anthropic/claude-3.5-sonnet). Returns None when the model is absent or its pricing is not a usable positive number.