Skip to main content

Look up a model

The data comes from OpenRouter’s model list, fetched on first use and cached for five minutes. If a refresh fails, the previous data is kept. Each successful fetch is also written to ~/.cache/routehub/openrouter_models.json (or $XDG_CACHE_HOME/routehub), and that file is used when OpenRouter can’t be reached, so an offline or air-gapped run keeps the catalog it last saw. Set ROUTEHUB_CACHE_DIR to move the file, or to off to disable it. The supports_* functions return False for unknown models, and get_model_info raises ModelNotMappedError. Prices can be None.

Capability checks

supports_vision, supports_reasoning, supports_function_calling, supports_parallel_function_calling, supports_response_schema, supports_prompt_caching, supports_tool_choice, supports_system_messages, supports_pdf_input, supports_audio_input, supports_audio_output, supports_web_search, supports_computer_use and supports_assistant_prefill all take a model string.

How names are matched

  • Anthropic-style names find OpenRouter’s: claude-opus-4-7-20251001 finds anthropic/claude-opus-4.7.
  • Serving providers’ IDs find the vendor’s entry. groq/llama-3.3-70b-versatile, together_ai/meta-llama/Llama-3.3-70B-Instruct-Turbo and cerebras/llama3.3-70b all resolve to meta-llama/llama-3.3-70b-instruct. Output limits come from the vendor’s entry and may differ from what the serving provider allows.
  • Embedding models, which OpenRouter doesn’t list, come from a small built-in table: text-embedding-3-small, text-embedding-3-large, text-embedding-ada-002, gemini-embedding-001 and mistral-embed.
Every entry carries provider, the RouteHub provider that serves it. litellm_provider holds the same value for code written against litellm.

Compute the cost of a call

Multiply the usage from a response by the prices from the catalog:

Register your own models

Register private, fine-tuned or self-hosted models. Registered entries take priority and never expire:

List models from every provider

get_all_models asks each provider’s own models API what it serves, concurrently, and returns one consistent shape:
Sources are OpenRouter (no key needed), OpenAI, Anthropic, Gemini, Groq, xAI, DeepSeek, Mistral, Together, Fireworks, Cerebras, Cohere, and a local Ollama server when OLLAMA_API_BASE is set.
id, provider, model, name, type, context_window, max_output_tokens, input_modalities, output_modalities, supports_vision, supports_function_calling, supports_reasoning, supports_structured_output, input_cost_per_token, output_cost_per_token, created, endpoints and the provider’s raw record. A field is None where the provider doesn’t report it.
Results are cached per provider for five minutes, failures included, so an unavailable provider is retried once per window rather than on every call. Pass refresh=True to fetch again, or call clear_cache(). aget_all_models and aget_models are the async forms.

Count tokens

Counting uses tiktoken with the model’s encoding, or o200k_base for models tiktoken doesn’t know, so counts for non-OpenAI models are estimates. When no tokenizer can be loaded, for example offline before tiktoken has cached its files, counts fall back to four bytes per token.