@standardagents/cloudflare
Cloudflare Workers AI provider package for Standard Agents using the OpenAI-compatible Chat Completions API
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.
- 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
npm install @standardagents/cloudflarepnpm
pnpm add @standardagents/cloudflareyarn
yarn add @standardagents/cloudflareQuick Start
import { defineModel } from '@standardagents/spec';
import { cloudflare } from '@standardagents/cloudflare';
export default defineModel({
name: 'workers-fast',
provider: cloudflare,
model: '@cf/google/gemma-4-26b-a4b-it',
// Prices change. Check https://developers.cloudflare.com/workers-ai/platform/pricing/
inputPrice: 0.1,
outputPrice: 0.3,
});Provider Factory
import { cloudflare } from '@standardagents/cloudflare';
defineModel({
name: 'workers-reasoning',
provider: cloudflare,
model: '@cf/openai/gpt-oss-120b',
});Provider Options
import { defineModel } from '@standardagents/spec';
import { cloudflare } from '@standardagents/cloudflare';
export default defineModel({
name: 'workers-reasoning',
provider: cloudflare,
model: '@cf/openai/gpt-oss-120b',
providerOptions: {
seed: 42,
user: 'user-123',
logprobs: true,
top_logprobs: 5,
},
});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 |
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
The builder fetches available models from Cloudflare's account-scoped models API, so the model picker can search and paginate through the live Workers AI catalog. The provider keeps a small static fallback catalog for capability hints and as a fallback if the models API is unavailable.
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
CLOUDFLARE_API_TOKEN=...
CLOUDFLARE_ACCOUNT_ID=...For a deployed project, set CLOUDFLARE_API_TOKEN in your project's environment settings on the Standard Agents platform.
Set CLOUDFLARE_ACCOUNT_ID in the same place.
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.