CrewAI with SovereignEG
Goal: run one CrewAI agent on a SovereignEG model, then a two-agent crew.
Time: 10 minutes.
CrewAI talks to OpenAI-compatible servers through its LLM class. The only special rule: the model name must start with openai/ so CrewAI knows which API format to use.
Step 1 — Install
CrewAI needs Python 3.10 – 3.13.
pip install crewaiStep 2 — One agent
Save as crewai_hello.py:
import os
from crewai import Agent, LLM
llm = LLM(
model="openai/SovereignEG/Qwen3.8-27B-FP8", # "openai/" prefix + SovereignEG model id
base_url="https://backend.sovereigneg.com/v1",
api_key=os.environ["SOVEREIGNEG_API_KEY"],
)
agent = Agent(
role="AI Assistant",
goal="Help the user",
backstory="You are a helpful AI assistant.",
llm=llm,
)
result = agent.kickoff("Hello")
print(result.raw)python crewai_hello.pyIf your CrewAI version says the provider is unknown, add
custom_openai=Trueto theLLM(...)call. Newer versions accept theopenai/prefix alone.
Step 3 — A crew of two agents
Agents get tasks; a crew runs the tasks in order and passes results along.
import os
from crewai import Agent, Task, Crew, LLM
llm = LLM(
model="openai/SovereignEG/Qwen3.8-27B-FP8",
base_url="https://backend.sovereigneg.com/v1",
api_key=os.environ["SOVEREIGNEG_API_KEY"],
temperature=0.3,
)
researcher = Agent(
role="Researcher",
goal="Collect clear facts about {topic}",
backstory="You are careful and only state facts you are sure of.",
llm=llm,
verbose=True,
)
writer = Agent(
role="Writer",
goal="Turn facts into a short, simple article",
backstory="You write in easy English for busy readers.",
llm=llm,
verbose=True,
)
research = Task(
description="List 5 key facts about {topic}.",
expected_output="A bullet list of 5 facts.",
agent=researcher,
)
write = Task(
description="Write a 150-word article using the facts from the research task.",
expected_output="A short article with a title.",
agent=writer,
context=[research], # the writer sees the researcher's output
)
crew = Crew(agents=[researcher, writer], tasks=[research, write])
result = crew.kickoff(inputs={"topic": "the Suez Canal"})
print(result.raw)verbose=True prints every step, so you can watch the agents think and hand work to each other.
Step 4 — Give an agent a tool
from crewai.tools import tool
@tool("Exchange rate")
def exchange_rate(currency: str) -> str:
"""Return today's rate of 1 USD in the given currency."""
return {"EGP": "48.5", "SAR": "3.75"}.get(currency.upper(), "unknown")
analyst = Agent(
role="Analyst",
goal="Answer money questions",
backstory="You always use the tool for rates.",
llm=llm,
tools=[exchange_rate],
)
print(analyst.kickoff("How many EGP is 100 USD?").raw)Troubleshooting
| Problem | Fix |
|---|---|
Provider ... not found / BadRequestError | The model string must be openai/SovereignEG/Qwen3.8-27B-FP8 — keep the openai/ prefix in front of the SovereignEG id |
| Slow or long runs | Set max_iter=5 on the Agent and temperature=0 on the LLM |
| Python version error | CrewAI does not support Python 3.14 yet; use 3.12 |
Next: LlamaIndex