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

# CrewAI framework integration

> Connect CrewAI to Orq.ai's AI Gateway for complete observability, built-in reliability, and access to 300+ LLMs across 20+ providers.

## AI Gateway

### Overview

CrewAI is a framework for orchestrating multi-agent teams with role-based agents, hierarchical task management, and collaborative AI workflows. Connecting CrewAI to Orq.ai's AI Gateway provides access to 300+ models with a single configuration change.

### Key Benefits

Orq.ai's AI Gateway enhances CrewAI applications with:

<CardGroup cols={2}>
  <Card title="Complete Observability" icon="chart-line">
    Track every agent task, tool use, and crew interaction with detailed traces
  </Card>

  <Card title="Built-in Reliability" icon="shield-check">
    Automatic fallbacks, retries, and load balancing for production resilience
  </Card>

  <Card title="Cost Optimization" icon="chart-pie">
    Real-time cost tracking and spend management across all AI operations
  </Card>

  <Card title="Multi-Provider Access" icon="cubes">
    Access 300+ LLMs and 20+ providers through a single, unified integration
  </Card>
</CardGroup>

### Prerequisites

Before integrating CrewAI with Orq.ai, ensure the following are in place:

* An Orq.ai account and [API Key](/docs/ai-gateway/configuration/api-keys)
* Python 3.10 to 3.12

<Info>
  To set up an API key, see [API keys & Endpoints](/docs/ai-gateway/configuration/api-keys).
</Info>

<Warning>
  **Python 3.13 and 3.14 are not yet supported.** CrewAI's `chromadb` dependency uses Pydantic v1, which breaks at import time on Python 3.13+. Use Python 3.10 to 3.12.
</Warning>

### Installation

```bash theme={"theme":{"light":"github-light","dark":"github-dark"}}
pip install crewai
```

### Configuration

Configure CrewAI to use Orq.ai's AI Gateway via the `LLM` class with a custom `base_url`:

```python Python theme={"theme":{"light":"github-light","dark":"github-dark"}}
from crewai import LLM
import os

llm = LLM(
    model="openai/gpt-4o",
    api_key=os.getenv("ORQ_API_KEY"),
    base_url="https://api.orq.ai/v3/router",
)
```

> **base\_url**: `https://api.orq.ai/v3/router`

### Basic Agent Example

```python Python theme={"theme":{"light":"github-light","dark":"github-dark"}}
from crewai import Agent, Task, Crew, LLM
import os

llm = LLM(
    model="openai/gpt-4o",
    api_key=os.getenv("ORQ_API_KEY"),
    base_url="https://api.orq.ai/v3/router",
)

researcher = Agent(
    role="Research Analyst",
    goal="Provide accurate and concise information on topics",
    backstory="Expert analyst with broad knowledge across many domains.",
    llm=llm,
)

task = Task(
    description="In two sentences, explain what machine learning is.",
    agent=researcher,
    expected_output="A concise two-sentence explanation of machine learning.",
)

crew = Crew(agents=[researcher], tasks=[task])
result = crew.kickoff()
print(result)
```

### Multi-Agent Crew

Orchestrate multiple agents with specialized roles:

```python Python theme={"theme":{"light":"github-light","dark":"github-dark"}}
from crewai import Agent, Task, Crew, LLM
import os

llm = LLM(
    model="openai/gpt-4o",
    api_key=os.getenv("ORQ_API_KEY"),
    base_url="https://api.orq.ai/v3/router",
)

researcher = Agent(
    role="Research Analyst",
    goal="Research topics and gather key facts",
    backstory="Expert at finding and summarizing information.",
    llm=llm,
)

writer = Agent(
    role="Content Writer",
    goal="Write clear, engaging content",
    backstory="Skilled at turning research into readable content.",
    llm=llm,
)

research_task = Task(
    description="Research the key benefits of renewable energy in 3 bullet points.",
    agent=researcher,
    expected_output="3 bullet points about renewable energy benefits.",
)

write_task = Task(
    description="Write a one-paragraph summary based on the research.",
    agent=writer,
    expected_output="A single paragraph summarizing renewable energy benefits.",
    context=[research_task],
)

crew = Crew(agents=[researcher, writer], tasks=[research_task, write_task])
result = crew.kickoff()
print(result)
```

### Model Selection

With **Orq.ai**, any supported model from 20+ providers can be used:

<Note>
  Always prefix model IDs with `openai/` when using **CrewAI** with the **AI Gateway**. Without it, **CrewAI** may route the request through a matching native provider client (notably its built-in Google client) that ignores `base_url`, producing misleading errors like "API key not valid". The `openai/` prefix forces the OpenAI-compatible code path, which respects `base_url` for every provider.
</Note>

```python Python theme={"theme":{"light":"github-light","dark":"github-dark"}}
from crewai import LLM
import os

# Use Claude
claude_llm = LLM(
    model="openai/anthropic/claude-sonnet-4-6",
    api_key=os.getenv("ORQ_API_KEY"),
    base_url="https://api.orq.ai/v3/router",
)

# Use Gemini
gemini_llm = LLM(
    model="openai/google-ai/gemini-2.5-flash",
    api_key=os.getenv("ORQ_API_KEY"),
    base_url="https://api.orq.ai/v3/router",
)

# Use Groq
groq_llm = LLM(
    model="openai/groq/llama-3.3-70b-versatile",
    api_key=os.getenv("ORQ_API_KEY"),
    base_url="https://api.orq.ai/v3/router",
)
```
