Add multi-provider API support and refactor authentication#1
Open
cometben54-arch wants to merge 2 commits intoMixtoo:mainfrom
Open
Add multi-provider API support and refactor authentication#1cometben54-arch wants to merge 2 commits intoMixtoo:mainfrom
cometben54-arch wants to merge 2 commits intoMixtoo:mainfrom
Conversation
…nfig Migrate from Vercel to Cloudflare Pages + Workers: - Add functions/api/ with proxy, verify-code, stats Workers - Replace @vercel/kv with Cloudflare KV bindings - Replace AWS S3 with Cloudflare R2 bindings - Add wrangler.toml and _routes.json for CF Pages routing - Simplify vite.config.ts dev middleware Add multi-provider API configuration UI: - Redesign ApiKeyModal with tabbed interface (API Key / Passcode) - Support Google Gemini, OpenAI-compatible, and custom endpoints - Model selector for each provider - Update geminiService to route calls by provider - Add ApiProviderConfig type and model constants - Update translations (EN/CN) for new config UI https://claude.ai/code/session_01RGY4k7JQ6QT27E7KBYJ1KT
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
This PR introduces support for multiple AI providers (Google Gemini, OpenAI-compatible APIs, and custom endpoints) while refactoring the authentication system to support both API key and passcode modes with a cleaner separation of concerns.
Key Changes
API Provider Support
ApiProviderConfigtype to support multiple providers: Google Gemini, OpenAI-compatible, and custom endpointsgeminiService.tsto handle different provider implementations:callGemini()callOpenAICompatible()supporting both image generation and vision modelsprocessImageWithGemini()to route requests based on configured providerAuthentication Refactor
ApiKeyModalinto two tabs: "API Key" and "Passcode" modeshandleSaveApiKey()andhandleSavePasscode()api_provider_configwith backward compatibility for legacy keysuseAuthhook to check for new config format while maintaining legacy supportBackend Infrastructure
functions/api/proxy.ts: Handles image processing with quota management via Cloudflare KVfunctions/api/verify-code.ts: Validates access codes and returns quota infofunctions/api/stats.ts: Tracks global usage statisticswrangler.tomlconfiguration for Cloudflare deploymentvite.config.tswith mock access codesUI/UX Improvements
Type System
ApiProvidertype union for supported providersGEMINI_MODELSandOPENAI_MODELSconstants for model selectionQuotaInfointerface usage across authentication flowTranslations
Notable Implementation Details
gemini_api_key_localandgemini_access_codeare still supportedcompressImage()functionhttps://claude.ai/code/session_01RGY4k7JQ6QT27E7KBYJ1KT