Skip to content

fix(gateway): honor Anthropic protocol base URLs. - #8079

Open
wucm667 wants to merge 1 commit into
Wei-Shaw:mainfrom
wucm667:fix/issue-8074-anthropic-base-url
Open

wucm667 wants to merge 1 commit into
Wei-Shaw:mainfrom
wucm667:fix/issue-8074-anthropic-base-url

Conversation

@wucm667

@wucm667 wucm667 commented Oct 14, 2026

Copy link
Copy Markdown
Contributor

问题

Adaptive accounts with different Anthropic and OpenAI-compatible upstream bases ignored api_base_urls.anthropic on the native Anthropic gateway and count_tokens paths, sending requests to the wrong upstream endpoint.

根因

These GatewayService request builders used GetBaseURL() directly, unlike the corresponding protocol-aware OpenAI gateway path. That also made Ollama Cloud capability clamping and authentication-header mode checks use the wrong base.

改动

  • Resolve the Anthropic gateway base from GetAnthropicProtocolBaseURL() with a fallback to GetBaseURL().
  • Apply the selected base consistently to native Messages, API-key passthrough, count_tokens, Ollama Cloud max_tokens clamping, and authentication-header selection.
  • Add regression coverage for adaptive base selection, provider fallback, ordinary Anthropic API-key compatibility, count_tokens, and Ollama Cloud behavior.

验证

  • 已验证:定向 GatewayService 回归测试通过。
  • 已验证:go vet -tags=unit ./internal/service 通过。
  • 已验证:go test ./internal/service -count=1 通过。
  • 已验证:go test -tags=unit ./internal/service -count=1 通过。
  • 已验证:gofmt 与 git diff --check 通过。

Fixes #8074

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug: api_base_urls 在 Anthropic 网关主转发路径被静默忽略 —— 入站 /v1/messages 时 adaptive 账号走错上游 base

1 participant