# Generate an image

Use Beacon AI credits to generate and save one image for a post.

This operation requires **Generate with AI** access. The selected provider must support generated images.

## Generate the image

```ts
const image = await beacon.ai.generateImage({
  altText: "A weekly calendar with planned social posts",
  aspectRatio: "1:1",
  confirmed: true,
  prompt: "A clear editorial calendar on a calm studio desk",
  provider: "instagram",
});

console.log(image.mediaId, image.billing.creditCost);
```

Beacon saves a successful result in the workspace Media library.

## Retry rule

Do not retry this request automatically. Generation or storage can start before a network failure reaches your application.

If the result is unclear, show a **Checking** state. Ask the user to inspect Media before another request.
