Using undici to make Anthropic API accessible even behind a proxy #392
r-yoshihara-j
started this conversation in
Show and tell
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Overview
With the following implementation, you can now use the Anthropic provider even in corporate proxy environments or settings that require proxy configuration. (Note: Communication through browsers launched by playwright is not covered by this implementation, so tests using addresses other than localhost may not display correctly)
Steps
1. Install undici
2. Add the following to shortest.config.ts
3. Configure environment settings according to your environment
HTTP_PROXY
HTTPS_PROXY
NO_PROXY
NODE_EXTRA_CA_CERTS
(if needed for custom certificates)Additional Information
The AI SDK uses the fetch function to communicate with the Anthropic API, and undici configures proxy settings for the global fetch function from environment variables. Therefore, following the steps above allows communication with the Anthropic API even when behind a proxy.
Beta Was this translation helpful? Give feedback.
All reactions