Skip to content

add gemini image models in .chat#2771

Open
P3il4 wants to merge 4 commits intoHeyPuter:mainfrom
P3il4:gemini-image-chats2
Open

add gemini image models in .chat#2771
P3il4 wants to merge 4 commits intoHeyPuter:mainfrom
P3il4:gemini-image-chats2

Conversation

@P3il4
Copy link
Copy Markdown
Contributor

@P3il4 P3il4 commented Apr 6, 2026

added support for gemini models in .chat that can edit images in a conversation
similar to how openrouter does it (image_config, response formats, etc)
implementation based on gemini image provider
kept the same usage keys as txt2img (gemini:model:output:text/image or input)
testing:

await puter.ai.chat([
    { role: 'user', content: 'Draw a cat' },
], { 
  model: "gemini-3.1-flash-image-preview", 
  stream: false, 
  image_config: { aspect_ratio: '16:9', image_size: '1K' } 
});

for stream: false, image is in result.message.images
for stream: true, in image type event
also works with openai compatible route, matching openrouter format exactly

const apiBase = puter.APIOrigin;
const token = puter.authToken;
const resp = await fetch(`${apiBase}/puterai/openai/v1/chat/completions`, {
    method: 'POST',
    headers: {
        'Content-Type': 'application/json',
        'Authorization': `Bearer ${token}`,
    },
    body: JSON.stringify({
        model: "gemini-3.1-flash-image-preview",
        messages: [{ role: 'user', content: 'Draw a small red dot' }],
        stream: true,
        image_config: { aspect_ratio: '16:9', image_size: '1K' }
    }),
});

there are more examples in docs but those are the main ones
tested with a mock server, would appreciate testing on a real key.

@ProgrammerIn-wonderland
Copy link
Copy Markdown
Collaborator

This is awesome

@P3il4 P3il4 force-pushed the gemini-image-chats2 branch from 6f65ce1 to 484a17b Compare April 9, 2026 14:50
@ProgrammerIn-wonderland
Copy link
Copy Markdown
Collaborator

I see thoughtsignature is fixed now, testing again

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants