# Generate an image

> Generate an image from a text prompt. Returns base64 image data with its MIME type.

Source: https://docs.generalinput.com/api/platform/generate-image



<Endpoint method="POST" path="/v1/platform/generate-image" />

<Access scope="platform:use" />

## Body [#body]

| Field         | Type   | Required | Notes                                   |
| ------------- | ------ | -------- | --------------------------------------- |
| `prompt`      | string | yes      | What to draw.                           |
| `aspectRatio` | string | no       | `1:1`, `16:9`, `9:16`, `4:3`, or `3:4`. |

## Response [#response]

```json
{ "imageBase64": "iVBORw0KGgo…", "mimeType": "image/png", "text": "…" }
```

| Field         | Type   | Notes                                     |
| ------------- | ------ | ----------------------------------------- |
| `imageBase64` | string | The image bytes, base64-encoded.          |
| `mimeType`    | string | `image/png`, for instance.                |
| `text`        | string | Optional descriptive text from the model. |

## Example [#example]

```sh
curl -s -X POST https://cloud.generalinput.com/v1/platform/generate-image \
  -H "Authorization: Bearer $GI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"prompt":"a line drawing of a lighthouse","aspectRatio":"1:1"}' \
  | jq -r .imageBase64 | base64 -d > lighthouse.png
```
