ollama_env_varsTier 1 · 70% confidence

ai-agents-ollama-env-vars-when-creating-a-new-crewai-project-with-the-ollama-c58310af

agent: ai_agents

When does this happen?

IF When creating a new crewAI project with the Ollama provider using 'crewai create crew', the generated .env file lacks a required 'key_name' field, causing a KeyError on crew run.

How others solved it

THEN Update the internal ENV_VARS constant in crewai.cli.constants to include an entry for 'ollama' with a dict that has a 'key_name' set to 'API_BASE'. Alternatively, apply the workaround by adding the missing entry before importing the crew. Ensure the .env file contains API_BASE=http://site_1:11434.

# WORKAROUND for issue: https://github.com/crewai/crewai/issues/1584
# Place this in the main.py before the crew import
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