"""Unified LLM client using litellm for multi-provider support."""

import litellm

# Suppress litellm's verbose logging
litellm.suppress_debug_info = True

DEFAULT_MODEL = "gpt-4o"
DEFAULT_MAX_TOKENS = 1024


def chat(messages: list[dict], model: str = DEFAULT_MODEL, max_tokens: int = DEFAULT_MAX_TOKENS) -> str:
    """Send a chat completion request via litellm.

    Supports any model string that litellm understands:
      - "gpt-4o", "gpt-4o-mini"           (needs OPENAI_API_KEY)
      - "anthropic/claude-sonnet-4-5-20250929"   (needs ANTHROPIC_API_KEY)
      - "gemini/gemini-2.0-flash"          (needs GOOGLE_API_KEY)

    Returns the assistant's response text.
    """
    response = litellm.completion(
        model=model,
        messages=messages,
        max_tokens=max_tokens,
    )
    return response.choices[0].message.content.strip()
