-
Notifications
You must be signed in to change notification settings - Fork 93
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
New builtin fetch alpha #645
Comments
ky is a great replacement of fetch (it's a wrapper with great DX., sharing here incase you'd like to consider it. |
Thanks! However we're not considering other HTTP libraries as one great benefit of just depending on the builtin |
do you have a migration guide to support httpAgent from https://www.npmjs.com/package/https-proxy-agent ? |
@pelikhan we haven't tested Node: import Anthropic from '@anthropic-ai/sdk';
import * as undici from 'undici';
const dispatcher = new undici.ProxyAgent('http://localhost:8888');
const client = new Anthropic({
fetch(url, init = {}) {
return undici.fetch(url, {
...(init as unknown as undici.RequestInit),
dispatcher,
}) as unknown as Promise<Response>;
},
}); Bun: import Anthropic from '@anthropic-ai/sdk';
const client = new Anthropic({
fetch(url, init) {
return fetch(url, { ...init, proxy: 'http://localhost:8888' });
},
}); Deno: import Anthropic from '@anthropic-ai/sdk';
const httpClient = Deno.createHttpClient({ proxy: { url: 'http://localhost:8888' } });
const client = new Anthropic({
fetch(url, init) {
return fetch(url, { ...init, client: httpClient });
},
}); |
node-openai used this library already |
@pelikhan sorry what do you mean? |
Here are the docs about using a proxy with node-openai --> https://github.com/openai/openai-node?tab=readme-ov-file#configuring-an-https-agent-eg-for-proxies |
Ah, I think passing the |
hi @RobertCraigie , I'm wondering is the alpha vesion be stable now? We are meeting an issue of
but actually we have imported the shims before: // sort-imports-ignore
import '@anthropic-ai/sdk/shims/web';
import Anthropic from '@anthropic-ai/sdk';
// ... and we are using |
@arvinxx thanks for the report, yeah the alpha version should be stable. The shims aren't needed at all in the new version so I'm surprised you're seeing that error, maybe you have multiple versions of the SDK installed somehow? |
We've been working on an alpha version of the SDK that alongside many other cleanups, migrates from
node-fetch
to builtin fetch.You can try it out by installing the
0.34.0-alpha.0
version:The core happy path of the SDK remains the same, your existing method calls should just work! However you may run into typing issues as we now expect that
fetch
is defined as a global.There are many other small breaking changes which you may run into, we'll share a full migration guide as soon as possible.
Please share feedback on anything you think could be improved or if you run into any issues! Hope this is a nice early present for you all :)
Important
Unfortunately we cannot guarantee support over the holiday break (December 20th - January 6th inclusive) but we will go through every comment as soon as possible.
The text was updated successfully, but these errors were encountered: