Skip to content
Try chatGet API key

CrewAI

CrewAI is a Python framework for orchestrating teams of role-playing agents. Bayle connects through its LLM class.

Copies this page's setup instructions, to paste into your coding agent.
Show the prompt
Help me set this up to use Bayle AI, an OpenAI-compatible API. Full guide: https://docs.bayle.ai/guides/sdks/crewai/

Goal: run my CrewAI (https://crewai.com) agents and crews on a Bayle model.

1. Install CrewAI if `python -c "import crewai"` fails. It needs Python 3.10 to 3.13 and CrewAI 1.x (older releases send an empty `stop` list that Bayle rejects with 400 invalid_request):
   pip install crewai
2. Pick a model that supports function calling, since agents call tools:
   curl -s "https://api.bayle.ai/models?type=text" \
     | jq -r '.data[] | select(.model_spec.capabilities.supportsFunctionCalling) | .id'
   Show me the list, let me choose, and use that id as MODEL_ID.
3. In my CrewAI code, build the LLM like this and pass it as `llm=` to my agents. If I have no CrewAI code yet, create a small example from the snippet:
   import os
   from crewai import LLM

   llm = LLM(
       model="openai/MODEL_ID",
       base_url="https://api.bayle.ai",
       api_key=os.environ["BAYLE_API_KEY"],
   )
   The `openai/` prefix only selects CrewAI's OpenAI-compatible client; Bayle never receives it. `llm.call("...")` also works for a single prompt outside a crew.
4. Verify by running a one-agent crew (or `llm.call("In one sentence, what is an embedding?")`) and show me the output.

Rules:
1. The base URL is https://api.bayle.ai exactly as written. Append no path to it.
2. Read the key from the BAYLE_API_KEY environment variable. Never write the key itself into a file you create, a command, a commit or the chat. Where the tool keeps the key in its own settings screen, tell me where to paste it. If BAYLE_API_KEY is not set, stop and ask me to create a key at https://chat.bayle.ai/developers and export it.
3. Take model ids only from GET https://api.bayle.ai/models (no key needed). Never guess one.
4. Finish with one real test request, show me the result and list the files you changed.
Terminal window
pip install crewai

CrewAI needs Python 3.10 to 3.13; see the official installation guide.

Don't have a Bayle key yet?Get API key
import os
from crewai import LLM, Agent, Task, Crew
llm = LLM(
model="openai/MODEL_ID",
base_url="https://api.bayle.ai",
api_key=os.environ["BAYLE_API_KEY"],
)
writer = Agent(
role="Writer",
goal="Explain technical ideas briefly",
backstory="You write one-sentence explanations.",
llm=llm,
)
task = Task(
description="Explain what an embedding is.",
expected_output="One sentence",
agent=writer,
)
print(Crew(agents=[writer], tasks=[task]).kickoff())
  • The openai/ prefix selects CrewAI’s OpenAI-compatible client. It is not part of the id Bayle receives.
  • llm.call("...") works too, for a single prompt outside a crew.

Use CrewAI 1.x. Older releases send an empty stop list on a plain call, which Bayle rejects with 400 invalid_request; if you’re stuck on one, pass stop=[...] with at least one value.

Agents call tools, so choose a model that supports them:

Terminal window
curl -s "https://api.bayle.ai/models?type=text" \
| jq -r '.data[] | select(.model_spec.capabilities.supportsFunctionCalling) | .id'