Skip to content

[Bug]: Openrouter APIErrorΒ #2644

@nanoport

Description

@nanoport

Bug Description

I am getting this repeatedly. i can use curl "https://openrouter.ai/api/v1/models" and get all the models fine. my api key has credits and is valid. it just stops working.
Is there any way to add logging to APIError to suggest which error code is it? https://openrouter.ai/docs/api/reference/errors-and-debugging
I have installed using docker. could that be the issue? but this was working and it just stopped working
API call failed (attempt 1/3): APIError
πŸ”Œ Provider: openrouter Model: anthropic/claude-opus-4.6
🌐 Endpoint: https://openrouter.ai/api/v1
πŸ“ Error: Network connection lost.

Steps to Reproduce

Exception in thread Thread-17 (run_agent):
Traceback (most recent call last):
File "/root/.local/share/uv/python/cpython-3.11.15-linux-x86_64-gnu/lib/python3.11/threading.py", line 1045, in _bootstrap_inner
Nothing went wrong - all the research completed successfully! I just need to compile it into one document now. Let me write it out immediately.
╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
self.run()
File "/root/.local/share/uv/python/cpython-3.11.15-linux-x86_64-gnu/lib/python3.11/threading.py", line 982, in run
self._target(*self._args, **self._kwargs)
File "/root/.hermes/hermes-agent/cli.py", line 5509, in run_agent
result = self.agent.run_conversation(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/root/.hermes/hermes-agent/run_agent.py", line 6424, in run_conversation
raise api_error
File "/root/.hermes/hermes-agent/run_agent.py", line 5753, in run_conversation
response = self._interruptible_streaming_api_call(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/root/.hermes/hermes-agent/run_agent.py", line 3763, in _interruptible_streaming_api_call
raise result["error"]
File "/root/.hermes/hermes-agent/run_agent.py", line 3718, in _call
result["response"] = _call_chat_completions()
^^^^^^^^^^^^^^^^^^^^^^^^
File "/root/.hermes/hermes-agent/run_agent.py", line 3581, in _call_chat_completions
for chunk in stream:
File "/root/.hermes/hermes-agent/venv/lib/python3.11/site-packages/openai/_streaming.py", line 49, in iter
for item in self._iterator:
File "/root/.hermes/hermes-agent/venv/lib/python3.11/site-packages/openai/_streaming.py", line 95, in stream
raise APIError(
openai.APIError: Network connection lost.

Expected Behavior

It should work without network errors.

Actual Behavior

Exception in thread Thread-17 (run_agent):
Traceback (most recent call last):
File "/root/.local/share/uv/python/cpython-3.11.15-linux-x86_64-gnu/lib/python3.11/threading.py", line 1045, in _bootstrap_inner
Nothing went wrong - all the research completed successfully! I just need to compile it into one document now. Let me write it out immediately.
╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
self.run()
File "/root/.local/share/uv/python/cpython-3.11.15-linux-x86_64-gnu/lib/python3.11/threading.py", line 982, in run
self._target(*self._args, **self._kwargs)
File "/root/.hermes/hermes-agent/cli.py", line 5509, in run_agent
result = self.agent.run_conversation(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/root/.hermes/hermes-agent/run_agent.py", line 6424, in run_conversation
raise api_error
File "/root/.hermes/hermes-agent/run_agent.py", line 5753, in run_conversation
response = self._interruptible_streaming_api_call(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/root/.hermes/hermes-agent/run_agent.py", line 3763, in _interruptible_streaming_api_call
raise result["error"]
File "/root/.hermes/hermes-agent/run_agent.py", line 3718, in _call
result["response"] = _call_chat_completions()
^^^^^^^^^^^^^^^^^^^^^^^^
File "/root/.hermes/hermes-agent/run_agent.py", line 3581, in _call_chat_completions
for chunk in stream:
File "/root/.hermes/hermes-agent/venv/lib/python3.11/site-packages/openai/_streaming.py", line 49, in iter
for item in self._iterator:
File "/root/.hermes/hermes-agent/venv/lib/python3.11/site-packages/openai/_streaming.py", line 95, in stream
raise APIError(
openai.APIError: Network connection lost.

Affected Component

CLI (interactive chat)

Messaging Platform (if gateway-related)

N/A (CLI only)

Operating System

Ubuntu 24.04.4 LTS

Python Version

3.11.15

Hermes Version

Hermes Agent v0.4.0 (2026.3.18)

Relevant Logs / Traceback

Root Cause Analysis (optional)

Exception in thread Thread-17 (run_agent):
Traceback (most recent call last):
File "/root/.local/share/uv/python/cpython-3.11.15-linux-x86_64-gnu/lib/python3.11/threading.py", line 1045, in _bootstrap_inner
Nothing went wrong - all the research completed successfully! I just need to compile it into one document now. Let me write it out immediately.
╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
self.run()
File "/root/.local/share/uv/python/cpython-3.11.15-linux-x86_64-gnu/lib/python3.11/threading.py", line 982, in run
self._target(*self._args, **self._kwargs)
File "/root/.hermes/hermes-agent/cli.py", line 5509, in run_agent
result = self.agent.run_conversation(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/root/.hermes/hermes-agent/run_agent.py", line 6424, in run_conversation
raise api_error
File "/root/.hermes/hermes-agent/run_agent.py", line 5753, in run_conversation
response = self._interruptible_streaming_api_call(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/root/.hermes/hermes-agent/run_agent.py", line 3763, in _interruptible_streaming_api_call
raise result["error"]
File "/root/.hermes/hermes-agent/run_agent.py", line 3718, in _call
result["response"] = _call_chat_completions()
^^^^^^^^^^^^^^^^^^^^^^^^
File "/root/.hermes/hermes-agent/run_agent.py", line 3581, in _call_chat_completions
for chunk in stream:
File "/root/.hermes/hermes-agent/venv/lib/python3.11/site-packages/openai/_streaming.py", line 49, in iter
for item in self._iterator:
File "/root/.hermes/hermes-agent/venv/lib/python3.11/site-packages/openai/_streaming.py", line 95, in stream
raise APIError(
openai.APIError: Network connection lost.

Proposed Fix (optional)

No response

Are you willing to submit a PR for this?

  • I'd like to fix this myself and submit a PR

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions