Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.mellea.ai/llms.txt

Use this file to discover all available pages before exploring further.

LLM pricing via litellm’s pricing API. Pricing metrics require the litellm package (mellea[litellm]). Pricing is auto-enabled when litellm is installed and can be explicitly controlled via the MELLEA_PRICING_ENABLED environment variable. MELLEA_PRICING_ENABLED tri-state:
  • "true" + litellm installed → enabled
  • "true" + litellm absent → warning, disabled
  • "false" (any) → disabled (silent)
  • unset + litellm installed → enabled (auto)
  • unset + litellm absent → disabled (silent)
Pricing is only active when MELLEA_METRICS_ENABLED is also set. Custom pricing: Set MELLEA_PRICING_FILE to a JSON file using litellm’s native per-token schema. Minimal entries with only cost fields are supported:: { “my-model”: { “input_cost_per_token”: 0.000003, “output_cost_per_token”: 0.000015 } } Optional cache fields: cache_read_input_token_cost, cache_creation_input_token_cost. Environment variables:
  • MELLEA_PRICING_ENABLED: Tri-state pricing flag (true/false/unset).
  • MELLEA_PRICING_FILE: Path to a JSON file with custom model pricing.

Functions

FUNC compute_cost

compute_cost(model: str, provider: str | None, prompt_tokens: int | None, completion_tokens: int | None, cached_tokens: int | None = None, cache_creation_tokens: int | None = None) -> float | None
Estimate request cost in USD using litellm’s pricing data. Args:
  • model: Model identifier (e.g. "gpt-5.4", "claude-sonnet-4-6").
  • provider: Provider name from the backend (e.g. "openai", "watsonx"). Passed to litellm as custom_llm_provider to aid model resolution — e.g. "watsonx" causes litellm to try watsonx/ibm/granite-4-h-small.
  • prompt_tokens: Total prompt tokens including any cached tokens, or None.
  • completion_tokens: Number of completion tokens, or None.
  • cached_tokens: Tokens served from prompt cache, or None.
  • cache_creation_tokens: Tokens written to prompt cache, or None.
Returns:
  • Estimated cost in USD, or None if pricing is disabled or no pricing
  • data exists for the model.

FUNC is_pricing_enabled

is_pricing_enabled() -> bool
Return True if pricing metrics are enabled. Returns:
  • True if litellm is available and pricing is not explicitly disabled.