Skip to content

AiGatewayDataset

Source: src/Cloudflare/AiGateway/Dataset.ts

A saved log filter (“dataset”) on a Cloudflare AI Gateway.

Datasets capture a slice of the gateway’s request logs (filtered by provider, model, success, cost, tokens, etc.) and serve as the input to AI Gateway evaluations. Name, enablement, and filters are all mutable in place; only moving the dataset to a different gateway forces a replacement.

Capture successful requests

const gateway = yield* Cloudflare.AiGateway("Gateway");
const dataset = yield* Cloudflare.AiGatewayDataset("SuccessLogs", {
gatewayId: gateway.gatewayId,
filters: [{ key: "success", operator: "eq", value: [true] }],
});

Capture logs for a specific model

const dataset = yield* Cloudflare.AiGatewayDataset("LlamaLogs", {
gatewayId: gateway.gatewayId,
name: "llama-traffic",
filters: [
{ key: "provider", operator: "eq", value: ["workers-ai"] },
{ key: "model", operator: "contains", value: ["llama"] },
],
});
const dataset = yield* Cloudflare.AiGatewayDataset("SuccessLogs", {
gatewayId: gateway.gatewayId,
enable: false,
filters: [{ key: "success", operator: "eq", value: [true] }],
});