# app/xulcan/llm/adapters/groq.py

import os
from xulcan.llm.adapters.openai_protocol import OpenAICompatibleAdapter

class GroqAdapter(OpenAICompatibleAdapter):
    """Adapter for Groq's lightning-fast LPU inference engine."""
    
    def __init__(self, api_key: str = None, **kwargs):
        key = api_key or os.getenv("GROQ_API_KEY")
        if not key:
            raise ValueError("[GroqAdapter] Falta la GROQ_API_KEY en el entorno.")
            
        # Llamamos al protocolo padre, inyectando la URL de Groq
        super().__init__(
            api_key=key,
            base_url="https://api.groq.com/openai/v1",
            **kwargs
        )