Add Workers AI gateway for direct API integration - #1
Merged
Conversation
3 tasks
meirdick
force-pushed
the
feature/workersai-gateway
branch
from
April 14, 2026 19:49
adfc63b to
efe4147
Compare
Adds a native WorkersAiGateway that calls the Cloudflare Workers AI API directly via the Chat Completions format, removing the Prism dependency for Workers AI text generation, streaming, and embeddings. Key features: - Direct and AI Gateway URL construction from account_id/gateway config - Reasoning model support (ReasoningStart/Delta/End events) for Kimi K2.5, Gemma 4, and QwQ models - Session affinity header for prefix caching - Content string coercion for Workers AI compatibility - /compat endpoint model name validation with helpful error messages - Embeddings via /embeddings endpoint Follows the same trait-based composition pattern as the Groq and Mistral gateway migrations. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
meirdick
force-pushed
the
feature/workersai-gateway
branch
from
April 14, 2026 20:08
efe4147 to
743c18c
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds a native
WorkersAiGatewaythat calls the Cloudflare Workers AI API directly via the Chat Completions format, following the same trait-based composition pattern as the Groq and Mistral gateway migrations.WorkersAiProviderwith text generation + embeddingsWorkersAiGateway implements EmbeddingGateway, TextGatewayaccount_id(direct) orgatewayconfig (AI Gateway)ReasoningStart/Delta/Endevents for Kimi K2.5, Gemma 4, QwQx-session-affinityheader for prefix caching/compatURL used withoutworkers-ai/model prefixUser setup
Test plan
🤖 Generated with Claude Code