Skip to content

Commit 5827b21

Browse files
author
scuffi
committed
Add note on overriding inbuilt requests
1 parent fddee34 commit 5827b21

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

src/content/docs/sandbox/guides/proxy-requests.mdx

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,19 @@ response = requests.post(
189189

190190
The real `MY_API_KEY` is never present in the sandbox. The Worker substitutes it transparently.
191191

192+
:::note[Pointing SDKs at the proxy URL]
193+
Many API clients and SDKs default to the official API base URL. After setting up the proxy, you need to tell the library to send requests to your Worker instead. Most SDKs support an environment variable or constructor option to override the base URL.
194+
195+
For example, the Anthropic SDK reads `ANTHROPIC_BASE_URL`. Pass your proxy URL as that value and the JWT token as the API key:
196+
197+
```bash
198+
export ANTHROPIC_BASE_URL="$PROXY_BASE/proxy/anthropic"
199+
export ANTHROPIC_API_KEY="$PROXY_TOKEN"
200+
```
201+
202+
The SDK then sends all requests to your Worker proxy, which validates the token and forwards them to `api.anthropic.com` with the real key injected. Check the documentation for your API client to find the equivalent base URL setting.
203+
:::
204+
192205
## Adding more services
193206

194207
To proxy additional APIs, define another `ServiceConfig` and add it to `createProxyHandler`:

0 commit comments

Comments
 (0)