> ## Documentation Index
> Fetch the complete documentation index at: https://thethirdpenco-feat-tool-lifecycle-events.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Providers Overview

> Connect to AI models from any provider

ai-query supports multiple AI providers through a unified interface. Each provider has its own factory function that creates a `LanguageModel` instance.

## Supported Providers

<CardGroup cols={2}>
  <Card title="OpenAI" icon="brain" href="/how-to/how-to/providers/openai/openai">
    GPT-5, GPT-4o, and o-series reasoning models
  </Card>

  <Card title="Anthropic" icon="message" href="/how-to/how-to/providers/openai/anthropic">
    Claude 3.5 Sonnet, Claude 3 Opus, and more
  </Card>

  <Card title="Google" icon="google" href="/how-to/how-to/providers/openai/google">
    Gemini 2.0, Gemini 1.5 Pro and Flash
  </Card>

  <Card title="OpenRouter" icon="shuffle" href="/how-to/how-to/providers/openai/openrouter">
    Access any model through one API
  </Card>

  <Card title="DeepSeek" icon="lightbulb" href="/how-to/how-to/providers/openai/deepseek">
    DeepSeek Chat and Reasoner models
  </Card>

  <Card title="Groq" icon="bolt" href="/how-to/how-to/providers/openai/groq">
    Groq LPU Inference
  </Card>

  <Card title="Workers AI" icon="cloud" href="/how-to/how-to/providers/openai/workers-ai">
    Cloudflare Workers AI via OpenAI-compatible endpoints
  </Card>

  <Card title="Custom Providers" icon="toolbox" href="/how-to/how-to/providers/openai/custom-providers">
    Build your own provider adapters and wrappers
  </Card>

  <Card title="Meta Llama" icon="meta" href="/how-to/how-to/providers/openai/llama">
    Official Meta Llama API
  </Card>

  <Card title="xAI" icon="x" href="/how-to/how-to/providers/openai/xai">
    Grok Models via xAI API
  </Card>
</CardGroup>

## Cloud Providers

<CardGroup cols={2}>
  <Card title="Bedrock" icon="aws" href="/how-to/how-to/providers/openai/bedrock">
    AWS Bedrock - managed foundation models
  </Card>
</CardGroup>

<Tip>
  Bedrock requires an extra dependency: `pip install ai-query[bedrock]` or `uv add ai-query[bedrock]`
</Tip>

## Quick Start

Each provider requires an API key set as an environment variable:

```bash theme={null}
# OpenAI
export OPENAI_API_KEY="sk-..."

# Anthropic
export ANTHROPIC_API_KEY="sk-ant-..."

# Google
export GOOGLE_API_KEY="..."

# OpenRouter
export OPENROUTER_API_KEY="sk-or-v1-..."

# DeepSeek
export DEEPSEEK_API_KEY="sk-..."

# Groq
export GROQ_API_KEY="gsk-..."

# Workers AI
export CLOUDFLARE_ACCOUNT_ID="..."
export CLOUDFLARE_API_TOKEN="..."
```

## Usage

All providers follow the same pattern - import the factory function and use it with `generate_text()` or `stream_text()`:

```python theme={null}
from ai_query import generate_text
from ai_query.providers import openai, anthropic, google, openrouter, deepseek, groq, workers_ai

# OpenAI
result = await generate_text(model=openai("gpt-4o"), prompt="Hello!")

# Anthropic  
result = await generate_text(model=anthropic("claude-sonnet-4-20250514"), prompt="Hello!")

# Google
result = await generate_text(model=google("gemini-2.0-flash"), prompt="Hello!")

# OpenRouter (access any model)
result = await generate_text(model=openrouter("openai/gpt-4o"), prompt="Hello!")

# DeepSeek
result = await generate_text(model=deepseek("deepseek-chat"), prompt="Hello!")

# Groq (ultra-fast inference)
result = await generate_text(model=groq("llama-3.3-70b-versatile"), prompt="Hello!")

# Workers AI
result = await generate_text(model=workers_ai("@cf/moonshotai/kimi-k2.5"), prompt="Hello!")
```

## Switching Providers

One of the key benefits of ai-query is how easy it is to switch between providers:

```python theme={null}
from ai_query import generate_text
from ai_query.providers import openai, anthropic

# Just change the model - everything else stays the same!
async def generate_response(prompt: str, use_openai: bool = True):
    model = openai("gpt-4o") if use_openai else anthropic("claude-sonnet-4-20250514")
    
    result = await generate_text(
        model=model,
        prompt=prompt,
        tools=my_tools  # Same tools work with any provider
    )
    return result.text
```

## Provider Options

Each provider supports specific options through the `provider_options` parameter:

```python theme={null}
result = await generate_text(
    model=openai("gpt-4o"),
    prompt="Be creative!",
    provider_options={
        "openai": {
            "temperature": 0.9,
            "max_tokens": 1000
        }
    }
)
```

See individual provider pages for available options.

## OpenAI-Compatible Providers

OpenRouter, DeepSeek, Groq, and Workers AI use OpenAI-compatible APIs internally. This means:

* They share the same request/response format
* Provider options still use their own provider keys (`"openrouter"`, `"deepseek"`, `"groq"`, `"workers_ai"`)
* Tool calling works identically

```python theme={null}
# All four use the same underlying format
result = await generate_text(
    model=openrouter("openai/gpt-4o"),  # or deepseek(...), groq(...), workers_ai(...)
    prompt="Hello!",
    provider_options={
        "workers_ai": {"temperature": 0.7}
    }
)
```
