Skip to content

feat: Add NVIDIA provider support with OpenAI-compatible API#2847

Open
rohithmahesh3 wants to merge 3 commits intoantinomyhq:mainfrom
rohithmahesh3:feat/nvidia-provider
Open

feat: Add NVIDIA provider support with OpenAI-compatible API#2847
rohithmahesh3 wants to merge 3 commits intoantinomyhq:mainfrom
rohithmahesh3:feat/nvidia-provider

Conversation

@rohithmahesh3
Copy link
Copy Markdown

Summary

Add NVIDIA as a supported provider using their OpenAI-compatible API, with handling for NVIDIA-specific response and request format requirements.

Context

NVIDIA's API endpoint (integrate.api.nvidia.com) follows the OpenAI chat completions format but has two key differences:

  1. Response format: NVIDIA sends reasoning_content instead of reasoning, and sometimes sends both fields simultaneously. The previous #[serde(alias)] approach caused deserialization failures when both fields appeared in the same response (serde's "duplicate value" error).
  2. Request constraints: NVIDIA rejects requests with multiple system messages or system messages not positioned at the start of the conversation.

Changes

Provider Registration

  • Added NVIDIA provider constant with string mappings in ProviderId
  • Added NVIDIA entry to provider.json with API URL and NVIDIA_API_KEY environment variable

Response Handling (Serde Fix)

  • Replaced #[serde(alias = "reasoning_content")] with a dedicated reasoning_content field on ResponseMessage
  • Added merged_reasoning() helper that prefers reasoning over reasoning_content when both are present
  • Updated both streaming and non-streaming response paths to use merged_reasoning()

Request Transformer

  • Added MergeSystemMessages transformer that consolidates all system messages into a single leading system message
  • Wired into the provider pipeline for NVIDIA requests only

Testing

  • 4 NVIDIA deserialization tests (tool call streaming, tool call parsing, response message, choice)
  • 4 MergeSystemMessages transformer tests (multiple system messages, single system message, no system messages, empty messages)
  • 2 provider config tests
  • All existing tests updated and passing (551 in forge_app, 282 in forge_domain/forge_repo)

Testing

cargo test -p forge_app -p forge_domain -p forge_repo --lib

All 832 tests pass.

- Add NVIDIA provider constant and configuration
- Add reasoning_content field to handle NVIDIA's response format
- Implement MergeSystemMessages transformer for NVIDIA's system message requirements
- Add comprehensive test coverage for NVIDIA deserialization
@CLAassistant
Copy link
Copy Markdown

CLAassistant commented Apr 5, 2026

CLA assistant check
All committers have signed the CLA.

@github-actions github-actions bot added the type: feature Brand new functionality, features, pages, workflows, endpoints, etc. label Apr 5, 2026
…st.rs

Co-authored-by: graphite-app[bot] <96075541+graphite-app[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type: feature Brand new functionality, features, pages, workflows, endpoints, etc.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants