🤯 LobeHub - Super-Agents on Your Team. Add super-agents to the chats your team already uses.They take on work by themselves and get better every week.
TypeScript agentagent-collaborationagent-harnessloop-engineeringmcppersonal-assistantproactive-agentskillssuper-agenttask-management
✨ feat: add Gemini 3.1 Flash-Lite provider cards (#14604)
YuTengjing7bd7baf6b69b
diff --git a/packages/model-bank/src/aiModels/google.ts b/packages/model-bank/src/aiModels/google.tsindex f090ed72e5e..09ff0e35c89 100644--- a/packages/model-bank/src/aiModels/google.ts+++ b/packages/model-bank/src/aiModels/google.ts@@ -301,11 +301,13 @@ const googleChatModels: AIChatModelCard[] = [pricing: {units: [{ name: 'textInput_cacheRead', rate: 0.025, strategy: 'fixed', unit: 'millionTokens' },+ { name: 'audioInput_cacheRead', rate: 0.05, strategy: 'fixed', unit: 'millionTokens' },{ name: 'textInput', rate: 0.25, strategy: 'fixed', unit: 'millionTokens' },{ name: 'imageInput', rate: 0.25, strategy: 'fixed', unit: 'millionTokens' },{ name: 'videoInput', rate: 0.25, strategy: 'fixed', unit: 'millionTokens' },{ name: 'audioInput', rate: 0.5, strategy: 'fixed', unit: 'millionTokens' },{ name: 'textOutput', rate: 1.5, strategy: 'fixed', unit: 'millionTokens' },+ { name: 'textInput_cacheWrite', rate: 1, strategy: 'fixed', unit: 'millionTokens' },],},releasedAt: '2026-05-07',diff --git a/packages/model-bank/src/aiModels/lobehub/chat/google.ts b/packages/model-bank/src/aiModels/lobehub/chat/google.tsindex 72ef6537097..165956a68b3 100644--- a/packages/model-bank/src/aiModels/lobehub/chat/google.ts+++ b/packages/model-bank/src/aiModels/lobehub/chat/google.ts@@ -89,6 +89,42 @@ export const googleChatModels: AIChatModelCard[] = [},type: 'chat',},+ {+ abilities: {+ functionCall: true,+ reasoning: true,+ search: true,+ structuredOutput: true,+ video: true,+ vision: true,+ },+ contextWindowTokens: 1_048_576 + 65_536,+ description:+ "Gemini 3.1 Flash-Lite is Google's most cost-efficient multimodal model, optimized for high-volume agentic tasks, translation, and data processing.",+ displayName: 'Gemini 3.1 Flash-Lite',+ enabled: true,+ id: 'gemini-3.1-flash-lite',+ maxOutput: 65_536,+ pricing: {+ units: [+ { name: 'textInput_cacheRead', rate: 0.025, strategy: 'fixed', unit: 'millionTokens' },+ { name: 'audioInput_cacheRead', rate: 0.05, strategy: 'fixed', unit: 'millionTokens' },+ { name: 'textInput', rate: 0.25, strategy: 'fixed', unit: 'millionTokens' },+ { name: 'imageInput', rate: 0.25, strategy: 'fixed', unit: 'millionTokens' },+ { name: 'videoInput', rate: 0.25, strategy: 'fixed', unit: 'millionTokens' },+ { name: 'audioInput', rate: 0.5, strategy: 'fixed', unit: 'millionTokens' },+ { name: 'textOutput', rate: 1.5, strategy: 'fixed', unit: 'millionTokens' },+ { name: 'textInput_cacheWrite', rate: 1, strategy: 'fixed', unit: 'millionTokens' },+ ],+ },+ releasedAt: '2026-05-07',+ settings: {+ extendParams: ['thinkingLevel5', 'urlContext'],+ searchImpl: 'params',+ searchProvider: 'google',+ },+ type: 'chat',+ },{abilities: {functionCall: true,@@ -145,7 +181,6 @@ export const googleChatModels: AIChatModelCard[] = [description:"Gemini 3.1 Flash-Lite Preview is Google's most cost-efficient multimodal model, optimized for high-volume agentic tasks, translation, and data processing.",displayName: 'Gemini 3.1 Flash-Lite Preview',- enabled: true,id: 'gemini-3.1-flash-lite-preview',maxOutput: 65_536,pricing: {diff --git a/packages/model-bank/src/aiModels/vertexai.ts b/packages/model-bank/src/aiModels/vertexai.tsindex b66165ad90d..e0e57a53265 100644--- a/packages/model-bank/src/aiModels/vertexai.ts+++ b/packages/model-bank/src/aiModels/vertexai.ts@@ -122,6 +122,42 @@ const vertexaiChatModels: AIChatModelCard[] = [},type: 'chat',},+ {+ abilities: {+ functionCall: true,+ reasoning: true,+ search: true,+ structuredOutput: true,+ video: true,+ vision: true,+ },+ contextWindowTokens: 1_048_576 + 65_536,+ description:+ "Gemini 3.1 Flash-Lite is Google's most cost-efficient multimodal model, optimized for high-volume agentic tasks, translation, and data processing.",+ displayName: 'Gemini 3.1 Flash-Lite',+ enabled: true,+ id: 'gemini-3.1-flash-lite',+ maxOutput: 65_536,+ pricing: {+ units: [+ { name: 'textInput_cacheRead', rate: 0.025, strategy: 'fixed', unit: 'millionTokens' },+ { name: 'audioInput_cacheRead', rate: 0.05, strategy: 'fixed', unit: 'millionTokens' },+ { name: 'textInput', rate: 0.25, strategy: 'fixed', unit: 'millionTokens' },+ { name: 'imageInput', rate: 0.25, strategy: 'fixed', unit: 'millionTokens' },+ { name: 'videoInput', rate: 0.25, strategy: 'fixed', unit: 'millionTokens' },+ { name: 'audioInput', rate: 0.5, strategy: 'fixed', unit: 'millionTokens' },+ { name: 'textOutput', rate: 1.5, strategy: 'fixed', unit: 'millionTokens' },+ { name: 'textInput_cacheWrite', rate: 1, strategy: 'fixed', unit: 'millionTokens' },+ ],+ },+ releasedAt: '2026-05-07',+ settings: {+ extendParams: ['thinkingLevel5', 'urlContext'],+ searchImpl: 'params',+ searchProvider: 'google',+ },+ type: 'chat',+ },{abilities: {functionCall: true,@@ -135,7 +171,6 @@ const vertexaiChatModels: AIChatModelCard[] = [description:"Gemini 3.1 Flash-Lite Preview is Google's most cost-efficient multimodal model, optimized for high-volume agentic tasks, translation, and data processing.",displayName: 'Gemini 3.1 Flash-Lite Preview',- enabled: true,id: 'gemini-3.1-flash-lite-preview',maxOutput: 65_536,pricing: {diff --git a/packages/model-runtime/src/core/usageConverters/utils/computeChatCost.test.ts b/packages/model-runtime/src/core/usageConverters/utils/computeChatCost.test.tsindex 3b778999758..40fe1aabafe 100644--- a/packages/model-runtime/src/core/usageConverters/utils/computeChatCost.test.ts+++ b/packages/model-runtime/src/core/usageConverters/utils/computeChatCost.test.ts@@ -6,6 +6,7 @@ import deepseekChatModels from 'model-bank/deepseek';import googleChatModels from 'model-bank/google';import { lobehubChatModels } from 'model-bank/lobehub';import openaiChatModels from 'model-bank/openai';+import vertexAiModels from 'model-bank/vertexai';import { describe, expect, it } from 'vitest';import { computeChatCost } from './computeChatCost';@@ -334,7 +335,7 @@ describe('computeChatPricing', () => {it('charges Gemini 3.1 Flash-Lite image, video, and audio input tokens', () => {const pricing = googleChatModels.find(- (model: { id: string }) => model.id === 'gemini-3.1-flash-lite-preview',+ (model: { id: string }) => model.id === 'gemini-3.1-flash-lite',)?.pricing;expect(pricing).toBeDefined();@@ -362,6 +363,55 @@ describe('computeChatPricing', () => {expect(breakdown.find((item) => item.unit.name === 'textOutput')?.credits).toBe(519);});+ it('charges Gemini 3.1 Flash-Lite cached audio and cache writes across Google cards', () => {+ const modelLists = [googleChatModels, lobehubChatModels, vertexAiModels];++ for (const models of modelLists) {+ const pricing = models.find(+ (model: { id: string }) => model.id === 'gemini-3.1-flash-lite',+ )?.pricing;+ expect(pricing).toBeDefined();++ const usage: ModelTokensUsage = {+ inputAudioTokens: 1000,+ inputCachedAudioTokens: 400,+ inputCachedImageTokens: 200,+ inputCachedTextTokens: 600,+ inputCachedTokens: 1300,+ inputCachedVideoTokens: 100,+ inputImageTokens: 500,+ inputTextTokens: 1200,+ inputVideoTokens: 300,+ inputWriteCacheTokens: 300,+ outputTextTokens: 100,+ totalInputTokens: 3000,+ totalOutputTokens: 100,+ totalTokens: 3100,+ };++ const result = computeChatCost(pricing, usage);+ expect(result).toBeDefined();+ expect(result?.issues).toHaveLength(0);+ expect(result?.totalCredits).toBe(1068);++ const { breakdown } = result!;+ expect(breakdown.find((item) => item.unit.name === 'textInput_cacheRead')?.credits).toBe(+ 23,+ );+ expect(breakdown.find((item) => item.unit.name === 'audioInput_cacheRead')?.credits).toBe(+ 20,+ );+ expect(breakdown.find((item) => item.unit.name === 'textInput')?.credits).toBe(150);+ expect(breakdown.find((item) => item.unit.name === 'imageInput')?.credits).toBe(75);+ expect(breakdown.find((item) => item.unit.name === 'videoInput')?.credits).toBe(50);+ expect(breakdown.find((item) => item.unit.name === 'audioInput')?.credits).toBe(300);+ expect(breakdown.find((item) => item.unit.name === 'textOutput')?.credits).toBe(150);++ const cacheWrite = breakdown.find((item) => item.unit.name === 'textInput_cacheWrite');+ expect(cacheWrite?.credits).toBe(300);+ }+ });+it('charges multimodal input units for LobeHub-hosted Gemini 3 Flash', () => {const pricing = lobehubChatModels.find((model: { id: string }) => model.id === 'gemini-3-flash-preview',diff --git a/packages/model-runtime/src/core/usageConverters/utils/computeChatCost.ts b/packages/model-runtime/src/core/usageConverters/utils/computeChatCost.tsindex b0652387d2b..134baf6c20f 100644--- a/packages/model-runtime/src/core/usageConverters/utils/computeChatCost.ts+++ b/packages/model-runtime/src/core/usageConverters/utils/computeChatCost.ts@@ -53,6 +53,8 @@ export interface PricingComputationResult {}interface UnitQuantityResolverContext {+ hasDedicatedAudioCacheReadUnit: boolean;+ hasDedicatedImageCacheReadUnit: boolean;hasDedicatedModalityCacheReadUnit: boolean;}@@ -108,6 +110,13 @@ const resolveInputVideoTokens = (usage: ModelTokensUsage) => {return usage.inputVideoTokens;};+const sumDefinedTokens = (...values: Array<number | undefined>) => {+ const definedValues = values.filter((value): value is number => typeof value === 'number');+ if (definedValues.length === 0) return undefined;++ return definedValues.reduce((sum, value) => sum + value, 0);+};+const UNIT_QUANTITY_RESOLVERS: Partial<Record<PricingUnitName, UnitQuantityResolver>> = {textInput: (usage) => {const toolTokens = usage.inputToolTokens ?? 0;@@ -143,7 +152,24 @@ const UNIT_QUANTITY_RESOLVERS: Partial<Record<PricingUnitName, UnitQuantityResol},textInput_cacheRead: (usage, context) => {if (hasCachedModalityBreakdown(usage) && context.hasDedicatedModalityCacheReadUnit) {- return usage.inputCachedTextTokens;+ if (typeof usage.inputCachedTokens === 'number') {+ return Math.max(+ 0,+ usage.inputCachedTokens -+ (context.hasDedicatedAudioCacheReadUnit ? (usage.inputCachedAudioTokens ?? 0) : 0) -+ (context.hasDedicatedImageCacheReadUnit ? (usage.inputCachedImageTokens ?? 0) : 0),+ );+ }++ // `textInput_cacheRead` is the fallback bucket for same-price cached modalities.+ // For Gemini 3.1 Flash-Lite, text/image/video cache reads share one rate while+ // audio has a dedicated higher rate.+ return sumDefinedTokens(+ usage.inputCachedTextTokens,+ context.hasDedicatedImageCacheReadUnit ? undefined : usage.inputCachedImageTokens,+ context.hasDedicatedAudioCacheReadUnit ? undefined : usage.inputCachedAudioTokens,+ usage.inputCachedVideoTokens,+ );}return usage.inputCachedTokens;@@ -337,9 +363,13 @@ export const computeChatCost = (const currency = pricing.currency || 'USD';const usdToCnyRate = options?.usdToCnyRate ?? USD_TO_CNY;const pricingUnitNames = new Set(pricing.units.map((unit) => unit.name));+ const hasDedicatedAudioCacheReadUnit = pricingUnitNames.has('audioInput_cacheRead');+ const hasDedicatedImageCacheReadUnit = pricingUnitNames.has('imageInput_cacheRead');const resolverContext: UnitQuantityResolverContext = {+ hasDedicatedAudioCacheReadUnit,+ hasDedicatedImageCacheReadUnit,hasDedicatedModalityCacheReadUnit:- pricingUnitNames.has('audioInput_cacheRead') || pricingUnitNames.has('imageInput_cacheRead'),+ hasDedicatedAudioCacheReadUnit || hasDedicatedImageCacheReadUnit,};for (const unit of pricing.units) {