# Generate an image

Send a synchronous image-generation request.

`POST /v1/images/generations`

<a id="authentication"></a>

## Authentication

Use Authorization: Bearer YOUR_API_KEY. The selected model must be enabled for that key’s group. JSON requests use Content-Type: application/json.

<a id="parameters"></a>

## Parameters



| Field | Type | Required | Description |
| --- | --- | --- | --- |
| model | string | Required | Enabled image model, such as image-2. |
| prompt | string | Required | Describe the desired image. |
| n | integer | Optional | Start with 1; check limits for the chosen model. |

<a id="request"></a>

## Request example



```
export OHGROK_API_KEY='YOUR_API_KEY'

curl --fail-with-body --silent --show-error \
  'https://api.ohgrok.com/v1/images/generations' \
  -H "Authorization: Bearer $OHGROK_API_KEY" \
  -H 'Content-Type: application/json' \
  -d '{
    "model": "image-2",
    "prompt": "A blue inflatable puppy on a peach studio set, soft natural shadows",
    "n": 1
  }' \
  -o image-response.json
```

<a id="response"></a>

## Response structure

Inspect data[].url or data[].b64_json according to the format actually returned. Do not assume all models return the same field or file type. Size options and other parameters require model-specific confirmation.

<a id="errors"></a>

## Error handling

Read the HTTP status together with the returned error message. Check your key and group for authentication or model-access failures. Inspect balance and upstream limits for quota/rate errors; retain task IDs on timeouts.

- [Troubleshoot a request](/docs/errors/)

