Skip to content

Custom Fetch Client #167

@jczstudios

Description

@jczstudios

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)
    },
  })

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions