anyllm-cloudflare-worker
Cloudflare Workers AI provider adapter for anyllm.
Use it when
- you are already running inside a Cloudflare Worker
- you want to call Workers AI through the shared
anyllm::ChatProvidertrait - you want native binding-based execution instead of issuing outbound HTTP calls
Identity
Provider::provider_name() returns "cloudflare" so OTEL gen_ai.provider.name
matches the value emitted by anyllm-openai-compat's Cloudflare preset,
regardless of which transport you choose.
Capabilities
anyllm-cloudflare-worker currently reports:
- tools
- streaming
- structured output
It does not currently support multimodal user input or assistant image replay on the native Workers AI chat path used by this crate.
The native chat path also rejects unsupported request controls such as
stop, tool_choice, provider-agnostic reasoning config, and
parallel_tool_calls rather than silently ignoring them.
Structured output here means request-level ChatRequest.response_format
mapping on the non-streaming native chat path. This crate does not currently
expose anyllm's ExtractExt convenience API.
For ResponseFormat::JsonSchema, this adapter currently supports the schema
payload itself but not the portable name / strict controls, which are
rejected explicitly instead of being silently dropped.
chat_stream(...) is intentionally narrower than chat(...): it rejects tools
and response_format requests because Workers AI JSON Mode is non-streaming and
the native stream exposed through worker::Ai::run_bytes() does not surface a
stable streamed tool-call event shape.
Quick start
[]
= "0.1.0"
= "0.1.0"
= "0.3"
= "0.7"
use *;
use Provider;
async
Notes
- This crate does not use
from_env()because construction happens from a Cloudflareworker::Aibinding. - The binding name must match your
wrangler.tomlconfiguration:
[]
= "AI"