Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@roomote
Copy link
Contributor

@roomote roomote bot commented Jan 29, 2026

This PR attempts to address Issue #10939.

Summary

Adds support for custom HTTP headers in the Anthropic provider, enabling users to pass headers required by API gateways like Portkey. This mirrors the existing openAiHeaders pattern used by the OpenAI provider.

Changes

  1. Schema update (packages/types/src/provider-settings.ts):

    • Added anthropicHeaders: z.record(z.string(), z.string()).optional() to the anthropicSchema
  2. Handler update (src/api/providers/anthropic.ts):

    • Pass custom headers via the defaultHeaders option when initializing the Anthropic SDK client
  3. UI update (webview-ui/src/components/settings/providers/Anthropic.tsx):

    • Added custom headers UI matching the OpenAI pattern
    • Users can add, edit, and remove custom header key-value pairs
  4. Tests (src/api/providers/__tests__/anthropic.spec.ts):

    • Added tests to verify custom headers are passed to the SDK

UI Preview

The custom headers UI allows users to:

  • Add new headers using the + button
  • Enter header name and value in text fields
  • Remove headers using the trash icon
  • Headers are persisted in provider settings

Testing

  • All existing tests pass
  • TypeScript compilation succeeds
  • Lint checks pass

Feedback and guidance are welcome!


Important

Adds support for custom HTTP headers in the Anthropic provider, including schema, handler, UI, and test updates.

  • Behavior:
    • Adds anthropicHeaders to anthropicSchema in provider-settings.ts for custom HTTP headers.
    • Passes custom headers via defaultHeaders in AnthropicHandler constructor in anthropic.ts.
  • UI:
    • Adds UI for custom headers in Anthropic.tsx, allowing users to add, edit, and remove headers.
  • Tests:
    • Adds tests in anthropic.spec.ts to verify custom headers are passed correctly.
  • Misc:
    • Adds StandardTooltip for custom headers UI in ApiOptions.provider-filtering.spec.tsx.

This description was created by Ellipsis for b16fae9. You can customize this summary. It will automatically update as commits are pushed.

This change adds support for custom HTTP headers in the Anthropic provider,
enabling users to pass headers required by API gateways like Portkey.

Changes:
- Add anthropicHeaders field to provider settings schema
- Pass defaultHeaders to Anthropic SDK client constructor
- Add custom headers UI in Anthropic settings (matching OpenAI pattern)
- Add tests for custom headers functionality

Closes #10939
@roomote
Copy link
Contributor Author

roomote bot commented Jan 29, 2026

Rooviewer Clock   See task on Roo Cloud

Review complete. No issues found.

The implementation is clean and consistent with existing patterns:

  • Schema update correctly adds anthropicHeaders field
  • Handler properly passes headers via SDK's defaultHeaders option
  • UI mirrors the OpenAI compatible provider pattern
  • Tests adequately cover the new functionality
Previous reviews

Mention @roomote in a comment to request specific changes to this pull request or fix all unresolved issues.

@yunhailuo
Copy link

@roomote you seem to have failed checks. It seems to me related to ui. I wonder if you can learn from openai provide about how to configure the ui for custom header and update the code (then update tests if needed) to fix the failure?

@roomote
Copy link
Contributor Author

roomote bot commented Jan 29, 2026

Fixaroo Clock   See task on Roo Cloud

Fixed the reported issues. All local checks passed.

View commit | Revert commit

@yunhailuo
Copy link

I tested this pr just now and it solved the problem in my specific use case in #10939. Thank you. What's next or how should we proceed here? @roomote

@roomote
Copy link
Contributor Author

roomote bot commented Jan 29, 2026

Planneroo Clock   See task on Roo Cloud

Thank you for testing and confirming this works for your use case! The review found no issues with the implementation.

I have marked this PR as ready for review. The next step is for a maintainer to review and approve the changes, after which it can be merged.

@roomote roomote bot marked this pull request as ready for review January 29, 2026 16:53
@roomote roomote bot requested review from cte, jr and mrubens as code owners January 29, 2026 16:53
@dosubot dosubot bot added size:L This PR changes 100-499 lines, ignoring generated files. Enhancement New feature or request labels Jan 29, 2026
@roomote
Copy link
Contributor Author

roomote bot commented Jan 29, 2026

Rooviewer Clock   See task on Roo Cloud

Review complete. No issues found.

The implementation correctly adds custom headers support for the Anthropic provider:

  • Schema properly extends anthropicSchema with anthropicHeaders field
  • Handler passes headers via SDK's defaultHeaders option
  • UI follows the established OpenAICompatible pattern with debounced state sync
  • Tests adequately cover the new functionality

Mention @roomote in a comment to request specific changes to this pull request or fix all unresolved issues.

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

Labels

Enhancement New feature or request size:L This PR changes 100-499 lines, ignoring generated files.

Projects

Status: Triage

Development

Successfully merging this pull request may close these issues.

2 participants