You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
LLM translation only works with the Workers AI binding (no translation for self-hosted/Docker deployments) #2535
LLM translation (src/helpers/translateAI.ts) only works through the Cloudflare Workers AI AI binding (@cf/openai/gpt-oss-120b, then @cf/meta/m2m100-1.2b), and each build-host adapter gates it with aiEnabled: Boolean(c.env?.AI).
Self-hosted deployments that don't have that binding, including the Docker image (wrangler dev --local), get no LLM fallback at all:
Bluesky / Mastodon: translation depends entirely on Polyglot. The .env.example default points at polyglot.fxembed.com with an empty POLYGLOT_ACCESS_TOKEN, so a self-hoster gets no translation for /en, /ja and so on.
Twitter: only the Grok path is left.
The prompt already in translateTextLLM is provider-agnostic. The only thing tying it to Cloudflare is the c.env.AI.run(...) call.
Proposal
Add an optional OpenAI-compatible chat completions backend, configured through environment variables in the same way as POLYGLOT_*:
Variable
Purpose
LLM_TRANSLATION_BASE_URL
e.g. https://api.openai.com/v1, http://localhost:8080/v1
LLM_TRANSLATION_API_KEY
Bearer token (optional for local servers)
LLM_TRANSLATION_MODEL
model name
LLM_TRANSLATION_EXTRA_BODY
optional JSON merged into the request body
When it's configured, it's tried before the Workers AI binding. If it fails, the existing Workers AI → M2M100 chain runs unchanged.
aiEnabled becomes true if either backend is available.
Nothing changes for deployments that don't set it.
LLM_TRANSLATION_EXTRA_BODY covers the provider-specific knobs that reasoning models need. For example, a hosted reasoning model I tried took about 9.6 s to translate a short post with thinking on, and about 1.4 s with {"thinking":{"type":"disabled"}}. llama.cpp and vLLM use {"chat_template_kwargs":{"enable_thinking":false}} instead. Any <think>…</think> left in the content by servers running without a reasoning parser is stripped.
It works with any OpenAI-compatible endpoint (OpenAI, OpenRouter, a local llama.cpp, vLLM or Ollama server, and so on). It doesn't add any vendor-specific code or dependencies. Gateways like the one in #2506 are OpenAI-compatible too, so they could use it through configuration alone.
Activity