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

Supported Providers

OpenAI

GPT-5, GPT-4o, and o-series reasoning models

Anthropic

Claude 3.5 Sonnet, Claude 3 Opus, and more

Google

Gemini 2.0, Gemini 1.5 Pro and Flash

OpenRouter

Access any model through one API

DeepSeek

DeepSeek Chat and Reasoner models

Groq

Groq LPU Inference

Workers AI

Cloudflare Workers AI via OpenAI-compatible endpoints

Custom Providers

Build your own provider adapters and wrappers

Meta Llama

Official Meta Llama API

xAI

Grok Models via xAI API

Cloud Providers

Bedrock

AWS Bedrock - managed foundation models
Bedrock requires an extra dependency: pip install ai-query[bedrock] or uv add ai-query[bedrock]

Quick Start

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

Usage

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

Switching Providers

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

Provider Options

Each provider supports specific options through the provider_options parameter:
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