Enabled when both
CLOUDFLARE_API_TOKEN and CLOUDFLARE_ACCOUNT_ID are set in your environment.Overview
The@standardagents/cloudflare package provides a Cloudflare Workers AI provider factory for Standard Agents. It targets Cloudflare’s OpenAI-compatible Chat Completions endpoint and adds typed providerOptions, model discovery via Cloudflare’s models API, and request inspection support in the admin UI.
Key Features
- Direct integration with Cloudflare’s account-scoped
/ai/v1/chat/completionsendpoint - Typed
providerOptionsfor Workers AI request parameters - Remote model discovery with search and pagination for
@cf/...chat models in the builder UI - Tool calling, structured outputs, streaming, and multimodal model support where documented
Installation
npm
pnpm
yarn
Quick Start
agents/models/workers_fast.ts
Provider Factory
Provider Options
Available Options
| Option | Type | Description |
|---|---|---|
baseUrl | string | Override the default OpenAI-compatible base URL |
seed | number | Best-effort deterministic sampling seed |
user | string | End-user identifier |
logprobs | boolean | Return token log probabilities |
top_logprobs | number | Number of top logprobs to return |
frequency_penalty | number | Frequency penalty forwarded to the chat endpoint |
presence_penalty | number | Presence penalty forwarded to the chat endpoint |
By default, the provider builds the base URL from
CLOUDFLARE_ACCOUNT_ID. Set providerOptions.baseUrl if you want to route through a different OpenAI-compatible endpoint such as AI Gateway.Model IDs
Workers AI model IDs are sent directly, for example:@cf/meta/llama-3.1-8b-instruct@cf/meta/llama-4-scout-17b-16e-instruct@cf/openai/gpt-oss-120b@cf/qwen/qwen3-30b-a3b-fp8@cf/zhipu-ai/glm-4.7-flash
Capabilities
The provider exposes model capabilities for the bundled Workers AI fallback catalog, including:supportsImagesfor multimodal models like Llama 3.2 Vision and Llama 4 ScoutsupportsToolCallsfor models Cloudflare documents with function callingsupportsJsonModeandsupportsStreamingfor the OpenAI-compatible chat APIreasoningLevelsfor reasoning-focused models like@cf/openai/gpt-oss-120b
Environment Setup
.dev.vars
CLOUDFLARE_ACCOUNT_ID should be set as an environment variable in your worker configuration.
Notes
- The provider uses Cloudflare’s OpenAI-compatible
/chat/completionsAPI. - Authentication uses a Cloudflare API token, not a traditional provider-specific API key.
- The current package focuses on text-generation/chat-completions models, not embeddings or image generation.
Related
Models
Core model concepts
Cerebras Provider
Compare with Cerebras
OpenRouter Provider
Compare with OpenRouter