Skip to content

fix: request usage for NVIDIA streams - #658

Open
cruush23 wants to merge 1 commit into
kittors:devfrom
cruush23:fix/nvidia-stream-usage
Open

fix: request usage for NVIDIA streams#658
cruush23 wants to merge 1 commit into
kittors:devfrom
cruush23:fix/nvidia-stream-usage

Conversation

@cruush23

@cruush23 cruush23 commented Jul 13, 2026

Copy link
Copy Markdown

Summary

  • request the final usage chunk for streaming calls to NVIDIA's official OpenAI-compatible endpoint
  • inject stream_options.include_usage=true only when the translated upstream payload has stream=true
  • leave NVIDIA non-stream requests and other OpenAI-compatible providers unchanged

Problem

NVIDIA streaming responses return usage: null unless stream_options.include_usage is requested, so CliRelay records zero input/output tokens even though the stream succeeds.

A payload rule is not a safe workaround because payload rules match model/protocol but not the stream flag. The same rule is then applied to non-stream requests, which NVIDIA rejects with:

400 Validation: The 'stream_options' field is only allowed when 'stream' is set to true.

Implementation

The OpenAI compatibility executor now recognizes the official integrate.api.nvidia.com endpoint and adds stream_options.include_usage=true in ExecuteStream only when the final translated payload is actually streaming.

Verification

  • added coverage for NVIDIA streaming injection
  • added coverage that NVIDIA non-stream requests do not receive stream_options
  • added coverage that other OpenAI-compatible providers remain unchanged
  • go test ./internal/runtime/executor -run 'TestOpenAICompatExecutor(RequestsUsageForNVIDIAStreamsOnly|DoesNotRequestUsageForNVIDIANonStream)$' -count=1
  • go test ./...
  • go vet ./...
  • golangci-lint run --config .golangci.yml
  • go build ./cmd/server
  • backend structure and restricted translator path checks passed

@cruush23

cruush23 commented Jul 13, 2026

Copy link
Copy Markdown
Author

Hi @kittors, the fork workflows are currently waiting for maintainer approval (action_required, no jobs started). I ran the repository checks locally with Go 1.26.1: focused executor tests, go test ./..., go vet ./..., golangci-lint, backend structure checks, and the server build all passed.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant