| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Name | Name | Last commit date | ||
|---|---|---|---|---|
parent directory.. | ||||
The modelsdev package provides model pricing lookup backed by the public models.dev catalog.
This package downloads and parses https://models.dev/catalog.json, normalizes provider/model identifiers, and exposes per-token pricing for callers that need cost-aware behavior.
The catalog is loaded once per process via a singleton cache (syncutil.OnceLoader) to avoid repeated network fetches.
| Function | Signature | Description |
|---|---|---|
| FindPricing | func(ctx context.Context, provider, model string) (map[string]float64, bool) | Returns normalized per-token pricing for a provider/model pair. Falls back to cross-provider matching when provider lookup fails. Returns (nil, false) when no pricing is available |
| NormalizeProvider | func(provider string) string | Normalizes provider aliases such as github, copilot, and github_models to github-copilot, and lower-cases other provider identifiers |
| NormalizeComparableModelID | func(value string) string | Lower-cases a model identifier, trims surrounding whitespace, and replaces . and _ with - so equivalent model IDs compare consistently |
import "github.com/github/gh-aw/pkg/modelsdev"
pricing, ok := modelsdev.FindPricing(ctx, "github", "gpt-4.1")
if !ok {
// pricing unavailable
return
}
inputUSD := pricing["input"] // per token
outputUSD := pricing["output"] // per token
_ = inputUSD
_ = outputUSDInternal:
Reviewed against recent source updates on 2026-07-17; no additional public-contract deltas were identified beyond the sections above.
This specification is automatically maintained by the spec-extractor workflow.
| Back | FazBrowse Home | New Git URL |