Skip to content

Conversation

@suprjinx
Copy link

@suprjinx suprjinx commented Jul 24, 2025

Related GitHub Issue

Closes: #4337

Description

This PR adds support for obtaining API keys from the environment. A checkbox is added to each configuration that allows inputting an API key -- when checked, a given environment variable (eg, OPENAI_API_KEY, etc) is consulted for the key and the user is not required to provide one in the configuration. Env Var key is predictable but not editable.

Test Procedure

I tested this using VS Code run configurations, where the expected environment variable could be provided or omitted.

Pre-Submission Checklist

  • Issue Linked: This PR is linked to an approved GitHub Issue (see "Related GitHub Issue" above).
  • Scope: My changes are focused on the linked issue (one major feature/fix per PR).
  • Self-Review: I have performed a thorough self-review of my code.
  • Testing: New and/or updated tests have been added to cover my changes (if applicable).
  • Documentation Impact: I have considered if my changes require documentation updates (see "Documentation Updates" section below).

A documentation update is advised, to describe environment variable usage to supply API keys.

Screenshots / Videos

Documentation Updates

Additional Notes

Get in Touch


Important

Adds support for using environment variables for API keys across multiple providers, updates UI components to reflect this, and enhances testing and translation capabilities.

  • Behavior:
    • Adds support for API keys from environment variables for providers like anthropic, glama, openrouter, openai, gemini, mistral, deepseek, unbound, requesty, xai, groq, chutes, litellm in provider-settings.ts.
    • Updates validateModelsAndKeysProvided() in validate.ts to check for environment variable usage for API keys.
  • UI Components:
    • Introduces ApiKey component in ApiKey.tsx to handle API key input and environment variable toggle.
    • Updates various provider components like Anthropic.tsx, Chutes.tsx, DeepSeek.tsx, etc., to use the new ApiKey component.
  • Testing:
    • Adds tests for environment variable integration in index.spec.ts and ApiKey.spec.tsx.
  • Misc:
    • Adds --create-missing option in find-missing-translations.js for generating placeholder translation keys.

This description was created by Ellipsis for f154eb2. You can customize this summary. It will automatically update as commits are pushed.

@hannesrudolph hannesrudolph added the Issue/PR - Triage New issue. Needs quick review to confirm validity and assign labels. label Jul 24, 2025
@suprjinx suprjinx marked this pull request as ready for review July 25, 2025 18:01
@suprjinx suprjinx requested review from cte, jr and mrubens as code owners July 25, 2025 18:01
@dosubot dosubot bot added size:XXL This PR changes 1000+ lines, ignoring generated files. documentation Improvements or additions to documentation labels Jul 25, 2025
@suprjinx
Copy link
Author

Thanks, @daniel-lxs -- addressed these issues and added some new providers, let me know if you see any other problems!

Signed-off-by: Geoff Wilson <[email protected]>
@suprjinx
Copy link
Author

suprjinx commented Oct 8, 2025

@daniel-lxs would love to get this approved, can you take a look at the changes since your last comment?

@roomote
Copy link

roomote bot commented Oct 27, 2025

Review Summary

I've reviewed the latest changes (commit 7b24b89) and found no new issues. All previously flagged issues have been successfully addressed.

Issues to Fix

  • Fix typo in constant name: MOONSHOOT should be MOONSHOT in packages/types/src/constants.ts
  • Remove trailing whitespace in packages/types/src/provider-settings.ts (lines 372, 397, 417)
  • Add validation checks for new providers with env var support in webview-ui/src/utils/validate.ts (deepinfra, huggingface, cerebras, fireworks, featherless, io-intelligence, vercel-ai-gateway, doubao, moonshot)

Overall Assessment

The implementation is well-structured and follows a consistent pattern across all providers. The core functionality for reading API keys from environment variables is solid. All validation logic for the newly added providers has been properly implemented.

Follow Along on Roo Code Cloud

Previous Reviews

Copy link

@roomote roomote bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review complete. Found 3 issues that should be addressed before merging. Please see the inline comments for details.

@suprjinx
Copy link
Author

@daniel-lxs I addressed the issues found by the review bot with 4597469

Copy link

@roomote roomote bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found in the latest commit (142412c). The translation updates look good.

Signed-off-by: Geoff Wilson <[email protected]>
Copy link

@roomote roomote bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review updated. The formatting commit looks good - all trailing whitespace issues have been resolved.

Signed-off-by: Geoff Wilson <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation enhancement New feature or request PR - Changes Requested size:XXL This PR changes 1000+ lines, ignoring generated files.

Projects

Status: PR [Changes Requested]

Development

Successfully merging this pull request may close these issues.

Obtain API keys from environment in addition to UI form

4 participants