feat(ai): add input-based pricing tiers

This commit is contained in:
Armin Ronacher
2026-07-09 22:43:19 +02:00
parent 6c735db060
commit a9ecf301fb
14 changed files with 241 additions and 60 deletions
@@ -49,7 +49,21 @@ describe("ExtensionRunner", () => {
name: "Instant Model",
reasoning: false,
input: ["text"],
cost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0 },
cost: {
input: 1,
output: 2,
cacheRead: 0.1,
cacheWrite: 1.25,
tiers: [
{
inputTokensAbove: 272000,
input: 2,
output: 3,
cacheRead: 0.2,
cacheWrite: 2.5,
},
],
},
contextWindow: 128000,
maxTokens: 4096,
},
@@ -859,7 +873,15 @@ describe("ExtensionRunner", () => {
runtime.registerProvider("instant-provider", providerModelConfig);
expect(runtime.pendingProviderRegistrations).toHaveLength(0);
expect(modelRegistry.find("instant-provider", "instant-model")).toBeDefined();
expect(modelRegistry.find("instant-provider", "instant-model")?.cost.tiers).toEqual([
{
inputTokensAbove: 272000,
input: 2,
output: 3,
cacheRead: 0.2,
cacheWrite: 2.5,
},
]);
runtime.unregisterProvider("instant-provider");
expect(modelRegistry.find("instant-provider", "instant-model")).toBeUndefined();