Skip to content

fix(relay): wrong URL for claude model in GCP Vertex AI - #1817

Merged
seefs001 merged 2 commits into
QuantumNous:alphafrom
wzxjohn:hotfix/relay_vertex_claude
Sep 30, 2025
Merged

fix(relay): wrong URL for claude model in GCP Vertex AI#1817
seefs001 merged 2 commits into
QuantumNous:alphafrom
wzxjohn:hotfix/relay_vertex_claude

Conversation

@wzxjohn

@wzxjohn wzxjohn commented Sep 16, 2025

Copy link
Copy Markdown
Contributor

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

    • Expanded Vertex integration to support multiple model families (Gemini, Claude, Llama) with region-aware routing, including global and regional endpoints.
    • Preserves existing API key–based behavior while enhancing credential-based flows.
  • Bug Fixes

    • Improved handling of unsupported request modes with clear errors.
    • Minor header setup consistency improvements.

@coderabbitai

coderabbitai Bot commented Sep 16, 2025

Copy link
Copy Markdown
Contributor

Walkthrough

Introduces 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

Cohort / File(s) Summary
Vertex adaptor URL construction
relay/channel/vertex/adaptor.go
Reworked getRequestUrl to branch by provider (Gemini, Claude, Llama) under non-API-key auth: constructs global/regional publisher URLs for Gemini (google) and Claude (anthropic); preserves Llama v1beta1 openapi/chat/completions endpoint; adds default unsupported-mode error; minor non-functional SetupRequestHeader formatting; API-key path unchanged.

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)
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Poem

I hop between clouds where endpoints lie,
Stitching paths for bots that try,
Gemini gleams, Claude hums low,
Llama trots where betas go.
With keys in paw and routes aligned,
I nibble errors, leave none behind. 🐇✨

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed The title "fix(relay): wrong URL for claude model in GCP Vertex AI" succinctly identifies the primary change—fixing the Claude model URL in the Vertex Relay—and names the affected subsystem and provider, making the intent clear to a reviewer. It is specific, concise, and not vague, so it accurately represents the changes described in the PR summary.
Docstring Coverage ✅ Passed No functions found in the changes. Docstring coverage check skipped.
✨ Finishing touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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.

  • Built-in checks – Quickly apply ready-made checks to enforce title conventions, require pull request descriptions that follow templates, validate linked issues for compliance, and more.
  • Custom agentic checks – Define your own rules using CodeRabbit’s advanced agentic capabilities to enforce organization-specific policies and workflows. For example, you can instruct CodeRabbit’s agent to verify that API documentation is updated whenever API schema files are modified in a PR. Note: Upto 5 custom checks are currently allowed during the preview period. Pricing for this feature will be announced in a few weeks.

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

📥 Commits

Reviewing files that changed from the base of the PR and between 4ac7d94 and f2e9fd7.

📒 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 present

Good 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.

@wzxjohn

wzxjohn commented Sep 19, 2025

Copy link
Copy Markdown
Contributor Author

@Calcium-Ion 麻烦尽快看下这个 PR?目前最新版本 GCP Vertex AI 的 Claude 模型完全不可用。

@wzxjohn

wzxjohn commented Sep 30, 2025

Copy link
Copy Markdown
Contributor Author

@seefs001 辛苦帮忙看下?

@seefs001

Copy link
Copy Markdown
Collaborator

@seefs001 辛苦帮忙看下?

😭不是不想看,是咱没这个渠道支持claude的key不好测试呀

@seefs001
seefs001 merged commit aab82f2 into QuantumNous:alpha Sep 30, 2025
@wzxjohn

wzxjohn commented Sep 30, 2025

Copy link
Copy Markdown
Contributor Author

@seefs001 辛苦帮忙看下?

😭不是不想看,是咱没这个渠道支持claude的key不好测试呀

啊,Vertex AI 的 Claude 不是填表之后秒批的么?付费账号的话。

@wzxjohn
wzxjohn deleted the hotfix/relay_vertex_claude branch September 30, 2025 03:41
@seefs001

Copy link
Copy Markdown
Collaborator

@seefs001 辛苦帮忙看下?

😭不是不想看,是咱没这个渠道支持claude的key不好测试呀

啊,Vertex AI 的 Claude 不是填表之后秒批的么?付费账号的话。

唉,之前没给批,总之合并了晚点发版本,麻烦帮忙看看了

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.

2 participants