Deploy an OpenAI-compatible endpoint backed by Cloudflare Workers AI to your own Cloudflare account — from your browser.
Use it hosted at open.notebooker.ai, or clone this repo and run the same app locally.
Pick models from the live Cloudflare catalog, deploy, and test everything in the browser: streaming chat, image generation, text-to-speech, speech-to-text (file upload), vision (image upload), and embeddings similarity — plus an estimated free-tier usage monitor and a downloadable credentials.txt for your endpoint.
Supports chat/completions (including vision models), images/generations, images/edits, images/variations, embeddings, audio/transcriptions, and audio/speech — each endpoint is enabled only if you pick a model for it.
- No login, no database. You paste a scoped Cloudflare API token; it lives only in an AES-GCM-encrypted, expiring
HttpOnlycookie. Every Cloudflare call is proxied server-side, so the token never reaches the browser. Delete the token in Cloudflare when you're done — a new one restores access later. - Config is remembered in your account. Worker name + models (never secrets) are stored in a KV namespace in your own Cloudflare account and rediscovered on your next visit.
- The endpoint API key is never persisted anywhere. It exists as the worker's write-only secret and, transiently, in your session cookie. Save it when it's shown (or download
credentials.txt); renewing replaces it. Model changes never touch the key (the redeploy uses aninheritbinding). - Just testing? Upload your
credentials.txt(or enter base URL + key) on the homepage to use the testers without any Cloudflare token — management stays locked until you provide one.
-
Open open.notebooker.ai (or your local instance).
-
Follow the Before you start checklist: verify your Cloudflare account email, and visit Workers AI once so your
workers.devsubdomain gets registered. -
Create a Custom API token at dash.cloudflare.com → API Tokens, scoped to your account:
Resource Permission Workers Scripts Edit Workers KV Storage Edit Workers AI Read Account Analytics Read -
Paste it in, pick your models, deploy, test, and download your credentials.
Gated models: some Meta models (e.g.
@cf/meta/llama-3.2-11b-vision-instruct) need a one-time license agreement per account — if chat replies with a license notice, send the single messageagreeonce.
@cf/deepgram/fluxis WebSocket-only and can't work through this request/response API (it's filtered from the picker).
git clone https://github.com/Notebooker-ai/cloudflare-ai-deployer
cd cloudflare-ai-deployer/web
npm install
npm run dev # http://localhost:4321web/.dev.vars ships with a dev-only SESSION_SECRET. Paste your scoped token on the landing page and you get the full dashboard against your own account. See web/README.md for architecture, the security model, and deploying your own instance.
Point any OpenAI-compatible client at your base URL with your bearer key:
import OpenAI from "openai";
const client = new OpenAI({
baseURL: "https://<worker>.<your-subdomain>.workers.dev/v1",
apiKey: "<your bearer key>",
});
const res = await client.chat.completions.create({
model: "chat",
messages: [{ role: "user", content: "Hello!" }],
});Or with curl:
# Chat
curl $BASE_URL/chat/completions \
-H "Authorization: Bearer $API_KEY" \
-H "Content-Type: application/json" \
-d '{"model":"chat","messages":[{"role":"user","content":"Hi"}]}'
# Image generation (base64 PNG/JPEG in data[0].b64_json)
curl $BASE_URL/images/generations \
-H "Authorization: Bearer $API_KEY" \
-H "Content-Type: application/json" \
-d '{"model":"text_to_image","prompt":"A red apple on a white table","n":1}'
# Image edit (image-to-image models; add -F mask=@mask.png to inpaint)
curl $BASE_URL/images/edits \
-H "Authorization: Bearer $API_KEY" \
-F "model=text_to_image" \
-F "image=@room.png" \
-F "prompt=add a sleeping cat on the desk"
# Embeddings
curl $BASE_URL/embeddings \
-H "Authorization: Bearer $API_KEY" \
-H "Content-Type: application/json" \
-d '{"model":"embedding","input":"hello world"}'
# Text-to-speech (writes audio file)
curl $BASE_URL/audio/speech \
-H "Authorization: Bearer $API_KEY" \
-H "Content-Type: application/json" \
-d '{"model":"text_to_speech","input":"Hello!"}' \
--output speech.wav
# Speech-to-text
curl $BASE_URL/audio/transcriptions \
-H "Authorization: Bearer $API_KEY" \
-F "file=@sample.m4a" \
-F "model=speech_to_text"The model field accepts either the type alias (chat, text_to_image, embedding, text_to_speech, speech_to_text) or the full Cloudflare model id.
All three OpenAI image routes are implemented:
| Route | What it needs | Which models can serve it |
|---|---|---|
POST /v1/images/generations |
prompt |
text-to-image models |
POST /v1/images/edits |
image + prompt, optional mask |
image-to-image models |
POST /v1/images/variations |
image, prompt optional |
image-to-image models |
Diffusion models differ in what they accept, so the worker publishes each one's capabilities and only advertises the routes it can serve:
curl $BASE_URL/models -H "Authorization: Bearer $API_KEY"
# { "id": "text_to_image", "backend": "@cf/stabilityai/stable-diffusion-xl-base-1.0",
# "capabilities": ["text-to-image", "image-to-image", "inpainting"] }Ask a model for something it can't do and you get a 400 that says where to go
instead — model_requires_image (inpainting models can't work from a prompt
alone), model_no_image_input (Flux can't take a source image),
model_no_mask_input (img2img models can't take a mask). The dashboard's image
tester reads the same capabilities and only offers the modes that will work.
Caveats a storage-less worker implies, and the knobs it adds:
- There's nowhere to host a generated file, so images always come back inline.
response_formatdefaults tob64_json;"url"returns adata:URI so clients that only readdata[].urlkeep working. nis 1–4. Workers AI produces one image per inference call, sonimages costncalls (run sequentially) against your free-tier neurons.sizeacceptsautoorWIDTHxHEIGHT(each side 256–2048). Flux models generate at a fixed size and ignore it.quality(low/medium/standard/high/hd) maps onto the model's diffusion step count — capped at 8 for Flux, 20 for Stable Diffusion.- Non-OpenAI extras:
steps,negative_prompt,guidance,seed, andstrength(Stable Diffusion family only).strengthdefaults to 0.75 for edits, 1 for masked edits, and 0.5 for variations, since Workers AI's own default of 1 discards the source image. /editsand/variationstake multipart/form-data like the OpenAI SDKs send, and also accept a JSON body withimage/maskas base64 (or adata:URI) for convenience.- Variations have no prompt in the OpenAI spec but every Workers AI diffusion
model requires one, so a neutral prompt is substituted; pass your own
promptto steer it.
const img = await client.images.generate({
model: "text_to_image",
prompt: "A neon terminal glowing in a dark room",
});
// Buffer.from(img.data[0].b64_json, "base64")
const edited = await client.images.edit({
model: "text_to_image",
image: fs.createReadStream("room.png"),
mask: fs.createReadStream("mask.png"), // optional, inpainting models only
prompt: "add a sleeping cat on the desk",
});To use your endpoint inside Notebooker.ai, see the guide: Run your own AI provider.
workers/template-unified.js the worker that gets deployed (single source of truth)
web/ the Astro app (open.notebooker.ai)
test/ vitest suite for the worker template
Unit tests run without credentials:
npm testTo run the integration suites against a deployed worker, create a .env with:
OPENAI_BASE_URL=https://<worker>.<your-subdomain>.workers.dev/v1
API_KEY=<your bearer key>
Then npm test again — integration tests auto-skip any endpoint type that isn't deployed.