# Examples of the LiteLLM model format
model="openai/gpt-4o"                          # OpenAI
model="anthropic/claude-3-5-sonnet-20241022"   # Anthropic
model="gemini/gemini-2.0-flash"                # Google Gemini
model="azure/my-deployment-name"               # Azure OpenAI
model="ollama/llama3"                          # Ollama (local)
model="openrouter/google/gemini-2.0-flash"     # OpenRouter
```

## Provider Configuration

<Tabs>
  <Tab value="openai" title="OpenAI">
    ### OpenAI

    **Environment Variable:**

    ```bash
    export OPENAI_API_KEY="sk-..."
    ```

    **Available Models:**

    * `openai/gpt-4o` - Most capable model
    * `openai/gpt-4o-mini` - Fast and cost-effective
    * `openai/gpt-4-turbo` - Previous generation
    * `openai/o1` - Reasoning model
    * `openai/o3-mini` - Efficient reasoning model

    **Example:**

    ```python
    from opik_optimizer import ChatPrompt, MetaPromptOptimizer

    prompt = ChatPrompt(
        messages=[
            {"role": "system", "content": "You are a helpful assistant."},
            {"role": "user", "content": "{question}"}
        ],
        model="openai/gpt-4o-mini"
    )

    optimizer = MetaPromptOptimizer(model="openai/gpt-4o")
    ```
  </Tab>

  <Tab value="anthropic" title="Anthropic">
    ### Anthropic (Claude)

    **Environment Variable:**

    ```bash
    export ANTHROPIC_API_KEY="sk-ant-..."
    ```

    **Available Models:**

    * `anthropic/claude-3-5-sonnet-20241022` - Best balance of speed and capability
    * `anthropic/claude-3-opus-20240229` - Most capable
    * `anthropic/claude-3-haiku-20240307` - Fastest

    **Example:**

    ```python
    from opik_optimizer import ChatPrompt, MetaPromptOptimizer

    prompt = ChatPrompt(
        messages=[
            {"role": "system", "content": "You are a helpful assistant."},
            {"role": "user", "content": "{question}"}
        ],
        model="anthropic/claude-3-5-sonnet-20241022"
    )

    optimizer = MetaPromptOptimizer(model="anthropic/claude-3-5-sonnet-20241022")
    ```
  </Tab>

  <Tab value="gemini" title="Google Gemini">
    ### Google Gemini

    **Environment Variable:**

    ```bash
    export GOOGLE_API_KEY="..."
    # or
    export GEMINI_API_KEY="..."
    ```

    <Tip>
      Get your API key from [Google AI Studio](https://aistudio.google.com/apikey).
    </Tip>

    **Available Models:**

    * `gemini/gemini-2.0-flash` - Latest fast model
    * `gemini/gemini-1.5-pro` - Most capable
    * `gemini/gemini-1.5-flash` - Fast and efficient
    * `gemini/gemini-1.5-flash-8b` - Lightweight model

    **Example:**

    ```python
    from opik_optimizer import ChatPrompt, MetaPromptOptimizer

    prompt = ChatPrompt(
        messages=[
            {"role": "system", "content": "You are a helpful assistant."},
            {"role": "user", "content": "{question}"}
        ],
        model="gemini/gemini-2.0-flash"
    )

    optimizer = MetaPromptOptimizer(model="gemini/gemini-1.5-pro")
    ```

    **Complete Gemini Example:**

    ```python
    import os
    from opik_optimizer import ChatPrompt, MetaPromptOptimizer
    from opik.evaluation.metrics import LevenshteinRatio
    import opik

    # Set your API key
    os.environ["GOOGLE_API_KEY"] = "your-api-key-here"

    # Initialize Opik client and create dataset
    client = opik.Opik()
    dataset = client.get_or_create_dataset(name="gemini-optimization-demo")
    dataset.insert([
        {"question": "What is machine learning?", "answer": "Machine learning is a subset of AI that enables systems to learn from data."},
        {"question": "What is Python?", "answer": "Python is a high-level programming language known for its readability."},
    ])

    # Define metric
    def answer_quality(dataset_item, llm_output):
        metric = LevenshteinRatio()
        return metric.score(reference=dataset_item["answer"], output=llm_output)

    # Configure prompt with Gemini
    prompt = ChatPrompt(
        messages=[
            {"role": "system", "content": "Answer the question concisely."},
            {"role": "user", "content": "{question}"}
        ],
        model="gemini/gemini-2.0-flash"
    )

    # Configure optimizer (can use same or different provider)
    optimizer = MetaPromptOptimizer(
        model="gemini/gemini-1.5-pro",
        n_threads=4
    )

    # Run optimization
    result = optimizer.optimize_prompt(
        prompt=prompt,
        dataset=dataset,
        metric=answer_quality,
        max_trials=5,
        n_samples=2
    )

    result.display()
    ```
  </Tab>

  <Tab value="azure" title="Azure OpenAI">
    ### Azure OpenAI

    **Environment Variables:**

    ```bash
    export AZURE_API_KEY="..."
    export AZURE_API_BASE="https://your-resource.openai.azure.com"
    export AZURE_API_VERSION="2024-02-15-preview"
    ```

    **Model Format:**

    ```python
    # Use your deployment name
    model="azure/your-deployment-name"
    ```

    **Example:**

    ```python
    from opik_optimizer import ChatPrompt, MetaPromptOptimizer

    prompt = ChatPrompt(
        messages=[
            {"role": "system", "content": "You are a helpful assistant."},
            {"role": "user", "content": "{question}"}
        ],
        model="azure/gpt-4o-deployment"  # Your Azure deployment name
    )

    optimizer = MetaPromptOptimizer(model="azure/gpt-4o-deployment")
    ```
  </Tab>

  <Tab value="ollama" title="Ollama (Local)">
    ### Ollama (Local Models)

    **Setup:**

    1. Install Ollama from [ollama.ai](https://ollama.ai)
    2. Pull a model: `ollama pull llama3`
    3. Ollama runs on `http://localhost:11434` by default

    **Environment Variable (optional):**

    ```bash
    export OLLAMA_API_BASE="http://localhost:11434"
    ```

    **Available Models:**

    * `ollama/llama3` - Meta's Llama 3
    * `ollama/mistral` - Mistral 7B
    * `ollama/codellama` - Code-focused Llama
    * `ollama/phi3` - Microsoft Phi-3

    **Example:**

    ```python
    from opik_optimizer import ChatPrompt, MetaPromptOptimizer

    prompt = ChatPrompt(
        messages=[
            {"role": "system", "content": "You are a helpful assistant."},
            {"role": "user", "content": "{question}"}
        ],
        model="ollama/llama3"
    )

    # Note: Local models may be slower for optimization
    optimizer = MetaPromptOptimizer(model="ollama/llama3")
    ```
  </Tab>

  <Tab value="openrouter" title="OpenRouter">
    ### OpenRouter

    OpenRouter provides access to multiple providers through a single API.

    **Environment Variable:**

    ```bash
    export OPENROUTER_API_KEY="sk-or-..."
    ```

    **Model Format:**

    ```python
    # Format: openrouter/provider/model
    model="openrouter/google/gemini-2.0-flash"
    model="openrouter/anthropic/claude-3-5-sonnet"
    model="openrouter/meta-llama/llama-3-70b-instruct"
    ```

    **Example:**

    ```python
    from opik_optimizer import ChatPrompt, MetaPromptOptimizer

    prompt = ChatPrompt(
        messages=[
            {"role": "system", "content": "You are a helpful assistant."},
            {"role": "user", "content": "{question}"}
        ],
        model="openrouter/google/gemini-2.0-flash"
    )

    optimizer = MetaPromptOptimizer(model="openrouter/anthropic/claude-3-5-sonnet")
    ```
  </Tab>
</Tabs>

## Environment Variables Reference

| Provider      | Environment Variable                                   | How to Get                                                           |
| ------------- | ------------------------------------------------------ | -------------------------------------------------------------------- |
| OpenAI        | `OPENAI_API_KEY`                                       | [platform.openai.com/api-keys](https://platform.openai.com/api-keys) |
| Anthropic     | `ANTHROPIC_API_KEY`                                    | [console.anthropic.com](https://console.anthropic.com/settings/keys) |
| Google Gemini | `GOOGLE_API_KEY` or `GEMINI_API_KEY`                   | [aistudio.google.com/apikey](https://aistudio.google.com/apikey)     |
| Azure OpenAI  | `AZURE_API_KEY`, `AZURE_API_BASE`, `AZURE_API_VERSION` | Azure Portal                                                         |
| OpenRouter    | `OPENROUTER_API_KEY`                                   | [openrouter.ai/keys](https://openrouter.ai/keys)                     |
| Ollama        | None required (local)                                  | [ollama.ai](https://ollama.ai)                                       |

## Model Parameters

You can pass additional parameters to control model behavior:

```python
from opik_optimizer import ChatPrompt, MetaPromptOptimizer