-
Notifications
You must be signed in to change notification settings - Fork 2.8k
feat(anthropic): add custom headers support for API gateways #11078
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
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
Review complete. No issues found. The implementation is clean and consistent with existing patterns:
Mention @roomote in a comment to request specific changes to this pull request or fix all unresolved issues. |
|
@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? |
Fixed the reported issues. All local checks passed. |
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. |
Review complete. No issues found. The implementation correctly adds custom headers support for the Anthropic provider:
Mention @roomote in a comment to request specific changes to this pull request or fix all unresolved issues. |
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
openAiHeaderspattern used by the OpenAI provider.Changes
Schema update (
packages/types/src/provider-settings.ts):anthropicHeaders: z.record(z.string(), z.string()).optional()to the anthropicSchemaHandler update (
src/api/providers/anthropic.ts):defaultHeadersoption when initializing the Anthropic SDK clientUI update (
webview-ui/src/components/settings/providers/Anthropic.tsx):Tests (
src/api/providers/__tests__/anthropic.spec.ts):UI Preview
The custom headers UI allows users to:
Testing
Feedback and guidance are welcome!
Important
Adds support for custom HTTP headers in the Anthropic provider, including schema, handler, UI, and test updates.
anthropicHeaderstoanthropicSchemainprovider-settings.tsfor custom HTTP headers.defaultHeadersinAnthropicHandlerconstructor inanthropic.ts.Anthropic.tsx, allowing users to add, edit, and remove headers.anthropic.spec.tsto verify custom headers are passed correctly.StandardTooltipfor custom headers UI inApiOptions.provider-filtering.spec.tsx.This description was created by
for b16fae9. You can customize this summary. It will automatically update as commits are pushed.