Skip to content

Commit ffcf597

Browse files
authored
deepinfra/claude-3.7-sonnet-latest (#5062)
* integrate deepinfra/claude-3.7-sonnet; * update snapshot
1 parent f705b8b commit ffcf597

File tree

3 files changed

+141
-8
lines changed

3 files changed

+141
-8
lines changed

packages/__tests__/cost/__snapshots__/registrySnapshots.test.ts.snap

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -478,6 +478,26 @@ exports[`Registry Snapshots endpoint configurations snapshot 1`] = `
478478
"us-east-1",
479479
],
480480
},
481+
"claude-3.7-sonnet:deepinfra": {
482+
"context": 200000,
483+
"crossRegion": false,
484+
"maxTokens": 16384,
485+
"modelId": "anthropic/claude-3-7-sonnet-latest",
486+
"parameters": [
487+
"max_tokens",
488+
"stop",
489+
"temperature",
490+
"tool_choice",
491+
"tools",
492+
"top_k",
493+
"top_p",
494+
],
495+
"provider": "deepinfra",
496+
"ptbEnabled": true,
497+
"regions": [
498+
"*",
499+
],
500+
},
481501
"claude-3.7-sonnet:openrouter": {
482502
"context": 200000,
483503
"crossRegion": false,
@@ -3645,6 +3665,7 @@ exports[`Registry Snapshots model coverage snapshot 1`] = `
36453665
"anthropic/claude-3.7-sonnet": [
36463666
"anthropic",
36473667
"bedrock",
3668+
"deepinfra",
36483669
"openrouter",
36493670
"vertex",
36503671
],
@@ -4004,6 +4025,16 @@ exports[`Registry Snapshots pricing snapshot 1`] = `
40044025
"web_search": 0.00001,
40054026
},
40064027
],
4028+
"deepinfra": [
4029+
{
4030+
"cacheMultipliers": {
4031+
"cachedInput": 0.1,
4032+
},
4033+
"input": 0.0000033,
4034+
"output": 0.0000165,
4035+
"threshold": 0,
4036+
},
4037+
],
40074038
"openrouter": [
40084039
{
40094040
"input": 0.000003165,
@@ -4889,6 +4920,7 @@ exports[`Registry Snapshots verify registry state 1`] = `
48894920
"providers": [
48904921
"anthropic",
48914922
"bedrock",
4923+
"deepinfra",
48924924
"openrouter",
48934925
"vertex",
48944926
],

packages/cost/models/authors/anthropic/claude-3.7-sonnet/endpoints.ts

Lines changed: 38 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ export const endpoints = {
2121
},
2222
},
2323
],
24-
contextLength: 200000,
25-
maxCompletionTokens: 64000,
24+
contextLength: 200_000,
25+
maxCompletionTokens: 64_000,
2626
supportedParameters: [
2727
"tools",
2828
"tool_choice",
@@ -58,8 +58,8 @@ export const endpoints = {
5858
},
5959
},
6060
],
61-
contextLength: 200000,
62-
maxCompletionTokens: 64000,
61+
contextLength: 200_000,
62+
maxCompletionTokens: 64_000,
6363
supportedParameters: [
6464
"tools",
6565
"tool_choice",
@@ -93,8 +93,8 @@ export const endpoints = {
9393
},
9494
},
9595
],
96-
contextLength: 200000,
97-
maxCompletionTokens: 64000,
96+
contextLength: 200_000,
97+
maxCompletionTokens: 64_000,
9898
supportedParameters: [
9999
"tools",
100100
"tool_choice",
@@ -121,8 +121,8 @@ export const endpoints = {
121121
output: 0.00001583, // $15.83/1M - worst-case: $15.00/1M (Google) * 1.055,
122122
},
123123
],
124-
contextLength: 200000,
125-
maxCompletionTokens: 64000,
124+
contextLength: 200_000,
125+
maxCompletionTokens: 64_000,
126126
supportedParameters: [
127127
"max_tokens",
128128
"temperature",
@@ -138,6 +138,36 @@ export const endpoints = {
138138
"*": {},
139139
},
140140
},
141+
"claude-3.7-sonnet:deepinfra": {
142+
provider: "deepinfra",
143+
author: "anthropic",
144+
providerModelId: "anthropic/claude-3-7-sonnet-latest",
145+
pricing: [
146+
{
147+
threshold: 0,
148+
input: 0.0000033, // $3.30/1M
149+
output: 0.0000165, // $16.50/1M
150+
cacheMultipliers: {
151+
cachedInput: 0.1, // $0.33/1M
152+
},
153+
},
154+
],
155+
contextLength: 200_000,
156+
maxCompletionTokens: 16_384,
157+
supportedParameters: [
158+
"max_tokens",
159+
"temperature",
160+
"top_p",
161+
"top_k",
162+
"stop",
163+
"tools",
164+
"tool_choice",
165+
],
166+
ptbEnabled: true,
167+
endpointConfigs: {
168+
"*": {},
169+
},
170+
},
141171
} satisfies Partial<
142172
Record<`${Claude37SonnetModelName}:${ModelProviderName}`, ModelProviderConfig>
143173
>;

worker/test/ai-gateway/registry-anthropic.spec.ts

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,12 @@ const bedrockAuthExpectations = {
2626
},
2727
};
2828

29+
const deepinfraAuthExpectations = {
30+
headers: {
31+
Authorization: /^Bearer /,
32+
},
33+
};
34+
2935
describe("Anthropic Registry Tests", () => {
3036
beforeEach(() => {
3137
// Clear all mocks between tests
@@ -278,6 +284,23 @@ describe("Anthropic Registry Tests", () => {
278284
},
279285
}));
280286

287+
it("should handle deepinfra provider", () =>
288+
runGatewayTest({
289+
model: "claude-3.7-sonnet/deepinfra",
290+
expected: {
291+
providers: [
292+
{
293+
url: "https://api.deepinfra.com/v1/openai/chat/completions",
294+
response: "success",
295+
model: "anthropic/claude-3-7-sonnet-latest",
296+
data: createAnthropicMockResponse("claude-3.7-sonnet"),
297+
expects: deepinfraAuthExpectations,
298+
},
299+
],
300+
finalStatus: 200,
301+
},
302+
}));
303+
281304
it("should auto-select provider when none specified", () =>
282305
runGatewayTest({
283306
model: "claude-3.7-sonnet",
@@ -664,6 +687,54 @@ describe("Anthropic Registry Tests", () => {
664687
finalStatus: 401,
665688
},
666689
}));
690+
691+
it("should handle DeepInfra provider failure for claude-3.7-sonnet", () =>
692+
runGatewayTest({
693+
model: "claude-3.7-sonnet/deepinfra",
694+
expected: {
695+
providers: [
696+
{
697+
url: "https://api.deepinfra.com/v1/openai/chat/completions",
698+
response: "failure",
699+
statusCode: 500,
700+
errorMessage: "DeepInfra service unavailable",
701+
},
702+
],
703+
finalStatus: 500,
704+
},
705+
}));
706+
707+
it("should handle rate limiting from DeepInfra for claude-3.7-sonnet", () =>
708+
runGatewayTest({
709+
model: "claude-3.7-sonnet/deepinfra",
710+
expected: {
711+
providers: [
712+
{
713+
url: "https://api.deepinfra.com/v1/openai/chat/completions",
714+
response: "failure",
715+
statusCode: 429,
716+
errorMessage: "Rate limit exceeded",
717+
},
718+
],
719+
finalStatus: 429,
720+
},
721+
}));
722+
723+
it("should handle authentication failure from DeepInfra for claude-3.7-sonnet", () =>
724+
runGatewayTest({
725+
model: "claude-3.7-sonnet/deepinfra",
726+
expected: {
727+
providers: [
728+
{
729+
url: "https://api.deepinfra.com/v1/openai/chat/completions",
730+
response: "failure",
731+
statusCode: 401,
732+
errorMessage: "Invalid API key",
733+
},
734+
],
735+
finalStatus: 401,
736+
},
737+
}));
667738
});
668739
});
669740
});

0 commit comments

Comments
 (0)