CrewAI
CrewAI is a framework for building multi-agent systems with agents, tasks, crews, flows, tools, and memory. AISIX fits at the model request boundary, while CrewAI continues to own agent coordination and task execution.
CrewAI's documented gateway-friendly path is its LLM configuration with a custom base_url. Use that setting when a CrewAI application should send OpenAI-compatible chat requests through AISIX.
This guide uses CrewAI with a custom LLM. You will configure the LLM with an AISIX proxy URL, caller API key, and model alias.
Prerequisites
Before starting, prepare the following:
- A Python environment supported by CrewAI.
- A running AISIX gateway with the proxy listener available.
- An AISIX caller API key.
- A model alias the caller API key can access through the OpenAI-Compatible API.
Configure CrewAI
Install CrewAI if the application does not already include it:
pip install crewai
Set the values that the CrewAI application will use:
# Replace with your values
export AISIX_BASE_URL="http://127.0.0.1:3000/v1"
export AISIX_API_KEY="YOUR_CALLER_API_KEY"
export AISIX_MODEL="gpt-4o-prod"
Create a CrewAI LLM with the AISIX values and pass it to agents:
import os
from crewai import Agent, Crew, LLM, Task
llm = LLM(
model=os.environ["AISIX_MODEL"],
provider="openai",
api_key=os.environ["AISIX_API_KEY"],
base_url=os.environ["AISIX_BASE_URL"],
)
writer = Agent(
role="Writer",
goal="Write concise explanations.",
backstory="You explain technical systems clearly.",
llm=llm,
)
task = Task(
description="Write one sentence about governed multi-agent systems.",
expected_output="One concise sentence.",
agent=writer,
)
crew = Crew(
agents=[writer],
tasks=[task],
)
print(crew.kickoff())
The model value is the AISIX model alias, not the upstream provider model ID. The provider value tells CrewAI to use its OpenAI-compatible client for the custom endpoint. AISIX governs the model request path, while CrewAI still owns agents, tasks, crews, flows, memory, and tool orchestration.
Verify the Integration
Run the script from the shell where the AISIX environment variables are set.
When the request succeeds, verify the following results:
- The script prints the crew output.
- AISIX records one or more successful
POST /v1/chat/completionsrequests for the selected model alias.
If you use AISIX Cloud or an on-premises managed control plane, verify the request in the managed gateway logs. For self-hosted gateways, use your configured logs, metrics, or upstream provider logs.
If the request fails, first confirm that the caller API key can access the selected model alias and that base_url points to the AISIX proxy API root with /v1.
Multi-agent workflows can issue multiple model calls for planning, delegation, tool use, memory, and task execution. Configure every agent or crew-level LLM that should use AISIX, and account for the additional requests when configuring budgets, rate limits, and usage review.
CrewAI does not currently document a stable native OpenAI Responses API configuration equivalent to the base_url path shown here. Keep the OpenAI-compatible route for AISIX unless your CrewAI version exposes and documents a Responses API client path. If it does, validate the exact agent, tool, and memory workflow before switching production traffic.
Next Steps
- OpenAI-Compatible API: review gateway-facing request behavior.
- Tool Calling: confirm tool-call behavior before enabling CrewAI tools.
- Budgets: account for multi-agent request fan-out in spend controls.