Skip to content

Bug: OPENAI_BASE_URL double-suffix leads to silent 404 — document no-/v1/-in-base URL rule #628

Closed

Description

@skywalker-35

Symptom

Setting OPENAI_BASE_URL=https://api.deepseek.com/v1 (as commonly documented) causes mem::compress to silently fail with HTTP 404. Combined with another bug (#XXX), this leads to 700+ failures with 0 success and Circuit Breaker repeatedly opening.

Root Cause

buildChatUrl() (line 234) unconditionally appends /v1/chat/completions:

return `${baseUrl}/v1/chat/completions`;

This produces https://api.deepseek.com/v1/v1/chat/completions — a double /v1/v1 path.

The same issue exists for buildEmbeddingUrl() (line 238):

return `${baseUrl}/v1/embeddings`;

Scope

This affects all OpenAI-compatible providers whose documented base URLs include /v1:

  • DeepSeek: documented as https://api.deepseek.com/v1
  • SiliconFlow: documented as https://api.siliconflow.cn/v1
  • vLLM: often http://localhost:8000/v1
  • LM Studio: often http://localhost:1234/v1
  • Ollama: often http://localhost:11434/v1

Current workaround

Strip /v1 from OPENAI_BASE_URL — set https://api.deepseek.com instead of https://api.deepseek.com/v1.

Suggested fixes (pick one)

  1. Smart suffix detection — if base URL already ends with /v1, don't append it again
  2. Documentation — add a prominent warning in README and .env.example that the base URL must NOT include /v1
  3. normalizeBaseUrl() improvement — strip /v1 suffix during normalization

Fix #3 is the simplest — one line change in normalizeBaseUrl().

Related

Environment

  • agentmemory v0.9.21
  • Windows 11

Activity

  1. skywalker-35 commented on May 25, 2026

    @skywalker-35
    Author

    Related: #646 — same root cause with Zhipu (/v4 base URL without /v1/). The buildEmbeddingUrl fix proposed there (regex-checking for /v\d+$ suffix) would also fix the double-suffix case described here.

  2. rohitg00 commented on May 26, 2026

    @rohitg00
    Owner

    Fixed in v0.9.22 — https://github.com/rohitg00/agentmemory/releases/tag/v0.9.22. Thanks for the report.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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