Skip to content

Conversation

@roomote
Copy link

@roomote roomote bot commented Nov 3, 2025

This PR attempts to address Issue #8998 by adding support for generic OpenAI-compatible APIs like NVIDIA.

Summary

Adds a new openai-compatible provider that allows users to connect to any OpenAI-compatible API endpoint by specifying a custom base URL and API key. This enables support for services like NVIDIA API and other OpenAI-compatible services that use the same protocol.

Changes

  • New Provider Handler: Added OpenAiCompatibleHandler that extends the base OpenAI-compatible provider class
  • Configuration Support: Added openAiCompatibleBaseUrl and openAiCompatibleApiKey settings in provider-settings.ts
  • API Integration: Registered the new provider in the API index for proper instantiation
  • UI Support: Added handling for the openai-compatible provider in the UI model selection hook
  • Tests: Added comprehensive test coverage for the new provider

Testing

  • ✅ Unit tests pass for the new provider handler
  • ✅ Type checking passes for all packages
  • ✅ Linting passes

Example Usage

Users can now use NVIDIA API or any OpenAI-compatible service by:

  1. Selecting "OpenAI Compatible" as the provider
  2. Setting the base URL (e.g., https://integrate.api.nvidia.com/v1)
  3. Providing their API key
  4. Selecting the model (e.g., minimaxai/minimax-m2)

Fixes #8998

Feedback and guidance are welcome!


Important

Add OpenAiCompatibleHandler for OpenAI-compatible APIs, including NVIDIA, with configuration, API integration, UI support, and tests.

  • New Provider Handler:
    • Added OpenAiCompatibleHandler in openai-compatible.ts for OpenAI-compatible APIs.
    • Supports custom base URL and API key.
  • Configuration:
    • Added openAiCompatibleBaseUrl and openAiCompatibleApiKey in provider-settings.ts.
    • Updated providerSettingsSchemaDiscriminated and providerSettingsSchema to include new settings.
  • API Integration:
    • Registered OpenAiCompatibleHandler in index.ts.
    • Updated buildApiHandler() to handle openai-compatible provider.
  • UI Support:
    • Added handling for openai-compatible in useSelectedModel.ts.
  • Tests:
    • Added openai-compatible.spec.ts for testing OpenAiCompatibleHandler.
  • Misc:
    • Updated modelIdKeysByProvider and MODELS_BY_PROVIDER in provider-settings.ts.

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

- Add new OpenAiCompatibleHandler provider for generic OpenAI-compatible APIs
- Add configuration support in provider-settings.ts and API index
- Support custom base URLs and API keys for services like NVIDIA
- Include comprehensive tests for the new provider
- Fixes #8998
@roomote roomote bot requested review from cte, jr and mrubens as code owners November 3, 2025 19:54
@dosubot dosubot bot added size:L This PR changes 100-499 lines, ignoring generated files. enhancement New feature or request labels Nov 3, 2025
@roomote
Copy link
Author

roomote bot commented Nov 3, 2025

See this task on Roo Code Cloud

Review complete. Found 1 issue that should be addressed:

  • Remove type assertions in openai-compatible.ts constructor - properties are already available in ApiHandlerOptions

Mention @roomote in a comment to trigger your PR Fixer agent and make changes to this pull request.

Comment on lines +21 to +25
// Since ApiHandlerOptions doesn't have openAiCompatibleBaseUrl/ApiKey yet,
// we'll use the openAiBaseUrl and openAiApiKey for now as a workaround
// This will be properly fixed when we add the proper types
const baseURL = (options as any).openAiCompatibleBaseUrl || options.openAiBaseUrl
const apiKey = (options as any).openAiCompatibleApiKey || options.openAiApiKey
Copy link
Author

Choose a reason for hiding this comment

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

The type assertion (options as any) bypasses TypeScript's type checking. Since ApiHandlerOptions extends ProviderSettings which includes openAiCompatibleBaseUrl and openAiCompatibleApiKey (defined in provider-settings.ts lines 425-427), these properties should be directly accessible without casting. The fallback to openAiBaseUrl/openAiApiKey creates ambiguity about which properties are authoritative for this provider.

@hannesrudolph hannesrudolph added the Issue/PR - Triage New issue. Needs quick review to confirm validity and assign labels. label Nov 3, 2025
@daniel-lxs daniel-lxs closed this Nov 3, 2025
@github-project-automation github-project-automation bot moved this from Triage to Done in Roo Code Roadmap Nov 3, 2025
@github-project-automation github-project-automation bot moved this from New to Done in Roo Code Roadmap Nov 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request Issue/PR - Triage New issue. Needs quick review to confirm validity and assign labels. size:L This PR changes 100-499 lines, ignoring generated files.

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

[BUG] Unable to use minimax-M2 on OpenAI Compatible API

4 participants