Skip to content

[Bug]: Custom OPENAI_BASE_URL drops /v1 on chat completions for OpenAI-compatible endpoints #4600

@pr0n

Description

@pr0n

Bug Description

When Hermes is configured to use a custom OpenAI-compatible endpoint through OPENAI_BASE_URL, chat completions can be sent to /chat/completions instead of /v1/chat/completions.

This breaks OpenAI-compatible providers like xAI when the base URL is configured as https://api.x.ai and the client is expected to hit https://api.x.ai/v1/chat/completions.

In our integration, Hermes produced requests equivalent to:

  • POST /chat/completions

But the working endpoint was:

  • POST /v1/chat/completions

Steps to Reproduce

  1. Set OPENAI_BASE_URL to a custom OpenAI-compatible endpoint that expects /v1 paths.
    Example: https://api.x.ai
  2. Set OPENAI_API_KEY to a valid key for that endpoint.
  3. Run Hermes in non-interactive mode:
    hermes chat -q "Reply with exactly TEST_OK" -Q
  4. Observe the upstream request path or provider response.

Expected Behavior

Hermes should send chat completions to the provider's OpenAI-compatible /v1 path, e.g.:
https://api.x.ai/v1/chat/completions

Actual Behavior

Hermes sent requests equivalent to:
https://api.x.ai/chat/completions

That returned a 404 from the upstream provider.

A direct request to https://api.x.ai/v1/chat/completions with the same key and model succeeded.

Affected Component

Configuration (config.yaml, .env, hermes setup)

Messaging Platform (if gateway-related)

No response

Operating System

macOS 15.4.1

Python Version

3.11.8

Hermes Version

v0.6.0 (v2026.3.30)

Relevant Logs / Traceback

Observed request path from adapter logs:
- incoming_path=/primary/chat/completions
- upstream_url=https://api.x.ai/chat/completions

Direct successful comparison:
- https://api.x.ai/v1/chat/completions

Root Cause Analysis (optional)

It appears Hermes's OpenAI-compatible client path construction assumes the base URL already includes /v1 for chat completions. In our environment, other successful calls worked when /v1 was included explicitly in the forwarded upstream path.

Proposed Fix (optional)

When using a custom OpenAI-compatible base URL, Hermes should normalize chat completion requests consistently so that providers expecting /v1/chat/completions work correctly.

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

    type/bugSomething isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions