Skip to content
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

[Roadmap] multiple Gemini API keys #653

Open
2 tasks
darthalex2014 opened this issue Sep 30, 2024 · 0 comments
Open
2 tasks

[Roadmap] multiple Gemini API keys #653

darthalex2014 opened this issue Sep 30, 2024 · 0 comments

Comments

@darthalex2014
Copy link

darthalex2014 commented Sep 30, 2024

Why
Users will be able to use multiple Gemini API keys to access the AI, allowing them to bypass rate limits and improve performance, especially when working with Beam and a single AI provider.

Description
Add support for using multiple Gemini API keys in the application.

Requirements

  • Environment Variable:
    • Add a new environment variable GEMINI_API_KEYS in src/server/env.mjs to store a comma-separated list of API keys.
  • Key Selection Logic:
    • Modify the line const geminiKey = access.geminiKey || env.GEMINI_API_KEY || ''; in src/modules/llms/server/gemini/gemini.router.ts to:
  let geminiKey: string;
  if (access.geminiKey.includes(',')) {
    // If access.geminiKey includes commas, treat it as a list of keys and choose a random one
    const keys = access.geminiKey.split(',').map(key => key.trim()).filter(key => key.length > 0);
    geminiKey = keys[Math.floor(Math.random() * keys.length)];
  } else {
    // Otherwise, treat it as a single key
    geminiKey = access.geminiKey;
  }

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant