# CrewAI

Source: https://staging-docs.aiand.com/integrations/crewai/

[CrewAI](https://docs.crewai.com/) builds role-playing multi-agent systems. It uses LiteLLM under the hood, which natively supports OpenAI-compatible providers — so ai& works by setting two env vars.

## Setup

```bash
pip install crewai
```

```bash
export OPENAI_API_KEY="sk-your-aiand-api-key"
export OPENAI_API_BASE="https://api.aiand.com/v1"
```

## A two-agent crew

```python
from crewai import Agent, Task, Crew, LLM

llm = LLM(model="openai/openai/gpt-oss-120b")

researcher = Agent(
    role="Researcher",
    goal="Find accurate information",
    backstory="An experienced research analyst.",
    llm=llm,
)

writer = Agent(
    role="Writer",
    goal="Write a clear summary",
    backstory="A concise technical writer.",
    llm=llm,
)

research_task = Task(
    description="Research the city of Tokyo — population, history, notable features.",
    expected_output="Bullet points covering the key facts.",
    agent=researcher,
)

write_task = Task(
    description="Write a 100-word summary based on the research.",
    expected_output="A 100-word paragraph.",
    agent=writer,
)

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

## With tools

```python
from crewai.tools import tool

@tool("get_weather")
def get_weather(city: str) -> str:
    """Get current weather for a city."""
    return f"Sunny in {city}, 22°C"

researcher = Agent(
    role="Weather Reporter",
    goal="Answer weather questions",
    backstory="A meteorologist.",
    llm=llm,
    tools=[get_weather],
)
```

<Aside type="note">
  Note the double prefix in `LLM(model="openai/openai/gpt-oss-120b")` — LiteLLM uses `openai/` to mean "OpenAI-compatible provider," and `openai/gpt-oss-120b` is the actual ai& model id.
</Aside>
