def get_keywords_models():
    """
    Get available models from KeywordsAI API.

    Returns:
        List of model configurations with pricing and provider info.

    Raises:
        Exception if API call fails after retries.

    """
    import requests
    from typing import Dict, List

    def _get_models() -> List[Dict]:
        response = requests.get("https://api.keywordsai.co/api/models/public")
        if not response.ok:
            raise Exception(f"Failed to fetch models: {response.status_code}")

        data = response.json()
        models = [m for m in data["models"] if m.get("input_cost")]

        # Process model data
        for model in models:
            # Convert costs from per token to per million tokens
            model["input_cost"] = model["input_cost"] * 1e6
            model["output_cost"] = model["output_cost"] * 1e6

            # Normalize Google provider names
            if model["provider"]["provider_id"] in [
                "google_palm",
                "google_vertex_ai",
                "google_gemini_ai",
            ]:
                model["provider"]["provider_id"] = "google"
                model["provider"]["provider_name"] = "Google"

        return {model["model_name"]: model for model in models}

    # Use retry decorator for resilience
    retry_decorator = create_retry_decorator(
        max_retries=3, random_exponential=True, min_seconds=1, max_seconds=10
    )

    try:
        return retry_decorator(_get_models)()
    except Exception as e:
        logger.error(f"Failed to fetch models after retries: {e!s}")
        return []

    Get available models from KeywordsAI API.

    Returns:
        List of model configurations with pricing and provider info.

    Raises:
        Exception if API call fails after retries.

    
llama-index-integrations/llms/llama-index-llms-keywordsai/llama_index/llms/keywordsai/utils.py