provider: Antigravity counts Gemini 4 Carbon and Argon at their original price, $4 / $20 / $0.20
ZhouYimingsjtu on X: with an Ultra 20x plan, ~$200 of real use gave
Carbon:Neon:Hydrogen = 1.64:1:0.39. magpie priced them 2:3:1.5 by input
(0.67:1:0.5), so Carbon read cheaper than Neon while Antigravity counts it
above. Google's pricing page (ai.google.dev/gemini-api/docs/pricing, read
2026-11-19) lists Carbon and Argon at $2/$10/$0.10 through 2026-11-30 and
$4/$20/$0.20 from 12-01; Neon $3/$15/$0.15 and Hydrogen $1.50/$7.50/$0.075
have no promotion. models.dev (google, vertex, openrouter, copilot) carries
the promo. With the original the ratio is 1.33:1:0.5.
Only the Antigravity route changes: role ids (gemini-pro-orchestrator-*),
agy-cli/ and antigravity/ ids, providers served by Antigravity, and usage
calls from the agy/antigravity agents (priceAsk gains Agy). The price is
the field-wise max of the catalog's and the original, so once models.dev
moves to the original nothing is raised twice. Gemini API, Vertex and
OpenRouter prices are unchanged; Neon and Hydrogen unchanged. Argon is the
sibling with the same promo on Google's page; the reporter did not name it.
Not covered: the Sessions page prices by model name alone, so a bare
gemini-4-carbon in an agy session stays at the promo there; only role and
route-prefixed ids are scoped.
Run (mote, origin/main 352b124b3 base): go vet ./..., GOOS=linux go vet
-tags nogui ./..., GOOS=windows go vet ./... clean; gofmt -l clean.
Full go test -count=1 -timeout 45m ./...: provider red on this change
(effort_price_test, updated here and green: ok internal/provider), usage,
sessions, agent, dirent ok on rerun; reds that also fail on the same base:
TestOpenCodeGoOwnFreeModelGetsNothingOfOpenCodes (#7117); sessions hit the
45m timeout under load (WSL tests pass alone); gui TestSetPortServes... and
agent/dirent/gui WSL and watcher reds pass alone on both trees. New tests
red on old code, green on new.
This commit is contained in:
@@ -75,6 +75,11 @@ func TestAntigravityOrchestratorIDsPricedAsTheirModel(t *testing.T) {
|
||||
"gemini-flash-worker-agy-extra-high": "gemini-4-hydrogen",
|
||||
} {
|
||||
w := want[model]
|
||||
// Argon and Carbon under Antigravity's own ids at its original price
|
||||
// (antigravityOriginal); cache read the catalog's where higher
|
||||
if o, ok := antigravityOriginal[model]; ok {
|
||||
w = catalog.Price{Input: o.Input, Output: o.Output, CacheRead: max(o.CacheRead, w.CacheRead)}
|
||||
}
|
||||
for name, price := range map[string]func(string) (catalog.Price, bool){
|
||||
"MakerPrice": MakerPrice, "antigravity ListPrice": ag.ListPrice, "relay ListPrice": other.ListPrice} {
|
||||
if pr, ok := price(id); !ok || !samePrice(pr, w) {
|
||||
@@ -108,3 +113,91 @@ func TestAntigravityOrchestratorIDsPricedAsTheirModel(t *testing.T) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Antigravity counts Gemini 4 Carbon and Argon at their original price, not
|
||||
// the introductory one models.dev lists until 2026-11-30
|
||||
// (ZhouYimingsjtu on X: Carbon : Neon : Hydrogen measured at 1.64 : 1 :
|
||||
// 0.39 on an Ultra 20x plan). The Gemini API key, Vertex and any other
|
||||
// route keep the catalog's price; Neon and Hydrogen have no introductory
|
||||
// one and are the same everywhere. Once the catalog lists the original, it
|
||||
// is not raised again.
|
||||
func TestAntigravityCountsCarbonAtOriginalPrice(t *testing.T) {
|
||||
t.Cleanup(AntigravityBuiltinForTest())
|
||||
home := t.TempDir()
|
||||
t.Setenv("HOME", home)
|
||||
t.Setenv("USERPROFILE", home)
|
||||
t.Setenv("XDG_CONFIG_HOME", filepath.Join(home, ".config"))
|
||||
t.Setenv("XDG_CACHE_HOME", filepath.Join(home, ".cache"))
|
||||
os.MkdirAll(filepath.Dir(catalog.CachePath()), 0o755)
|
||||
// models.dev's google on 2026-11-19, with a later catalog's Argon
|
||||
os.WriteFile(catalog.CachePath(), []byte(`{"google":{"id":"google","models":{
|
||||
"gemini-4-argon":{"id":"gemini-4-argon","cost":{"input":4,"output":20,"cache_read":0.2}},
|
||||
"gemini-4-carbon":{"id":"gemini-4-carbon","cost":{"input":2,"output":10,"cache_read":0.1}},
|
||||
"gemini-4-hydrogen":{"id":"gemini-4-hydrogen","cost":{"input":1.5,"output":7.5,"cache_read":0.075}},
|
||||
"gemini-4-neon":{"id":"gemini-4-neon","cost":{"input":3,"output":15,"cache_read":0.15}}}}}`), 0o644)
|
||||
catalog.Reset()
|
||||
t.Cleanup(catalog.Reset)
|
||||
|
||||
orig := catalog.Price{Input: 4, Output: 20, CacheRead: 0.2}
|
||||
promo := catalog.Price{Input: 2, Output: 10, CacheRead: 0.1}
|
||||
same := func(a, b catalog.Price) bool {
|
||||
return a.Input == b.Input && a.Output == b.Output && a.CacheRead == b.CacheRead
|
||||
}
|
||||
ag := Provider{ID: "antigravity", Name: "Antigravity"}
|
||||
agy := Provider{ID: "agy-cli", Name: "Antigravity (local agy CLI)"}
|
||||
other := Provider{ID: "some-relay", Name: "Relay"}
|
||||
for _, id := range []string{"gemini-4-carbon", "gemini-4-carbon-high", "agy-cli/gemini-4-carbon-high"} {
|
||||
for name, p := range map[string]Provider{"antigravity": ag, "agy-cli": agy} {
|
||||
if pr, ok := p.ListPrice(id); !ok || !same(pr, orig) {
|
||||
t.Errorf("%s ListPrice(%q) = %+v, %v; want the original %+v", name, id, pr, ok, orig)
|
||||
}
|
||||
if pr, ok, _ := p.listPrice(id); !ok || !same(pr, orig) {
|
||||
t.Errorf("%s listPrice(%q) = %+v, %v; want the original", name, id, pr, ok)
|
||||
}
|
||||
}
|
||||
}
|
||||
// the Gemini API key, a relay and the maker's list are the catalog's
|
||||
for _, id := range []string{"gemini-4-carbon", "gemini-4-carbon-high", "google/gemini-4-carbon"} {
|
||||
if pr, ok := other.ListPrice(id); !ok || !same(pr, promo) {
|
||||
t.Errorf("relay ListPrice(%q) = %+v, %v; want the catalog's %+v", id, pr, ok, promo)
|
||||
}
|
||||
if pr, ok := MakerPrice(id); !ok || !same(pr, promo) {
|
||||
t.Errorf("MakerPrice(%q) = %+v, %v; want the catalog's %+v", id, pr, ok, promo)
|
||||
}
|
||||
}
|
||||
// Antigravity's own route and role ids are its alone
|
||||
for _, id := range []string{"agy-cli/gemini-4-carbon-high", "antigravity/gemini-4-carbon", "gemini-pro-orchestrator-carbon", "gemini-pro-orchestrator"} {
|
||||
if pr, ok := MakerPrice(id); !ok || !same(pr, orig) {
|
||||
t.Errorf("MakerPrice(%q) = %+v, %v; want the original %+v", id, pr, ok, orig)
|
||||
}
|
||||
}
|
||||
// the record of an Antigravity call, whichever the model's route
|
||||
if pr := AgyPriced("gemini-4-carbon-high", promo); !same(pr, orig) {
|
||||
t.Errorf("AgyPriced(carbon) = %+v, want %+v", pr, orig)
|
||||
}
|
||||
// Neon and Hydrogen have no introductory price, and the catalog's own
|
||||
// original is not raised
|
||||
for id, w := range map[string]catalog.Price{
|
||||
"gemini-4-neon": {Input: 3, Output: 15, CacheRead: 0.15}, "gemini-4-hydrogen": {Input: 1.5, Output: 7.5, CacheRead: 0.075},
|
||||
"gemini-4-argon": orig,
|
||||
} {
|
||||
for name, p := range map[string]Provider{"antigravity": ag, "agy-cli": agy, "relay": other} {
|
||||
if pr, ok := p.ListPrice(id); !ok || !same(pr, w) {
|
||||
t.Errorf("%s ListPrice(%q) = %+v, %v; want %+v", name, id, pr, ok, w)
|
||||
}
|
||||
}
|
||||
}
|
||||
// what a call costs there: Carbon dearer than Neon, as measured
|
||||
if c, n := mustPrice(t, ag, "gemini-4-carbon"), mustPrice(t, ag, "gemini-4-neon"); c.Cost(1e6, 1e6, 0, 0) <= n.Cost(1e6, 1e6, 0, 0) {
|
||||
t.Errorf("Antigravity's Carbon %+v is not dearer than Neon %+v", c, n)
|
||||
}
|
||||
}
|
||||
|
||||
func mustPrice(t *testing.T, p Provider, id string) catalog.Price {
|
||||
t.Helper()
|
||||
pr, ok := p.ListPrice(id)
|
||||
if !ok {
|
||||
t.Fatalf("%s ListPrice(%q) unpriced", p.ID, id)
|
||||
}
|
||||
return pr
|
||||
}
|
||||
|
||||
@@ -0,0 +1,82 @@
|
||||
package provider
|
||||
|
||||
import (
|
||||
"strings"
|
||||
|
||||
"github.com/yetone/magpie/internal/catalog"
|
||||
)
|
||||
|
||||
// antigravityOriginal is what Antigravity counts Gemini 4 Carbon and Gemini
|
||||
// 4 Argon at: their original price, not the introductory one the Gemini API
|
||||
// charges until 2026-11-30. Google's own page
|
||||
// (https://ai.google.dev/gemini-api/docs/pricing, read 2026-11-19) lists both
|
||||
// at "$2.00 through November 30, 2026. $4.00 starting December 1, 2026" in,
|
||||
// $10 then $20 out and $0.10 then $0.20 cached, and models.dev lists the
|
||||
// introductory $2 / $10 / $0.10. ZhouYimingsjtu on X ran an Ultra 20x plan
|
||||
// through about $200 of calls and measured Carbon : Neon : Hydrogen at
|
||||
// 1.64 : 1 : 0.39 ("Carbon在antigravity的订阅其实还是按照原价,并没有用打折价"),
|
||||
// which the introductory price (0.67 : 1 : 0.5 of a call's cost) can't
|
||||
// give. Gemini 4 Neon ($3 / $15) and Hydrogen ($1.50 / $7.50) have no
|
||||
// introductory price. Only Antigravity's route: the Gemini API key, Vertex
|
||||
// and OpenRouter charge what their own pages list.
|
||||
var antigravityOriginal = map[string]catalog.Price{
|
||||
"gemini-4-carbon": {Input: 4, Output: 20, CacheRead: 0.2},
|
||||
"gemini-4-argon": {Input: 4, Output: 20, CacheRead: 0.2},
|
||||
}
|
||||
|
||||
// atLeastOriginal is pr with no field under Antigravity's original price of
|
||||
// the Gemini 4 model model names (at an effort, under a route's prefix, as a
|
||||
// role id), else pr as it is. A catalog that has moved to the original price
|
||||
// (Google's page says so from 2026-12-01) is left as it lists it.
|
||||
func atLeastOriginal(model string, pr catalog.Price) catalog.Price {
|
||||
model = model[strings.LastIndexByte(model, '/')+1:]
|
||||
for _, n := range pricedNames(model) {
|
||||
o, ok := antigravityOriginal[strings.ToLower(n)]
|
||||
if !ok {
|
||||
continue
|
||||
}
|
||||
pr.Input = max(pr.Input, o.Input)
|
||||
pr.Output = max(pr.Output, o.Output)
|
||||
pr.CacheRead = max(pr.CacheRead, o.CacheRead)
|
||||
return pr
|
||||
}
|
||||
return pr
|
||||
}
|
||||
|
||||
// agyOnlyID is whether model is a name only Antigravity gives: one of its
|
||||
// Orchestrator role ids (antigravityRoles), or any id under its own route
|
||||
// (agy-cli/, antigravity/).
|
||||
func agyOnlyID(model string) bool {
|
||||
l := strings.ToLower(strings.TrimSpace(model))
|
||||
if strings.HasPrefix(l, "agy-cli/") || strings.HasPrefix(l, "antigravity/") {
|
||||
return true
|
||||
}
|
||||
_, ok := antigravityRole(l)
|
||||
return ok
|
||||
}
|
||||
|
||||
// agyScoped is pr, a price found for model without saying who charges it,
|
||||
// at Antigravity's original price when the name is Antigravity's alone
|
||||
// (agyOnlyID).
|
||||
func agyScoped(model string, pr catalog.Price) catalog.Price {
|
||||
if !agyOnlyID(model) {
|
||||
return pr
|
||||
}
|
||||
return atLeastOriginal(model, pr)
|
||||
}
|
||||
|
||||
// AgyScoped is agyScoped for the callers that price by a model's name alone.
|
||||
func AgyScoped(model string, pr catalog.Price) catalog.Price { return agyScoped(model, pr) }
|
||||
|
||||
// AgyPriced is pr, a price found for model, at what Antigravity counts it
|
||||
// at: for a call known to be Antigravity's (the agy CLI's or the app's own
|
||||
// session log).
|
||||
func AgyPriced(model string, pr catalog.Price) catalog.Price { return atLeastOriginal(model, pr) }
|
||||
|
||||
// servedByAntigravity is whether p is an Antigravity route: the built-in's
|
||||
// accounts, or the agy-cli plugin's.
|
||||
func (p Provider) servedByAntigravity() bool {
|
||||
return p.ID == "antigravity" || p.ID == agyCLIID ||
|
||||
p.Account != nil && p.Account.Agent == "antigravity" ||
|
||||
p.PluginProvider() == "antigravity" || p.PluginProvider() == agyCLIID
|
||||
}
|
||||
@@ -57,9 +57,12 @@ func TestEffortIDPricedAsItsModel(t *testing.T) {
|
||||
"gemini-4-carbon-extra-high": "gemini-4-carbon", "gemini-4-carbon-extra-low": "gemini-4-carbon",
|
||||
"Claude-Opus-5-5-High": "claude-opus-5-5", "google/gemini-4-argon-high": "gemini-4-argon",
|
||||
} {
|
||||
w := want[base]
|
||||
for name, price := range map[string]func(string) (catalog.Price, bool){
|
||||
"MakerPrice": MakerPrice, "antigravity ListPrice": ag.ListPrice, "relay ListPrice": other.ListPrice} {
|
||||
w := want[base]
|
||||
if _, orig := antigravityOriginal[base]; name == "antigravity ListPrice" && orig {
|
||||
w = antigravityOriginal[base] // Antigravity counts Carbon and Argon at the original price
|
||||
}
|
||||
pr, ok := price(id)
|
||||
if !ok || pr.Input != w.Input || pr.Output != w.Output || pr.CacheRead != w.CacheRead || pr.CacheWrite != w.CacheWrite {
|
||||
t.Errorf("%s(%q) = %+v, %v; want %s's %+v", name, id, pr, ok, base, w)
|
||||
@@ -121,8 +124,12 @@ func TestGeminiTrialIDPricedAsItsModel(t *testing.T) {
|
||||
for name, price := range map[string]func(string) (catalog.Price, bool){
|
||||
"MakerPrice": MakerPrice, "antigravity ListPrice": ag.ListPrice} {
|
||||
pr, ok := price(id)
|
||||
if !ok || pr.Input != 2 || pr.Output != 10 || pr.CacheRead != 0.1 {
|
||||
t.Errorf("%s(%q) = %+v, %v; want %s's $2/$10", name, id, pr, ok, base)
|
||||
in, out, cr := 2.0, 10.0, 0.1
|
||||
if name == "antigravity ListPrice" { // Antigravity counts Carbon and Argon at the original price
|
||||
in, out, cr = 4, 20, 0.2
|
||||
}
|
||||
if !ok || pr.Input != in || pr.Output != out || pr.CacheRead != cr {
|
||||
t.Errorf("%s(%q) = %+v, %v; want %s's $%v/$%v", name, id, pr, ok, base, in, out)
|
||||
}
|
||||
}
|
||||
if got := PricedName(id); got != base && got != "google/"+base { // a route's prefix stays
|
||||
|
||||
@@ -2428,8 +2428,23 @@ func (p Provider) listPrice(model string) (catalog.Price, bool, int) {
|
||||
return p.listPriceIn(p.priceCatsOf(), model)
|
||||
}
|
||||
|
||||
// listPriceIn is listPrice with p's catalogs given.
|
||||
// listPriceIn is listPrice with p's catalogs given, Gemini 4 Carbon and
|
||||
// Argon at Antigravity's original price on an Antigravity route, and under
|
||||
// its own ids anywhere (antigravityOriginal).
|
||||
func (p Provider) listPriceIn(c priceCats, model string) (catalog.Price, bool, int) {
|
||||
pr, ok, from := p.listPriceBase(c, model)
|
||||
if ok {
|
||||
if p.servedByAntigravity() {
|
||||
pr = atLeastOriginal(model, pr)
|
||||
} else {
|
||||
pr = agyScoped(model, pr)
|
||||
}
|
||||
}
|
||||
return pr, ok, from
|
||||
}
|
||||
|
||||
// listPriceBase is listPriceIn before Antigravity's original prices.
|
||||
func (p Provider) listPriceBase(c priceCats, model string) (catalog.Price, bool, int) {
|
||||
if own := p.OwnModelID(model); own != model {
|
||||
// a model listed by an id the user gave it is priced as the
|
||||
// provider's own id of it first, then as the id it is listed by
|
||||
@@ -2815,7 +2830,7 @@ var kimiCodeAPI = map[string]string{
|
||||
func MakerPrice(model string) (catalog.Price, bool) {
|
||||
for _, m := range pricedNames(model) {
|
||||
if pr, ok := makerListPrice(m); ok {
|
||||
return pr, true
|
||||
return agyScoped(model, pr), true
|
||||
}
|
||||
}
|
||||
if f, ok := mythosFable(model); ok {
|
||||
@@ -2998,6 +3013,9 @@ func tariffOf(s settings.Settings, p Provider, known bool, model string) (catalo
|
||||
return catalog.Price{}, true
|
||||
}
|
||||
pr, ok := MakerPrice(model)
|
||||
if ok && p.servedByAntigravity() {
|
||||
pr = atLeastOriginal(model, pr)
|
||||
}
|
||||
if ok {
|
||||
if k := p.PeakOf(model); k != "" {
|
||||
pr.Peak = k
|
||||
@@ -3015,6 +3033,9 @@ func tariffOf(s settings.Settings, p Provider, known bool, model string) (catalo
|
||||
pr, ok := p.ListPrice(model)
|
||||
if !ok {
|
||||
pr, ok = MakerPrice(model)
|
||||
if ok && p.servedByAntigravity() {
|
||||
pr = atLeastOriginal(model, pr)
|
||||
}
|
||||
}
|
||||
if !ok {
|
||||
pr, ok = SamePriceIn(s, id, model)
|
||||
|
||||
@@ -26,13 +26,19 @@ func TestPriceOfAntigravityOrchestratorRoles(t *testing.T) {
|
||||
catalog.Reset()
|
||||
t.Cleanup(catalog.Reset)
|
||||
for m, in := range map[string]float64{
|
||||
"gemini-pro-orchestrator-argon": 2, "gemini-pro-orchestrator-carbon": 2.5, "gemini-flash-worker-agy": 1.5,
|
||||
"gemini-pro-orchestrator-g1-pro": 2, "gemini-pro-orchestrator-neon": 3,
|
||||
// Argon and Carbon at Antigravity's original $4, not the
|
||||
// introductory $2 (provider.AgyScoped)
|
||||
"gemini-pro-orchestrator-argon": 4, "gemini-pro-orchestrator-carbon": 4, "gemini-flash-worker-agy": 1.5,
|
||||
"gemini-pro-orchestrator-g1-pro": 4, "gemini-pro-orchestrator-neon": 3,
|
||||
} {
|
||||
if pr, ok := priceOf(settings.Load(), m); !ok || pr.Input != in {
|
||||
t.Errorf("priceOf(%q) = %+v, %v; want input $%v", m, pr, ok, in)
|
||||
}
|
||||
}
|
||||
// a bare Carbon is the Gemini API's, at the catalog's price
|
||||
if pr, ok := priceOf(settings.Load(), "gemini-4-carbon"); !ok || pr.Input != 2.5 {
|
||||
t.Errorf("priceOf(gemini-4-carbon) = %+v, %v; want the catalog's input $2.5", pr, ok)
|
||||
}
|
||||
if pr, ok := priceOf(settings.Load(), "gemini-pro-orchestrator-krypton"); ok {
|
||||
t.Errorf("priceOf(gemini-pro-orchestrator-krypton) = %+v; want unpriced", pr)
|
||||
}
|
||||
|
||||
@@ -2971,7 +2971,8 @@ func priceOf(s settings.Settings, model string) (catalog.Price, bool) {
|
||||
// claude-opus-4-6
|
||||
for _, id := range []string{bare, dated.ReplaceAllString(bare, ""), provider.PricedName(bare)} {
|
||||
if pr, ok := catalog.PricedBy(makers(id), id); ok {
|
||||
return pr, true
|
||||
// an Antigravity role id at what Antigravity counts it at
|
||||
return provider.AgyScoped(m, pr), true
|
||||
}
|
||||
}
|
||||
// Grok Build's fast variant (grok-4.7-build-fast), which only the Grok
|
||||
|
||||
@@ -49,10 +49,12 @@ func TestAntigravityOrchestratorCallsPriced(t *testing.T) {
|
||||
|
||||
cost := func(in, out, cr float64) float64 { return (100000*in + 20000*out + 400000*cr) / 1e6 }
|
||||
want := map[string]float64{
|
||||
"gemini-pro-orchestrator-argon": cost(2, 10, 0.1),
|
||||
"gemini-pro-orchestrator-carbon": cost(2.5, 12, 0.25),
|
||||
// Argon and Carbon at Antigravity's original $4 / $20 (cache read
|
||||
// the catalog's 0.25 where that is higher)
|
||||
"gemini-pro-orchestrator-argon": cost(4, 20, 0.2),
|
||||
"gemini-pro-orchestrator-carbon": cost(4, 20, 0.25),
|
||||
"gemini-flash-worker-agy": cost(1.5, 7.5, 0.075),
|
||||
"gemini-pro-orchestrator-g1-pro": cost(2, 10, 0.1),
|
||||
"gemini-pro-orchestrator-g1-pro": cost(4, 20, 0.2),
|
||||
"gemini-pro-orchestrator-neon": cost(3, 15, 0.15),
|
||||
}
|
||||
near := func(a, b float64) bool { return math.Abs(a-b) < 1e-9 }
|
||||
@@ -81,3 +83,54 @@ func TestAntigravityOrchestratorCallsPriced(t *testing.T) {
|
||||
t.Errorf("agy: cost %v unpriced %d, want %v and 0", agy.Cost, agy.Unpriced, g)
|
||||
}
|
||||
}
|
||||
|
||||
// A call of agy's or the Antigravity app's own session log on Gemini 4
|
||||
// Carbon is counted at Antigravity's original price (ZhouYimingsjtu on X:
|
||||
// Carbon : Neon : Hydrogen measured 1.64 : 1 : 0.39 on an Ultra 20x plan),
|
||||
// not the introductory one models.dev lists; the same model in another
|
||||
// agent's log (the Gemini API's) keeps the catalog's.
|
||||
func TestAntigravityLogCarbonAtOriginalPrice(t *testing.T) {
|
||||
home := t.TempDir()
|
||||
t.Setenv("HOME", home)
|
||||
t.Setenv("USERPROFILE", home)
|
||||
t.Setenv("XDG_CONFIG_HOME", filepath.Join(home, ".config"))
|
||||
t.Setenv("XDG_CACHE_HOME", filepath.Join(home, ".cache"))
|
||||
os.MkdirAll(filepath.Dir(catalog.CachePath()), 0o755)
|
||||
os.WriteFile(catalog.CachePath(), []byte(`{"google":{"id":"google","models":{
|
||||
"gemini-4-carbon":{"id":"gemini-4-carbon","cost":{"input":2,"output":10,"cache_read":0.1}},
|
||||
"gemini-4-hydrogen":{"id":"gemini-4-hydrogen","cost":{"input":1.5,"output":7.5,"cache_read":0.075}},
|
||||
"gemini-4-neon":{"id":"gemini-4-neon","cost":{"input":3,"output":15,"cache_read":0.15}}}}}`), 0o644)
|
||||
catalog.Reset()
|
||||
t.Cleanup(catalog.Reset)
|
||||
|
||||
now := holdClock(t, time.Date(2026, 11, 19, 12, 0, 0, 0, time.Local))
|
||||
tok := sessions.Tokens{Input: 100000, Output: 20000, CacheRead: 400000}
|
||||
old := LogCalls
|
||||
LogCalls = func(time.Time) []sessions.Call {
|
||||
return []sessions.Call{
|
||||
{Time: now.Add(-1 * time.Hour), Agent: "antigravity", Session: "a1", Model: "gemini-4-carbon", Tokens: tok},
|
||||
{Time: now.Add(-2 * time.Hour), Agent: "agy", Session: "g1", Model: "gemini-4-carbon-high", Tokens: tok},
|
||||
{Time: now.Add(-3 * time.Hour), Agent: "agy", Session: "g2", Model: "gemini-4-neon-high", Tokens: tok},
|
||||
{Time: now.Add(-4 * time.Hour), Agent: "agy", Session: "g3", Model: "gemini-4-hydrogen-low", Tokens: tok},
|
||||
// the Gemini CLI's call on the same model is the Gemini API's
|
||||
{Time: now.Add(-5 * time.Hour), Agent: "gemini", Session: "x1", Model: "gemini-4-carbon", Tokens: tok},
|
||||
}
|
||||
}
|
||||
t.Cleanup(func() { LogCalls = old })
|
||||
cost := func(in, out, cr float64) float64 { return (100000*in + 20000*out + 400000*cr) / 1e6 }
|
||||
want := map[string]float64{
|
||||
"antigravity/gemini-4-carbon": cost(4, 20, 0.2), "agy/gemini-4-carbon-high": cost(4, 20, 0.2),
|
||||
"agy/gemini-4-neon-high": cost(3, 15, 0.15), "agy/gemini-4-hydrogen-low": cost(1.5, 7.5, 0.075),
|
||||
"gemini/gemini-4-carbon": cost(2, 10, 0.1),
|
||||
}
|
||||
rows, _, _ := Ledger(Month, Filter{})
|
||||
if len(rows) != len(want) {
|
||||
t.Fatalf("rows %d, want %d", len(rows), len(want))
|
||||
}
|
||||
for _, r := range rows {
|
||||
w := want[r.Agent+"/"+r.Model]
|
||||
if !r.Priced || math.Abs(r.Cost-w) > 1e-9 {
|
||||
t.Errorf("%s %s: priced %v cost %v, want %v", r.Agent, r.Model, r.Priced, r.Cost, w)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -218,7 +218,7 @@ func (a priceAsk) ask() string {
|
||||
if a.Unknown {
|
||||
u = "1"
|
||||
}
|
||||
return strings.Join([]string{"p", a.ID, a.Model, a.Served, a.SessionProvider, a.Effort, a.Key, u}, askSep)
|
||||
return strings.Join([]string{"p", a.ID, a.Model, a.Served, a.SessionProvider, a.Effort, a.Key, u, boolAnswer(a.Agy)}, askSep)
|
||||
}
|
||||
|
||||
func listedAsk(prov, model, served string) string {
|
||||
@@ -246,8 +246,8 @@ func boolAnswer(b bool) string {
|
||||
func answerAsk(s settings.Settings, wires map[string]string, q string) (string, bool) {
|
||||
f := strings.Split(q, askSep)
|
||||
switch {
|
||||
case f[0] == "p" && len(f) == 8:
|
||||
a := priceAsk{ID: f[1], Model: f[2], Served: f[3], SessionProvider: f[4], Effort: f[5], Key: f[6], Unknown: f[7] == "1"}
|
||||
case f[0] == "p" && len(f) == 9:
|
||||
a := priceAsk{ID: f[1], Model: f[2], Served: f[3], SessionProvider: f[4], Effort: f[5], Key: f[6], Unknown: f[7] == "1", Agy: f[8] == "1"}
|
||||
pr, ws := basePriceIn(s, wires, a)
|
||||
return priceAnswer(pr, ws), true
|
||||
case f[0] == "l" && len(f) == 4:
|
||||
|
||||
@@ -586,7 +586,7 @@ var ownPrice catalog.Price
|
||||
// one whose other models alone would stand for this call's, prices
|
||||
// nothing (#4278).
|
||||
func Pricer() func(Record) *catalog.Price {
|
||||
prices := map[[7]string]*catalog.Price{}
|
||||
prices := map[[8]string]*catalog.Price{}
|
||||
// each provider's rate windows as the same read of the prices saw
|
||||
// them: the windows are held once (BasePriceIn), each record's rate
|
||||
// read at its own time (provider.RateAt), so a window that opens
|
||||
@@ -607,11 +607,12 @@ func Pricer() func(Record) *catalog.Price {
|
||||
// its calls apart from the provider's other keys
|
||||
key := r.ProviderKeyID
|
||||
tier := r.billedTier()
|
||||
k := [7]string{id, r.Model, served, r.SessionProvider, r.Effort, key, r.tierKey(tier, served)}
|
||||
agy := r.Provider == UnknownProvider && agyLocal(r.Agent)
|
||||
k := [8]string{id, r.Model, served, r.SessionProvider, r.Effort, key, r.tierKey(tier, served), strconv.FormatBool(agy)}
|
||||
if pr, ok := prices[k]; ok {
|
||||
return atWindow(pr, windows[id], r.Time)
|
||||
}
|
||||
a := priceAsk{ID: id, Model: r.Model, Served: served, SessionProvider: r.SessionProvider, Effort: r.Effort, Key: key, Unknown: r.Provider == UnknownProvider}
|
||||
a := priceAsk{ID: id, Model: r.Model, Served: served, SessionProvider: r.SessionProvider, Effort: r.Effort, Key: key, Unknown: r.Provider == UnknownProvider, Agy: agy}
|
||||
pr, ws := basePriceIn(s, wires, a)
|
||||
noteAsk(a.ask(), priceAnswer(pr, ws))
|
||||
if pr != nil {
|
||||
@@ -697,6 +698,10 @@ func (r Record) billedTier() string {
|
||||
type priceAsk struct {
|
||||
ID, Model, Served, SessionProvider, Effort, Key string
|
||||
Unknown bool
|
||||
// Agy is a call of the agy CLI's or the Antigravity app's own session
|
||||
// log, which Antigravity counts Gemini 4 Carbon and Argon at their
|
||||
// original price for (provider.AgyPriced)
|
||||
Agy bool
|
||||
}
|
||||
|
||||
// basePriceIn is a's price before its time's rate window, and the
|
||||
@@ -744,6 +749,10 @@ func basePriceIn(s settings.Settings, wires map[string]string, a priceAsk) (*cat
|
||||
ws = nil
|
||||
}
|
||||
}
|
||||
if pr != nil && a.Agy {
|
||||
v := provider.AgyPriced(a.Model, *pr)
|
||||
pr = &v
|
||||
}
|
||||
return pr, ws
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user