provbalance

package
v1.2.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 10, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package provbalance reads a model provider's balance through the seat's key: the transport of the sprint's balance poll (internal/sprint balance.go; nova-tools#5199). It decides nothing: it answers what the provider said, or that its balance is unknown and why, and never says the key.

Index

Constants

View Source
const OpenRouterKeyURL = "https://openrouter.ai/api/v1/key"

OpenRouterKeyURL is openrouter's key endpoint: GET with the key as a bearer token answers {"data": {"usage_daily": <dollars the key used today, the UTC day>, ...}}, the provider's own count the cost reconciliation sets beside the sprint's records (sprint.CostReconcile).

View Source
const OpenRouterURL = "https://openrouter.ai/api/v1/credits"

OpenRouterURL is openrouter's credits endpoint: GET with the key as a bearer token answers {"data": {"total_credits": <dollars bought>, "total_usage": <dollars used>}}.

View Source
const Timeout = 15 * time.Second

Timeout bounds one read: a provider that does not answer leaves the balance unknown.

Variables

View Source
var KeyEnv = map[string]string{"openrouter": "OPENROUTER_API_KEY"}

KeyEnv is the variable each provider's key is in, as nova-secrets exec delivers it to the run loop (`nova-secrets exec --only OPENROUTER_API_KEY -- nova-sprint run ...`).

Functions

func Read

func Read(ctx context.Context, rt http.RoundTripper, provider string, getenv func(string) string) sprint.ProviderRead

Read is the provider's balance over the transport (nil is http.DefaultTransport), its key read from getenv; a provider with no endpoint, no key, or an answer that is not its shape is unknown with why.

func ReadUsage

func ReadUsage(ctx context.Context, rt http.RoundTripper, provider, day string, getenv func(string) string) sprint.UsageRead

ReadUsage is the provider's own count of the UTC day's usage over the transport (nil is http.DefaultTransport), its key read from getenv; day is the UTC day the count is of, 2006-01-02. A provider with no usage endpoint, no key, or an answer that is not its shape is unknown with why, and the key is never in the why.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL