# Image

This quickstart walks you through generating your first image with Infron.

### Image generation

{% tabs %}
{% tab title="cURL" %}

<pre class="language-sh"><code class="lang-sh">curl https://image.onerouter.pro/v1/images/generations \
<strong>    -H "Content-Type: application/json" \
</strong>    -H "Authorization: &#x3C;API_KEY>" \
    -d '{
    "model": "openai/gpt-image-1-text-to-image",
    "prompt": "A cute baby sea otter",
    "n": 1,
    "output_format": "url"
  }'
</code></pre>

{% endtab %}

{% tab title="Python" %}

```python
from openai import OpenAI
import base64
import os

client = OpenAI(
    api_key="<API_KEY>", # Replace with your Key "sk-***"
    base_url="https://image.onerouter.pro/v1"
)

prompt = """A cute baby sea otter."""

result = client.images.generate(
    model="openai/gpt-image-1-text-to-image",
    prompt=prompt,
    n=1,
    output_format="url"
)

print(result)
```

{% endtab %}
{% endtabs %}

* `https://image.onerouter.pro/v1/images/generations` is the base URL
* `<API_KEY>` is your API Key generated in [API page](https://app.onerouter.pro/apiKeys).
* `model` is the model name, such as `gpt-image-1`, available model list can be access in [Model page](https://app.onerouter.pro/models).
* `prompt`  is the prompt.
* `n`  is the number of images to generate, default value is `1`.
* `output_format` indicate the output format, default value is `url`.
  * `b64_json`
  * `url`&#x20;

**Example response**

```json
{
    "data": [
        {
            "url": "https://resource.onerouter.pro/image/generated%2Fonerouter_848a9432-b9ee-4e58-9ea4-adf390ab61ac.png",
            "b64_json": "",
            "revised_prompt": ""
        }
    ],
    "created": 1760177063
}
```

### Image **editing**

{% tabs %}
{% tab title="Curl" %}

<pre class="language-sh"><code class="lang-sh">curl https://image.onerouter.pro/v1/images/edits \
<strong>    -H "Content-Type: application/json" \
</strong>    -H "Authorization: &#x3C;API_KEY>" \
    --data-raw '{
    "model": "jia-lab/dreamomni2-image-to-image",
    "prompt": "Replace the first image have the same image style as the second image.",
    "image_urls": [
        "https://resource.trustai.sg/image/generated%2Fonerouter_a146ee8a-1fe2-43ce-803a-fb1e7f3f6949.png",
        "https://resource.onerouter.pro/image/generated%2Fonerouter_fe4771ae-d67c-41bb-a366-b07f1411ae06.png"
    ],
    "n": 1,
    "output_format": "url"
}'
</code></pre>

{% endtab %}
{% endtabs %}

* `https://image.onerouter.pro/v1/images/edits` is the base URL
* `<API_KEY>` is your API Key generated in [API page](https://app.onerouter.pro/apiKeys).
* `model` is the model name, such as `dreamomni2-image-to-image`, available model list can be access in [Model page](https://app.onerouter.pro/models).
* `prompt`  is the prompt.
* `image_urls` is the list of URLs of input images for editing.
* `n`  is the number of images to generate, default value is `1`.
* `output_format` indicate the output format, default value is `url`.
  * `b64_json`
  * `url`&#x20;

**Example response**

```json
{
    "data": [
        {
            "url": "https://resource.trustai.sg/image/generated%2Fonerouter_a146ee8a-1fe2-43ce-803a-fb1e7f3f6949.png",
            "b64_json": "",
            "revised_prompt": ""
        }
    ],
    "created": 1760177063
}

```

### Next steps

{% content-ref url="<https://app.gitbook.com/s/cigiTud9XJSe6mNo26dh/text-to-image-api>" %}
[Text to Image API](https://app.gitbook.com/s/cigiTud9XJSe6mNo26dh/text-to-image-api)
{% endcontent-ref %}
