🤯 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 2.5 flash image model (#8940)
YuTengjing9832bf758bfc
diff --git a/packages/model-runtime/src/google/index.ts b/packages/model-runtime/src/google/index.tsindex a38e35d29d2..f3499646d54 100644--- a/packages/model-runtime/src/google/index.ts+++ b/packages/model-runtime/src/google/index.ts@@ -34,12 +34,14 @@ const modelsWithModalities = new Set(['gemini-2.0-flash-exp','gemini-2.0-flash-exp-image-generation','gemini-2.0-flash-preview-image-generation',+ 'gemini-2.5-flash-image-preview',]);const modelsDisableInstuction = new Set(['gemini-2.0-flash-exp','gemini-2.0-flash-exp-image-generation','gemini-2.0-flash-preview-image-generation',+ 'gemini-2.5-flash-image-preview','gemma-3-1b-it','gemma-3-4b-it','gemma-3-12b-it',@@ -211,6 +213,7 @@ export class LobeGoogleAI implements LobeRuntimeAI {};const inputStartAt = Date.now();+const geminiStreamResponse = await this.client.models.generateContentStream({config,contents,diff --git a/packages/model-runtime/src/utils/streams/google-ai.ts b/packages/model-runtime/src/utils/streams/google-ai.tsindex 7a7a11c381e..cc5e7a910a2 100644--- a/packages/model-runtime/src/utils/streams/google-ai.ts+++ b/packages/model-runtime/src/utils/streams/google-ai.ts@@ -139,6 +139,31 @@ const transformGoogleGenerativeAIStream = (];}+ // Check for image data before handling finishReason+ if (Array.isArray(candidate.content?.parts) && candidate.content.parts.length > 0) {+ const part = candidate.content.parts[0];++ if (part && part.inlineData && part.inlineData.data && part.inlineData.mimeType) {+ const imageChunk = {+ data: `data:${part.inlineData.mimeType};base64,${part.inlineData.data}`,+ id: context.id,+ type: 'base64_image' as const,+ };++ // If also has finishReason, combine image with finish chunks+ if (candidate.finishReason) {+ const chunks: StreamProtocolChunk[] = [imageChunk];+ if (chunk.usageMetadata) {+ chunks.push(...usageChunks);+ }+ chunks.push({ data: candidate.finishReason, id: context?.id, type: 'stop' });+ return chunks;+ }++ return imageChunk;+ }+ }+if (candidate.finishReason) {if (chunk.usageMetadata) {return [@@ -150,23 +175,10 @@ const transformGoogleGenerativeAIStream = (}if (!!text?.trim()) return { data: text, id: context?.id, type: 'text' };-- // streaming the image- if (Array.isArray(candidate.content?.parts) && candidate.content.parts.length > 0) {- const part = candidate.content.parts[0];-- if (part && part.inlineData && part.inlineData.data && part.inlineData.mimeType) {- return {- data: `data:${part.inlineData.mimeType};base64,${part.inlineData.data}`,- id: context.id,- type: 'base64_image',- };- }- }}return {- data: text,+ data: text || '',id: context?.id,type: 'text',};diff --git a/packages/types/src/aiModel.ts b/packages/types/src/aiModel.tsindex dacc7536bb6..21122236352 100644--- a/packages/types/src/aiModel.ts+++ b/packages/types/src/aiModel.ts@@ -121,7 +121,8 @@ export type PricingUnitName =| 'audioInput_cacheRead' // corresponds to ChatModelPricing.cachedAudioInput// Image-based pricing units- | 'imageGeneration'; // for image generation models+ | 'imageGeneration' // for image generation models+ | 'imageOutput';export type PricingUnitType =| 'millionTokens' // per 1M tokensdiff --git a/src/config/aiModels/google.ts b/src/config/aiModels/google.tsindex 3c93a7c2c5b..11428273605 100644--- a/src/config/aiModels/google.ts+++ b/src/config/aiModels/google.ts@@ -296,6 +296,28 @@ const googleChatModels: AIChatModelCard[] = [},type: 'chat',},+ {+ abilities: {+ imageOutput: true,+ vision: true,+ },+ contextWindowTokens: 32_768 + 32_768,+ description:+ 'Gemini 2.5 Flash Image Preview 是 Google 最新、最快、最高效的原生多模态模型,它允许您通过对话生成和编辑图像。',+ displayName: 'Gemini 2.5 Flash Image Preview',+ enabled: true,+ id: 'gemini-2.5-flash-image-preview',+ maxOutput: 32_768,+ pricing: {+ units: [+ { name: 'textInput', rate: 0.3, strategy: 'fixed', unit: 'millionTokens' },+ { name: 'textOutput', rate: 2.5, strategy: 'fixed', unit: 'millionTokens' },+ { name: 'imageOutput', rate: 3, strategy: 'fixed', unit: 'millionTokens' },+ ],+ },+ releasedAt: '2025-08-27',+ type: 'chat',+ },{abilities: {imageOutput: true,@@ -304,7 +326,6 @@ const googleChatModels: AIChatModelCard[] = [contextWindowTokens: 32_768 + 8192,description: 'Gemini 2.0 Flash 预览模型,支持图像生成',displayName: 'Gemini 2.0 Flash Preview Image Generation',- enabled: true,id: 'gemini-2.0-flash-preview-image-generation',maxOutput: 8192,pricing: {