Skip to content

Failed to deploy with OpenRouter Key #3

@greyishsong

Description

@greyishsong

Environment

  • OS: Ubuntu 24.04 via Docker
  • Python: 3.12.3
  • Node.js: 18.19.1
  • LLM Provider: OpenRouter

Steps to Reproduce

  1. Create a container with docker run -itd --name open-pulse --network host ubuntu:24.04 /bin/bash
  2. Install dependencies following README (uv for Python packages)
  3. Create a .env file as follows: (API keys are masked)
    # LLM API Keys
    OPENROUTER_API_KEY=sk-or-v1-xxxx
    
    MODEL_ID = "openai/gpt-4o-mini"
    
    # Google Gemini API Key (for image generation)
    GOOGLE_API_KEY=AIxxxx
    
    # Custom Readers API Keys(optional)
    JINA_API_KEY=jina_xxxx
    
    # Database
    DATABASE_URL=sqlite:///./open_pulse.db
    
    # AgentOS Configuration
    AGENTOS_PORT=7777
    AGENTOS_HOST=0.0.0.0
    
    # Telemetry (optional)
    AGNO_TELEMETRY=false
    
    #for Gmail
    GOOGLE_CLIENT_ID=your_client_id_here
    GOOGLE_CLIENT_SECRET=your_client_secret_here
    GOOGLE_PROJECT_ID=your_project_id_here
    GOOGLE_REDIRECT_URI=http://localhost  # Default value
    
  4. Start the backend / frontend process in Tmux
  5. Visit http://localhost:3000 and type anything in the chat window
  6. Error message is shown on UI
    Oops! Something went wrong while streaming. 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
    

Captured Logs

Backend

NFO:     Will watch for changes in these directories: ['/root/open_pulse']
INFO:     Uvicorn running on http://0.0.0.0:7777 (Press CTRL+C to quit)
INFO:     Started reloader process [11783] using WatchFiles
__ Registered JinaWebReader
__ Registered JinaWebReader
__ Registered JinaWebReader
__ Agents created successfully
__ Workflows created successfully
__ Agents created successfully
__ Workflows created successfully
INFO:     Started server process [11827]
INFO:     Waiting for application startup.
INFO:     Application startup complete.
__ NotificationManager initialized
__ New subscriber: 0558df79-6931-4baa-821a-adaffd7c2c71 (total: 1)
INFO:     127.0.0.1:34852 - "GET /api/notifications/stream HTTP/1.1" 200 OK
__ SSE client 0558df79-6931-4baa-821a-adaffd7c2c71 connected
INFO:     127.0.0.1:34860 - "GET /health HTTP/1.1" 200 OK
INFO:     127.0.0.1:34860 - "GET /teams HTTP/1.1" 200 OK
INFO:     127.0.0.1:34860 - "GET /agents HTTP/1.1" 200 OK
INFO:     127.0.0.1:34860 - "GET /workflows HTTP/1.1" 200 OK
INFO:     127.0.0.1:34884 - "GET /sessions?type=agent&component_id=newsletter-agent&db_id=21138089-9477-5cb5-98c0-fdc32ef6f1e0 HTTP/1.1" 200 OK
INFO:     127.0.0.1:34868 - "GET /memories?user_id=default&limit=20&page=1 HTTP/1.1" 200 OK
INFO:     127.0.0.1:34860 - "GET /knowledge/content?db_id=21138089-9477-5cb5-98c0-fdc32ef6f1e0&limit=20&page=1 HTTP/1.1" 200 OK
INFO:     127.0.0.1:34860 - "GET /sessions/67b04efc-cea9-421d-a1ee-b2609259c345/runs?type=agent&db_id=21138089-9477-5cb5-98c0-fdc32ef6f1e0 HTTP/1.1" 404 Not Found
INFO:     127.0.0.1:55408 - "POST /agents/newsletter-agent/runs HTTP/1.1" 200 OK
ERROR    OPENAI_API_KEY not set. Please set the OPENAI_API_KEY environment variable.                                                                                                        
ERROR    Error from OpenAI API: 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                         
Traceback (most recent call last):
  File "/root/open_pulse/.venv/lib/python3.12/site-packages/agno/models/openai/chat.py", line 603, in ainvoke_stream
    async_stream = await self.get_async_client().chat.completions.create(
                         ^^^^^^^^^^^^^^^^^^^^^^^
  File "/root/open_pulse/.venv/lib/python3.12/site-packages/agno/models/openai/chat.py", line 156, in get_async_client
    return AsyncOpenAIClient(**client_params)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/root/open_pulse/.venv/lib/python3.12/site-packages/openai/_client.py", line 480, in __init__
    raise OpenAIError(
openai.OpenAIError: 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

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/root/open_pulse/.venv/lib/python3.12/site-packages/agno/os/router.py", line 247, in agent_response_streamer
    async for run_response_chunk in run_response:
  File "/root/open_pulse/.venv/lib/python3.12/site-packages/agno/agent/agent.py", line 1746, in _arun_stream
    async for event in self._ahandle_model_response_stream(
  File "/root/open_pulse/.venv/lib/python3.12/site-packages/agno/agent/agent.py", line 3715, in _ahandle_model_response_stream
    async for model_response_event in model_response_stream:  # type: ignore
agno.exceptions.ModelProviderError: 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

Frontend

> agent-ui@0.1.0 dev
> next dev -p 3000

   _ Next.js 15.2.3
   - Local:        http://localhost:3000
   - Network:      http://192.168.50.10:3000

 _ Starting...
 _ Ready in 1804ms
 _ Compiling / ...
 _ Compiled / in 10.9s (2618 modules)
 GET /?agent=newsletter-agent&db_id=21138089-9477-5cb5-98c0-fdc32ef6f1e0&session=67b04efc-cea9-421d-a1ee-b2609259c345 200 in 11762ms
 _ Compiled in 1017ms (1247 modules)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions