> ## Documentation Index
> Fetch the complete documentation index at: https://docs.therefrain.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Set Up Your AI Provider

> Configure your AI provider and API key before generating or executing runbooks.

## Overview

Refrain supports **Bring Your Own Key (BYOK)** across 7 AI providers. Use whichever provider fits your infrastructure, compliance requirements, or budget. No vendor lock-in.

## Supported providers

| Provider          | `--model-provider`  | Default model                    | Key variable(s)                                            |
| ----------------- | ------------------- | -------------------------------- | ---------------------------------------------------------- |
| Anthropic         | `anthropic`         | `claude-sonnet-4-6`              | `ANTHROPIC_API_KEY`                                        |
| OpenAI            | `openai`            | `gpt-4o`                         | `OPENAI_API_KEY`                                           |
| OpenAI-compatible | `openai-compatible` | `gpt-4o`                         | `OPENAI_COMPATIBLE_BASE_URL` + `OPENAI_COMPATIBLE_API_KEY` |
| Gemini            | `google`            | `gemini-2.5-pro`                 | `GOOGLE_GENERATIVE_AI_API_KEY`                             |
| Azure OpenAI      | `azure`             | `gpt-4o`                         | `AZURE_RESOURCE_NAME` + `AZURE_API_KEY`                    |
| Amazon Bedrock    | `bedrock`           | `anthropic.claude-sonnet-4-6-v1` | `AWS_REGION` + AWS credentials                             |
| Google Vertex AI  | `vertex`            | `claude-sonnet-4-6@20250514`     | `GOOGLE_VERTEX_PROJECT` + `GOOGLE_VERTEX_LOCATION`         |

## Provider setup

<Tabs>
  <Tab title="Anthropic (default)">
    ```bash theme={null}
    export ANTHROPIC_API_KEY="sk-ant-..."
    ```

    Anthropic is the default provider. No additional flags needed:

    ```bash theme={null}
    npx @refrainai/cli generate -- \
      --url "https://example.com" --goal "..." --output ./runbook.yaml
    ```

    To use a specific model:

    ```bash theme={null}
    npx @refrainai/cli generate -- \
      --model "claude-sonnet-4-6" --model-provider anthropic \
      --url "https://example.com" --goal "..." --output ./runbook.yaml
    ```
  </Tab>

  <Tab title="OpenAI">
    ```bash theme={null}
    export OPENAI_API_KEY="sk-..."
    ```

    ```bash theme={null}
    npx @refrainai/cli generate -- \
      --model "gpt-4o" --model-provider openai \
      --url "https://example.com" --goal "..." --output ./runbook.yaml
    ```
  </Tab>

  <Tab title="OpenAI-compatible">
    For any OpenAI-compatible endpoint (e.g., local models, custom deployments):

    ```bash theme={null}
    export OPENAI_COMPATIBLE_BASE_URL="https://your-endpoint.com/v1"
    export OPENAI_COMPATIBLE_API_KEY="your-key"
    ```

    ```bash theme={null}
    npx @refrainai/cli generate -- \
      --model "your-model" --model-provider openai-compatible \
      --url "https://example.com" --goal "..." --output ./runbook.yaml
    ```
  </Tab>

  <Tab title="Gemini">
    ```bash theme={null}
    export GOOGLE_GENERATIVE_AI_API_KEY="..."
    ```

    ```bash theme={null}
    npx @refrainai/cli generate -- \
      --model "gemini-2.5-pro" --model-provider google \
      --url "https://example.com" --goal "..." --output ./runbook.yaml
    ```
  </Tab>

  <Tab title="Azure OpenAI">
    ```bash theme={null}
    export AZURE_RESOURCE_NAME="your-resource"
    export AZURE_API_KEY="..."
    ```

    ```bash theme={null}
    npx @refrainai/cli generate -- \
      --model "gpt-4o" --model-provider azure \
      --url "https://example.com" --goal "..." --output ./runbook.yaml
    ```

    Optionally set `AZURE_API_VERSION` for a specific API version.
  </Tab>

  <Tab title="Amazon Bedrock">
    ```bash theme={null}
    export AWS_REGION="us-east-1"
    export AWS_ACCESS_KEY_ID="..."
    export AWS_SECRET_ACCESS_KEY="..."
    ```

    ```bash theme={null}
    npx @refrainai/cli generate -- \
      --model "anthropic.claude-sonnet-4-6-v1:0" --model-provider bedrock \
      --url "https://example.com" --goal "..." --output ./runbook.yaml
    ```

    IAM role-based authentication is also supported — omit the access key variables if using instance roles.
  </Tab>

  <Tab title="Google Vertex AI">
    ```bash theme={null}
    export GOOGLE_VERTEX_PROJECT="your-project"
    export GOOGLE_VERTEX_LOCATION="us-central1"
    ```

    ```bash theme={null}
    npx @refrainai/cli generate -- \
      --model "claude-sonnet-4-6@20250514" --model-provider vertex \
      --url "https://example.com" --goal "..." --output ./runbook.yaml
    ```

    Application Default Credentials (ADC) are used automatically. Run `gcloud auth application-default login` if needed.
  </Tab>
</Tabs>

## Default model

Instead of passing `--model` and `--model-provider` on every command, set defaults via environment variables:

```bash theme={null}
export AI_MODEL_ID="claude-sonnet-4-6"
export AI_MODEL_PROVIDER="anthropic"
```

| Variable            | Description         |
| ------------------- | ------------------- |
| `AI_MODEL_ID`       | Default AI model ID |
| `AI_MODEL_PROVIDER` | Default AI provider |

## What's next

<CardGroup cols={2}>
  <Card title="Generate a runbook" icon="wand-magic-sparkles" href="/guides/generate-runbook">
    Build your first runbook with AI.
  </Card>

  <Card title="Execute a runbook" icon="play" href="/guides/execute-runbook">
    Run a generated runbook.
  </Card>
</CardGroup>
