-
Notifications
You must be signed in to change notification settings - Fork 321
Add GatewayConfig and expand AI provider support #745
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Introduces a new GatewayConfig component and updates dependencies to add support for multiple AI providers (Amazon Bedrock, Azure, Cerebras, Cohere, Deepgram, Deepseek, ElevenLabs, Fireworks, Google, Google Vertex, Groq, Mistral, OpenRouter, Perplexity, xAI). Updates app and server logic to integrate with the new providers and configuration options.
|
Claude Code ReviewIssues Found1. Security: API Keys Stored in Agent State (server.ts:44-49)
Recommendation: These sensitive credentials should be stored in environment variables or a secrets manager, not in agent state that could be logged/persisted. 2. Missing Input Validation (server.ts:116-127) Recommendation: Add validation before line 130: if (!this.state.gatewayAccountId || !this.state.gatewayId || !this.state.gatewayApiKey) {
throw new Error("Missing required gateway credentials");
}3. Model Name Parsing Fragility (server.ts:118-121) if (modelName.includes("/")) {
modelName = modelName.split("/")[1];
}This is fragile - if the format changes to have multiple slashes (e.g., "provider/version/model"), this breaks. Consider using 4. xAI Hardcoded Base URL (server.ts:183) Recommendation: Move to configuration or environment variable. 5. Silent Fallback Behavior (server.ts:193-196) Recommendation: Throw an error or emit a warning when falling back, so users know their configuration is incomplete. 6. Hardcoded Model Lists (UnifiedModelSelector.tsx:10-135) Recommendation: Consider fetching available models from an API or configuration file that can be updated without code changes. Testing CoverageNo test files included in this PR. Given the complexity of multi-provider authentication logic with multiple failure modes, this needs test coverage for:
Architecture AlignmentThe implementation is reasonable but mixing UI state (model selection) with security-sensitive data (API keys) in the same state object is concerning. Consider separating concerns. SummaryThe core functionality looks solid, but there are security and validation issues that should be addressed before merging. The lack of tests for the authentication logic is also a gap. |
commit: |
Sync documentation for PR #745: Add GatewayConfig and expand AI provider support This update documents the new capability to use AI Gateway with multiple AI providers (OpenAI, Anthropic, Google, Amazon Bedrock, Azure, and more) when building agents. The documentation includes: - List of 15+ supported AI providers through AI Gateway - Example code showing how to integrate AI Gateway with different providers - Reference to the AI Playground as a demonstration - Benefits of routing requests through AI Gateway (logging, caching, etc.) - Links to BYOK configuration documentation Related PR: cloudflare/agents#745 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Replaces ModelSelector and GatewayConfig with UnifiedModelSelector, enabling selection between Workers AI and external providers (OpenAI, Anthropic, Google) with unified billing or BYOK authentication. Updates Playground state and server logic to support provider/gateway selection, model IDs, and authentication methods. Refactors UI and server to handle new model selection and authentication flows.
Refactored the code generation logic in ViewCodeModal to support Workers AI, OpenAI, Anthropic, and Google providers, with options for both direct API keys and Cloudflare AI Gateway unified billing. Improved string escaping for generated code and updated UI messaging to reflect the selected provider and authentication method.
This update adds detailed documentation for the Cloudflare AI Playground, covering the new external AI provider support and authentication methods introduced in PR #745. Key documentation additions: - External provider support (OpenAI, Anthropic, Google) - Two authentication methods: - Provider API Key (BYOK - Bring Your Own Key) - AI Gateway (Unified Billing) - Configuration options (system prompt, temperature, model filtering) - Code export examples for all authentication modes - MCP server integration guide Related PR: cloudflare/agents#745 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Introduces xAI as a selectable provider in the AI Playground, including model selection, API key handling, and code generation. xAI models are integrated using the OpenAI-compatible API with appropriate base URL configuration. Updates are made across the app, model selector, code modal, and server logic to support xAI alongside existing providers.
Introduces a new GatewayConfig component and updates dependencies to add support for multiple AI providers (OpenAI, Anthropic, Google, xAI). Updates app and server logic to integrate with the new providers and configuration options.