model_registry
What it is
A static model registry: a centralized catalog of AI models across multiple providers. It exposes metadata (capabilities, context window, etc.) and helper functions to query models and providers.
Public API
Types
ModelInfo (TypedDict)- Model metadata fields:
id: strname: strprovider: Literal["openai","anthropic","cloudflare","ollama","openrouter","xai","mistral","perplexity","google"]context_window: intsupports_streaming: boolsupports_vision: boolsupports_function_calling: boolmax_output_tokens: int | Nonereleased: str(date stringYYYY-MM-DD)
- Model metadata fields:
Data
MODEL_REGISTRY: dict[str, list[ModelInfo]]- Provider → list of registered
ModelInfo.
- Provider → list of registered
PROVIDER_LOGOS: dict[str, str]- Provider → local logo path (served from a
/logosendpoint).
- Provider → local logo path (served from a
Functions
get_models_for_provider(provider: str) -> list[ModelInfo]- Returns all models registered for the given provider (or
[]if unknown).
- Returns all models registered for the given provider (or
get_all_models() -> list[ModelInfo]- Returns a flattened list of all models across all providers.
get_model_by_id(model_id: str) -> ModelInfo | None- Finds a model by exact
idacross all providers (first match wins) or returnsNone.
- Finds a model by exact
get_all_provider_names() -> list[str]- Returns all provider keys registered in
MODEL_REGISTRY.
- Returns all provider keys registered in
get_logo_for_provider(provider: str) -> str | None- Returns the logo path for a provider or
Noneif not defined.
- Returns the logo path for a provider or
Configuration/Dependencies
- Depends only on the standard library:
typing(Literal,TypedDict). - Provider logos are stored as local URL paths (e.g.
"/logos/openai.jpg"); serving those assets is handled elsewhere.
Usage
from naas_abi.apps.nexus.apps.api.app.services.model_registry import (
get_all_provider_names,
get_models_for_provider,
get_model_by_id,
get_logo_for_provider,
)
providers = get_all_provider_names()
print(providers)
openai_models = get_models_for_provider("openai")
print(openai_models[0]["id"], openai_models[0]["supports_vision"])
model = get_model_by_id("gpt-4o")
if model:
print(model["provider"], model["context_window"])
print(get_logo_for_provider("anthropic"))
Caveats
- Registry is static; models must be added/updated manually in
MODEL_REGISTRY. get_models_for_provider()returns an empty list for unknown providers (no error).get_model_by_id()matches by exact stringidand returns the first match across providers.