feat: add Workers AI text embeddings and multimodal captioning (#5414)

* feat: add Workers AI text embeddings and multimodal captioning

Extends the Cloudflare Workers AI integration to the vectors and
caption extensions.

Embeddings: adds workers_ai source to the vectors extension using the
OpenAI-compatible /v1/embeddings endpoint, with dynamic model listing
from the Cloudflare model search API.

Captioning: adds workers_ai as a multimodal caption API with dynamic
vision model discovery via the multimodal-models endpoint.

* Add logo svg

* Refactor caption dropdown population

* Fix order of sources

* feat: add error handling for missing Workers AI account ID

---------

Co-authored-by: Cohee <18619528+Cohee1207@users.noreply.github.com>
This commit is contained in:
Tony Gies
2026-04-08 15:43:21 -05:00
committed by GitHub
parent 94a5773412
commit a9c377c3c8
10 changed files with 211 additions and 3 deletions
+8
View File
@@ -126,6 +126,10 @@ export async function getMultimodalCaption(base64Img, prompt) {
requestBody.zai_endpoint = oai_settings.zai_endpoint || ZAI_ENDPOINT.COMMON;
}
if (extension_settings.caption.multimodal_api === 'workers_ai') {
requestBody.workers_ai_account_id = oai_settings.workers_ai_account_id;
}
function getEndpointUrl() {
switch (extension_settings.caption.multimodal_api) {
case 'google':
@@ -283,6 +287,10 @@ function throwIfInvalidModel(useReverseProxy) {
if (multimodalApi === 'pollinations' && !secret_state[SECRET_KEYS.POLLINATIONS]) {
throw new Error('Pollinations API key is not set.');
}
if (multimodalApi === 'workers_ai' && (!secret_state[SECRET_KEYS.WORKERS_AI] || !oai_settings.workers_ai_account_id)) {
throw new Error('Workers AI API key or account ID is not set.');
}
}
/**