add Nemotron-3-Super to ai lib #118

Open
opened 2026-03-12 03:25:00 +00:00 by despiegk · 3 comments
Owner

specs
https://deepinfra.com/dash/models/details?model=nvidia%2FNVIDIA-Nemotron-3-Super-120B-A12B&tab=api

check that all parameters can be used in our AI client API, using builder paradigm

make sure we give deepinfra priority if we can find the DEEPINFRA_API_KEY key for this model

make some integration tests which only run when the DEEPINFRA_API_KEY or OPENROUTER_API_KEY is being set

make nice example in rust

make sure we support https://openrouter.ai/nvidia/nemotron-3-super-120b-a12b:free
as well

so we support the deepinfra if key = preferred otherwise the openrouter one

specs https://deepinfra.com/dash/models/details?model=nvidia%2FNVIDIA-Nemotron-3-Super-120B-A12B&tab=api check that all parameters can be used in our AI client API, using builder paradigm make sure we give deepinfra priority if we can find the DEEPINFRA_API_KEY key for this model make some integration tests which only run when the DEEPINFRA_API_KEY or OPENROUTER_API_KEY is being set make nice example in rust make sure we support https://openrouter.ai/nvidia/nemotron-3-super-120b-a12b:free as well so we support the deepinfra if key = preferred otherwise the openrouter one
Author
Owner

Implementation Spec for Issue #118: Add Nemotron-3-Super to AI Lib

Objective

Add NVIDIA Nemotron-3-Super-120B-A12B as a new model in the herolib_ai crate with DeepInfra as a new provider (preferred when DEEPINFRA_API_KEY is set) and OpenRouter as a fallback (including the free tier endpoint).

Requirements

  • Add DeepInfra as a new Provider variant with base URL https://api.deepinfra.com/v1/openai
  • Add NemotronSuper120B as a new Model variant
  • DeepInfra is the preferred provider when DEEPINFRA_API_KEY is set
  • OpenRouter fallback uses nvidia/nemotron-3-super-120b-a12b:free as model ID
  • All builder parameters (temperature, max_tokens, top_p, etc.) already supported — no changes to types.rs needed
  • Integration tests gated behind DEEPINFRA_API_KEY or OPENROUTER_API_KEY env vars
  • Rust example demonstrating usage
  • Rhai bindings updated for the new model

Files to Modify

File Description
crates/ai/src/provider.rs Add DeepInfra variant with base URL, env var, display name
crates/ai/src/model.rs Add NemotronSuper120B variant with DeepInfra + OpenRouter providers
crates/ai/src/client/mod.rs Register DeepInfra in from_env() auto-discovery
crates/ai/src/rhai.rs Add model parsing for Rhai scripting
crates/ai/src/lib.rs Update crate documentation
crates/ai/Cargo.toml Update description

Files to Create

File Description
crates/ai/tests/nemotron_super_integration.rs Integration tests gated behind API keys
crates/ai/examples/rust/nemotron_super.rs Rust example

Implementation Plan

Step 1: Add DeepInfra Provider

Files: crates/ai/src/provider.rs

  • Add DeepInfra to Provider enum
  • Add base URL, env var, name match arms
    Dependencies: none

Step 2: Add Nemotron-3-Super Model

Files: crates/ai/src/model.rs

  • Add NemotronSuper120B variant with provider mappings
  • DeepInfra model ID: nvidia/NVIDIA-Nemotron-3-Super-120B-A12B
  • OpenRouter model ID: nvidia/nemotron-3-super-120b-a12b:free
  • Context window: 128K
    Dependencies: Step 1

Step 3: Register DeepInfra in Client

Files: crates/ai/src/client/mod.rs

  • Add Provider::DeepInfra to provider array (first position for priority)
    Dependencies: Step 1

Step 4: Update Rhai Bindings

Files: crates/ai/src/rhai.rs

  • Add nemotron_super_120b parsing in parse_model()
    Dependencies: Step 2

Step 5: Update Documentation

Files: crates/ai/src/lib.rs, crates/ai/Cargo.toml
Dependencies: Steps 1-2

Step 6: Create Integration Tests

Files: crates/ai/tests/nemotron_super_integration.rs
Dependencies: Steps 1-3

Step 7: Create Rust Example

Files: crates/ai/examples/rust/nemotron_super.rs
Dependencies: Steps 1-3

Acceptance Criteria

  • Provider::DeepInfra exists with correct base URL and env var
  • Model::NemotronSuper120B exists with DeepInfra first, OpenRouter second
  • AiClient::from_env() auto-discovers DEEPINFRA_API_KEY
  • Rhai parse_model() handles the new model
  • Integration tests exist and are gated behind API keys
  • Example compiles successfully
  • cargo build and cargo test succeed
## Implementation Spec for Issue #118: Add Nemotron-3-Super to AI Lib ### Objective Add NVIDIA Nemotron-3-Super-120B-A12B as a new model in the `herolib_ai` crate with DeepInfra as a new provider (preferred when `DEEPINFRA_API_KEY` is set) and OpenRouter as a fallback (including the free tier endpoint). ### Requirements - Add `DeepInfra` as a new `Provider` variant with base URL `https://api.deepinfra.com/v1/openai` - Add `NemotronSuper120B` as a new `Model` variant - DeepInfra is the preferred provider when `DEEPINFRA_API_KEY` is set - OpenRouter fallback uses `nvidia/nemotron-3-super-120b-a12b:free` as model ID - All builder parameters (temperature, max_tokens, top_p, etc.) already supported — no changes to types.rs needed - Integration tests gated behind `DEEPINFRA_API_KEY` or `OPENROUTER_API_KEY` env vars - Rust example demonstrating usage - Rhai bindings updated for the new model ### Files to Modify | File | Description | |------|-------------| | `crates/ai/src/provider.rs` | Add `DeepInfra` variant with base URL, env var, display name | | `crates/ai/src/model.rs` | Add `NemotronSuper120B` variant with DeepInfra + OpenRouter providers | | `crates/ai/src/client/mod.rs` | Register DeepInfra in `from_env()` auto-discovery | | `crates/ai/src/rhai.rs` | Add model parsing for Rhai scripting | | `crates/ai/src/lib.rs` | Update crate documentation | | `crates/ai/Cargo.toml` | Update description | ### Files to Create | File | Description | |------|-------------| | `crates/ai/tests/nemotron_super_integration.rs` | Integration tests gated behind API keys | | `crates/ai/examples/rust/nemotron_super.rs` | Rust example | ### Implementation Plan #### Step 1: Add DeepInfra Provider Files: `crates/ai/src/provider.rs` - Add `DeepInfra` to `Provider` enum - Add base URL, env var, name match arms Dependencies: none #### Step 2: Add Nemotron-3-Super Model Files: `crates/ai/src/model.rs` - Add `NemotronSuper120B` variant with provider mappings - DeepInfra model ID: `nvidia/NVIDIA-Nemotron-3-Super-120B-A12B` - OpenRouter model ID: `nvidia/nemotron-3-super-120b-a12b:free` - Context window: 128K Dependencies: Step 1 #### Step 3: Register DeepInfra in Client Files: `crates/ai/src/client/mod.rs` - Add `Provider::DeepInfra` to provider array (first position for priority) Dependencies: Step 1 #### Step 4: Update Rhai Bindings Files: `crates/ai/src/rhai.rs` - Add `nemotron_super_120b` parsing in `parse_model()` Dependencies: Step 2 #### Step 5: Update Documentation Files: `crates/ai/src/lib.rs`, `crates/ai/Cargo.toml` Dependencies: Steps 1-2 #### Step 6: Create Integration Tests Files: `crates/ai/tests/nemotron_super_integration.rs` Dependencies: Steps 1-3 #### Step 7: Create Rust Example Files: `crates/ai/examples/rust/nemotron_super.rs` Dependencies: Steps 1-3 ### Acceptance Criteria - [ ] `Provider::DeepInfra` exists with correct base URL and env var - [ ] `Model::NemotronSuper120B` exists with DeepInfra first, OpenRouter second - [ ] `AiClient::from_env()` auto-discovers `DEEPINFRA_API_KEY` - [ ] Rhai `parse_model()` handles the new model - [ ] Integration tests exist and are gated behind API keys - [ ] Example compiles successfully - [ ] `cargo build` and `cargo test` succeed
Author
Owner

Test Results

  • Total tests: 46
  • Passed: 46
  • Failed: 0
  • Ignored: 2 (API integration tests requiring DEEPINFRA_API_KEY / OPENROUTER_API_KEY)

All unit and integration tests pass successfully.

Implementation Summary

Files Modified

  • crates/ai/src/provider.rs — Added DeepInfra provider variant with base URL, env var, and display name
  • crates/ai/src/model.rs — Added NemotronSuper120B model with DeepInfra (preferred) + OpenRouter (free) providers
  • crates/ai/src/client/mod.rs — Registered DeepInfra in from_env() auto-discovery (first position for priority)
  • crates/ai/src/rhai.rs — Added nemotron_super_120b parsing in Rhai bindings
  • crates/ai/src/lib.rs — Updated crate documentation with DeepInfra provider
  • crates/ai/Cargo.toml — Updated description to include DeepInfra
  • crates/ai/src/bin/modeltest.rs — Added DeepInfra model fetcher and discovery
  • crates/ai/examples/rust/modeltest.rs — Added DeepInfra model fetcher and discovery

Files Created

  • crates/ai/tests/nemotron_super_integration.rs — Integration tests (6 tests: 2 API-gated, 4 unit)
  • crates/ai/examples/rust/nemotron_super.rs — Rust example with prompt builder and custom options

Key Details

  • DeepInfra model ID: nvidia/NVIDIA-Nemotron-3-Super-120B-A12B
  • OpenRouter model ID: nvidia/nemotron-3-super-120b-a12b:free
  • Context window: 128K tokens
  • DeepInfra pricing: $0.12/$0.18 per million tokens (input/output)
  • Provider priority: DeepInfra → OpenRouter (automatic fallback)
## Test Results - **Total tests:** 46 - **Passed:** 46 - **Failed:** 0 - **Ignored:** 2 (API integration tests requiring DEEPINFRA_API_KEY / OPENROUTER_API_KEY) All unit and integration tests pass successfully. ## Implementation Summary ### Files Modified - `crates/ai/src/provider.rs` — Added `DeepInfra` provider variant with base URL, env var, and display name - `crates/ai/src/model.rs` — Added `NemotronSuper120B` model with DeepInfra (preferred) + OpenRouter (free) providers - `crates/ai/src/client/mod.rs` — Registered DeepInfra in `from_env()` auto-discovery (first position for priority) - `crates/ai/src/rhai.rs` — Added `nemotron_super_120b` parsing in Rhai bindings - `crates/ai/src/lib.rs` — Updated crate documentation with DeepInfra provider - `crates/ai/Cargo.toml` — Updated description to include DeepInfra - `crates/ai/src/bin/modeltest.rs` — Added DeepInfra model fetcher and discovery - `crates/ai/examples/rust/modeltest.rs` — Added DeepInfra model fetcher and discovery ### Files Created - `crates/ai/tests/nemotron_super_integration.rs` — Integration tests (6 tests: 2 API-gated, 4 unit) - `crates/ai/examples/rust/nemotron_super.rs` — Rust example with prompt builder and custom options ### Key Details - DeepInfra model ID: `nvidia/NVIDIA-Nemotron-3-Super-120B-A12B` - OpenRouter model ID: `nvidia/nemotron-3-super-120b-a12b:free` - Context window: 128K tokens - DeepInfra pricing: $0.12/$0.18 per million tokens (input/output) - Provider priority: DeepInfra → OpenRouter (automatic fallback)
Author
Owner

Implementation committed: 6227079b

Browse: 6227079b

Implementation committed: `6227079b` Browse: https://forge.ourworld.tf/lhumina_code/hero_lib/commit/6227079b
Sign in to join this conversation.
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
lhumina_code/hero_lib#118
No description provided.