Integration

Cloudflare Workers AI through the Vigil proxy

Cloudflare Workers AI, reached through api.cloudflare.com, with an OpenAI-compatible endpoint. Point your SDK's base URL at Vigil, add one header, and every Cloudflare Workers AI call is logged with its cost, tokens, latency, errors and agent, then forwarded to https://api.cloudflare.com unchanged unless you switch on an optimisation. Prompt caching never changes answers. History trimming and model routing can: both are opt-in, run in Shadow first, and stop automatically if errors, cut-off answers or failed answers rise.

What Vigil records per Cloudflare Workers AI call

Each Cloudflare Workers AI call is one record: model id, tokens, cache reads and writes, latency, status, error code and agent. What a record holds, what happens to your Cloudflare Workers AI key and what the hop costs in latency are answered once in the FAQ: what Vigil sees, your provider key and added latency.

Cost is left empty for this provider. Cloudflare Workers AI model slugs are an open gap — no `@cf/…` id has been read, so no rate row can be keyed to one. These calls are logged and monitored; their cost column stays empty rather than showing a made-up figure.

Setup

The Cloudflare Workers AI base URL is https://api.vigil.tools/{user_id}/cloudflare; a request path such as /v1/chat/completions is forwarded unchanged, and your Cloudflare Workers AI key stays in CLOUDFLARE_API_TOKEN. The path after the segment is whatever your client already uses, /v1 for most OpenAI-compatible APIs. The two Vigil headers, the modes and the error codes are the same for every provider: see the LLM proxy setup.

your Cloudflare Workers AI client
import OpenAI from "openai";

const client = new OpenAI({
  apiKey: process.env.CLOUDFLARE_API_TOKEN,   // unchanged
  baseURL: "https://api.vigil.tools/{user_id}/cloudflare/v1",
  defaultHeaders: {
    // MUST be X-Vigil-Key: Authorization already carries your Cloudflare Workers AI key.
    "X-Vigil-Key": "vk_your_vigil_key",
    "X-Vigil-Agent": "my-agent",
  },
});

const completion = await client.chat.completions.create({
  model: "<your model id>",
  messages: [{ role: "user", content: "Hello!" }],
});

Vigil forwards everything after /cloudflare unchanged to https://api.cloudflare.com. The path above is whatever your client already uses — /v1 is the OpenAI-compatible default and is right for most, but some providers prefix it with a product segment. If you get a 404, compare it against the base URL in your Cloudflare Workers AI config: the part after https://api.cloudflare.com is exactly what belongs here. Cloudflare Workers AI model slugs are an open gap — no `@cf/…` id has been read, so no rate row can be keyed to one. These calls are logged and monitored; their cost column stays empty rather than showing a made-up figure.

your Cloudflare Workers AI client
from openai import OpenAI

client = OpenAI(
    api_key=os.environ["CLOUDFLARE_API_TOKEN"],  # unchanged
    base_url="https://api.vigil.tools/{user_id}/cloudflare/v1",
    default_headers={
        "X-Vigil-Key": "vk_your_vigil_key",
        "X-Vigil-Agent": "my-agent",
    },
)

completion = client.chat.completions.create(
    model="<your model id>",
    messages=[{"role": "user", "content": "Hello!"}],
)

Vigil forwards everything after /cloudflare unchanged to https://api.cloudflare.com. The path above is whatever your client already uses — /v1 is the OpenAI-compatible default and is right for most, but some providers prefix it with a product segment. If you get a 404, compare it against the base URL in your Cloudflare Workers AI config: the part after https://api.cloudflare.com is exactly what belongs here. Cloudflare Workers AI model slugs are an open gap — no `@cf/…` id has been read, so no rate row can be keyed to one. These calls are logged and monitored; their cost column stays empty rather than showing a made-up figure.

terminal
curl https://api.vigil.tools/{user_id}/cloudflare/v1/chat/completions \
  -H "content-type: application/json" \
  -H "Authorization: Bearer $CLOUDFLARE_API_TOKEN" \
  -H "X-Vigil-Key: vk_your_vigil_key" \
  -H "X-Vigil-Agent: my-agent" \
  -d '{
    "model": "<your model id>",
    "messages": [{ "role": "user", "content": "Hello!" }]
  }'

Vigil forwards everything after /cloudflare unchanged to https://api.cloudflare.com. The path above is whatever your client already uses — /v1 is the OpenAI-compatible default and is right for most, but some providers prefix it with a product segment. If you get a 404, compare it against the base URL in your Cloudflare Workers AI config: the part after https://api.cloudflare.com is exactly what belongs here. Cloudflare Workers AI model slugs are an open gap — no `@cf/…` id has been read, so no rate row can be keyed to one. These calls are logged and monitored; their cost column stays empty rather than showing a made-up figure.

Prompt caching on Cloudflare Workers AI

This provider caches automatically, on its own terms. Vigil records what it reports and prices it — there is nothing for Vigil to add to the request.

With optimisation On: the provider caches automatically or not at all; Vigil records cache use and does not change the request. In Shadow, Vigil measures what caching would have saved and changes nothing. Off records the call and nothing more.

Questions

Which Cloudflare Workers AI models does Vigil price?
None yet. Cloudflare Workers AI model slugs are an open gap — no `@cf/…` id has been read, so no rate row can be keyed to one. These calls are logged and monitored; their cost column stays empty rather than showing a made-up figure.

Other providers: Anthropic · AWS Bedrock · Google Vertex · OpenAI · Google Gemini · Mistral · xAI Grok · DeepSeek · Together AI · Fireworks AI · Groq · Cerebras · Baseten · Moonshot · Z.ai · OpenRouter