Skip to content

About

OpenCode plugin for AI image generation via Google Gemini API

Resources

Stars

1 star

Watchers

0 watching

Forks

Latest commit

 

History

1 Commit

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 

Repository files navigation

opencode-plugin-image-gen

OpenCode plugin for AI image generation via Google Gemini API. Registers a generate_image tool and /imagine command that inject generated images as FilePart into the message stream.

Install

Copy image-gen.ts to your OpenCode plugins directory:

cp image-gen.ts ~/.config/opencode/plugins/

Create the config file with your API key:

mkdir -p ~/.config/opencode/plugin-data
cp image-gen.example.json ~/.config/opencode/plugin-data/image-gen.json
# Edit the file and replace YOUR_GEMINI_API_KEY_HERE with your actual key

Or use an environment variable instead:

export GEMINI_API_KEY="your-key-here"

Restart OpenCode to load the plugin.

Usage

AI tool — ask the AI to generate an image, it will call generate_image automatically:

"Generate a cyberpunk cityscape at night"

Slash command — type directly in the input:

/imagine a cat wearing a space helmet, digital art style

Config

~/.config/opencode/plugin-data/image-gen.json

Field Description Default
apiKey Gemini API key (or use GEMINI_API_KEY / GOOGLE_API_KEY env) ""
model gemini-2.5-flash-image, gemini-3.1-flash-image-preview, gemini-3-pro-image-preview, or any imagen-* model gemini-2.5-flash-image
aspectRatio 1:1, 16:9, 9:16, 4:3, 3:4, 2:3, 3:2, 4:5, 5:4, 21:9 1:1
imageSize 1K, 2K, 4K (4K only on pro model) 2K
outputDir Where to save images (empty = default plugin-data dir) ""
baseUrl API base URL https://generativelanguage.googleapis.com

Supported Models

Model Type Quality
gemini-2.5-flash-image Gemini native Fast, good quality
gemini-3.1-flash-image-preview Gemini native Fast, latest
gemini-3-pro-image-preview Gemini native Studio quality, 4K
imagen-4.0-generate-001 Imagen (predict) High quality
imagen-4.0-fast-generate-001 Imagen (predict) Fast

License

MIT

About

OpenCode plugin for AI image generation via Google Gemini API

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages