haive.core.models.metadata¶

Model metadata utilities for LLM configurations.

This module provides utilities for downloading, caching, and accessing model metadata from LiteLLM’s model_prices_and_context_window.json.

Classes¶

ModelMetadata

A class to store and provide model metadata.

Functions¶

get_model_metadata(model_name[, provider, force_refresh])

Get metadata for a specific model with improved matching.

Module Contents¶

class haive.core.models.metadata.ModelMetadata[source]¶

A class to store and provide model metadata.

This class encapsulates metadata about a language model, including its pricing, context window limits, and provider information.

property context_window: int¶

Get the context window size for this model.

Return type:

int

property pricing: dict[str, float]¶

Get the pricing information for this model.

Return type:

dict[str, float]

haive.core.models.metadata.get_model_metadata(model_name, provider=None, force_refresh=False)[source]¶

Get metadata for a specific model with improved matching.

This function tries to find the most relevant model metadata based on the model name and provider, with multiple fallback strategies.

Parameters:
  • model_name (str) – Name of the model (e.g., “gpt-4”, “claude-3-opus”)

  • provider (str | None) – Optional provider prefix (e.g., “azure”, “anthropic”)

  • force_refresh (bool) – Force download fresh metadata

Returns:

Model metadata dictionary or empty dict if not found

Return type:

dict[str, Any]