Models and embeddings
Felix runs each conversation turn on one model, and which models it offers is yours to name. Workers AI is the default provider. A hosted deployment can offer models from several providers side by side (see Several providers); each request still runs on the model it names. Felix never picks a model for you; a deployment can name a fallback for when the chosen model cannot answer (see Fallback model), and it is off unless set.
Choosing a provider
Section titled “Choosing a provider”| Provider | Value | Model IDs | Credentials |
|---|---|---|---|
| Workers AI | workers-ai (default) |
A native ID, @cf/vendor/model or @hf/vendor/model, for example @cf/zai-org/glm-5.3. |
In the API Worker, the AI binding. In the terminal client, a Cloudflare account ID and an API token with Workers AI access. |
| Anthropic | anthropic |
An Anthropic model ID. | An Anthropic API key. |
| OpenAI | openai |
An OpenAI model ID, run on the Responses API. | An OpenAI API key. |
| Gemini | google |
A Gemini model ID. | A Gemini API key. |
| Vertex AI | vertex |
A Gemini model ID. | A Google Cloud API key; or, in the API Worker, a service account key, and in the terminal client, Application Default Credentials. |
| Amazon Bedrock | bedrock |
A Bedrock model ID. | A region, and a Bedrock API key or AWS access keys. |
| Mistral | mistral |
A Mistral model ID. | A Mistral API key. |
Pick a model that supports tool calling: the terminal client always gives the model its file tools. Which models support tools is up to the provider. A model that returns some other output format is refused rather than read loosely.
In transcripts, assistant messages from Workers AI, Anthropic, Bedrock, Gemini (including Vertex AI), Mistral, OpenAI Responses and OpenAI-compatible Chat Completions include rawStopReason when the provider reports how generation ended. For example, on Bedrock stop_sequence identifies a reply that ended at a stop sequence and end_turn identifies a normal end of turn.
Anthropic’s model_context_window_exceeded stop and streamed request_too_large error can trigger compaction before any output. If tool-call data has already streamed, Felix stops without executing or checkpointing the call.
Anthropic tool calls require a consistent stop reason. An unknown reason or a change from max_tokens to tool_use ends the reply before any call runs.
If Claude reports a refusal or sensitive stop, Felix ends the run immediately. Any tool calls streamed in that reply remain unexecuted.
When Claude streams citation metadata alongside an answer, Felix skips the metadata and continues streaming the text.
Anthropic tool progress shows arguments as they stream. When Claude supplies all the arguments in the opening event, they appear when the tool block closes.
Anthropic token totals include cache reads and writes, even when the model reports those counts separately from output tokens.
Anthropic reasoning appears as soon as its first text arrives. A provider failure after only reasoning has been shown is retried like one before any output: the reasoning shown so far is cleared and the new attempt’s takes its place. Once answer text or a tool call has started, a failure ends the attempt, and the text written so far is kept.
If a Workers AI connection drops while Felix is reading a buffered tool reply, Felix can retry the request. It runs tools only after it has received and validated the complete reply.
Felix also retries a Workers AI request that never reached Cloudflare (a refused or reset connection, a failed lookup), and a reply that arrives with a success status but reports a temporary failure, such as a model out of capacity. A reply that reports the context window was exceeded is compacted and tried again, as when the same error comes with an error status.
Token counts a Workers AI or OpenAI-compatible reply reports impossibly (a missing count, or more cached input than input) are left out of usage. The reply itself is kept.
Workers AI can spend a requested output allowance entirely on reasoning. Felix retains that reasoning even if the provider reports zero output tokens.
When Anthropic pauses a text reply, Felix shows the text and waits for your next turn. If Anthropic reports a different model for a reply, Felix sends the full conversation on the next turn.
When Anthropic replay requires a tool call ID to be rewritten, Felix uses the same ID for its result and preserves the order of signed thinking blocks. If that rewrite changes the conversation held by a message thread, Felix sends the full history in a new thread.
Anthropic tool results point Claude to attached images when a tool returns only images. When a tool fails, its result includes a note pointing to the images, which follow the batch under the failed call’s ID.
When a tool returns only images, Workers AI and OpenAI-compatible chat tell vision-capable models how many images follow that result. The images arrive together after the batch of tool results. A tool that returns neither text nor images sends [no output].
For Chat Completions endpoints that require an assistant message between tool results and user content, enable compat.requiresAssistantAfterToolResult. Felix inserts a brief acknowledgement in the outgoing request, including before tool images sent as a user message.
OpenAI-compatible Chat Completions identifies each tool result by its call ID. If your endpoint also requires the function name on tool results, set compat.requiresToolResultName to true in its provider settings.
Some Chat Completions endpoints require a tools field whenever the conversation contains an earlier tool call or result. Set compat.requiresToolsWithToolHistory to true in the provider settings to send tools: [] when the current turn has no active tools.
Felix sends store: false on Chat Completions requests to OpenAI, including through Cloudflare AI Gateway’s OpenAI endpoint. For another compatible server that accepts this field, set compat.supportsStore to true in its provider settings.
Chat Completions sends the conversation cache key to OpenAI and to Cloudflare AI Gateway’s OpenAI provider endpoint. Long retention requests 24 hours on those endpoints. One-off requests and disabled caching omit both fields.
OpenAI Chat Completions requires a finish reason before Felix accepts a reply or runs its tools. For a compatible server that ends replies with only [DONE], set compat.supportsFinishReason to false in its provider settings.
If OpenAI Chat Completions reports invalid credentials or an unsupported request, Felix stops the run. A context-window rejection before output can trigger compaction.
With reasoning explicitly set to off, OpenAI Responses sends effort: "none" and omits requests for summaries and encrypted reasoning. A follow-up still sends the same model its earlier reasoning items alongside the tool result.
OpenAI Responses limits conversation cache keys to 64 Unicode code points. Long cache retention requests 24 hours even without a conversation key. One-off requests such as compaction summaries omit both fields.
OpenAI Responses usage includes cache writes when the provider reports input_tokens_details.cache_write_tokens. Cache reads and writes are separate portions of total input, and cost estimates apply the configured rate to each.
When a conversation continues with the same OpenAI Responses model, Felix preserves commentary and final-answer phases around tool calls.
On a same-model follow-up, OpenAI Responses keeps the original item ID even for a single answer or refusal without a phase label. A turn with several assistant messages keeps their order. When switching models, Felix carries the visible text forward.
OpenAI Responses replays completed function and custom tool calls with their original item ID, call type, and input on the same model. Their results keep the matching output type even if the tool gains a grammar or is removed before the next turn.
OpenAI Responses sends tool images inside the corresponding function or custom tool output. An image-only result contains just its images, while a result with neither text nor images sends [no output].
A complete OpenAI Responses function or custom tool call can arrive in the finished item alone. OpenAI Responses tool progress includes input sent when the call opens and any remaining input first supplied by the finished call. Felix waits for the call and the response to finish before running the tool.
If an OpenAI Responses stream mixes function-call arguments and custom tool input, Felix stops the turn before executing any calls from that reply.
If OpenAI Responses reports temporary overload or throttling before output, Felix can retry. An exhausted quota stops the request. A failure a gateway reports for itself, such as an upstream stream it could not forward, is retried the same way.
When Claude on Bedrock returns encrypted reasoning, Felix preserves it for subsequent turns with the same model, even when it arrives in several stream events.
If a reply reaches the provider’s output limit while writing tool calls, Felix records each call as unexecuted. The model can issue complete calls on its next turn. Unexpected truncation of a text answer fails the turn; the text written up to the limit stays in the conversation, marked as cut off, and the next message can ask the model to carry on from it. Raise the model’s maxOutputTokens if answers are cut off often.
Some models accept tools but answer with the call written out as text, such as
{"type": "function", "name": "run_script", ...}, instead of returning a tool call. Felix
runs only real tool calls, so such a reply is shown as text and nothing runs. @cf/meta/llama-3.3-70b-instruct-fp8-fast
does this on Workers AI. @cf/zai-org/glm-5.3 is the example used throughout these docs.
Each inference asks for at most 4,096 output tokens unless a limit is configured: the terminal
client uses the model record’s maxOutputTokens, or for Workers AI the limit from Cloudflare’s
model listing. A reply cut off at the limit fails instead of being saved half-finished; if it was
making tool calls, those calls are not run and the model is asked to make them again.
API Worker
Section titled “API Worker”The Worker reads its settings from its environment. Conversations are configured only when every setting
the chosen provider needs is present and valid. Otherwise POST /v1/runs/stream answers 503 with
model_not_configured, and GET /health reports "model": false.
| Setting | Kind | Needed for | Meaning |
|---|---|---|---|
FELIX_API_TOKEN |
Secret | Both | The bearer token clients send to the API. It is not a model credential. |
FELIX_MODEL |
Variable | Both | The model ID. |
FELIX_PROVIDER |
Variable | workers-ai (default), anthropic, openai (OpenAI’s Responses API), google (the Gemini API), vertex (Gemini on Vertex AI), bedrock (Amazon Bedrock) or mistral (Mistral’s own API). Any other value leaves conversations unconfigured. |
|
AI |
Binding | Workers AI | The Workers AI binding. |
FELIX_ANTHROPIC_API_KEY |
Secret | Anthropic | The Anthropic API key. |
FELIX_GEMINI_API_KEY |
Secret | Gemini | The Gemini API key. |
FELIX_MISTRAL_API_KEY |
Secret | Mistral | The Mistral API key. |
FELIX_VERTEX_API_KEY |
Secret | Vertex AI | A Google Cloud API key for Vertex AI. Or: |
FELIX_GCP_SERVICE_ACCOUNT |
Secret | Vertex AI | A service account key’s JSON; the Worker mints an access token from it and renews it hourly. |
FELIX_GCP_PROJECT |
Variable | Vertex AI | The project, with a service account key; default the key’s own project_id. |
FELIX_GCP_LOCATION |
Variable | Vertex AI | A region such as us-central1, or global (the default). |
FELIX_AWS_REGION |
Variable | Bedrock | The Bedrock region, such as us-east-1. |
FELIX_BEDROCK_API_KEY |
Secret | Bedrock | A Bedrock API key; or, instead, FELIX_AWS_ACCESS_KEY_ID and FELIX_AWS_SECRET_ACCESS_KEY (secrets) to sign requests. |
FELIX_OPENAI_API_KEY |
Secret | OpenAI | The OpenAI API key. Models are taken to reason unless their FELIX_MODELS entry says "reasoning": false. |
FELIX_ANTHROPIC_MESSAGE_THREADS |
Variable | Anthropic | off stops message threads, which let each turn of a run send only its new messages while Anthropic keeps the conversation in memory for up to an hour. On by default, except through an AI Gateway (FELIX_AI_GATEWAY), where on turns them on. |
FELIX_MODELS |
Variable | More models a request may choose, as JSON (a string, or an object in Wrangler vars): { "<model id>": { "provider": "anthropic", "label": "Claude Opus 5.5", "contextWindow": 131072, "maxOutputTokens": 8192, "vision": true, "reasoning": true, "streamsToolCalls": true, "pricing": { "input": 0.6, "output": 2.2 } } } (every field optional). An entry for FELIX_MODEL describes the default. With Mistral, set "vision": true for models that take images, and "promptModeReasoning": true for Magistral models, which reason through Mistral’s prompt_mode instead of a reasoning effort. pricing estimates each run’s cost; see Model prices. provider names who serves the model (default FELIX_PROVIDER), and label is its name in the web app’s model picker (at most 80 characters; the ID otherwise). "access": "admins" keeps a model for admins; see Several providers. A malformed value, or an unknown provider, leaves conversations unconfigured. |
|
FELIX_MODEL_FALLBACK |
Variable | A model ID from FELIX_MODELS that a run finishes on when its own model cannot answer; see Fallback model. Off when unset. An ID that is not listed leaves conversations unconfigured. |
|
FELIX_UTILITY_MODEL |
Variable | A model ID from FELIX_MODELS for the calls around runs: suggestions, the summaries compaction writes (in a run or on request), and summaries of branches left by a fork or rewind. Unset, the chat model writes them. One whose provider has no credentials is off; one that is not listed, or is kept for admins, leaves conversations unconfigured. |
|
FELIX_CONTEXT_WINDOW |
Variable | The default model’s context window in tokens, for when its FELIX_MODELS entry gives none. See Context window and compaction. |
|
FELIX_MAX_CONTEXT_TOKENS |
Variable | The most input tokens a turn is kept within: every model compacts as if its window were at most this many tokens. Default 200000; off compacts only near each model’s own window. A value that is not a whole number of at least 4096 leaves conversations unconfigured. |
|
FELIX_AI_GATEWAY |
Variable | An AI Gateway id. Workers AI, Anthropic, OpenAI and Gemini requests go through it; see AI Gateway. Unset, they go direct. A value that is not a gateway name leaves conversations unconfigured. | |
FELIX_AI_GATEWAY_LOG_PAYLOADS |
Variable | on keeps request and response bodies in the gateway’s logs. Off by default: the logs keep each request’s metadata, tokens, cost and duration. |
|
FELIX_AI_GATEWAY_TOKEN |
Secret | A token with AI Gateway Run, for Anthropic, OpenAI and Gemini calls to an authenticated gateway from a host without the AI binding. Not used where the binding is present. |
|
FELIX_CLOUDFLARE_ANALYTICS_TOKEN |
Secret | An API token with Account Analytics Read and AI Gateway Read. With FELIX_AI_GATEWAY and FELIX_CLOUDFLARE_ACCOUNT_ID, a signed-in person’s account menu shows what their model calls cost today and their daily limit, as the gateway counts them (GET /v1/me/spend). Unset, the menu shows no spend. |
|
FELIX_REASONING |
Variable | Reasoning effort for models that reason: off, low, medium, high, xhigh or max. Any other value leaves conversations unconfigured. |
|
FELIX_STREAM_TOOL_CALLS |
Variable | Workers AI | true streams turns that offer tools too. Turn it on only for models that call tools reliably while streaming. Default false. |
FELIX_DELEGATE |
Variable | on gives the model the delegate tool for child agents; see Concepts. |
|
FELIX_TIMEZONE |
Variable | The IANA time zone (such as America/New_York) for the date at the end of the system prompt, and for a time the model gives without one. Default UTC. An unknown zone leaves conversations unconfigured. |
|
FELIX_IMAGE_MODEL |
Variable | The image model, named by provider: a Workers AI model id such as @cf/black-forest-labs/flux-2-klein-4b (on the AI binding), google/ and a Gemini model such as google/gemini-nano-banana-2.1, or openai/ and an OpenAI one such as openai/gpt-image-2.5-flare. With FELIX_AI_GATEWAY, image requests go through the gateway, labelled kind: image; Gemini and OpenAI use FELIX_GEMINI_API_KEY and FELIX_OPENAI_API_KEY when set, and otherwise the key stored in the gateway. Without a gateway, they need the key. A FLUX.2 request goes straight to Workers AI, since AI Gateway does not take its streamed form. Runs on a deployment with image storage (IMAGES) get generate_image: the image is stored, shown in the conversation (also when it is reopened) and seen by the model, at most 4 a run. Every generated image is kept in the person’s Files under Generated, and the model is told so, so a request to save one is answered from there rather than by generating it again; save_image puts a copy of an earlier one in the thread’s workspace. list_images finds the person’s images from any conversation, and with IMAGE_TRANSFORM, transform_image resizes, crops, rotates, flips, removes the background of or converts one without generating it again. Each image is billed by its provider and counts against the person’s FELIX_DAILY_TOKENS as FELIX_IMAGE_TOKEN_COST tokens; one that would pass the budget is refused and nothing is made. With a FLUX.2, Gemini or OpenAI model and IMAGE_TRANSFORM, earlier images can be references (by their sha256: reference; the person’s attached images are listed to the model); with the thread’s workspace, path also saves the image there. Unset, or a model nothing here can run: no image generation. FELIX_DEFAULT_TOOLS can leave it out like any built-in. |
|
FELIX_IMAGE_FALLBACK |
Variable | An image model, named as FELIX_IMAGE_MODEL is, that makes the image when that one fails (an outage, a rate limit, a missing key). Not for a prompt the first model declines, a cancelled run, or reference images the fallback cannot take. The result names the model that made it. When FELIX_IMAGE_MODEL cannot run here, the fallback serves alone. Unset: no fallback. |
|
FELIX_IMAGE_TOKEN_COST |
Variable | What one generated image counts as against FELIX_DAILY_TOKENS, in tokens (0 to 1,000,000). Default 10,000. A value out of range turns image generation off rather than leaving it uncounted. |
|
FELIX_IMAGE_TOKEN_COSTS |
Variable | What an image by each model counts as, as JSON from model id (as FELIX_IMAGE_MODEL names it) to tokens, such as {"google/gemini-nano-banana-2.1": 8000, "@cf/black-forest-labs/flux-2-klein-4b": 1000}; a model not listed counts as FELIX_IMAGE_TOKEN_COST. An image is charged as FELIX_IMAGE_MODEL before it is made; when FELIX_IMAGE_FALLBACK makes it, the charge moves to the fallback’s count. Each cost is 0 to 1,000,000; JSON that does not parse, or a cost out of range, turns image generation off rather than leaving it uncounted. |
|
FELIX_IMAGE_PRICING |
Variable | For an image model AI Gateway does not price, what its requests cost: JSON from model id (as FELIX_IMAGE_MODEL names it) to {"input": …, "output": …} in US dollars per million tokens, such as {"openai/gpt-image-2.5-flare": {"input": 5, "output": 30}}. Sent to the gateway as the request’s custom cost, so its analytics and spend limits count those images. JSON that does not parse, or a price that is not a number from 0 to 10,000, turns image generation off. |
|
FELIX_IMAGE_SWEEP |
Variable | off stops the daily sweep (cron 41 4 * * *) that removes image uploads never sent, a day after upload. On by default; images stored before the sweep existed are never removed by it. |
|
FELIX_TRANSCRIPTION_MODEL |
Variable | A Workers AI speech-to-text model run on the AI binding: @cf/openai/whisper-large-v3-turbo, @cf/openai/whisper or @cf/openai/whisper-tiny-en. Signed-in people get POST /v1/transcriptions, which the web app uses for voice input in a browser with no speech recognition of its own (Firefox). A clip is at most 4 MiB, is sent to the model and kept nowhere, and goes through FELIX_AI_GATEWAY with the person’s label when the gateway is set. A person over FELIX_DAILY_TOKENS is refused, and each clip counts against it as 1,000 tokens a minute of audio (a minute when the model does not say how long it was). Unset, or another model: not offered, and voice input stays with the browser’s own recognition. |
|
FELIX_TIME_TOOLS |
Variable | off leaves out time_now, time_convert, date_math and calculate. On by default. On Workers AI a turn that offers tools is not streamed unless FELIX_STREAM_TOOL_CALLS=true. |
|
FELIX_WEB_SEARCH |
Variable | on (the service’s default provider, currently Ceramic), or ceramic, exa or linkup: adds web_search, on Cloudflare’s Web Search API through the AI binding and FELIX_AI_GATEWAY (the default gateway when unset). Each search is billed to the account’s AI Gateway credits, or to a provider key stored on the gateway, and does not count against FELIX_DAILY_TOKENS. The query goes to that provider and appears in the gateway’s log; check the provider’s retention terms. Off by default; any other value leaves conversations unconfigured. |
|
FELIX_LOOKUPS |
Variable | Public services the agent may look things up in, comma separated. weather adds find_place, weather (Open-Meteo) and weather_alerts (US National Weather Service); wikipedia adds wikipedia_search and wikipedia_read; currency adds convert_currency (European Central Bank daily rates through Frankfurter). What the agent asks goes to that service. None by default; a name not listed here leaves conversations unconfigured. |
|
FELIX_OPEN_METEO_KEY |
Secret | An Open-Meteo API key, used for weather. Open-Meteo’s free service is for non-commercial use only. |
|
FELIX_DEFAULT_TOOLS |
Variable | The built-in tools runs may offer, comma separated. Unset, every configured built-in is offered. Names, or the presets coding (read_file, run_command, edit_file, write_file) and read-only (read_file, list_files, find_files, grep_files), replace that default; a list of only +name and -name entries adjusts it, for example -run_command,-fetch_url. Tools from MCP servers, skills and connections are not affected. A mistake leaves conversations unconfigured. |
|
FELIX_ALLOW_BYPASS |
Variable | on lets an admin put a thread in bypass mode, which skips approval rules. Off by default. |
|
FELIX_DAILY_TOKENS |
Variable | Model tokens, input and output together, one person may use in a UTC day: their conversations, those conversations’ schedules and the child agents they start. A run asked for once the day’s budget is spent is refused with 429 quota_exceeded, and Retry-After says when the day ends. A run that starts is kept within what is left of the day: its input and output caps are lowered to it, and it ends as at its turn limit when it reaches them. Each model call sets aside what it is likely to use before it starts, so runs at once share what is left: a run whose next call does not fit beside the others stops at a spending limit, and an image, a side question, a summary or a transcription that does not fit is refused until that work finishes. The summaries a run writes when it compacts count too, as do the model calls made for a thread outside a run: a compaction asked for, a summary of a branch left by a fork or rewind, and a side question (/ask), each counted against the thread’s owner, and refused once the budget is spent, as a run is. Skill evaluations, skill rewrites from accepted feedback and the grading of eval runs count against whoever asked for them. When the day’s use cannot be read, a run or any of these calls is refused with 503 usage_unavailable rather than let through uncounted. Default 20000000; off for no cap. Needs sign-in. A value that is not a whole number of at least 1000 leaves conversations unconfigured. |
|
FELIX_SUGGESTIONS |
Variable | off stops writing suggestions for a signed-in person’s empty conversation (GET /v1/me/suggestions). On by default: one call to the utility model (FELIX_UTILITY_MODEL, or the chat model when it is unset) per person and workspace (General, CodeWork, Cowork), when they open an empty conversation there after six hours, or after they have been active since the last one, and after a run of theirs ends (at most every 15 minutes, and only for someone who asked for suggestions in the past week). CodeWork’s also read the pull requests waiting on the person’s review, and Cowork’s the rest of their calendar today, through their own connections. Those tokens count against FELIX_DAILY_TOKENS, and none are written once it is spent. |
|
FELIX_RUN_INPUT_TOKENS |
Variable | Input tokens one run may use, and each child agent it starts; a run that reaches it ends as at its turn limit. Default 4000000; off for no cap. |
|
FELIX_RUN_OUTPUT_TOKENS |
Variable | Output tokens one run may use, and each child agent it starts. Default 200000; off for no cap. |
|
FELIX_SIGNING_SECRET |
Secret | With RUNS: verifies signed POST /v1/threads/<id>/trigger requests and signs completion webhooks. |
|
FELIX_WEBHOOK_URL |
Variable | With FELIX_SIGNING_SECRET: where a scheduled or triggered run posts a signed run.finished when it ends. |
|
FELIX_MCP_SERVERS |
Secret | Hosted MCP servers; see MCP. | |
THREADS |
Durable Object | Hosted threads and approvals, with FELIX_API_TOKEN. Without it, only stateless runs are available. See Persistence. |
|
RUNS |
Durable Object | With THREADS: a hosted run keeps going when its client disconnects, and can be rejoined or stopped. Without it, closing the stream cancels the run. See REST API. |
|
TELEMETRY |
Durable Object | With FELIX_API_TOKEN: every run records its spans and metrics in the deployment’s trace store, kept seven days and read with GET /v1/traces and GET /v1/metrics. Without it, nothing is recorded. |
|
FELIX_TRACING |
Variable | on also sends each run’s spans to Workers tracing, so they reach the OTLP destinations set for the Worker. Turn on the Worker’s traces in its Wrangler configuration as well. Off by default. |
|
IMAGES |
R2 bucket | Stores uploaded and tool-returned images. | |
WORKSPACES |
R2 bucket | With THREADS: each hosted thread gets a workspace of files and the file tools; see Workspaces. |
|
BROWSER |
Browser Run | Adds the fetch_url tool, which reads a public page as Markdown. |
|
LOADER |
Worker Loader | Adds the run_script tool, which runs code in an isolate with no network. |
|
RATE_LIMITER |
Rate limit | Turns on the API rate limit; see REST API. |
The AI binding is declared only in the workers-ai and workers-ai-sandbox environments of
apps/api/wrangler.jsonc, so Workers AI needs one of them (see Deploy):
pnpm dev:worker:ai # local Worker with the AI binding (runs inference on your account)pnpm build:worker:ai # bundle it as a dry run; nothing is deployedpnpm dev:worker runs the base environment, which has no AI binding. Conversations there work
with any provider other than Workers AI selected.
For local runs, copy apps/api/.dev.vars.example to apps/api/.dev.vars (or
.dev.vars.workers-ai for the workers-ai environment) and fill it in:
FELIX_API_TOKEN=…FELIX_PROVIDER=workers-aiFELIX_MODEL=@cf/zai-org/glm-5.3# FELIX_CONTEXT_WINDOW=…# For Anthropic instead:# FELIX_PROVIDER=anthropic# FELIX_ANTHROPIC_API_KEY=…The Workers AI binding needs no API key of its own.
Several providers
Section titled “Several providers”FELIX_PROVIDER names the provider of the default model and of any FELIX_MODELS entry that does
not name its own. An entry with provider runs on that provider instead, so Workers AI and
Anthropic models can sit in the same picker:
"FELIX_MODEL": "@cf/zai-org/glm-5.3","FELIX_MODELS": { "@cf/zai-org/glm-5.3": { "label": "GLM-5.3", "contextWindow": 1048576 }, "claude-opus-5-5": { "provider": "anthropic", "label": "Claude Opus 5.5", "contextWindow": 1000000, "maxOutputTokens": 32000, "vision": true }}A provider is available when its credentials are set (the AI binding for Workers AI,
FELIX_ANTHROPIC_API_KEY for Anthropic, and so on, as in the table above). A model whose provider
has none is left out of GET /v1/models and refused if a request names it, so you can list it
before you set the key. A model whose record leaves vision out takes images if its provider
sends them by default (Anthropic, OpenAI, Gemini, Vertex AI and Bedrock), and not if it does not
(Workers AI and Mistral): set "vision": true on a Workers AI or Mistral model that sees images.
While images are attached to a message for a model without vision, the web app says that model
gets a note that they were attached, and offers a model that can see them. GET /v1/models lists the default first, then the rest of its provider’s
models, then each other provider’s, by label:
wrangler secret put FELIX_ANTHROPIC_API_KEY --env workers-aiTo keep a costly model for admins, give its entry "access": "admins". Only admins and the
operator token see it in GET /v1/models (marked "access": "admins", and admins only in the
picker), and anyone else whose request names it gets 403 model_not_allowed. An agent an admin
sets up on such a model still runs on it for everyone, since choosing it was an admin’s decision.
The default model’s provider must be available, and the default cannot be kept for admins, or conversations are not configured. A conversation can change model between turns. Reasoning from one model is not sent to another, and tool-call IDs are rewritten where a provider needs another format.
Fallback model
Section titled “Fallback model”FELIX_MODEL_FALLBACK names a model from FELIX_MODELS to finish a run on when the run’s own
model cannot answer. Choosing one from another provider keeps conversations working when a provider is down:
"FELIX_MODEL_FALLBACK": "claude-sonnet-5-5"A run moves to the fallback only before any answer text or tool call of the reply has streamed (reasoning alone does not prevent it), and only when:
- a temporary failure (HTTP 408, 409, 429 or 5xx, or a lost connection) is still failing after the run’s retries, or
- the provider says the model is gone (HTTP 404 or 410), which moves at once without retries.
A refused request (such as HTTP 400 or 401), a context overflow, a reply Felix could not use, and a run someone stopped do not move. A run moves at most once and stays on the fallback until it ends; the next run starts on its own model again. A run already on the fallback model has none. Once on the fallback, the run’s child agents and compaction summaries use it too, and the conversation is compacted to the fallback’s context window before it is first asked.
The run’s record then names the fallback model, and its cost uses the fallback’s price from the
move on; a fallback without a price leaves the run unpriced. The trace has a
felix.model_fallback event. The fallback may cost more than the model it stands in for, and it
works within the context window the run’s own model was compacted for, so choose one whose window
is at least as large. It is offered to everyone whose run moves, including when it is kept for
admins.
When the fallback’s provider has no credentials, there is no fallback and runs go on as before.
Model prices
Section titled “Model prices”Give a model a pricing record in FELIX_MODELS and each hosted run on it records an estimated
cost. Prices are US dollars per million tokens, copied from your provider’s price list:
| Field | Required | Meaning |
|---|---|---|
input |
Yes | Per million input tokens. |
output |
Yes | Per million output tokens. |
cachedInput |
Per million input tokens served from the provider’s prompt cache. Without it, cached input is priced as input. | |
cacheWrite |
Per million input tokens written to the prompt cache (Anthropic’s five-minute cache). Without it, writes are priced as input. | |
cacheWriteLong |
Per million input tokens written to the one-hour prompt cache. Without it, those writes are priced as cacheWrite. |
|
tiers |
Long-context prices: a list of rate sets, each with inputTokensAbove plus input, output and the optional fields above. A request whose input exceeds a tier’s threshold is priced wholly at the highest such tier; a rate the tier leaves out falls back within the tier, not to the base rate. |
FELIX_MODELS='{"@cf/zai-org/glm-5.3":{"contextWindow":1048576,"pricing":{"input":1.4,"output":4.4,"cachedInput":0.26}},"@cf/meta/llama-3.3-70b-instruct-fp8-fast":{}}'The prices above only show the shape; use your provider’s current ones. Here runs on the second model are not priced.
A run’s cost is worked out from its tokens at the price in force while it runs, and stored with
the run as cost: {priced: true, usd} (see REST API). Changing or
removing a price later leaves the costs already recorded as they were. A run on a model with no
pricing records cost: {priced: false}: it is not priced, and is never counted as $0. A run’s
tokens and cost cover every model call it made: its own turns, the child agents it delegated to,
and the summaries compaction wrote, each at the price of the model that made the call (a named
agent’s model, or FELIX_UTILITY_MODEL for summaries). If any of those models has no pricing,
the run is recorded as not priced rather than priced in part. A model call that was stopped or
failed is counted too, when the provider had already reported its tokens (Claude reports a
request’s input as the reply starts; OpenAI’s APIs report only when a reply completes). The Activity
page shows these estimates per run, per thread and for the window, and says “not priced” where a
model has no price. They are estimates from the prices you set, not your provider’s bill.
A pricing record without input and output, a negative price or an unknown field is malformed,
and leaves conversations unconfigured like any other malformed FELIX_MODELS.
AI Gateway
Section titled “AI Gateway”With FELIX_AI_GATEWAY set to a gateway’s id, Workers AI calls (chat and images) go through it on
the AI binding, and Anthropic, OpenAI and Gemini calls (chat and images) go to the gateway’s
endpoint for each provider. On a Worker with the AI binding, those calls reach the gateway
through the binding too, which authenticates them, so no gateway token is needed; the gateway
passes the deployment’s key (FELIX_ANTHROPIC_API_KEY, FELIX_OPENAI_API_KEY,
FELIX_GEMINI_API_KEY) on to the provider. A host without the binding reaches the gateway over
HTTP, which needs FELIX_CLOUDFLARE_ACCOUNT_ID (the account the gateway is in) and, for an
authenticated gateway, FELIX_AI_GATEWAY_TOKEN; without the account, conversations are
unconfigured rather than sent around the gateway. Vertex AI, Bedrock and Mistral go direct.
With FELIX_CLOUDFLARE_ANALYTICS_TOKEN set too, each person’s account menu shows today’s spend against their daily limit. The limit shown is the gateway’s enabled daily cost rule split by the person metadata key for every model; a rule for one provider or model (for example Claude only) still applies but is not shown. The figures are the gateway’s own estimates from token counts, from sampled analytics, and a minute or two behind the latest calls.
When Workers AI or OpenAI-compatible Chat Completions sends reasoning and answer text together, Felix shows the reasoning first. It reads the first nonempty field among reasoning_content, reasoning, and reasoning_text.
Workers AI and OpenAI-compatible Chat Completions read token totals from the choice when a reply omits top-level usage. If both locations report usage, the top-level counts take precedence. When prompt_tokens_details.cache_write_tokens is present, Felix records those writes separately from cache hits. Both are included in total input tokens.
Workers AI and OpenAI-compatible Chat Completions discard tool calls when a reply ends with network_error or content_filter.
Workers AI rejects a Chat Completions choice with an unknown finish_reason, including any tool calls in that choice.
For Workers AI cache hits, Felix reads prompt_tokens_details.cached_tokens, then prompt_cache_hit_tokens, then cached_tokens. The first reported count wins, including zero.
Workers AI honors an output limit reported on the reply or its chat choice. A tool call from that reply stays marked as truncated even if a later chunk reports tool_calls.
Workers AI and OpenAI-compatible Chat Completions treat the model_context_window_exceeded stop reason as a context overflow. If it arrives before any output has streamed, the run can compact the conversation and try again.
Workers AI uses the normal retry policy for HTTP rate limits and temporary server failures, even when the error mentions the model’s context window.
When one of the gateway’s spend limits is used up, the run stops with a message saying a spending limit was reached. It is not retried, and it does not move to the fallback model, which the same limit would refuse.
Each request carries metadata the gateway’s logs, analytics and spend limits can use:
| Key | Value |
|---|---|
kind |
run, child, summary, compact, suggestions or image. |
person |
Who the run’s tokens count against: the thread’s owner, or the caller. Runs only. |
thread |
The hosted thread, on runs in one. |
agent |
The run’s agent, when it has one. |
Felix never asks the gateway to cache a response, and tells it to skip its cache on every model request (Workers AI, Claude, OpenAI and Gemini alike), so a gateway with response caching turned on still answers each turn and each retry afresh: each turn of a conversation differs. Felix retries passing failures itself (see Retries), so leave the gateway’s own retries off, or requests are retried twice over.
Terminal client
Section titled “Terminal client”The terminal client reads the same choices from flags or the environment. A flag wins over its
variable, and a FELIX_-prefixed credential wins over the generic name.
| Flag | Environment | Needed for | Meaning |
|---|---|---|---|
--provider workers-ai|anthropic|openai|google|vertex|bedrock|mistral |
FELIX_PROVIDER |
Default workers-ai. A server named under providers in your settings also works. |
|
--model <id> |
FELIX_MODEL |
Both | The model ID. |
FELIX_CLOUDFLARE_ACCOUNT_ID, then CLOUDFLARE_ACCOUNT_ID |
Workers AI | The account that runs inference: 32 hexadecimal characters. | |
FELIX_CLOUDFLARE_API_TOKEN, then CLOUDFLARE_API_TOKEN |
Workers AI | A Cloudflare API token with Workers AI access. | |
FELIX_ANTHROPIC_API_KEY, then ANTHROPIC_API_KEY |
Anthropic | The Anthropic API key. | |
FELIX_OPENAI_API_KEY, then OPENAI_API_KEY |
OpenAI | The OpenAI API key. | |
FELIX_GEMINI_API_KEY, then GEMINI_API_KEY |
Gemini | The Gemini API key. | |
FELIX_MISTRAL_API_KEY, then MISTRAL_API_KEY |
Mistral | The Mistral API key. | |
FELIX_VERTEX_API_KEY, then GOOGLE_CLOUD_API_KEY; else Application Default Credentials with GOOGLE_CLOUD_PROJECT and GOOGLE_CLOUD_LOCATION |
Vertex AI | A Google Cloud API key, or gcloud auth application-default login or GOOGLE_APPLICATION_CREDENTIALS. |
|
--context-window <tokens> |
FELIX_CONTEXT_WINDOW |
Turns on compaction; see below. |
Instead of an environment variable, the personal settings file (~/.felix/settings.json) can name
a command that prints the key, such as a password manager or the macOS Keychain:
"credentials": { "cloudflareApiToken": { "command": ["security", "find-generic-password", "-s", "felix", "-w"] } }
(or anthropicApiKey). The command runs without a shell and must finish within 30 seconds. An
environment variable still wins, and a workspace’s settings file cannot name one.
export CLOUDFLARE_ACCOUNT_ID=…export CLOUDFLARE_API_TOKEN=…pnpm chat --model @cf/zai-org/glm-5.3 "Review this project"
export ANTHROPIC_API_KEY=…pnpm chat --provider anthropic --model … "Review this project"Workers AI and Anthropic models in one session
Section titled “Workers AI and Anthropic models in one session”A model record in the personal settings file can name "provider": "workers-ai" or
"provider": "anthropic". That model then runs on that provider whatever the session’s provider
is, so /model and Ctrl+P can move between them:
{ "model": "@cf/zai-org/glm-5.3", "models": { "claude-sonnet-5-5": { "provider": "anthropic", "contextWindow": 1000000, "maxOutputTokens": 32000 } }}The other provider’s key comes from the same variables or credentials command as above, read once
at start when a record names that provider. Without it, choosing the model says what to set. A
workspace’s settings file cannot set a model’s provider, since it decides where the conversation
and your key go. Workers AI’s model listing is read only when Workers AI is the session’s provider,
so give a Workers AI record its own facts when Anthropic is.
On Workers AI the client calls your account’s REST inference endpoint. These are your own
credentials. Do not reuse them as the API’s FELIX_API_TOKEN, and do not put them in a browser.
The terminal client page covers the other flags.
Context window and compaction
Section titled “Context window and compaction”A model’s context window is its contextWindow in FELIX_MODELS; for the default model,
FELIX_CONTEXT_WINDOW overrides it. It must be a whole number of at least 4096. Felix compacts
for the smaller of that window and FELIX_MAX_CONTEXT_TOKENS (200,000 by default), so a model
with a very large window does not resend that much history on every turn. A model without a window
of its own compacts for the default model’s. Before each model turn Felix
estimates the size of the request: the history, the system prompt and the tool declarations. When the estimate would leave less than the reserve free, Felix
has the model summarise the older turns and sends the summary followed by the most recent turns
verbatim. The saved transcript is never rewritten; the summary is stored beside it.
| Budget | Value |
|---|---|
| Reserve kept free for the reply and tool output | 16,384 tokens, or a quarter of the window if that is smaller; at least the model’s maxOutputTokens, up to half the window, so a request and its reply always fit. |
| Recent history kept verbatim | About 20,000 tokens, or a quarter of the window if that is smaller. |
If the provider still rejects a request as too long, Felix compacts once and tries again. When neither the model nor the default model has a window, nothing is compacted, and an over-long conversation fails with the provider’s error.
An invalid value behaves differently on each surface. The terminal client stops with an error. The
API Worker leaves conversations unconfigured, so the mistake shows as model_not_configured rather than as
a silent run without compaction.
Retries
Section titled “Retries”Both surfaces retry a request up to twice when the provider reports a passing failure, such as a rate limit, an overload or a 5xx status. They back off between attempts and wait at least as long as the provider asks; if it asks for more than 30 seconds, the request fails instead. A request is not retried once answer text or a tool call has streamed. Reasoning alone does not prevent a retry: it is cleared, and the new attempt’s reasoning is shown instead.
© Felix. All rights reserved.