Skip to content

LLM ChatOpenAI connection test failed. #566

Open
@JAVazquez007

Description

@JAVazquez007

Upon launching agent. verified key in .env via script.....

import openai
import os
from dotenv import load_dotenv

def test_api_key():
load_dotenv()
api_key = os.getenv("OPENAI_API_KEY")

if not api_key:
    print("❗ OPENAI_API_KEY not found in .env file.")
    return

client = openai.OpenAI(api_key=api_key)

try:
    print("Testing API key...")
    models = client.models.list()
    print(f"API key is valid. {len(models.data)} models available:\n")

    for model in models.data:
        print(f"- {model.id}")

except openai.AuthenticationError:
    print("❌ Invalid API key.")
except Exception as e:
    print(f"⚠️ An error occurred: {e}")

if name == "main":
test_api_key()


Result from script:

Testing API key...
API key is valid. 64 models available:

  • gpt-4o-audio-preview-2024-12-17
  • dall-e-3
  • dall-e-2
  • gpt-4o-audio-preview-2024-10-01
  • gpt-4-turbo-preview
  • text-embedding-3-small
  • gpt-4-1106-preview
  • gpt-4-turbo
  • gpt-4-turbo-2024-04-09
  • gpt-4.1-nano
  • gpt-4.1-nano-2025-04-14
  • gpt-4o-realtime-preview-2024-10-01
  • gpt-4o-realtime-preview
  • babbage-002
  • gpt-4....

Error from Browser-Use WebUI

INFO [src.webui.components.browser_use_agent_tab] Submit button clicked for new task.
INFO [src.webui.components.browser_use_agent_tab] Initializing LLM: Provider=openai, Model=gpt-4.1-nano-2025-04-14, Temp=0.6
INFO [src.webui.components.browser_use_agent_tab] Launching new browser instance.
INFO [src.webui.components.browser_use_agent_tab] Creating new browser context.
INFO [src.webui.components.browser_use_agent_tab] Initializing new agent for task: go to google.com and type 'openai" click search and return the first url
INFO [agent] 🧠 Starting an agent with main_model=gpt-4.1-nano-2025-04-14 +tools +vision +memory, planner_model=None, extraction_model=gpt-4.1-nano-2025-04-14
ERROR [agent]

❌ LLM ChatOpenAI connection test failed. Check that OPENAI_API_KEY is set correctly in .env and that the LLM API account has sufficient funding.

Connection error.

:241: DeprecationWarning: builtin type SwigPyPacked has no module attribute
:241: DeprecationWarning: builtin type SwigPyObject has no module attribute
:241: DeprecationWarning: builtin type swigvarlink has no module attribute
INFO [mem0.vector_stores.faiss] Loaded FAISS index from /home/jim/.mem0/migrations_faiss/mem0_migrations.faiss with 19 vectors
INFO [mem0.vector_stores.faiss] Inserted 1 vectors into collection mem0_migrations
INFO [agent] 🚀 Starting task: go to google.com and type 'openai" click search and return the first url
INFO [agent] 📍 Step 1
ERROR [agent] ❌ Result failed 1/3 times:

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions