new·The score now tells you which way it movedA brain's exam only ever grows: its own material writes questions, and so does every question a real caller asked and did not get answered. The score is a percentage over that growing set, so a brain that learned more could post a smaller number — and this week three did. One of them answered two MORE questions than the week before and showed eighteen points less. Printed as a single percentage, that reads as decline to a reader and as punishment to anyone who contributes material.all news →
mozg.beta
Sign in

AI SDK · Providers · all subjects

cloudflare-ai-gateway/setup

8 notes, read out of this brain and free to use. Each one was extracted from a source and is re-checked against its exam.

Cloudflare AI Gateway provider module name

The Cloudflare AI Gateway Provider is available in the `ai-gateway-provider` module.

Cloudflare AI Gateway provider creation function

Create an aigateway provider instance using the `createAiGateway` function.

Cloudflare AI Gateway API key authentication parameters

API key authentication requires: accountId (Cloudflare account ID), gateway (gateway name), and optionally apiKey (Cloudflare API key, only required if gateway has authentication enabled).

Cloudflare AI Gateway binding authentication for Workers

For Cloudflare Workers, configure an AI binding in wrangler.toml with `[AI] binding = "AI"`, then create the provider instance using `createAiGateway({ binding: env.AI.gateway('my-gateway') })`.

Cloudflare AI Gateway API key authentication example

import { createAiGateway } from 'ai-gateway-provider'; const aigateway = createAiGateway({ accountId: 'your-cloudflare-account-id', gateway: 'your-gateway-name', apiKey: 'you••••••ey', options: { skipCache: true, }, });

Cloudflare AI Gateway Worker binding example

import { createAiGateway } from 'ai-gateway-provider'; const aigateway = createAiGateway({ binding: env.AI.gateway('my-gateway'), options: { skipCache: true, }, });

Cloudflare AI Gateway multi-model fallback example

import { createAiGateway } from 'ai-gateway-provider'; import { createOpenAI } from '@ai-sdk/openai'; import { createAnthropic } from '@ai-sdk/anthropic'; const aigateway = createAiGateway({ accountId: 'your-cloudflare-account-id', gateway: 'your-gateway-name', apiKey: 'you••••••ey', }); const openai = createOpenAI({ apiKey: 'openai-api-key' }); const anthropic = createAnthropic({ apiKey: 'ant••••••ey' }); const model = aigateway([ anthropic('claude-haiku-4-5'), openai('gpt-4o-mini'), ]);

Cloudflare AI Gateway error handling

The provider throws two custom errors: AiGatewayUnauthorizedError (invalid or missing API key when authentication is enabled) and AiGatewayDoesNotExist (specified Cloudflare AI Gateway does not exist).

Give your agent this brain