Documentation
¶
Overview ¶
Package nimclient calls an OpenAI-compatible NVIDIA NIM endpoint — either NVIDIA's hosted build.nvidia.com API (https://integrate.api.nvidia.com/v1, authenticated with an nvapi- key) or a self-hosted NIM container (http://host:8000/v1, no key). It is the harness's EXPLICIT remote-model tool: the local Gemma cascade and its sacred GBNF grammar path are untouched, and NIM calls never enter the savings ledger (they are deliberate experiments / escalations, not defer-avoidance). Pure net/http; no SDK.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func APIKeyFromEnv ¶
func APIKeyFromEnv() string
APIKeyFromEnv reads the NIM key from env ONLY (never from a config file, so a secret never lands in a tracked file): NVIDIA_API_KEY first, then NGC_API_KEY (the name NVIDIA's own NIM docs use). Empty = no key (a self-hosted NIM is keyless). The single source of truth for both the CLI and MCP paths.
func IsHostedNVIDIA ¶
IsHostedNVIDIA reports whether base targets NVIDIA's hosted API (which requires a key), as opposed to a self-hosted NIM container (which is keyless).
func KeyForBase ¶
KeyForBase returns the API key to transmit to base: the env key for NVIDIA's hosted API, and "" for ANY other base. This is a security boundary, not just a convenience — the NVIDIA key is only valid on NVIDIA's endpoints, so silently sending it to a user-supplied --base (a typo, a self-hosted NIM, or a third party) would leak the secret over the wire for no benefit. A self-hosted NIM is keyless by design; both the CLI and MCP paths resolve the key through here.
Types ¶
type ChatResult ¶
type ChatResult struct {
Content string
ReasoningContent string
Model string
TokensIn int
TokensOut int
Truncated bool
}
ChatResult holds the model output and per-call telemetry. ReasoningContent is populated for reasoning models that emit a separate reasoning_content field; Content is the user-facing answer (which can be empty if the response was cut at max_tokens mid-thought — Truncated then signals it).
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client targets one OpenAI-compatible base (".../v1"). apiKey may be empty for a keyless self-hosted NIM; when set it is sent as a Bearer token.
func New ¶
New builds a client. base should include the API version segment (e.g. "https://integrate.api.nvidia.com/v1"). A trailing slash is trimmed.