Vectrum
Sign In
36 lines · 1.0 KB · Go
package llm

import "testing"

// The model picker offers whatever /v1/models returns, which is dated ids and
// context-window variants. Those are the same model at the same price, so
// pricing has to look past the decoration rather than report "unknown".
func TestCostPricesDecoratedModelIDs(t *testing.T) {
	u := Usage{InputTokens: 1_000_000}
	base, ok := u.Cost("claude-sonnet-5")
	if !ok {
		t.Fatal("the bare id is not priced")
	}
	for _, id := range []string{
		"claude-sonnet-5-20250930",
		"claude-sonnet-5[1m]",
		"claude-sonnet-5-latest",
	} {
		got, ok := u.Cost(id)
		if !ok {
			t.Errorf("Cost(%q) reported no price", id)
			continue
		}
		if got != base {
			t.Errorf("Cost(%q) = %v, want the same %v as the bare id", id, got, base)
		}
	}

	// A model nobody has priced still reports nothing rather than guessing.
	if _, ok := u.Cost("some-gateway/mystery-model"); ok {
		t.Error("an unknown model was given a price")
	}
	if _, ok := u.Cost("claude-something-9-20990101"); ok {
		t.Error("an unknown Claude model was given a price")
	}
}