portkey-node-sdk
portkey-node-sdk copied to clipboard
Custom Fetch Client
Thoughts on support for a custom Fetch implementation? For example, in my Cloudflare worker, I'd like to use a worker to worker binding to call my Portkey gateway. I am able to do this with the Open AI like this:
const portkey = new OpenAI({
baseURL: baseUrl ?? env.PORTKEY_URL,
apiKey: provider === 'openai' ? env.OPENAI_API_KEY : env.ANTHROPIC_API_KEY,
defaultHeaders: createHeaders({
provider: provider,
}),
fetch: (url, options) => {
if (env.AI_GATEWAY) {
return env.AI_GATEWAY.fetch(url, options)
}
return fetch(url, options)
},
})