Skip to content

Shared task board where people and AI coding agents work as teammates. Source-available, self-hostable.

Go

fix(codex): price GPT-6.1 Terra and add it to the fallback catalog (#9668)

Noodles375b23247b2f
diff --git a/packages/views/runtimes/utils.test.ts b/packages/views/runtimes/utils.test.ts
index bdcd317089..a4792c8928 100644
--- a/packages/views/runtimes/utils.test.ts
+++ b/packages/views/runtimes/utils.test.ts
@@ -379,13 +379,14 @@ describe("estimateCost", () => {
it("prices current Codex models per OpenAI's official cache-aware rates", () => {
// Official announcement rates. 5.6 is the first OpenAI generation to bill
// cache writes separately: cacheRead generally = 0.1x input (GPT-6.1
- // Sol uses 0.05x), cacheWrite = 1.25x
+ // Sol and Terra use 0.05x), cacheWrite = 1.25x
// input. Cover every model x every token category so a wrong cache rate
// can't hide behind an input-only assertion. `total` is 1M of each of the
// four categories priced at its own rate.
const cases = [
{ model: "gpt-6-astra", input: 10, cacheRead: 1, cacheWrite: 12.5, output: 50, total: 73.5 },
{ model: "gpt-6.1-sol", input: 2, cacheRead: 0.1, cacheWrite: 2.5, output: 10, total: 14.6 },
+ { model: "gpt-6.1-terra", input: 1, cacheRead: 0.05, cacheWrite: 1.25, output: 5, total: 7.3 },
{ model: "gpt-6-sol", input: 2, cacheRead: 0.2, cacheWrite: 2.5, output: 10, total: 14.7 },
{ model: "gpt-6-luna", input: 0.1, cacheRead: 0.01, cacheWrite: 0.125, output: 0.5, total: 0.735 },
{ model: "gpt-5.6-sol", input: 5, cacheRead: 0.5, cacheWrite: 6.25, output: 30, total: 41.75 },
@@ -526,6 +527,10 @@ describe("estimateCost", () => {
expect(isModelPriced(model, "codex")).toBe(true);
expect(estimateCost({ ...zeroUsage, provider: "codex", model, cache_read_tokens: 1_000_000 })).toBeCloseTo(0.1, 5);
}
+ for (const model of ["openai:gpt-6.1-terra", "openai/gpt-6.1-terra", "gpt-6.1-terra[1m]"]) {
+ expect(isModelPriced(model, "codex")).toBe(true);
+ expect(estimateCost({ ...zeroUsage, provider: "codex", model, cache_read_tokens: 1_000_000 })).toBeCloseTo(0.05, 5);
+ }
});
it("flags catalog SKUs without a published price (gpt-5.5-mini) as unmapped", () => {
@@ -558,6 +563,8 @@ describe("estimateCost", () => {
expect(isModelPriced("gpt-6-astra-pro")).toBe(false);
expect(isModelPriced("gpt-6.1-sol-pro")).toBe(false);
expect(isModelPriced("gpt-6-1-sol")).toBe(false);
+ expect(isModelPriced("gpt-6.1-terra-pro")).toBe(false);
+ expect(isModelPriced("gpt-6-1-terra")).toBe(false);
expect(isModelPriced("gpt-6-sol-high")).toBe(false);
expect(isModelPriced("gpt-6-luna-pro")).toBe(false);
expect(
diff --git a/packages/views/runtimes/utils.ts b/packages/views/runtimes/utils.ts
index d11529fcd8..3569f8c1b2 100644
--- a/packages/views/runtimes/utils.ts
+++ b/packages/views/runtimes/utils.ts
@@ -186,7 +186,7 @@ export function formatUsd(n: number): string {
// is just discounted on subsequent reads), so cacheWrite mirrors input there.
// OpenAI historically did the same, but its GPT-5.6+ generation bills cache
// writes at 1.25× input (cache reads generally get the 90% cached-input
-// discount; GPT-6.1 Sol gets 95%), so those rows carry a distinct cacheWrite.
+// discount; GPT-6.1 Sol and Terra get 95%), so those rows carry a distinct cacheWrite.
// Codex usage doesn't yet stream cache-write tokens, so that rate isn't
// exercised today.
//
@@ -258,8 +258,9 @@ const MODEL_PRICING: Record<
// is kept correct for when it is.
"gpt-6-astra": { input: 10, output: 50, cacheRead: 1.00, cacheWrite: 12.50 },
// Standard short-context rates: developers.openai.com/api/docs/models/.
- // GPT-6.1 Sol's cached input is 0.05x input; GPT-6 Sol's is 0.1x.
+ // GPT-6.1 Sol and Terra's cached input is 0.05x input; GPT-6 Sol's is 0.1x.
"gpt-6.1-sol": { input: 2, output: 10, cacheRead: 0.10, cacheWrite: 2.50 },
+ "gpt-6.1-terra": { input: 1, output: 5, cacheRead: 0.05, cacheWrite: 1.25 },
"gpt-6-sol": { input: 2, output: 10, cacheRead: 0.20, cacheWrite: 2.50 },
"gpt-6-luna": { input: 0.10, output: 0.50, cacheRead: 0.01, cacheWrite: 0.125 },
"gpt-5.6-sol": { input: 5, output: 30, cacheRead: 0.50, cacheWrite: 6.25 },
diff --git a/server/internal/metrics/pricing.go b/server/internal/metrics/pricing.go
index ea93ae4edf..aefc34eb2b 100644
--- a/server/internal/metrics/pricing.go
+++ b/server/internal/metrics/pricing.go
@@ -31,8 +31,9 @@ var modelPrices = map[string]ModelPrice{
// normalizes those into mutually exclusive billing buckets.
"openai:gpt-6-astra": {Provider: "openai", Model: "gpt-6-astra", InputPerM: 10.00, CacheReadPerM: 1.00, CacheWritePerM: 12.50, OutputPerM: 50.00},
// Standard short-context rates from developers.openai.com/api/docs/models/.
- // GPT-6.1 Sol caches at 0.05x input, not GPT-6 Sol's 0.1x.
+ // GPT-6.1 Sol and Terra cache at 0.05x input, not GPT-6 Sol's 0.1x.
"openai:gpt-6.1-sol": {Provider: "openai", Model: "gpt-6.1-sol", InputPerM: 2.00, CacheReadPerM: 0.10, CacheWritePerM: 2.50, OutputPerM: 10.00},
+ "openai:gpt-6.1-terra": {Provider: "openai", Model: "gpt-6.1-terra", InputPerM: 1.00, CacheReadPerM: 0.05, CacheWritePerM: 1.25, OutputPerM: 5.00},
"openai:gpt-6-sol": {Provider: "openai", Model: "gpt-6-sol", InputPerM: 2.00, CacheReadPerM: 0.20, CacheWritePerM: 2.50, OutputPerM: 10.00},
"openai:gpt-6-luna": {Provider: "openai", Model: "gpt-6-luna", InputPerM: 0.10, CacheReadPerM: 0.01, CacheWritePerM: 0.125, OutputPerM: 0.50},
"openai:gpt-5.6-sol": {Provider: "openai", Model: "gpt-5.6-sol", InputPerM: 5.00, CacheReadPerM: 0.50, CacheWritePerM: 6.25, OutputPerM: 30.00},
@@ -193,6 +194,7 @@ var modelAliasRules = []struct {
// as unmapped on both sides rather than silently borrowing a tier here.
{regexp.MustCompile(`(^|/|:)gpt-6-astra$`), "openai:gpt-6-astra"},
{regexp.MustCompile(`(^|/|:)gpt-6\.1-sol$`), "openai:gpt-6.1-sol"},
+ {regexp.MustCompile(`(^|/|:)gpt-6\.1-terra$`), "openai:gpt-6.1-terra"},
{regexp.MustCompile(`(^|/|:)gpt-6-sol$`), "openai:gpt-6-sol"},
{regexp.MustCompile(`(^|/|:)gpt-6-luna$`), "openai:gpt-6-luna"},
{regexp.MustCompile(`(^|/|:)gpt-5\.6-sol$`), "openai:gpt-5.6-sol"},
diff --git a/server/internal/metrics/pricing_test.go b/server/internal/metrics/pricing_test.go
index 8b3b3e0e5a..11e27d72f6 100644
--- a/server/internal/metrics/pricing_test.go
+++ b/server/internal/metrics/pricing_test.go
@@ -81,6 +81,14 @@ func TestPriceForModelAliasCodexCurrentGeneration(t *testing.T) {
model: "openai:gpt-6.1-sol[1m]",
want: ModelPrice{Provider: "openai", Model: "gpt-6.1-sol", InputPerM: 2, CacheReadPerM: 0.1, CacheWritePerM: 2.5, OutputPerM: 10},
},
+ {
+ model: "gpt-6.1-terra",
+ want: ModelPrice{Provider: "openai", Model: "gpt-6.1-terra", InputPerM: 1, CacheReadPerM: 0.05, CacheWritePerM: 1.25, OutputPerM: 5},
+ },
+ {
+ model: "openai/gpt-6.1-terra[1m]",
+ want: ModelPrice{Provider: "openai", Model: "gpt-6.1-terra", InputPerM: 1, CacheReadPerM: 0.05, CacheWritePerM: 1.25, OutputPerM: 5},
+ },
{
model: "openai:gpt-6-sol",
want: ModelPrice{Provider: "openai", Model: "gpt-6-sol", InputPerM: 2, CacheReadPerM: 0.2, CacheWritePerM: 2.5, OutputPerM: 10},
@@ -118,6 +126,8 @@ func TestPriceForModelAliasCodexCurrentGeneration(t *testing.T) {
"gpt-6-astra-pro",
"gpt-6.1-sol-pro",
"gpt-6-1-sol",
+ "gpt-6.1-terra-pro",
+ "gpt-6-1-terra",
"gpt-6-sol-high",
"gpt-6-luna-pro",
"gpt-6-astra/unknown",
diff --git a/server/pkg/agent/models.go b/server/pkg/agent/models.go
index a738388fb7..c023b14e8f 100644
--- a/server/pkg/agent/models.go
+++ b/server/pkg/agent/models.go
@@ -614,8 +614,9 @@ func claudeStaticModels() []Model {
// codexStaticModels is the fallback for Codex versions older than 0.122.0
// and for failed/malformed live and bundled discovery calls. It lists the
// visible entries of the newest locally verified live catalog — which can run
-// ahead of the bundled one (gpt-6.1-sol was live-only on codex-cli 0.159.0)
-// — plus still-common models from older Codex releases.
+// ahead of the bundled one (gpt-6.1-sol was live-only on codex-cli 0.159.0,
+// gpt-6.1-terra on 0.164.0-alpha.11.1) — plus still-common models from older
+// Codex releases.
// Each entry carries its own reasoning catalog so old/offline CLIs retain the
// same model + thinking picker contract as dynamic discovery. Service tiers are
// intentionally NOT guessed here: they are runtime/version/account-sensitive,
@@ -660,6 +661,7 @@ func codexStaticModels() []Model {
return []Model{
{ID: "gpt-6-astra", Label: "GPT-6 Astra", Provider: "openai", Default: true, Thinking: standardThinking("low", true, true)},
{ID: "gpt-6.1-sol", Label: "GPT-6.1 Sol", Provider: "openai", Thinking: standardThinking("low", true, true)},
+ {ID: "gpt-6.1-terra", Label: "GPT-6.1 Terra", Provider: "openai", Thinking: standardThinking("low", true, true)},
{ID: "gpt-6-sol", Label: "GPT-6 Sol", Provider: "openai", Thinking: standardThinking("medium", true, true)},
{ID: "gpt-6-luna", Label: "GPT-6 Luna", Provider: "openai", Thinking: standardThinking("medium", true, false)},
{ID: "gpt-5.6-sol", Label: "GPT-5.6 Sol", Provider: "openai", Thinking: standardThinking("low", true, true)},
diff --git a/server/pkg/agent/thinking.go b/server/pkg/agent/thinking.go
index 14e22ae19c..a37a3acef2 100644
--- a/server/pkg/agent/thinking.go
+++ b/server/pkg/agent/thinking.go
@@ -432,6 +432,8 @@ func normalizeCodexModelLabel(id, label string) string {
return "GPT-6 Astra"
case "gpt-6.1-sol":
return "GPT-6.1 Sol"
+ case "gpt-6.1-terra":
+ return "GPT-6.1 Terra"
case "gpt-6-sol":
return "GPT-6 Sol"
case "gpt-6-luna":
diff --git a/server/pkg/agent/thinking_test.go b/server/pkg/agent/thinking_test.go
index 34694bace9..35b11a1f6c 100644
--- a/server/pkg/agent/thinking_test.go
+++ b/server/pkg/agent/thinking_test.go
@@ -362,9 +362,9 @@ func TestNormalizeCodexModelLabelMatchesStaticGPT6Family(t *testing.T) {
static := map[string]string{}
for _, m := range codexStaticModels() {
static[m.ID] = m.Label
- if m.ID == "gpt-6.1-sol" {
+ if m.ID == "gpt-6.1-sol" || m.ID == "gpt-6.1-terra" {
if m.Thinking == nil || m.Thinking.DefaultLevel != "low" || len(m.Thinking.SupportedLevels) != 6 || !hasThinkingLevel(m.Thinking, "max") || !hasThinkingLevel(m.Thinking, "ultra") {
- t.Errorf("GPT-6.1 Sol fallback must match the observed live efforts: %+v", m.Thinking)
+ t.Errorf("%s fallback must match the observed live efforts: %+v", m.ID, m.Thinking)
}
if m.Default || len(m.ServiceTiers) != 0 {
t.Errorf("new fallback must not change the default or guess service tiers: %+v", m)
@@ -372,10 +372,11 @@ func TestNormalizeCodexModelLabelMatchesStaticGPT6Family(t *testing.T) {
}
}
for id, reported := range map[string]string{
- "gpt-6-astra": "GPT-6-Astra",
- "gpt-6.1-sol": "GPT-6.1-Sol",
- "gpt-6-sol": "GPT-6-Sol",
- "gpt-6-luna": "GPT-6-Luna",
+ "gpt-6-astra": "GPT-6-Astra",
+ "gpt-6.1-sol": "GPT-6.1-Sol",
+ "gpt-6.1-terra": "GPT-6.1 Terra",
+ "gpt-6-sol": "GPT-6-Sol",
+ "gpt-6-luna": "GPT-6-Luna",
} {
if static[id] == "" {
t.Errorf("%s missing from the static Codex catalog", id)