fix(relay): wrong URL for claude model in GCP Vertex AI - #1817
Conversation
WalkthroughIntroduces provider-specific URL construction in Adaptor.getRequestUrl for Vertex when using non-API-key auth, branching for Gemini, Claude, and Llama with global/regional endpoints. Retains API-key-based path behavior. Adds a default error for unsupported request modes and minor header setup formatting adjustments. Changes
Sequence Diagram(s)sequenceDiagram
autonumber
participant C as Caller
participant A as Adaptor
participant V as Vertex AI Endpoint
C->>A: getRequestUrl(model, region, keyType, mode)
alt keyType == APIKey
A->>A: Build API-key URL (publisher=google)
A-->>C: URL
else keyType != APIKey
alt Provider == Gemini
A->>A: Build URL: publishers/google/models/{model}:{suffix}<br/>global or {region}-aiplatform
A-->>C: URL
else Provider == Claude
A->>A: Build URL: publishers/anthropic/models/{model}:{suffix}<br/>global or {region}-aiplatform
A-->>C: URL
else Provider == Llama
A->>A: Build URL: {region}-aiplatform.../v1beta1/.../openapi/chat/completions
A-->>C: URL
else Unsupported
A-->>C: error("unsupported request mode")
end
end
note over A,V: Header setup unchanged (minor formatting only)
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Poem
Pre-merge checks and finishing touches✅ Passed checks (3 passed)
✨ Finishing touches
🧪 Generate unit tests
Tip 👮 Agentic pre-merge checks are now available in preview!Pro plan users can now enable pre-merge checks in their settings to enforce checklists before merging PRs.
Please see the documentation for more information. Example: reviews:
pre_merge_checks:
custom_checks:
- name: "Undocumented Breaking Changes"
mode: "warning"
instructions: |
Pass/fail criteria: All breaking changes to public APIs, CLI flags, environment variables, configuration keys, database schemas, or HTTP/GraphQL endpoints must be documented in the "Breaking Change" section of the PR description and in CHANGELOG.md. Exclude purely internal or private changes (e.g., code not exported from package entry points or explicitly marked as internal).Please share your feedback with us on this Discord post. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (2)
relay/channel/vertex/adaptor.go (2)
93-111: Gemini OAuth URL construction looks correct; consider de-duplicating region/global branches.Paths match Vertex format. Optional: extract a small helper to build base host and locations path once to avoid repetition across Gemini/Claude.
155-155: Make the error actionable and guard API‑key misuse for non‑Gemini.Improve the error text now, and (separately) block API‑key auth for Claude/Llama to avoid returning a broken Google‑publisher URL.
Apply this diff to clarify the error message:
- return "", errors.New("unsupported request mode") + return "", fmt.Errorf("unsupported request mode (mode=%d)", a.RequestMode)For the API‑key branch (Lines 138–154), add a guard:
// inside the `else` (API key) branch, before building the URL if a.RequestMode != RequestModeGemini { return "", errors.New("API key auth supports only Google publisher models; use OAuth/ADC for Claude/Llama") }I can send a focused patch if you prefer.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
relay/channel/vertex/adaptor.go(3 hunks)
🔇 Additional comments (2)
relay/channel/vertex/adaptor.go (2)
112-129: Approve: Claude-on-Vertex URLs restored and verified.
- Anthropic endpoints correct: projects/{project}/locations/{location}/publishers/anthropic/models/{model}:rawPredict and :streamRawPredict (streaming via streamRawPredict / SSE).
- Gemini (publishers/google) uses :generateContent and :streamGenerateContent.
- Express-mode / API-key examples are for publishers/google only; Anthropic/Llama require OAuth.
209-211: Approve — x-goog-user-project header is correct; no QuotaProjectID presentGood addition; Credentials (relay/channel/vertex/service_account.go) defines ProjectID but has no QuotaProjectID, so using AccountCredentials.ProjectID is appropriate — prefer QuotaProjectID if you add it later.
|
@Calcium-Ion 麻烦尽快看下这个 PR?目前最新版本 GCP Vertex AI 的 Claude 模型完全不可用。 |
|
@seefs001 辛苦帮忙看下? |
😭不是不想看,是咱没这个渠道支持claude的key不好测试呀 |
啊,Vertex AI 的 Claude 不是填表之后秒批的么?付费账号的话。 |
唉,之前没给批,总之合并了晚点发版本,麻烦帮忙看看了 |
…claude fix(relay): wrong URL for claude model in GCP Vertex AI
In a previous commit, support for the Claude model in Vertex Relay was mistakenly removed. Currently, all URLs constructed for Claude models are incorrect, preventing the Claude model from being invoked via the Vertex channel.
Relevant commit:
d8410d2#r165861666
d8410d2#r165861572
This PR attempts to restore the original URL construction logic and resolve the issue preventing Claude from functioning.
Summary by CodeRabbit
New Features
Bug Fixes