Skip to main content
The Workers AI provider lets you call Cloudflare-hosted models through the OpenAI-compatible Workers AI endpoints.

Setup

Set your Cloudflare account ID and API token:
workers_ai() also accepts CLOUDFLARE_AUTH_TOKEN and CLOUDFLARE_API_KEY.

Usage

Embeddings

Available Models

Workers AI model IDs use Cloudflare’s @cf/... format. Browse the full catalog in the Cloudflare Workers AI models docs.

Custom Configuration

If you want to route through AI Gateway or another compatible base URL, pass base_url explicitly:
You can also pass account_id directly instead of relying on CLOUDFLARE_ACCOUNT_ID:

Tool Calling

Workers AI uses Cloudflare’s OpenAI-compatible chat completions API, so tool calling works through the same ai-query tool loop:

Cloudflare Workers Runtime

If you use the Cloudflare adapter, ai-query now forwards CLOUDFLARE_ACCOUNT_ID and Cloudflare token env bindings into provider configuration automatically, so workers_ai() can be used inside Durable Objects and Workers-backed agents.