Skip to content

How to get binding for AI Gateway to use with ai-gateway-provider SDK? #667

@raress96

Description

@raress96

Describe the bug
Seems like there is no way to get a binding directly to the AI Gateway so I can use other models outside of Cloudflare with the ai-gateway-provider when using AI SDK v5.

workers-ai-provider works:

const workersAI = createWorkersAI({
    binding: hubAI(),
    gateway: {
      id: process.env.CLOUDFLARE_AI_GATEWAY_ID!,
    },
  });

However ai-gateway-provider I see no way to get just the gateway binding:

const aiGateway = createAiGateway({
    binding: hubAI().gateway(process.env.CLOUDFLARE_AI_GATEWAY_ID!), // TODO: How to get this binding?
    options: {
      skipCache: true, // Optional request-level settings
    },
  });
  const anthropic = createAnthropic({ apiKey: process.env.ANTHROPIC_API_KEY! });
  const model = aiGateway([
    anthropic('claude-3-7-sonnet-latest'),
  ]);

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions