Hello DeepLearnig.AI community,
I’m taking the course Multi AI Agent Systems with CrewAI. I’m running this course locally, and I need some help with the class L3: Multi-agent Customer Support Automation
. By the way, I successfully ran the class L2: Create Agents to Research and Write an Article
locally and the AI agents successfully created the Artificial Intelligence
topic, followed by a custom topic of my choice.
This is the chunk of code I’m using to use the model phi-4 running under LM Studio:
import os
os.environ["OPENAI_API_KEY"] = "dummy_key" # Replace "dummy_key" with any value if LM Studio does not validate the key.
from crewai import LLM
phi4 = LLM(
model="openai/phi-4@q8_0",
base_url="http://192.168.15.184:1234/v1",
api_key="dummy_key"
)
But, as soon as I start Running the Crew “crew.kickoff(inputs=inputs) “, I get the error message below:
APIStatusError.__init__() missing 2 required keyword-only arguments: 'response' and 'body'
I found some discussions on GitHUB
, and CrewAI Community
, but none applied specifically to my issue. One guy didn’t have enough credits on his OpenAI account, and the other changed the embedded configuration. I followed this last approach using this chunk of code:
import os
os.environ["OPENAI_API_KEY"] = "dummy_key" # I also tried the value “phi-4@q8_0”
from crewai import LLM
phi4 = LLM(
model="openai/phi-4@q8_0",
base_url="http://192.168.15.184:1234/v1",
api_key="dummy_key"
)
embedder_config = {
"provider": "openai", # Specify the provider
"config": {
"api_key": None, # No API key needed for local setup
"api_base": "http://192.168.15.184:1234/v1", # Your local phi-4 endpoint
"model_name": "phi-4@q8_0", # Name of your local model
"model": "openai/phi-4@q8_0", # Model identifier
}
}
And then on Creating the Crew
I appended the “embedder_config”:
crew = Crew(
agents=[support_agent, support_quality_assurance_agent],
tasks=[inquiry_resolution, quality_assurance_review],
verbose=True,
memory=True,
embedder=embedder_config
)
When I executed the code again it ran properly, and the results got the responses back from my local LLM (LM Studio: phi-4). But, by analyzing the results I noticed that the CrewAI Memory Feature didn’t work as expected. Whilst Running the Crew I noticed the following errors message popping up a few times:
APIStatusError.__init__() missing 2 required keyword-only arguments: 'response' and 'body'
One of the logs from LM Studio (phi-4)
:
[LM STUDIO SERVER] [phi-4@q8_0] Generated prediction: { "id": "chatcmpl-qbwcwxm1bufvpbt820tz7", "object": "chat.completion", "created": 1737236297, "model": "phi-4@q8_0", "choices": [ { "index": 0, "logprobs": null, "finish_reason": "stop", "message": { "role": "assistant", "content": "\n**Final Answer:**\n\nDear Andrew,\n\nThank you for reaching out regarding your interest in setting up a Crew with memory using --trunctated} } ], "usage": { "prompt_tokens": 1049, "completion_tokens": 874, "total_tokens": 1923 }, "system_fingerprint": "phi-4@q8_0" }
Observations:
- The error seems related to the
rag_storage.py
file, whereAPIStatusError
is raised without required arguments (response
andbody
). - Based on the logs, it appears CrewAI might still be trying to use OpenAI embeddings for memory, despite the local LLM setup.
- When I check the LM Studio logs, it confirms that predictions (e.g., task responses) are working correctly. However, memory data is not being populated.
Steps Taken:
- Verified that LM Studio (phi-4) is running and accessible at
http://192.168.15.184:1234/v1
. - Ensured CrewAI is installed and updated (
pip install --upgrade crewai crewai-tools
). - Searched through CrewAI documentation but couldn’t find explicit steps for integrating memory with a local LLM using LM Studio (and phi-4).
Questions:
- How can I ensure that CrewAI’s memory functionalities are fully integrated with a local LLM like phi-4?
- Is there a specific configuration to set
phi-4
as the default memory provider for both short-term and entity memory? Not sure if this makes sense. - Could the
APIStatusError
be related to how CrewAI handles missing OpenAI credentials, even when a local LLM is being used?
I’d greatly appreciate any guidance or best practices for configuring CrewAI memory with a local setup. Let me know if additional details or logs are needed to diagnose the issue!
Setup Details:
- Operating System:
- Ubuntu WSL 2 (for Jupyter Notebook)
- Windows 10 (for LM Studio running phi-4)
- CrewAI Version: 0.95.0
- Phi-4 Configuration:
- Running locally on
http://192.168.15.184:1234/v1
. - Confirmed that predictions are generated successfully from phi-4 logs on LM Studio.
- API url:
http://192.168.15.184:1234
- Model’s API identifier:
phi-4@q8_0
- Supported endpoints (OpenAI-like)
GET: /v1/models
POST v1/chat/completions
POST v1/completions
POST v1/embeddings
- Running locally on
Thanks a lot,
Lúcio