Skip to content

CrewAI ​

CrewAI's LLM class on its OpenAI path.

Connect ​

MODEL is "openai/fast", BASE is http://127.0.0.1:4010/v1 and KEY is your plugboard key.

py
llm = LLM(model=MODEL, base_url=BASE, api_key=KEY, max_completion_tokens=1024)

openai/ picks CrewAI's OpenAI path; the rest (fast) is your plugboard alias or model. base_url replaces the default whole, so include /v1; it wins over OPENAI_BASE_URL.

To stream, pass stream=True and listen for the chunks:

py
@crewai_event_bus.on(LLMStreamChunkEvent)
def on_chunk(source, event):
    if event.chunk:
        stream_chunks.append(event.chunk)

A tool is a @tool function, used by an agent in a crew task:

py
@tool("get_weather")
def get_weather(city: str) -> str:
    """Get the current weather for a city."""
    weather_calls.append(city)
    return '{"city": "%s", "forecast": "sunny", "celsius": 24}' % city
py
agent = Agent(
    role="Weather reporter",
    goal="Report the weather for the requested city using the tool",
    backstory="You answer weather questions by calling get_weather.",
    llm=llm,
    tools=[get_weather],
    verbose=False,
)
task = Task(
    description="What is the weather in Lisbon? Call get_weather for Lisbon, then answer.",
    expected_output="One sentence with the weather in Lisbon.",
    agent=agent,
)
result = Crew(agents=[agent], tasks=[task], verbose=False).kickoff()

The script with a text reply, a stream and this crew task is in examples/crewai/:

sh
cd examples/crewai
PLUGBOARD_KEY=<app key> uv run crew.py

What works ​

Text, streaming (stream=True with an LLMStreamChunkEvent listener), @tool functions in a crew, and structured output with response_format.

Limits ​

  • A crew makes several model calls per task. Set the app's rate limit with that in mind.
  • Set max_completion_tokens high enough (the example uses 1024) when the model reasons.