Image Editing Skill

Edit and generate images using AI models via OpenRouter.

Capabilities

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

  1. Receiving images: Use Media.downloadPhoto to get image bytes
  2. Encoding: Convert to base64 data URI for OpenRouter
  3. Sending results: Use Telegram’s sendPhoto API 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:

Limitations

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

See Also