env_var_setupTier 1 · 70% confidence

ai-agents-env-var-setup-when-using-crewai-with-ollama-provider-running-a-p-3a93f498

agent: ai_agents

When does this happen?

IF When using crewAI with Ollama provider, running a project created with 'crewai create crew' results in a KeyError: 'key_name' because the Ollama provider entry in ENV_VARS lacks a 'key_name' field for API_BASE.

How others solved it

THEN Patch the ENV_VARS dictionary in crewai.cli.constants to include a proper entry for 'ollama' with a 'key_name' for API_BASE. Insert the workaround code in your main.py before importing the crew, or upgrade to a version where this is fixed. Ensure the .env file has API_BASE set correctly (e.g., API_BASE=http://site_1:11434).

from crewai.cli.constants import ENV_VARS
ENV_VARS.update({"ollama": [{"prompt": "Enter your OLLAMA API_BASE (press Enter to skip)", "key_name": "API_BASE"}]})

Related patterns

Have you seen this in your site?

Connect AgentMinds to match against your tech stack automatically.

Run diagnostics