crawl4ai icon indicating copy to clipboard operation
crawl4ai copied to clipboard

[Bug]: Craw4AI always falls back to OpenAI API despite using local Ollama provider

Open viphoangdep opened this issue 6 months ago • 5 comments

crawl4ai version

0.6.3

Expected Behavior

llm_config = LLMConfig( provider="ollama/llama3", base_url="http://localhost:11434"

)
llm_strat = LLMExtractionStrategy(
    config = llm_config....)

When configuring Craw4AI to use a local LLM provider (e.g., ollama/llama3 with base_url="http://localhost:11434"), the system still attempts to use the OpenAI API key and throws authentication errors (401 invalid API key).

Current Behavior

21:32:03 - LiteLLM:DEBUG: main.py:5264 - openai.py: Received openai error - The api_key client option must be set either by passing api_key to the client or by setting the OPENAI_API_KEY environment variable 21:32:03 - LiteLLM:DEBUG: utils.py:337 - RAW RESPONSE: The api_key client option must be set either by passing api_key to the client or by setting the OPENAI_API_KEY environment variable

Is this reproducible?

Yes

Inputs Causing the Bug


Steps to Reproduce


Code snippets


OS

Windows 11

Python version

3.11.11

Browser

No response

Browser version

No response

Error logs & Screenshots (if applicable)

No response

viphoangdep avatar Jun 01 '25 14:06 viphoangdep