Skip to content

Commit 77a0099

Browse files
committed
docs: add image generation adapters setup examples at the docs page
AdminForth/1836/https-claude.aicodeartifacte15
1 parent 771a3ac commit 77a0099

1 file changed

Lines changed: 39 additions & 5 deletions

File tree

adminforth/documentation/docs/tutorial/06-Adapters/03-image-generation-adapters.md

Lines changed: 39 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,24 +6,58 @@ description: "Reference page for AdminForth image generation adapters, including
66

77
Used for image-generating AI tools.
88

9-
[ImageGenerationAdapter source class](https://github.com/devforth/adminforth/blob/917d897c866975a4aee29273377f2c07cb6ddf81/adminforth/types/adapters/ImageGenerationAdapter.ts#L32)
10-
119
## OpenAI Image Generation Adapter
1210

1311
```bash
1412
pnpm add @adminforth/image-generation-adapter-openai
1513
```
1614

17-
Uses OpenAI image generation models such as DALL·E, `gpt-image-1`, and `gpt-image-1.5` to generate images from text prompts.
15+
Uses OpenAI image generation model `gpt-image` to generate images from text prompts.
1816

1917
Up to the winter 2026 OpenAI models are one of the most powerful image generation models available, especially GPT-Image-1.5, which is why we started with them.
2018

19+
```ts
20+
import ImageGenerationAdapterOpenAI from '@adminforth/image-generation-adapter-openai';
21+
22+
new ImageGenerationAdapterOpenAI({
23+
openAiApiKey: process.env.OPENAI_API_KEY as string,
24+
model: 'gpt-image-1',
25+
extraParams: {
26+
quality: 'high',
27+
},
28+
}),
29+
```
30+
2131
## Gemini (Nano Banana) Image Generation Adapter
2232

2333
```bash
2434
pnpm add @adminforth/image-generation-adapter-nano-banana
2535
```
2636

27-
Uses the latest `gemini-3.1-flash-image-preview` model for instant image generation with text descriptions.
37+
```ts
38+
import ImageGenerationAdapterNanoBanana from '@adminforth/image-generation-adapter-nano-banana';
39+
40+
new ImageGenerationAdapterNanoBanana({
41+
nanoBananaApiKey: process.env.GEMINI_API_KEY as string,
42+
model: 'gemini-3.1-flash-image-preview',
43+
attachImagesAllowedHosts: ['my-bucket.s3.eu-central-1.amazonaws.com'],
44+
}),
45+
```
46+
47+
### Restricting input image hosts (SSRF protection)
48+
49+
To use input images, the adapter downloads every URL passed in `inputFiles` from your server. If those URLs can be influenced by a user (for example they are built from a record field which the user can edit, or come from `attachFiles` of a plugin), an attacker can point them at internal addresses like `http://169.254.169.254/latest/meta-data/` or `http://localhost:9200/` and use your backend as a proxy to your private network — a classic SSRF.
50+
51+
`attachImagesAllowedHosts` closes this hole: only listed hosts are downloaded, anything else throws before the request is made. Always set it to the storage you actually serve images from:
52+
53+
```ts
54+
new ImageGenerationAdapterNanoBanana({
55+
nanoBananaApiKey: process.env.GEMINI_API_KEY as string,
56+
//diff-add
57+
attachImagesAllowedHosts: ['my-bucket.s3.eu-central-1.amazonaws.com'],
58+
}),
59+
```
60+
61+
Matching is case-insensitive: `example.com` matches that host only, while `.example.com` (or `*.example.com`) matches it and all its subdomains.
2862

29-
This model is the top of the Nano Banana line as of 2026, combining the speed of the Flash series with the improved detail of version 3.1. The adapter lets you integrate the advanced capabilities of previous models into your interface and generate precise visuals even for specific or complex prompts.
63+
> ⚠️ When `attachImagesAllowedHosts` is not set, images are downloaded from **any** host. Leave it unset only if the adapter never receives URLs which depend on user input.

0 commit comments

Comments
 (0)