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

# CrewAI

> Run a CrewAI task with a RedPill-backed LLM

CrewAI uses LiteLLM internally. Prefix the RedPill model ID with `openai/` so LiteLLM selects its
OpenAI-compatible adapter.

## Install

```bash theme={null}
pip install crewai
export REDPILL_AI_API_KEY="YOUR_API_KEY"
```

## Build a crew

```python theme={null}
import os

from crewai import Agent, Crew, LLM, Process, Task


llm = LLM(
    model="openai/z-ai/glm-5.2",
    base_url="https://api.redpill.ai/v1",
    api_key=os.environ["REDPILL_AI_API_KEY"],
    temperature=0,
)

reviewer = Agent(
    role="Code reviewer",
    goal="Identify correctness and security risks",
    backstory="A senior engineer who reports concrete findings.",
    llm=llm,
    max_iter=3,
)

review = Task(
    description="Review the supplied change summary: {change_summary}",
    expected_output="A prioritized list of findings with suggested fixes.",
    agent=reviewer,
)

crew = Crew(agents=[reviewer], tasks=[review], process=Process.sequential)
result = crew.kickoff(inputs={"change_summary": "Adds token refresh without retry limits."})
print(result)
```

The first `openai/` segment selects the LiteLLM provider. RedPill receives `z-ai/glm-5.2` as the
model ID.

## Production checks

Keep `max_iter` bounded and set timeouts around the crew run. Select a model that declares tool
support before adding tools. For confidential-only calls, change `base_url` to
`https://tee.redpill.ai/v1` and use an `is_tee: true` model.

## Troubleshooting

| Symptom                          | Check                                                            |
| -------------------------------- | ---------------------------------------------------------------- |
| LiteLLM cannot select a provider | Keep the `openai/` prefix before the RedPill model ID.           |
| Authentication fails             | Confirm `REDPILL_AI_API_KEY` is available to the Python process. |
| Crew loops too long              | Reduce `max_iter` and add task-level execution limits.           |

## References

* [CrewAI LLM connections](https://docs.crewai.com/en/learn/llm-connections)
* [RedPill function calling](/guides/function-calling)
