Image Editing Skill
Edit and generate images using AI models via OpenRouter.
Capabilities
- Image editing: Modify existing images (change colors, rearrange objects, add/remove elements)
- Image generation: Create new images from text descriptions
- Style transfer: Apply artistic styles to photos
Supported Models (via OpenRouter)
| Model | Best For | Cost |
|---|---|---|
google/gemini-2.5-flash-image |
Fast edits, good quality | $0.0003/1K tokens |
google/gemini-3-pro-image-preview |
Complex edits, best quality | $0.002/1K tokens |
openai/gpt-5-image-mini |
General purpose | $0.0025/1K tokens |
API Format
Request (to OpenRouter)
{
"model": "google/gemini-2.5-flash-image",
"messages": [{
"role": "user",
"content": [
{"type": "text", "text": "Move the couch to the left wall and add a plant in the corner"},
{"type": "image_url", "image_url": {"url": "data:image/png;base64,..."}}
]
}]
}
Response (from OpenRouter)
{
"choices": [{
"message": {
"role": "assistant",
"content": "Here's your edited image:",
"images": [{
"type": "image_url",
"image_url": {"url": "data:image/png;base64,..."}
}]
}
}]
}
Implementation Notes
Telegram Integration
- Receiving images: Use
Media.downloadPhototo get image bytes - Encoding: Convert to base64 data URI for OpenRouter
- Sending results: Use Telegram’s
sendPhotoAPI with the base64-decoded bytes
Telegram sendPhoto API
POST /bot{token}/sendPhoto
Content-Type: multipart/form-data
chat_id: <int>
photo: <file bytes>
caption: <optional text>
message_thread_id: <optional, for topics>
Example Prompts for Furniture Rearrangement
Good prompts for interior editing:
- “Move the couch to face the window”
- “Rearrange the furniture so the TV is on the opposite wall”
- “Add a coffee table in front of the sofa”
- “Remove the bookshelf and add a floor lamp”
- “Change the wall color to light blue”
Limitations
- Image editing is generative, not pixel-perfect — results may vary
- Complex rearrangements work better with clear, well-lit photos
- Model may interpret ambiguous instructions creatively
- Large images are resized; originals aren’t preserved
Tool Definition
editImageTool :: Engine.Tool
editImageTool = Engine.Tool
{ Engine.toolName = "edit_image"
, Engine.toolDescription = "Edit or modify an image. Provide the edit instructions and the image will be modified accordingly."
, Engine.toolParameters = ...
, Engine.toolExecute = \params -> do
-- 1. Get image from context (most recent photo in conversation)
-- 2. Call OpenRouter with image + prompt
-- 3. Return edited image
}
Environment Variables
OPENROUTER_API_KEY: Required for OpenRouter API access (already configured for Ava)
See Also
Omni/Agent/Telegram/Media.hs— Image download/upload utilitiesOmni/Agent/Provider.hs— Provider abstraction for API calls