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