Skip to content

Conversation

@Thachnh
Copy link
Contributor

@Thachnh Thachnh commented Sep 4, 2025

Related GitHub Issue

Closes: #7661

Description

This PR adds DeepInfra as a provider to Roo Code. DeepInfra hosts ~100 open-source and frontier models at very competitive pricing* and fast inference. Prompt caching is enabled by default for certain models, such as Qwen3 Coder.

Test Procedure

  • Open the provider selection menu and confirm DeepInfra appears as an option.
  • Verify models are fetched dynamically and listed correctly.
  • Add a valid DeepInfra API key. Run completions against several DeepInfra models and confirm results return as expected.
  • (Optional) Test prompt caching with a supported model and verify lower rate is applied.

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).
  • Contribution Guidelines: I have read and agree to the Contributor Guidelines.

Screenshots / Videos

Screenshot 2025-09-03 at 4 36 41 PM

Documentation Updates

  • No documentation updates are required.

Additional Notes

Get in Touch

Thach @ DeepInfra — happy to chat on the Roo Code Discord (@thachnh) or via DM.


Important

Adds DeepInfra as a model provider with dynamic model fetching, UI integration, and validation support.

  • Behavior:
    • Adds DeepInfra as a model provider with dynamic model fetching and prompt caching in deepinfra.ts.
    • Updates webviewMessageHandler.ts to handle DeepInfra model requests and responses.
  • UI Components:
    • Adds DeepInfra component in DeepInfra.tsx for provider-specific settings.
    • Updates ApiOptions.tsx and ModelPicker.tsx to include DeepInfra in provider selection and model picking.
  • Validation:
    • Updates validate.ts and ProfileValidator.ts to include DeepInfra in API key and model ID validation.
  • Misc:
    • Adds DeepInfra to provider-settings.ts, global-settings.ts, and constants.ts for configuration and default settings.
    • Updates tests in webviewMessageHandler.spec.ts and validate.test.ts to cover DeepInfra functionality.

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

@Thachnh Thachnh requested review from cte, jr and mrubens as code owners September 4, 2025 18:18
@dosubot dosubot bot added size:L This PR changes 100-499 lines, ignoring generated files. enhancement New feature or request labels Sep 4, 2025
onClick={() => {
vscode.postMessage({ type: "flushRouterModels", text: "deepinfra" })
refetchRouterModels()
setDidRefetch(true)
Copy link
Contributor

Choose a reason for hiding this comment

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

The DeepInfra component correctly triggers a refresh of models by sending a 'flushRouterModels' message and calling refetchRouterModels. Consider optionally resetting the didRefetch state after a timeout so the UI hint does not persist indefinitely.

Copy link
Contributor

@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.

Thank you for your contribution! I've reviewed the changes and found several issues that need attention before this can be merged.

...options,
openAiHeaders: {
"X-Deepinfra-Source": "roo-code",
"X-Deepinfra-Version": `2025-08-25`,
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this intentional? The version date appears to be in the future (August 2025). Should this be '2024-08-25' or another appropriate date?

Suggested change
"X-Deepinfra-Version": `2025-08-25`,
"X-Deepinfra-Version": `2024-08-25`,

Copy link
Collaborator

Choose a reason for hiding this comment

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

We live in the future!

): ApiStream {
// Ensure we have up-to-date model metadata
await this.fetchModel()
const { id: modelId, info, reasoningEffort: reasoning_effort } = await this.fetchModel()
Copy link
Contributor

Choose a reason for hiding this comment

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

There's a duplicate call to fetchModel() here. Line 61 already calls it, so line 62 is redundant and could cause unnecessary API calls. Consider removing this duplicate.

import { getModelParams } from "../transform/model-params"
import { getModels } from "./fetchers/modelCache"

export class DeepInfraHandler extends RouterProvider implements SingleCompletionHandler {
Copy link
Contributor

Choose a reason for hiding this comment

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

Missing test coverage for this new provider implementation. Could you add unit tests similar to other providers in the codebase? This would help ensure the DeepInfra integration works correctly and prevent regressions.

const url = `${baseUrl.replace(/\/$/, "")}/models`
const models: Record<string, ModelInfo> = {}

const response = await axios.get(url, { headers })
Copy link
Contributor

Choose a reason for hiding this comment

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

Consider adding more specific error handling here. For example, distinguishing between rate limiting (429), authentication failures (401/403), and other errors would provide better user feedback. Could we enhance this to match the error handling patterns used in other fetchers?

// The outer ApiOptions debounces and sends requestRouterModels; this keeps UI responsive
}, [apiConfiguration.deepInfraBaseUrl, apiConfiguration.deepInfraApiKey])

return (
Copy link
Contributor

Choose a reason for hiding this comment

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

The backend supports configuring a custom base URL, but there's no UI field for it here. Should we add a text field for deepInfraBaseUrl to give users more flexibility, similar to how other providers handle custom endpoints?

import type { ModelInfo } from "../model.js"

// Default fallback values for DeepInfra when model metadata is not yet loaded.
export const deepInfraDefaultModelId = "Qwen/Qwen3-Coder-480B-A35B-Instruct-Turbo"
Copy link
Contributor

Choose a reason for hiding this comment

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

Consider adding JSDoc comments to document the DeepInfra-specific features, especially the prompt caching support. This would help other developers understand the unique capabilities of this provider.

@hannesrudolph hannesrudolph added the Issue/PR - Triage New issue. Needs quick review to confirm validity and assign labels. label Sep 4, 2025
Copy link
Member

@daniel-lxs daniel-lxs left a comment

Choose a reason for hiding this comment

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

Thank you @Thachnh!

@dosubot dosubot bot added the lgtm This PR has been approved by a maintainer label Sep 4, 2025
@daniel-lxs daniel-lxs moved this from Triage to PR [Needs Review] in Roo Code Roadmap Sep 4, 2025
@hannesrudolph hannesrudolph added PR - Needs Review and removed Issue/PR - Triage New issue. Needs quick review to confirm validity and assign labels. labels Sep 4, 2025
@mrubens mrubens merged commit 72502d8 into RooCodeInc:main Sep 4, 2025
26 checks passed
@github-project-automation github-project-automation bot moved this from PR [Needs Review] to Done in Roo Code Roadmap Sep 4, 2025
@github-project-automation github-project-automation bot moved this from New to Done in Roo Code Roadmap Sep 4, 2025
@Thachnh
Copy link
Contributor Author

Thachnh commented Sep 4, 2025

Thanks @daniel-lxs @mrubens !!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request lgtm This PR has been approved by a maintainer PR - Needs Review size:L This PR changes 100-499 lines, ignoring generated files.