Skip to content

workers-ai-provider does not support ai-gateway even though it's stated in the README.md it does #403

@leodalcin

Description

@leodalcin

I've done some local tests and found out calls done through workers-ai-provider do not use the gateway config option.

As you can see the library states gateways are supported here: https://github.com/cloudflare/ai/tree/main/packages/workers-ai-provider#ai-gateway

It seems like the gateway config is ignored in this line:
https://github.com/cloudflare/ai/blob/main/packages/workers-ai-provider/src/utils.ts#L111

This results in no observability through the AI gateway.

I've tested this using AI SDK in conjunction with the provider library as follows:

import { embedMany } from 'ai';
import { createWorkersAI } from 'workers-ai-provider';

const workersai = createWorkersAI({
    accountId: 'id',
    apiKey: 'key',
    gateway: { id: 'gateway-name' }
  });
const embeddingModel = workersai.embedding('embedding model name', { gateway: { id: 'gateway-name' } });
await embedMany({
  model: embeddingModel,
  values: texts,
});

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