Skip to content

feat: support claude custom url#3676

Closed
ThxCode-Chen wants to merge 0 commit intoalibaba:mainfrom
ThxCode-Chen:main
Closed

feat: support claude custom url#3676
ThxCode-Chen wants to merge 0 commit intoalibaba:mainfrom
ThxCode-Chen:main

Conversation

@ThxCode-Chen
Copy link
Copy Markdown
Contributor

Ⅰ. Describe what this PR did

Synchronizes the claudeCustomUrl configuration support for the Claude (Anthropic) provider in plugins/wasm-go/extensions/ai-proxy with the implementation used in the main Higress tree.

provider/provider.go: Adds the claudeCustomUrl field on ProviderConfig (with metadata comments) and parses it from JSON in FromJson.

provider/claude.go: When claudeCustomUrl is set, parses host and path (supports plain origin, path prefix, or a direct /v1/messages URL), adjusts capabilities accordingly, stores custom domain for outbound requests, and keeps the default behavior when the field is empty. TransformRequestHeaders uses the custom host when configured; otherwise it still uses resolveDomain("", claudeDomain) so providerDomain and other domain overrides keep working.

test/claude.go: Adds WASM integration-style tests for config load and for :authority being rewritten to the custom host.

Ⅱ. Does this pull request fix one issue?

No. This is a parity / sync change; there is no linked issue.

Ⅲ. Why don't you add test cases (unit test/integration test)?

Integration coverage was added in test/claude.go (plugin config + request headers). No extra unit tests were added in provider/claude_test.go because the main Higress reference implementation does not add separate CreateProvider / claudeCustomUrl unit tests there either; behavior is covered at the integration layer.

Ⅳ. Describe how to verify it

From plugins/wasm-go/extensions/ai-proxy:
go test ./provider/... ./test/... -count=1
Manually: configure a Claude provider with claudeCustomUrl (e.g. https://custom.example.com/anthropic) and confirm upstream requests use the expected Host and path for chat/messages traffic.

Ⅴ. Special notes for reviews

Interaction with providerDomain: Custom URL host wins when claudeCustomUrl is set; when it is unset, existing resolveDomain behavior is unchanged.

Capabilities: Logic matches the main repo: a direct messages endpoint only overrides message-related paths; otherwise the configured path acts as a prefix for default capability paths.

Ⅵ. AI Coding Tool Usage Checklist (if applicable)

Please check all applicable items:

  • [√ ] For new standalone features (e.g., new wasm plugin or golang-filter plugin):

    • I have created a design/ directory in the plugin folder
    • I have added the design document to the design/ directory
    • I have included the AI Coding summary below
  • For regular updates/changes (not new plugins):

    • I have provided the prompts/instructions I gave to the AI Coding tool below
    • I have included the AI Coding summary below

AI Coding Prompts (for regular updates)

AI Coding Summary

@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented Apr 2, 2026

Codecov Report

❌ Patch coverage is 93.33333% with 4 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
...ins/wasm-go/extensions/ai-proxy/provider/claude.go 84.61% 2 Missing and 2 partials ⚠️

📢 Thoughts on this report? Let us know!

@CH3CHO
Copy link
Copy Markdown
Collaborator

CH3CHO commented Apr 2, 2026

Please sign the CLA. Thanks. @ThxCode-Chen

@ThxCode-Chen
Copy link
Copy Markdown
Contributor Author

/review

@ThxCode-Chen
Copy link
Copy Markdown
Contributor Author

Please sign the CLA. Thanks. @ThxCode-Chen

I have signed the CLA, but it looks not completed yet. Can you help me check where is wrong?@CH3CHO

@CH3CHO
Copy link
Copy Markdown
Collaborator

CH3CHO commented Apr 3, 2026

Please sign the CLA. Thanks. @ThxCode-Chen

I have signed the CLA, but it looks not completed yet. Can you help me check where is wrong?@CH3CHO

I've re-triggered the CLA check. It looks good now. Thanks.

@ThxCode-Chen ThxCode-Chen requested a review from CH3CHO April 3, 2026 13:19
Copy link
Copy Markdown
Collaborator

@CH3CHO CH3CHO left a comment

Choose a reason for hiding this comment

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

LGTM

@ThxCode-Chen
Copy link
Copy Markdown
Contributor Author

Please help review the code. Thanks.@johnlanni @rinfx @wydream

@CH3CHO
Copy link
Copy Markdown
Collaborator

CH3CHO commented Apr 8, 2026

Please resolve conflicts. @ThxCode-Chen

@wydream
Copy link
Copy Markdown
Collaborator

wydream commented Apr 8, 2026

@ThxCode-Chen #3686 has already implemented the claudeCustomUrl capability via providerDomain and providerBasePath.

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.

4 participants