@@ -12,6 +12,8 @@ import {
|
12 | 12 | discoverVercelAiGatewayModels, |
13 | 13 | getStaticVercelAiGatewayModelCatalog, |
14 | 14 | VERCEL_AI_GATEWAY_BASE_URL, |
| 15 | +VERCEL_AI_GATEWAY_DEFAULT_CONTEXT_WINDOW, |
| 16 | +VERCEL_AI_GATEWAY_DEFAULT_MAX_TOKENS, |
15 | 17 | } from "./api.js"; |
16 | 18 | import { |
17 | 19 | buildStaticVercelAiGatewayProvider, |
@@ -93,4 +95,47 @@ describe("vercel ai gateway provider catalog", () => {
|
93 | 95 | }); |
94 | 96 | } |
95 | 97 | }); |
| 98 | + |
| 99 | +it("falls back from malformed live token metadata", async () => { |
| 100 | +fetchWithSsrFGuardMock.mockResolvedValueOnce({ |
| 101 | +response: { |
| 102 | +ok: true, |
| 103 | +status: 200, |
| 104 | +json: async () => ({ |
| 105 | +data: [ |
| 106 | +{ |
| 107 | +id: "anthropic/claude-opus-4.6", |
| 108 | +name: "Claude Opus 4.6", |
| 109 | +context_window: -1, |
| 110 | +max_tokens: 128_000.5, |
| 111 | +tags: ["vision", "reasoning"], |
| 112 | +}, |
| 113 | +{ |
| 114 | +id: "custom/provider-model", |
| 115 | +name: "Custom model", |
| 116 | +context_window: Number.POSITIVE_INFINITY, |
| 117 | +max_tokens: 0, |
| 118 | +tags: ["reasoning"], |
| 119 | +}, |
| 120 | +], |
| 121 | +}), |
| 122 | +}, |
| 123 | +release: async () => {}, |
| 124 | +}); |
| 125 | + |
| 126 | +await withLiveDiscovery(async () => { |
| 127 | +const models = await discoverVercelAiGatewayModels(); |
| 128 | + |
| 129 | +expect(models[0]).toMatchObject({ |
| 130 | +id: "anthropic/claude-opus-4.6", |
| 131 | +contextWindow: 1_000_000, |
| 132 | +maxTokens: 128_000, |
| 133 | +}); |
| 134 | +expect(models[1]).toMatchObject({ |
| 135 | +id: "custom/provider-model", |
| 136 | +contextWindow: VERCEL_AI_GATEWAY_DEFAULT_CONTEXT_WINDOW, |
| 137 | +maxTokens: VERCEL_AI_GATEWAY_DEFAULT_MAX_TOKENS, |
| 138 | +}); |
| 139 | +}); |
| 140 | +}); |
96 | 141 | }); |