Skip to content

Commit 775f30b

Browse files
authored
💄 style: Add GPT-5 pro model (#9594)
* ✨ feat: 添加输入缓存读取和写入定价支持,更新相关接口和定价格式 * ✨ feat: 添加 GPT-5 pro 模型及其定价信息,更新模型集合 * ✨ feat: 添加 GPT Image 1 Mini 模型及其定价信息,更新模型参数和定价策略 * ✨ feat: 更新价格格式化函数,允许价格为 undefined,调整模型定价接口的可选属性 * ✨ feat: 更新 DeepSeek V3.1 模型信息,添加新模型及其参数,调整模型 ID * ✨ feat: 添加 GPT-5 pro 模型,更新其能力、定价和描述信息 * ✨ feat: 强制 gpt-5 pro 使用 high 推理等级,优化推理负担处理逻辑
1 parent 1f36158 commit 775f30b

File tree

9 files changed

+188
-20
lines changed

9 files changed

+188
-20
lines changed

packages/model-bank/src/aiModels/aihubmix.ts

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,31 @@
11
import { AIChatModelCard } from '../types/aiModel';
22

33
const aihubmixModels: AIChatModelCard[] = [
4+
{
5+
abilities: {
6+
functionCall: true,
7+
reasoning: true,
8+
search: true,
9+
vision: true,
10+
},
11+
contextWindowTokens: 400_000,
12+
description: 'GPT-5 pro 使用更多计算来更深入地思考,并持续提供更好的答案。',
13+
displayName: 'GPT-5 pro',
14+
id: 'gpt-5-pro',
15+
maxOutput: 272_000,
16+
pricing: {
17+
units: [
18+
{ name: 'textInput', rate: 15, strategy: 'fixed', unit: 'millionTokens' },
19+
{ name: 'textOutput', rate: 120, strategy: 'fixed', unit: 'millionTokens' },
20+
],
21+
},
22+
releasedAt: '2025-10-06',
23+
settings: {
24+
extendParams: ['textVerbosity'],
25+
searchImpl: 'params',
26+
},
27+
type: 'chat',
28+
},
429
{
530
abilities: {
631
functionCall: true,

packages/model-bank/src/aiModels/nvidia.ts

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,24 @@ const nvidiaChatModels: AIChatModelCard[] = [
99
contextWindowTokens: 131_072,
1010
description:
1111
'DeepSeek V3.1:下一代推理模型,提升了复杂推理与链路思考能力,适合需要深入分析的任务。',
12-
displayName: 'DeepSeek V3.1',
12+
displayName: 'DeepSeek V3.1 Terminus',
1313
enabled: true,
14+
id: 'deepseek-ai/deepseek-v3.1-terminus',
15+
maxOutput: 16_384,
16+
settings: {
17+
extendParams: ['enableReasoning'],
18+
},
19+
type: 'chat',
20+
},
21+
{
22+
abilities: {
23+
functionCall: true,
24+
reasoning: true,
25+
},
26+
contextWindowTokens: 131_072,
27+
description:
28+
'DeepSeek V3.1:下一代推理模型,提升了复杂推理与链路思考能力,适合需要深入分析的任务。',
29+
displayName: 'DeepSeek V3.1',
1430
id: 'deepseek-ai/deepseek-v3.1',
1531
maxOutput: 16_384,
1632
settings: {

packages/model-bank/src/aiModels/openai.ts

Lines changed: 80 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,31 @@ export const gptImage1ParamsSchema: ModelParamsSchema = {
1818
};
1919

2020
export const openaiChatModels: AIChatModelCard[] = [
21+
{
22+
abilities: {
23+
functionCall: true,
24+
reasoning: true,
25+
search: true,
26+
vision: true,
27+
},
28+
contextWindowTokens: 400_000,
29+
description: 'GPT-5 pro 使用更多计算来更深入地思考,并持续提供更好的答案。',
30+
displayName: 'GPT-5 pro',
31+
id: 'gpt-5-pro',
32+
maxOutput: 272_000,
33+
pricing: {
34+
units: [
35+
{ name: 'textInput', rate: 15, strategy: 'fixed', unit: 'millionTokens' },
36+
{ name: 'textOutput', rate: 120, strategy: 'fixed', unit: 'millionTokens' },
37+
],
38+
},
39+
releasedAt: '2025-10-06',
40+
settings: {
41+
extendParams: ['textVerbosity'],
42+
searchImpl: 'params',
43+
},
44+
type: 'chat',
45+
},
2146
{
2247
abilities: {
2348
functionCall: true,
@@ -614,7 +639,7 @@ export const openaiChatModels: AIChatModelCard[] = [
614639
contextWindowTokens: 128_000,
615640
description: 'GPT-4o Audio Preview 模型,支持音频输入输出',
616641
displayName: 'GPT-4o Audio Preview',
617-
id: 'gpt-4o-audio-preview', // deprecated on 2025-10-10
642+
id: 'gpt-4o-audio-preview',
618643
maxOutput: 16_384,
619644
pricing: {
620645
units: [
@@ -1046,9 +1071,63 @@ export const openaiImageModels: AIImageModelCard[] = [
10461071
{ name: 'imageInput', rate: 10, strategy: 'fixed', unit: 'millionTokens' },
10471072
{ name: 'imageInput_cacheRead', rate: 2.5, strategy: 'fixed', unit: 'millionTokens' },
10481073
{ name: 'imageOutput', rate: 40, strategy: 'fixed', unit: 'millionTokens' },
1074+
{
1075+
lookup: {
1076+
prices: {
1077+
'low_1024x1024': 0.011,
1078+
'low_1024x1536': 0.016,
1079+
'low_1536x1024': 0.016,
1080+
'medium_1024x1024': 0.042,
1081+
'medium_1024x1536': 0.063,
1082+
'medium_1536x1024': 0.063,
1083+
'high_1024x1024': 0.167,
1084+
'high_1024x1536': 0.25,
1085+
'high_1536x1024': 0.25,
1086+
},
1087+
pricingParams: ['quality', 'size'],
1088+
},
1089+
name: 'imageGeneration',
1090+
strategy: 'lookup',
1091+
unit: 'image',
1092+
},
1093+
],
1094+
},
1095+
resolutions: ['1024x1024', '1024x1536', '1536x1024'],
1096+
type: 'image',
1097+
},
1098+
{
1099+
description: '成本更低的 GPT Image 1 版本,原生支持文本与图像输入并生成图像输出。',
1100+
displayName: 'GPT Image 1 Mini',
1101+
enabled: true,
1102+
id: 'gpt-image-1-mini',
1103+
parameters: gptImage1ParamsSchema,
1104+
pricing: {
1105+
units: [
1106+
{ name: 'textInput', rate: 2, strategy: 'fixed', unit: 'millionTokens' },
1107+
{ name: 'textInput_cacheRead', rate: 0.2, strategy: 'fixed', unit: 'millionTokens' },
1108+
{ name: 'imageInput', rate: 2.5, strategy: 'fixed', unit: 'millionTokens' },
1109+
{ name: 'imageInput_cacheRead', rate: 0.25, strategy: 'fixed', unit: 'millionTokens' },
1110+
{ name: 'imageOutput', rate: 8, strategy: 'fixed', unit: 'millionTokens' },
1111+
{
1112+
lookup: {
1113+
prices: {
1114+
'low_1024x1024': 0.005,
1115+
'low_1024x1536': 0.006,
1116+
'low_1536x1024': 0.006,
1117+
'medium_1024x1024': 0.011,
1118+
'medium_1024x1536': 0.015,
1119+
'medium_1536x1024': 0.015,
1120+
},
1121+
pricingParams: ['quality', 'size'],
1122+
},
1123+
name: 'imageGeneration',
1124+
strategy: 'lookup',
1125+
unit: 'image',
1126+
},
10491127
],
10501128
},
10511129
resolutions: ['1024x1024', '1024x1536', '1536x1024'],
1130+
releasedAt: '2025-10-06',
10521131
type: 'image',
10531132
},
10541133
{

packages/model-runtime/src/const/models.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ export const responsesAPIModels = new Set([
3636
'computer-use-preview',
3737
'computer-use-preview-2025-03-11',
3838
'gpt-5-codex',
39+
'gpt-5-pro',
40+
'gpt-5-pro-2025-10-06',
3941
]);
4042

4143
/**

packages/model-runtime/src/providers/openai/index.ts

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -81,23 +81,27 @@ export const LobeOpenAI = createOpenAICompatibleRuntime({
8181

8282
const openaiTools = enabledSearch
8383
? [
84-
...(tools || []),
85-
{
86-
type: 'web_search',
87-
...(oaiSearchContextSize && {
88-
search_context_size: oaiSearchContextSize,
89-
}),
90-
},
91-
]
84+
...(tools || []),
85+
{
86+
type: 'web_search',
87+
...(oaiSearchContextSize && {
88+
search_context_size: oaiSearchContextSize,
89+
}),
90+
},
91+
]
9292
: tools;
9393

9494
if (prunePrefixes.some((prefix) => model.startsWith(prefix))) {
95+
const reasoning = payload.reasoning
96+
? { ...payload.reasoning, summary: 'auto' }
97+
: { summary: 'auto' };
98+
if (model.startsWith('gpt-5-pro')) {
99+
reasoning.effort = 'high';
100+
}
95101
return pruneReasoningPayload({
96102
...rest,
97103
model,
98-
reasoning: payload.reasoning
99-
? { ...payload.reasoning, summary: 'auto' }
100-
: { summary: 'auto' },
104+
reasoning,
101105
...(enableServiceTierFlex && supportsFlexTier(model) && { service_tier: 'flex' }),
102106
stream: payload.stream ?? true,
103107
tools: openaiTools as any,

packages/model-runtime/src/providers/openrouter/index.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ import { createOpenAICompatibleRuntime } from '../../core/openaiCompatibleFactor
44
import { processMultiProviderModelList } from '../../utils/modelParse';
55
import { OpenRouterModelCard, OpenRouterReasoning } from './type';
66

7-
const formatPrice = (price: string) => {
8-
if (price === '-1') return undefined;
7+
const formatPrice = (price?: string) => {
8+
if (price === undefined || price === '-1') return undefined;
99
return Number((Number(price) * 1e6).toPrecision(5));
1010
};
1111

@@ -81,6 +81,9 @@ export const LobeOpenRouterAI = createOpenAICompatibleRuntime({
8181

8282
const inputPrice = formatPrice(endpoint?.pricing?.prompt);
8383
const outputPrice = formatPrice(endpoint?.pricing?.completion);
84+
const cachedInputPrice = formatPrice(endpoint?.pricing?.input_cache_read);
85+
const writeCacheInputPrice = formatPrice(endpoint?.pricing?.input_cache_write);
86+
8487
const isFree = (inputPrice === 0 || outputPrice === 0) && !displayName.endsWith('(free)');
8588
if (isFree) {
8689
displayName += ' (free)';
@@ -98,6 +101,8 @@ export const LobeOpenRouterAI = createOpenAICompatibleRuntime({
98101
: undefined,
99102
pricing: {
100103
input: inputPrice,
104+
cachedInput: cachedInputPrice,
105+
writeCacheInput: writeCacheInputPrice,
101106
output: outputPrice,
102107
},
103108
reasoning: endpoint?.supports_reasoning || false,

packages/model-runtime/src/providers/openrouter/type.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
interface ModelPricing {
22
completion: string;
3-
image: string;
3+
image?: string;
4+
input_cache_read?: string;
5+
input_cache_write?: string;
46
prompt: string;
5-
request: string;
7+
request?: string;
68
}
79

810
export interface OpenRouterModelCard {

packages/model-runtime/src/providers/vercelaigateway/index.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ export interface VercelAIGatewayModelCard {
1313
pricing?: {
1414
input?: string | number;
1515
output?: string | number;
16+
input_cache_read?: string | number;
17+
input_cache_write?: string | number;
1618
};
1719
tags?: string[];
1820
type?: string;
@@ -68,6 +70,9 @@ export const LobeVercelAIGatewayAI = createOpenAICompatibleRuntime({
6870

6971
const inputPrice = formatPrice(m.pricing?.input);
7072
const outputPrice = formatPrice(m.pricing?.output);
73+
const cachedInputPrice = formatPrice(m.pricing?.input_cache_read);
74+
const writeCacheInputPrice = formatPrice(m.pricing?.input_cache_write);
75+
7176
let displayName = m.name ?? m.id;
7277
if (inputPrice === 0 && outputPrice === 0) {
7378
displayName += ' (free)';
@@ -82,8 +87,10 @@ export const LobeVercelAIGatewayAI = createOpenAICompatibleRuntime({
8287
id: m.id,
8388
maxOutput: typeof m.max_tokens === 'number' ? m.max_tokens : undefined,
8489
pricing: {
90+
cachedInput: cachedInputPrice,
8591
input: inputPrice,
8692
output: outputPrice,
93+
writeCacheInput: writeCacheInputPrice,
8794
},
8895
reasoning: tags.includes('reasoning') || false,
8996
type: m.type === 'embedding' ? 'embedding' : 'chat',

packages/model-runtime/src/utils/modelParse.ts

Lines changed: 31 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -326,13 +326,25 @@ const processModelCard = (
326326
return undefined;
327327
}
328328

329-
const formatPricing = (pricing?: { input?: number; output?: number; units?: any[] }) => {
329+
const formatPricing = (pricing?: {
330+
cachedInput?: number;
331+
input?: number;
332+
output?: number;
333+
units?: any[];
334+
writeCacheInput?: number;
335+
}) => {
330336
if (!pricing || typeof pricing !== 'object') return undefined;
331337
if (Array.isArray(pricing.units)) {
332338
return { units: pricing.units };
333339
}
334-
const { input, output } = pricing;
335-
if (typeof input !== 'number' && typeof output !== 'number') return undefined;
340+
const { input, output, cachedInput, writeCacheInput } = pricing;
341+
if (
342+
typeof input !== 'number' &&
343+
typeof output !== 'number' &&
344+
typeof cachedInput !== 'number' &&
345+
typeof writeCacheInput !== 'number'
346+
)
347+
return undefined;
336348

337349
const units = [];
338350
if (typeof input === 'number') {
@@ -351,6 +363,22 @@ const processModelCard = (
351363
unit: 'millionTokens' as const,
352364
});
353365
}
366+
if (typeof cachedInput === 'number') {
367+
units.push({
368+
name: 'textInput_cacheRead' as const,
369+
rate: cachedInput,
370+
strategy: 'fixed' as const,
371+
unit: 'millionTokens' as const,
372+
});
373+
}
374+
if (typeof writeCacheInput === 'number') {
375+
units.push({
376+
name: 'textInput_cacheWrite' as const,
377+
rate: writeCacheInput,
378+
strategy: 'fixed' as const,
379+
unit: 'millionTokens' as const,
380+
});
381+
}
354382
return { units };
355383
};
356384

0 commit comments

Comments
 (0)