|
| 1 | +# Gemini 2.5 Flash Image Edit |
| 2 | + |
| 3 | +{% hint style="info" %} |
| 4 | +This documentation is valid for the following list of our models: |
| 5 | + |
| 6 | +* `google/gemini-2.5-flash-image-edit` |
| 7 | +{% endhint %} |
| 8 | + |
| 9 | +## Model Overview |
| 10 | + |
| 11 | +The model takes multiple images as input, with the prompt defining how they are used or combined. |
| 12 | + |
| 13 | +## Setup your API Key |
| 14 | + |
| 15 | +If you don’t have an API key for the AI/ML API yet, feel free to use our [Quickstart guide](https://docs.aimlapi.com/quickstart/setting-up). |
| 16 | + |
| 17 | +## API Schema |
| 18 | + |
| 19 | +{% openapi-operation spec="gemini-2-5-flash-image-edit" path="/v1/images/generations" method="post" %} |
| 20 | +[OpenAPI gemini-2-5-flash-image-edit](https://raw.githubusercontent.com/aimlapi/api-docs/refs/heads/main/docs/api-references/image-models/Google/gemini-2.5-flash-image-edit.json) |
| 21 | +{% endopenapi-operation %} |
| 22 | + |
| 23 | +## Quick Example |
| 24 | + |
| 25 | +Let's generate an image of the specified size using a simple prompt. |
| 26 | + |
| 27 | +{% tabs %} |
| 28 | +{% tab title="Python" %} |
| 29 | +{% code overflow="wrap" %} |
| 30 | +```python |
| 31 | +import requests |
| 32 | +import json |
| 33 | + |
| 34 | + |
| 35 | +def main(): |
| 36 | + response = requests.post( |
| 37 | + "https://api.aimlapi.com/v1/images/generations", |
| 38 | + headers={ |
| 39 | + # Insert your AIML API Key instead of <YOUR_AIMLAPI_KEY>: |
| 40 | + "Authorization": "Bearer <YOUR_AIMLAPI_KEY>", |
| 41 | + "Content-Type": "application/json", |
| 42 | + }, |
| 43 | + json={ |
| 44 | + "model": "google/gemini-2.5-flash-image-edit", |
| 45 | + "image_urls": [ |
| 46 | + "https://raw.githubusercontent.com/aimlapi/api-docs/main/reference-files/t-rex.png", |
| 47 | + "https://raw.githubusercontent.com/aimlapi/api-docs/main/reference-files/blue-mug.jpg" |
| 48 | + ], |
| 49 | + "prompt": "Combine the images so the T-Rex is wearing a business suit, sitting in a cozy small café, drinking from the mug. Blur the background slightly to create a bokeh effect.", |
| 50 | + } |
| 51 | + ) |
| 52 | + |
| 53 | + data = response.json() |
| 54 | + print(json.dumps(data, indent=2, ensure_ascii=False)) |
| 55 | + |
| 56 | + |
| 57 | +if __name__ == "__main__": |
| 58 | + main() |
| 59 | +``` |
| 60 | +{% endcode %} |
| 61 | +{% endtab %} |
| 62 | + |
| 63 | +{% tab title="JS" %} |
| 64 | +{% code overflow="wrap" %} |
| 65 | +```javascript |
| 66 | +async function main() { |
| 67 | + try { |
| 68 | + const response = await fetch('https://api.aimlapi.com/v1/images/generations', { |
| 69 | + method: 'POST', |
| 70 | + headers: { |
| 71 | + // Insert your AIML API Key instead of <YOUR_AIMLAPI_KEY>: |
| 72 | + 'Authorization': 'Bearer <YOUR_AIMLAPI_KEY>', |
| 73 | + 'Content-Type': 'application/json', |
| 74 | + }, |
| 75 | + body: JSON.stringify({ |
| 76 | + model: 'google/gemini-2.5-flash-image-edit', |
| 77 | + image: 'https://raw.githubusercontent.com/aimlapi/api-docs/main/reference-files/t-rex.png', |
| 78 | + prompt: 'Add a bird to the foreground of the photo.', |
| 79 | + }), |
| 80 | + }); |
| 81 | +} |
| 82 | + |
| 83 | +main(); |
| 84 | +``` |
| 85 | +{% endcode %} |
| 86 | +{% endtab %} |
| 87 | +{% endtabs %} |
| 88 | +
|
| 89 | +<details> |
| 90 | +
|
| 91 | +<summary>Response</summary> |
| 92 | +
|
| 93 | +{% code overflow="wrap" %} |
| 94 | +```json5 |
| 95 | +{ |
| 96 | + "images": [ |
| 97 | + { |
| 98 | + "url": "https://cdn.aimlapi.com/eagle/files/panda/9g3PokYLjWoygTVrRgfvG_output.png", |
| 99 | + "content_type": "image/png", |
| 100 | + "file_name": "output.png", |
| 101 | + "file_size": 2273159, |
| 102 | + "width": null, |
| 103 | + "height": null |
| 104 | + } |
| 105 | + ], |
| 106 | + "description": "Here is your T-Rex in a business suit, enjoying a drink in a cozy cafe! " |
| 107 | +} |
| 108 | +``` |
| 109 | +{% endcode %} |
| 110 | +
|
| 111 | +</details> |
| 112 | +
|
| 113 | +<table data-full-width="false"><thead><tr><th width="339.6666259765625" valign="top">Reference Images</th><th valign="top">Generated Image</th></tr></thead><tbody><tr><td valign="top"><div><figure><img src="../../../.gitbook/assets/flux-dev-t-rex.png" alt=""><figcaption><p>Image #1</p></figcaption></figure></div></td><td valign="top"><div><figure><img src="../../../.gitbook/assets/gemini_2.5_flash_image_edit_output.png" alt=""><figcaption><p><kbd><code>"Combine the images so the T-Rex is wearing a business suit, sitting in a cozy small café, drinking from the mug. Blur the background slightly to create a bokeh effect."</code></kbd></p></figcaption></figure></div></td></tr><tr><td valign="top"><div><figure><img src="../../../.gitbook/assets/blue-mug (1).jpg" alt=""><figcaption><p>Image #2</p></figcaption></figure></div></td><td valign="top"></td></tr></tbody></table> |
0 commit comments