imageforge-mcp 0.3.0 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +459 -44
- package/dist/imageInput.d.ts +33 -3
- package/dist/imageInput.js +259 -54
- package/dist/imageInput.js.map +1 -1
- package/dist/index.d.ts +1 -29
- package/dist/index.js +46 -104
- package/dist/index.js.map +1 -1
- package/dist/providers.d.ts +53 -0
- package/dist/providers.js +385 -0
- package/dist/providers.js.map +1 -0
- package/package.json +3 -2
package/README.md
CHANGED
|
@@ -2,26 +2,82 @@
|
|
|
2
2
|
|
|
3
3
|
English | [中文](#中文说明)
|
|
4
4
|
|
|
5
|
-
A lightweight TypeScript MCP server for
|
|
5
|
+
A lightweight TypeScript MCP server for image generation with OpenAI, Zhipu BigModel, and MiniMax, plus OpenAI image editing.
|
|
6
6
|
|
|
7
|
-
-
|
|
8
|
-
-
|
|
7
|
+
- OpenAI text-to-image requests use `POST /v1/images/generations`; Zhipu uses `POST /api/paas/v4/images/generations`; MiniMax uses `POST /v1/image_generation`.
|
|
8
|
+
- OpenAI image editing and reference-image generation use multipart `POST /v1/images/edits`.
|
|
9
9
|
- Generated images are returned as native MCP `image` content blocks and can optionally be saved locally.
|
|
10
10
|
|
|
11
11
|
## Features
|
|
12
12
|
|
|
13
|
-
-
|
|
13
|
+
- OpenAI model: `gpt-image-2`
|
|
14
|
+
- Zhipu models: `glm-image`, `cogview-4-250304`, `cogview-4`, `cogview-3-flash`
|
|
15
|
+
- MiniMax models: `image-01`, `image-01-live`
|
|
14
16
|
- MCP tools: `generate_image` and `edit_image`
|
|
15
17
|
- Text-to-image generation
|
|
16
18
|
- Image generation guided by one or more reference images
|
|
19
|
+
- Zhipu text-to-image generation with optional server-side watermark control
|
|
20
|
+
- MiniMax text-to-image and single-subject reference generation
|
|
17
21
|
- Editing one or more existing images
|
|
18
22
|
- Local absolute paths and HTTP(S) URLs as image inputs
|
|
19
23
|
- PNG, JPEG, and WebP input and output
|
|
20
|
-
- Up to 16 input images, with a 50 MB limit per image
|
|
24
|
+
- Up to 16 input images, with a 50 MB limit per image and a 200 MB combined limit
|
|
21
25
|
- Optional local output path with automatic parent-directory creation
|
|
22
|
-
-
|
|
26
|
+
- URL validation against non-public network targets, with DNS addresses pinned to the actual connection
|
|
27
|
+
- Bounded input loading concurrency
|
|
23
28
|
- stdio transport
|
|
24
29
|
|
|
30
|
+
## Provider capability matrix
|
|
31
|
+
|
|
32
|
+
| Capability | OpenAI | Zhipu | MiniMax |
|
|
33
|
+
| --- | --- | --- | --- |
|
|
34
|
+
| Text-to-image | Yes | Yes | Yes |
|
|
35
|
+
| Reference-image generation | Yes, 1–16 images | No; fails before reading files or sending a request | Yes, exactly one PNG/JPEG subject reference under 10 MB |
|
|
36
|
+
| Image editing | Yes, through `edit_image` | No | No |
|
|
37
|
+
| Models | `gpt-image-2` | `glm-image`, `cogview-4-250304`, `cogview-4`, `cogview-3-flash` | `image-01`, `image-01-live` |
|
|
38
|
+
| Quality values | `auto`, `low`, `medium`, `high` | `glm-image`: `auto`, `hd`; other models: `auto`, `standard`, `hd` | `auto` only |
|
|
39
|
+
| `watermark_enabled` | Ignored without error | Forwarded only when explicitly supplied | Mapped to `aigc_watermark` when explicitly supplied |
|
|
40
|
+
| `output_format` | Sent to the provider | Ignored; actual MIME is authoritative | JPEG only; other values fail before the request |
|
|
41
|
+
| Provider response | Base64 image data | Temporary image URL, downloaded immediately | Base64 image data |
|
|
42
|
+
|
|
43
|
+
## Zhipu BigModel support
|
|
44
|
+
|
|
45
|
+
ImageForge calls the official Zhipu image generation endpoint with Bearer authentication. The supported models and ImageForge behavior are:
|
|
46
|
+
|
|
47
|
+
| Model | ImageForge quality values | Notes |
|
|
48
|
+
| --- | --- | --- |
|
|
49
|
+
| `glm-image` | `auto`, `hd` | Prompt is limited to 1,000 characters before the request is sent |
|
|
50
|
+
| `cogview-4-250304` | `auto`, `standard`, `hd` | Text-to-image only |
|
|
51
|
+
| `cogview-4` | `auto`, `standard`, `hd` | Text-to-image only |
|
|
52
|
+
| `cogview-3-flash` | `auto`, `standard`, `hd` | Text-to-image only |
|
|
53
|
+
|
|
54
|
+
`quality: "auto"` is an ImageForge compatibility value: it omits the `quality` field and lets Zhipu apply the model default. ImageForge validates only the `WIDTHxHEIGHT` shape of `size`; Zhipu remains authoritative for each model's supported dimensions and pixel limits. The MCP-level default remains `1024x1024` for compatibility across providers.
|
|
55
|
+
|
|
56
|
+
Zhipu returns one temporary image URL. ImageForge downloads it immediately and returns native MCP image content after validating the actual PNG, JPEG, or WebP signature. The download always enforces public-address checks, DNS pinning, redirect revalidation, a 30-second timeout, and a 50 MB limit, even when `IMAGEFORGE_SKIP_DNS_SAFETY_CHECKS` is enabled for user-supplied OpenAI input images. Provider credentials are never forwarded to the image URL.
|
|
57
|
+
|
|
58
|
+
`watermark_enabled` follows these rules:
|
|
59
|
+
|
|
60
|
+
- Omitted: ImageForge does not send the field, so the Zhipu account/model default applies.
|
|
61
|
+
- `true`: requests Zhipu's explicit and implicit watermarks.
|
|
62
|
+
- `false`: requests Zhipu to disable watermarks; the account must have the required watermark-removal authorization. ImageForge never removes or edits a watermark locally.
|
|
63
|
+
- OpenAI: the same unified parameter is silently ignored.
|
|
64
|
+
|
|
65
|
+
See the [official Zhipu image generation API](https://docs.bigmodel.cn/api-reference/%E6%A8%A1%E5%9E%8B-api/%E5%9B%BE%E5%83%8F%E7%94%9F%E6%88%90) for current provider-side size, quality, watermark, and account-policy rules.
|
|
66
|
+
|
|
67
|
+
## MiniMax support
|
|
68
|
+
|
|
69
|
+
ImageForge calls `POST /v1/image_generation` with Bearer authentication, requests one Base64 image, and returns the MIME detected from the decoded bytes. It supports `image-01` and `image-01-live`; MiniMax credentials never fall back to OpenAI or Zhipu variables.
|
|
70
|
+
|
|
71
|
+
- `image-01`: `size` becomes explicit `width` and `height`; each must be 512–2048 and divisible by 8, with at least `1024×1024` total pixels.
|
|
72
|
+
- `image-01-live`: `size` is reduced to an exact supported aspect ratio. Unsupported ratios fail before the request.
|
|
73
|
+
- `quality` must be `auto`; the provider has no quality field.
|
|
74
|
+
- Output is JPEG. Omit `output_format` or set it to `jpeg`; `png` and `webp` fail before the request because ImageForge does not transcode images.
|
|
75
|
+
- `reference_images` accepts at most one PNG/JPEG under 10 MB. ImageForge safely loads it and sends a Base64 Data URL as a `character` subject reference.
|
|
76
|
+
- `watermark_enabled` maps to `aigc_watermark` only when explicitly supplied.
|
|
77
|
+
- Paid requests are never retried automatically and are never switched to another provider.
|
|
78
|
+
|
|
79
|
+
See the [official MiniMax image-generation guide](https://platform.minimaxi.com/docs/guides/image-generation) for current provider behavior.
|
|
80
|
+
|
|
25
81
|
## OpenAI-compatible CPA and gateway support
|
|
26
82
|
|
|
27
83
|
ImageForge MCP works with OpenAI and with CPA, relay, or proxy services that implement a compatible OpenAI Images API. This includes deployments based on projects such as **New API**, **CLI Proxy API**, and similar OpenAI-compatible gateways.
|
|
@@ -38,7 +94,7 @@ A gateway that only implements `/v1/images/generations` can be used for text-to-
|
|
|
38
94
|
## Requirements
|
|
39
95
|
|
|
40
96
|
- Node.js 22 or later
|
|
41
|
-
-
|
|
97
|
+
- A credential for the selected provider: OpenAI/gateway, Zhipu, or MiniMax
|
|
42
98
|
|
|
43
99
|
## Install and build
|
|
44
100
|
|
|
@@ -49,25 +105,78 @@ npm run build
|
|
|
49
105
|
|
|
50
106
|
## MCP client configuration
|
|
51
107
|
|
|
52
|
-
Inject credentials through the MCP client environment:
|
|
108
|
+
For production use, start the published npm package with `npx`. No repository clone or local build is required. Inject credentials through the MCP client environment:
|
|
53
109
|
|
|
54
110
|
```json
|
|
55
111
|
{
|
|
56
112
|
"mcpServers": {
|
|
57
113
|
"imageforge": {
|
|
58
|
-
"command": "
|
|
59
|
-
"args": ["
|
|
114
|
+
"command": "npx",
|
|
115
|
+
"args": ["-y", "imageforge-mcp"],
|
|
60
116
|
"env": {
|
|
61
|
-
"OPENAI_BASE_URL": "https://your-openai-compatible-gateway.example/v1",
|
|
62
117
|
"OPENAI_API_KEY": "your-token",
|
|
63
|
-
"OPENAI_IMAGE_MODEL": "gpt-image-2"
|
|
118
|
+
"OPENAI_IMAGE_MODEL": "gpt-image-2",
|
|
119
|
+
"IMAGEFORGE_PROVIDER": "openai",
|
|
120
|
+
"IMAGEFORGE_INPUT_CONCURRENCY": "4"
|
|
64
121
|
}
|
|
65
122
|
}
|
|
66
123
|
}
|
|
67
124
|
}
|
|
68
125
|
```
|
|
69
126
|
|
|
70
|
-
`
|
|
127
|
+
`-y` allows `npx` to download or update the package without an interactive install prompt. Pin a specific version when reproducible deployments are required, for example `"imageforge-mcp@0.5.0"`.
|
|
128
|
+
|
|
129
|
+
For a Zhipu-default MCP server, use an independent credential and provider configuration:
|
|
130
|
+
|
|
131
|
+
```json
|
|
132
|
+
{
|
|
133
|
+
"mcpServers": {
|
|
134
|
+
"imageforge-zhipu": {
|
|
135
|
+
"command": "npx",
|
|
136
|
+
"args": ["-y", "imageforge-mcp@0.5.0"],
|
|
137
|
+
"env": {
|
|
138
|
+
"IMAGEFORGE_PROVIDER": "zhipu",
|
|
139
|
+
"ZHIPU_API_KEY": "your-zhipu-token",
|
|
140
|
+
"ZHIPU_IMAGE_MODEL": "glm-image"
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
`ZHIPU_BASE_URL` is optional and defaults to `https://open.bigmodel.cn/api/paas/v4`. `ZHIPU_IMAGE_MODEL` is optional and defaults to `glm-image`. Zhipu credentials never fall back to OpenAI variables, and OpenAI credentials never fall back to Zhipu variables. A per-call `provider`, `api_key`, `base_url`, or `model` overrides the corresponding environment configuration.
|
|
148
|
+
|
|
149
|
+
For a MiniMax-default server:
|
|
150
|
+
|
|
151
|
+
```json
|
|
152
|
+
{
|
|
153
|
+
"mcpServers": {
|
|
154
|
+
"imageforge-minimax": {
|
|
155
|
+
"command": "npx",
|
|
156
|
+
"args": ["-y", "imageforge-mcp@0.5.0"],
|
|
157
|
+
"env": {
|
|
158
|
+
"IMAGEFORGE_PROVIDER": "minimax",
|
|
159
|
+
"MINIMAX_API_KEY": "your-minimax-token",
|
|
160
|
+
"MINIMAX_IMAGE_MODEL": "image-01"
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
`MINIMAX_BASE_URL` defaults to `https://api.minimaxi.com/v1`; `MINIMAX_IMAGE_MODEL` defaults to `image-01`. MiniMax credentials are isolated from OpenAI and Zhipu credentials.
|
|
168
|
+
|
|
169
|
+
`OPENAI_BASE_URL` is optional. When it is unset, ImageForge MCP uses the official OpenAI endpoint `https://api.openai.com/v1`. Set it only when using New API, CLI Proxy API, or another OpenAI-compatible gateway:
|
|
170
|
+
|
|
171
|
+
```json
|
|
172
|
+
"OPENAI_BASE_URL": "https://your-openai-compatible-gateway.example/v1"
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
The value must point to the gateway's `/v1` root. ImageForge MCP appends `/images/generations` or `/images/edits` as required.
|
|
176
|
+
|
|
177
|
+
`IMAGEFORGE_INPUT_CONCURRENCY` optionally controls how many local or remote input images are loaded at once. It defaults to `4`, must be a positive integer, and is capped at the per-call limit of `16` input images. The combined input size remains capped at 200 MB.
|
|
178
|
+
|
|
179
|
+
DNS safety checks are enabled by default. Set `IMAGEFORGE_SKIP_DNS_SAFETY_CHECKS=true` only when private-network or DNS-proxy image URLs must be supported. This disables non-public address rejection and DNS pinning for every redirect hop, which can expose the MCP process to SSRF. HTTP(S)-only URLs, the credential restriction, redirect limit, size limits, and image signature validation remain enforced. Accepted true values are `true`, `1`, `yes`, and `on`; false values are `false`, `0`, `no`, and `off`.
|
|
71
180
|
|
|
72
181
|
Do not commit real API keys to Git or write them into shared configuration files.
|
|
73
182
|
|
|
@@ -80,7 +189,7 @@ Create a project-scoped `.codex/config.toml` using paths that match your machine
|
|
|
80
189
|
command = "/absolute/path/to/node"
|
|
81
190
|
args = ["/absolute/path/to/ImageForgeMCP/dist/index.js"]
|
|
82
191
|
cwd = "/absolute/path/to/ImageForgeMCP"
|
|
83
|
-
env_vars = ["OPENAI_API_KEY", "OPENAI_BASE_URL", "OPENAI_IMAGE_MODEL"]
|
|
192
|
+
env_vars = ["OPENAI_API_KEY", "OPENAI_BASE_URL", "OPENAI_IMAGE_MODEL", "ZHIPU_API_KEY", "ZHIPU_BASE_URL", "ZHIPU_IMAGE_MODEL", "MINIMAX_API_KEY", "MINIMAX_BASE_URL", "MINIMAX_IMAGE_MODEL", "IMAGEFORGE_PROVIDER", "IMAGEFORGE_INPUT_CONCURRENCY", "IMAGEFORGE_SKIP_DNS_SAFETY_CHECKS"]
|
|
84
193
|
startup_timeout_sec = 10
|
|
85
194
|
tool_timeout_sec = 300
|
|
86
195
|
enabled = true
|
|
@@ -93,11 +202,23 @@ Export the environment variables before starting Codex:
|
|
|
93
202
|
export OPENAI_API_KEY="your-gateway-token"
|
|
94
203
|
export OPENAI_BASE_URL="https://your-openai-compatible-gateway.example/v1"
|
|
95
204
|
export OPENAI_IMAGE_MODEL="gpt-image-2"
|
|
205
|
+
export IMAGEFORGE_INPUT_CONCURRENCY="4"
|
|
96
206
|
|
|
97
207
|
cd /absolute/path/to/ImageForgeMCP
|
|
98
208
|
codex app
|
|
99
209
|
```
|
|
100
210
|
|
|
211
|
+
For a Zhipu-default development process, export the Zhipu variables instead of the OpenAI credential/model variables:
|
|
212
|
+
|
|
213
|
+
```bash
|
|
214
|
+
export IMAGEFORGE_PROVIDER="zhipu"
|
|
215
|
+
export ZHIPU_API_KEY="your-zhipu-token"
|
|
216
|
+
export ZHIPU_IMAGE_MODEL="glm-image"
|
|
217
|
+
# Optional: export ZHIPU_BASE_URL="https://open.bigmodel.cn/api/paas/v4"
|
|
218
|
+
```
|
|
219
|
+
|
|
220
|
+
For MiniMax, export `IMAGEFORGE_PROVIDER=minimax`, `MINIMAX_API_KEY`, and optionally `MINIMAX_IMAGE_MODEL=image-01` or `image-01-live`.
|
|
221
|
+
|
|
101
222
|
Codex loads project-scoped `.codex/config.toml` only for trusted projects. After adding or changing the MCP configuration, restart Codex or open a new task, then use `/mcp verbose` to confirm that `imageforge_dev` exposes:
|
|
102
223
|
|
|
103
224
|
- `generate_image`
|
|
@@ -116,16 +237,87 @@ See the [official Codex MCP documentation](https://developers.openai.com/codex/m
|
|
|
116
237
|
| Parameter | Required | Default | Description |
|
|
117
238
|
| --- | --- | --- | --- |
|
|
118
239
|
| `prompt` | Yes | - | Image description |
|
|
119
|
-
| `model` | No | Environment or `gpt-image-2
|
|
120
|
-
| `base_url` | No |
|
|
121
|
-
| `api_key` | No |
|
|
240
|
+
| `model` | No | Environment or provider default | OpenAI: `gpt-image-2`; Zhipu models above; MiniMax: `image-01`, `image-01-live` |
|
|
241
|
+
| `base_url` | No | Provider environment variable or official default | Per-call provider API base URL override |
|
|
242
|
+
| `api_key` | No | Provider-specific API key | Per-call provider credential override; environment variables are preferred |
|
|
243
|
+
| `provider` | No | `IMAGEFORGE_PROVIDER`, then `openai` | `openai`, `zhipu`, or `minimax` |
|
|
122
244
|
| `size` | No | `1024x1024` | Output size requested from the provider |
|
|
123
|
-
| `quality` | No | `auto` |
|
|
124
|
-
| `output_format` | No | `png` | `png
|
|
245
|
+
| `quality` | No | `auto` | OpenAI and Zhipu values above; MiniMax accepts only `auto` |
|
|
246
|
+
| `output_format` | No | `png`; MiniMax: `jpeg` | OpenAI: `png/jpeg/webp`; Zhipu ignores it; MiniMax accepts only `jpeg` |
|
|
125
247
|
| `output_path` | No | - | Local save path; relative paths resolve from the MCP working directory |
|
|
126
|
-
| `
|
|
248
|
+
| `watermark_enabled` | No | - | Sent to Zhipu or mapped to MiniMax `aigc_watermark` only when explicitly supplied |
|
|
249
|
+
| `reference_images` | No | - | OpenAI: 1–16; MiniMax: one PNG/JPEG under 10 MB; Zhipu rejects it |
|
|
250
|
+
|
|
251
|
+
For OpenAI, calls without `reference_images` use `/images/generations`; reference images use multipart `/images/edits`. MiniMax always uses `/image_generation` and maps its single reference to `subject_reference`.
|
|
252
|
+
|
|
253
|
+
Zhipu supports synchronous text-to-image only. It rejects `reference_images` before reading the referenced files or making a request, does not support `edit_image`, and ignores `output_format`. No Authorization header is sent to the image CDN, and the returned MCP MIME type is based on the downloaded image bytes.
|
|
254
|
+
|
|
255
|
+
Zhipu `glm-image` without an explicit quality or watermark override:
|
|
256
|
+
|
|
257
|
+
```json
|
|
258
|
+
{
|
|
259
|
+
"provider": "zhipu",
|
|
260
|
+
"model": "glm-image",
|
|
261
|
+
"prompt": "A hand-painted lakeside village at sunrise, warm light, no text",
|
|
262
|
+
"size": "1280x1280",
|
|
263
|
+
"quality": "auto"
|
|
264
|
+
}
|
|
265
|
+
```
|
|
266
|
+
|
|
267
|
+
Zhipu `glm-image` requesting no provider watermark:
|
|
268
|
+
|
|
269
|
+
```json
|
|
270
|
+
{
|
|
271
|
+
"provider": "zhipu",
|
|
272
|
+
"model": "glm-image",
|
|
273
|
+
"prompt": "A clean studio product render on a neutral background, no text",
|
|
274
|
+
"size": "1280x1280",
|
|
275
|
+
"quality": "hd",
|
|
276
|
+
"watermark_enabled": false,
|
|
277
|
+
"output_path": "outputs/zhipu-product.png"
|
|
278
|
+
}
|
|
279
|
+
```
|
|
280
|
+
|
|
281
|
+
Faster CogView request using provider-standard quality:
|
|
282
|
+
|
|
283
|
+
```json
|
|
284
|
+
{
|
|
285
|
+
"provider": "zhipu",
|
|
286
|
+
"model": "cogview-4",
|
|
287
|
+
"prompt": "A colorful editorial illustration of a modern city park, no text",
|
|
288
|
+
"size": "1024x1024",
|
|
289
|
+
"quality": "standard"
|
|
290
|
+
}
|
|
291
|
+
```
|
|
292
|
+
|
|
293
|
+
Common Zhipu failures are returned as tool errors with the HTTP status and a provider response excerpt of at most 500 characters. Authentication failures must be fixed rather than retried; HTTP 429 with business code `1113` means the account balance is insufficient, while other 429 codes can indicate rate, model-load, or account-plan limits. ImageForge does not automatically retry paid generation requests. See the [official Zhipu error-code reference](https://docs.bigmodel.cn/cn/faq/api-code) for current business-code meanings.
|
|
294
|
+
|
|
295
|
+
MiniMax text-to-image:
|
|
296
|
+
|
|
297
|
+
```json
|
|
298
|
+
{
|
|
299
|
+
"provider": "minimax",
|
|
300
|
+
"model": "image-01",
|
|
301
|
+
"prompt": "A quiet coastal village at sunrise, cinematic light, no text",
|
|
302
|
+
"size": "1536x1024",
|
|
303
|
+
"output_format": "jpeg",
|
|
304
|
+
"output_path": "outputs/minimax-village.jpeg"
|
|
305
|
+
}
|
|
306
|
+
```
|
|
127
307
|
|
|
128
|
-
|
|
308
|
+
MiniMax single-subject reference generation:
|
|
309
|
+
|
|
310
|
+
```json
|
|
311
|
+
{
|
|
312
|
+
"provider": "minimax",
|
|
313
|
+
"model": "image-01",
|
|
314
|
+
"prompt": "Keep the reference character and place them in a quiet library, natural light",
|
|
315
|
+
"reference_images": ["/absolute/path/to/character.jpg"],
|
|
316
|
+
"output_format": "jpeg"
|
|
317
|
+
}
|
|
318
|
+
```
|
|
319
|
+
|
|
320
|
+
MiniMax requires exactly one `reference_images` entry for this mode. `image-01-live` converts `size` to an exact supported aspect ratio instead of sending custom dimensions.
|
|
129
321
|
|
|
130
322
|
## `edit_image`
|
|
131
323
|
|
|
@@ -136,7 +328,7 @@ Without `reference_images`, the tool uses `/images/generations`. With reference
|
|
|
136
328
|
| `prompt` | Yes | Editing instructions |
|
|
137
329
|
| `input_images` | Yes | 1–16 local absolute paths or HTTP(S) URLs |
|
|
138
330
|
|
|
139
|
-
Local images are read directly. URL images are downloaded and validated before upload.
|
|
331
|
+
Local images are read directly. URL images are downloaded and validated before upload. Every redirect target is revalidated, non-public addresses are rejected, and the validated DNS results are pinned to the actual connection to prevent DNS rebinding between validation and download.
|
|
140
332
|
|
|
141
333
|
Configuration precedence is: tool arguments, environment variables, then built-in defaults.
|
|
142
334
|
|
|
@@ -144,6 +336,22 @@ When `output_path` is supplied, ImageForge MCP returns the native MCP image cont
|
|
|
144
336
|
|
|
145
337
|
Some OpenAI-compatible gateways may return dimensions different from the requested `size`; the actual returned file dimensions are authoritative.
|
|
146
338
|
|
|
339
|
+
## Maintainer release script
|
|
340
|
+
|
|
341
|
+
Run the release workflow from a Git checkout of this repository:
|
|
342
|
+
|
|
343
|
+
```bash
|
|
344
|
+
# Read-only checks; allows a dirty worktree but prints a warning.
|
|
345
|
+
bash script/release.sh
|
|
346
|
+
|
|
347
|
+
# Actual npm publication.
|
|
348
|
+
bash script/release.sh --publish
|
|
349
|
+
```
|
|
350
|
+
|
|
351
|
+
The default check mode verifies version consistency, Git whitespace, TypeScript build, all tests, production dependency audit, the npm file list, npm publication dry-run, npm authentication when available, and whether the current version already exists in the Registry. If the version exists but its Registry shasum differs from the local package, the check fails and requires a version bump.
|
|
352
|
+
|
|
353
|
+
`--publish` additionally requires branch `main`, a clean worktree, local `HEAD` equal to `origin/main`, an authenticated npm account, and an unpublished package version. It publishes with public access and the `latest` tag, then waits for the exact version and `latest` tag to become visible in the Registry and prints the Registry shasum. The script intentionally does not change versions, create commits, push Git branches, create tags, retry a failed publication, or overwrite an existing npm version.
|
|
354
|
+
|
|
147
355
|
## Verification
|
|
148
356
|
|
|
149
357
|
```bash
|
|
@@ -161,26 +369,81 @@ Tests use a local HTTP mock. They do not call a real image API or incur generati
|
|
|
161
369
|
|
|
162
370
|
# 中文说明
|
|
163
371
|
|
|
164
|
-
ImageForge MCP 是一个轻量的 TypeScript MCP
|
|
372
|
+
ImageForge MCP 是一个轻量的 TypeScript MCP 图片生成与编辑服务,支持 OpenAI、智谱 BigModel 和 MiniMax 生图,并保留 OpenAI 图片编辑能力。
|
|
165
373
|
|
|
166
|
-
- 纯文本生图调用 `POST /v1/images/generations`。
|
|
167
|
-
- 图片编辑和参考图生图调用 multipart `POST /v1/images/edits`。
|
|
374
|
+
- OpenAI 纯文本生图调用 `POST /v1/images/generations`;智谱调用 `POST /api/paas/v4/images/generations`;MiniMax 调用 `POST /v1/image_generation`。
|
|
375
|
+
- OpenAI 图片编辑和参考图生图调用 multipart `POST /v1/images/edits`。
|
|
168
376
|
- 生成结果以原生 MCP `image` 内容块返回,也可以同时保存到本地。
|
|
169
377
|
|
|
170
378
|
## 功能
|
|
171
379
|
|
|
172
|
-
- 模型:`gpt-image-2`
|
|
380
|
+
- OpenAI 模型:`gpt-image-2`
|
|
381
|
+
- 智谱模型:`glm-image`、`cogview-4-250304`、`cogview-4`、`cogview-3-flash`
|
|
382
|
+
- MiniMax 模型:`image-01`、`image-01-live`
|
|
173
383
|
- MCP 工具:`generate_image`、`edit_image`
|
|
174
384
|
- 支持纯文本生图
|
|
175
385
|
- 支持一张或多张参考图引导生图
|
|
386
|
+
- 支持 MiniMax 单张主体参考图生图
|
|
176
387
|
- 支持一张或多张图片编辑
|
|
177
388
|
- 输入图片支持本地绝对路径和 HTTP(S) URL
|
|
178
389
|
- 输入与输出支持 PNG、JPEG、WebP
|
|
179
|
-
- 最多 16 张输入图片,每张不超过 50 MB
|
|
390
|
+
- 最多 16 张输入图片,每张不超过 50 MB,单次调用合计不超过 200 MB
|
|
180
391
|
- 支持通过 `output_path` 保存到本地,并自动创建父目录
|
|
181
|
-
- URL
|
|
392
|
+
- URL 安全校验,拒绝非公网地址,并将校验后的 DNS 地址固定到实际连接
|
|
393
|
+
- 输入图片加载并发受控
|
|
182
394
|
- stdio Transport
|
|
183
395
|
|
|
396
|
+
## 供应商能力矩阵
|
|
397
|
+
|
|
398
|
+
| 能力 | OpenAI | 智谱 | MiniMax |
|
|
399
|
+
| --- | --- | --- | --- |
|
|
400
|
+
| 文生图 | 支持 | 支持 | 支持 |
|
|
401
|
+
| 参考图生图 | 支持 1–16 张 | 不支持;读取文件或请求前失败 | 支持单张 PNG/JPEG 主体参考图,小于 10 MB |
|
|
402
|
+
| 图片编辑 | 支持,通过 `edit_image` | 不支持 | 不支持 |
|
|
403
|
+
| 模型 | `gpt-image-2` | `glm-image`、`cogview-4-250304`、`cogview-4`、`cogview-3-flash` | `image-01`、`image-01-live` |
|
|
404
|
+
| quality | `auto`、`low`、`medium`、`high` | `glm-image`:`auto`、`hd`;其他模型:`auto`、`standard`、`hd` | 仅 `auto` |
|
|
405
|
+
| `watermark_enabled` | 静默忽略 | 仅显式传入时转发 | 显式传入时映射为 `aigc_watermark` |
|
|
406
|
+
| `output_format` | 发送给供应商 | 忽略,以真实 MIME 为准 | 仅 JPEG,其他值在请求前失败 |
|
|
407
|
+
| 供应商响应 | Base64 图片数据 | 临时图片 URL,由 ImageForge 立即下载 | Base64 图片数据 |
|
|
408
|
+
|
|
409
|
+
## 智谱 BigModel 支持
|
|
410
|
+
|
|
411
|
+
ImageForge 使用 Bearer 认证调用智谱官方图片生成接口,各模型在当前实现中的规则如下:
|
|
412
|
+
|
|
413
|
+
| 模型 | ImageForge 接受的 quality | 说明 |
|
|
414
|
+
| --- | --- | --- |
|
|
415
|
+
| `glm-image` | `auto`、`hd` | 请求前限制提示词最多 1000 个字符 |
|
|
416
|
+
| `cogview-4-250304` | `auto`、`standard`、`hd` | 仅支持文生图 |
|
|
417
|
+
| `cogview-4` | `auto`、`standard`、`hd` | 仅支持文生图 |
|
|
418
|
+
| `cogview-3-flash` | `auto`、`standard`、`hd` | 仅支持文生图 |
|
|
419
|
+
|
|
420
|
+
`quality: "auto"` 是 ImageForge 的兼容值,表示不向智谱发送 `quality`,由智谱使用对应模型的默认质量。ImageForge 对 `size` 只校验 `宽x高` 格式,具体尺寸、整除要求和像素上限以智谱接口为准;为了保持供应商间兼容,MCP 层默认尺寸仍为 `1024x1024`。
|
|
421
|
+
|
|
422
|
+
智谱返回一张图片的临时 URL,ImageForge 会立即下载,并在验证实际内容为 PNG、JPEG 或 WebP 后返回原生 MCP 图片内容。即使用户为了 OpenAI 输入图设置了 `IMAGEFORGE_SKIP_DNS_SAFETY_CHECKS`,智谱结果图下载仍强制执行公网地址检查、DNS 固定、重定向复核、30 秒超时和 50 MB 限制,且不会把供应商认证信息转发给图片地址。
|
|
423
|
+
|
|
424
|
+
`watermark_enabled` 规则:
|
|
425
|
+
|
|
426
|
+
- 不传:ImageForge 不发送该字段,使用智谱账号或模型默认行为。
|
|
427
|
+
- `true`:请求智谱添加显式水印和隐式数字水印。
|
|
428
|
+
- `false`:请求智谱关闭水印,账号必须具备相应去水印权限;ImageForge 不会在本地擦除或修改水印。
|
|
429
|
+
- OpenAI:统一参数会被静默忽略。
|
|
430
|
+
|
|
431
|
+
智谱服务端当前尺寸、质量、水印和账号政策应以[官方图片生成 API 文档](https://docs.bigmodel.cn/api-reference/%E6%A8%A1%E5%9E%8B-api/%E5%9B%BE%E5%83%8F%E7%94%9F%E6%88%90)为准。
|
|
432
|
+
|
|
433
|
+
## MiniMax 支持
|
|
434
|
+
|
|
435
|
+
ImageForge 使用 Bearer 认证调用 `POST /v1/image_generation`,固定请求一张 Base64 图片,并根据解码后的真实图片内容返回 MIME。支持 `image-01` 和 `image-01-live`,MiniMax 密钥不会回退到 OpenAI 或智谱配置。
|
|
436
|
+
|
|
437
|
+
- `image-01`:将 `size` 转为 `width`、`height`,宽高须在 512–2048、均为 8 的倍数,且总像素不少于 `1024×1024`。
|
|
438
|
+
- `image-01-live`:将 `size` 约分为精确支持的宽高比;不支持的比例在请求前失败。
|
|
439
|
+
- `quality` 仅接受 `auto`。
|
|
440
|
+
- 输出仅支持 JPEG;省略 `output_format` 或传 `jpeg`,传 `png`/`webp` 会在请求前失败,不做本地转码。
|
|
441
|
+
- `reference_images` 最多一张 PNG/JPEG 且小于 10 MB,安全加载后以 `character` 主体 Data URL 发送。
|
|
442
|
+
- `watermark_enabled` 仅显式传入时映射为 `aigc_watermark`。
|
|
443
|
+
- 不自动重试收费请求,也不自动切换供应商。
|
|
444
|
+
|
|
445
|
+
供应商行为以 [MiniMax 官方图片生成指南](https://platform.minimaxi.com/docs/guides/image-generation)为准。
|
|
446
|
+
|
|
184
447
|
## OpenAI 兼容 CPA 与网关
|
|
185
448
|
|
|
186
449
|
ImageForge MCP 不仅支持 OpenAI 官方接口,也支持实现了 OpenAI Images API 兼容协议的 CPA、中转或代理服务,包括基于 **New API**、**CLI Proxy API** 等项目部署的 OpenAI 兼容网关。
|
|
@@ -197,7 +460,7 @@ ImageForge MCP 不仅支持 OpenAI 官方接口,也支持实现了 OpenAI Imag
|
|
|
197
460
|
## 环境要求
|
|
198
461
|
|
|
199
462
|
- Node.js 22 或更高版本
|
|
200
|
-
-
|
|
463
|
+
- 所选供应商对应的 OpenAI/网关、智谱或 MiniMax 密钥
|
|
201
464
|
|
|
202
465
|
## 安装与构建
|
|
203
466
|
|
|
@@ -208,25 +471,78 @@ npm run build
|
|
|
208
471
|
|
|
209
472
|
## MCP 客户端配置
|
|
210
473
|
|
|
211
|
-
|
|
474
|
+
生产环境推荐直接通过 `npx` 启动 npm 官方包,无需克隆仓库或在本地构建。通过 MCP 客户端环境变量注入密钥:
|
|
212
475
|
|
|
213
476
|
```json
|
|
214
477
|
{
|
|
215
478
|
"mcpServers": {
|
|
216
479
|
"imageforge": {
|
|
217
|
-
"command": "
|
|
218
|
-
"args": ["
|
|
480
|
+
"command": "npx",
|
|
481
|
+
"args": ["-y", "imageforge-mcp"],
|
|
219
482
|
"env": {
|
|
220
|
-
"OPENAI_BASE_URL": "https://你的-OpenAI-兼容网关域名/v1",
|
|
221
483
|
"OPENAI_API_KEY": "你的令牌",
|
|
222
|
-
"OPENAI_IMAGE_MODEL": "gpt-image-2"
|
|
484
|
+
"OPENAI_IMAGE_MODEL": "gpt-image-2",
|
|
485
|
+
"IMAGEFORGE_PROVIDER": "openai",
|
|
486
|
+
"IMAGEFORGE_INPUT_CONCURRENCY": "4"
|
|
223
487
|
}
|
|
224
488
|
}
|
|
225
489
|
}
|
|
226
490
|
}
|
|
227
491
|
```
|
|
228
492
|
|
|
229
|
-
`
|
|
493
|
+
`-y` 允许 `npx` 在没有交互式安装提示的情况下下载或更新包。如果部署需要固定版本,可将包名写成 `"imageforge-mcp@0.5.0"`。
|
|
494
|
+
|
|
495
|
+
如果希望 MCP 默认使用智谱,应使用独立的智谱凭据与供应商配置:
|
|
496
|
+
|
|
497
|
+
```json
|
|
498
|
+
{
|
|
499
|
+
"mcpServers": {
|
|
500
|
+
"imageforge-zhipu": {
|
|
501
|
+
"command": "npx",
|
|
502
|
+
"args": ["-y", "imageforge-mcp@0.5.0"],
|
|
503
|
+
"env": {
|
|
504
|
+
"IMAGEFORGE_PROVIDER": "zhipu",
|
|
505
|
+
"ZHIPU_API_KEY": "你的智谱令牌",
|
|
506
|
+
"ZHIPU_IMAGE_MODEL": "glm-image"
|
|
507
|
+
}
|
|
508
|
+
}
|
|
509
|
+
}
|
|
510
|
+
}
|
|
511
|
+
```
|
|
512
|
+
|
|
513
|
+
`ZHIPU_BASE_URL` 可选,默认值为 `https://open.bigmodel.cn/api/paas/v4`;`ZHIPU_IMAGE_MODEL` 可选,默认值为 `glm-image`。智谱与 OpenAI 的环境密钥不会互相回退。单次调用传入的 `provider`、`api_key`、`base_url` 或 `model` 优先于对应环境变量。
|
|
514
|
+
|
|
515
|
+
MiniMax 默认配置示例:
|
|
516
|
+
|
|
517
|
+
```json
|
|
518
|
+
{
|
|
519
|
+
"mcpServers": {
|
|
520
|
+
"imageforge-minimax": {
|
|
521
|
+
"command": "npx",
|
|
522
|
+
"args": ["-y", "imageforge-mcp@0.5.0"],
|
|
523
|
+
"env": {
|
|
524
|
+
"IMAGEFORGE_PROVIDER": "minimax",
|
|
525
|
+
"MINIMAX_API_KEY": "你的-MiniMax-令牌",
|
|
526
|
+
"MINIMAX_IMAGE_MODEL": "image-01"
|
|
527
|
+
}
|
|
528
|
+
}
|
|
529
|
+
}
|
|
530
|
+
}
|
|
531
|
+
```
|
|
532
|
+
|
|
533
|
+
`MINIMAX_BASE_URL` 默认 `https://api.minimaxi.com/v1`,`MINIMAX_IMAGE_MODEL` 默认 `image-01`。MiniMax、OpenAI 与智谱凭据互不回退。
|
|
534
|
+
|
|
535
|
+
`OPENAI_BASE_URL` 是可选配置。不设置时,ImageForge MCP 默认使用 OpenAI 官方接口 `https://api.openai.com/v1`。只有使用 New API、CLI Proxy API 或其他 OpenAI 兼容网关时才需要设置:
|
|
536
|
+
|
|
537
|
+
```json
|
|
538
|
+
"OPENAI_BASE_URL": "https://你的-OpenAI-兼容网关域名/v1"
|
|
539
|
+
```
|
|
540
|
+
|
|
541
|
+
地址应填写到网关的 `/v1` 根路径为止,服务会根据请求追加 `/images/generations` 或 `/images/edits`。
|
|
542
|
+
|
|
543
|
+
`IMAGEFORGE_INPUT_CONCURRENCY` 可选,用于控制同时加载的本地或远程输入图片数量。默认值为 `4`,必须是正整数,并直接受单次最多 `16` 张输入图片的限制。单次调用的输入图片合计大小仍固定限制为 200 MB。
|
|
544
|
+
|
|
545
|
+
DNS 安全检查默认启用。只有确实需要访问私有网络地址或 DNS 代理生成的图片地址时,才应设置 `IMAGEFORGE_SKIP_DNS_SAFETY_CHECKS=true`。启用后,每次重定向都不再执行非公网地址拦截和 DNS 地址固定,可能使 MCP 进程面临 SSRF 风险。HTTP(S) 协议限制、URL 凭据限制、重定向次数、图片大小和图片魔数校验仍然有效。真值支持 `true`、`1`、`yes`、`on`,假值支持 `false`、`0`、`no`、`off`。
|
|
230
546
|
|
|
231
547
|
不要把真实 API Key 写入 Git 或其他共享配置文件。
|
|
232
548
|
|
|
@@ -239,7 +555,7 @@ npm run build
|
|
|
239
555
|
command = "/你的/node/绝对路径"
|
|
240
556
|
args = ["/你的/ImageForgeMCP/绝对路径/dist/index.js"]
|
|
241
557
|
cwd = "/你的/ImageForgeMCP/绝对路径"
|
|
242
|
-
env_vars = ["OPENAI_API_KEY", "OPENAI_BASE_URL", "OPENAI_IMAGE_MODEL"]
|
|
558
|
+
env_vars = ["OPENAI_API_KEY", "OPENAI_BASE_URL", "OPENAI_IMAGE_MODEL", "ZHIPU_API_KEY", "ZHIPU_BASE_URL", "ZHIPU_IMAGE_MODEL", "MINIMAX_API_KEY", "MINIMAX_BASE_URL", "MINIMAX_IMAGE_MODEL", "IMAGEFORGE_PROVIDER", "IMAGEFORGE_INPUT_CONCURRENCY", "IMAGEFORGE_SKIP_DNS_SAFETY_CHECKS"]
|
|
243
559
|
startup_timeout_sec = 10
|
|
244
560
|
tool_timeout_sec = 300
|
|
245
561
|
enabled = true
|
|
@@ -252,11 +568,23 @@ required = false
|
|
|
252
568
|
export OPENAI_API_KEY="你的网关令牌"
|
|
253
569
|
export OPENAI_BASE_URL="https://你的-OpenAI-兼容网关域名/v1"
|
|
254
570
|
export OPENAI_IMAGE_MODEL="gpt-image-2"
|
|
571
|
+
export IMAGEFORGE_INPUT_CONCURRENCY="4"
|
|
255
572
|
|
|
256
573
|
cd /你的/ImageForgeMCP/绝对路径
|
|
257
574
|
codex app
|
|
258
575
|
```
|
|
259
576
|
|
|
577
|
+
如果本地开发进程默认使用智谱,应改为导出智谱配置,不要复用 OpenAI 密钥或模型变量:
|
|
578
|
+
|
|
579
|
+
```bash
|
|
580
|
+
export IMAGEFORGE_PROVIDER="zhipu"
|
|
581
|
+
export ZHIPU_API_KEY="你的智谱令牌"
|
|
582
|
+
export ZHIPU_IMAGE_MODEL="glm-image"
|
|
583
|
+
# 可选:export ZHIPU_BASE_URL="https://open.bigmodel.cn/api/paas/v4"
|
|
584
|
+
```
|
|
585
|
+
|
|
586
|
+
使用 MiniMax 时导出 `IMAGEFORGE_PROVIDER=minimax`、`MINIMAX_API_KEY`,并按需设置 `MINIMAX_IMAGE_MODEL=image-01` 或 `image-01-live`。
|
|
587
|
+
|
|
260
588
|
Codex 只会加载已信任项目中的 `.codex/config.toml`。新增或修改 MCP 配置后,需要重新启动 Codex 或新建任务,再使用 `/mcp verbose` 确认 `imageforge_dev` 提供以下工具:
|
|
261
589
|
|
|
262
590
|
- `generate_image`
|
|
@@ -275,16 +603,87 @@ npm run build
|
|
|
275
603
|
| 参数 | 必填 | 默认值 | 说明 |
|
|
276
604
|
| --- | --- | --- | --- |
|
|
277
605
|
| `prompt` | 是 | - | 图片描述 |
|
|
278
|
-
| `model` | 否 |
|
|
279
|
-
| `base_url` | 否 |
|
|
280
|
-
| `api_key` | 否 |
|
|
606
|
+
| `model` | 否 | 环境变量或供应商默认值 | OpenAI:`gpt-image-2`;智谱模型见上;MiniMax:`image-01`、`image-01-live` |
|
|
607
|
+
| `base_url` | 否 | 供应商环境变量或官方默认值 | 单次调用覆盖对应供应商 API 地址 |
|
|
608
|
+
| `api_key` | 否 | 供应商独立密钥 | 单次调用覆盖对应供应商密钥;推荐使用环境变量 |
|
|
609
|
+
| `provider` | 否 | `IMAGEFORGE_PROVIDER`,再默认 `openai` | `openai`、`zhipu` 或 `minimax` |
|
|
281
610
|
| `size` | 否 | `1024x1024` | 请求提供商输出的图片尺寸 |
|
|
282
|
-
| `quality` | 否 | `auto` | `auto
|
|
283
|
-
| `output_format` | 否 | `png` |
|
|
611
|
+
| `quality` | 否 | `auto` | OpenAI 与智谱取值见上;MiniMax 仅接受 `auto` |
|
|
612
|
+
| `output_format` | 否 | `png`;MiniMax 为 `jpeg` | OpenAI:`png/jpeg/webp`;智谱忽略;MiniMax 仅接受 `jpeg` |
|
|
284
613
|
| `output_path` | 否 | - | 本地保存路径;相对路径按 MCP 工作目录解析 |
|
|
285
|
-
| `
|
|
614
|
+
| `watermark_enabled` | 否 | - | 显式传入时发送给智谱,或映射为 MiniMax `aigc_watermark` |
|
|
615
|
+
| `reference_images` | 否 | - | OpenAI:1–16 张;MiniMax:单张小于 10 MB 的 PNG/JPEG;智谱拒绝 |
|
|
616
|
+
|
|
617
|
+
OpenAI 不传 `reference_images` 时调用 `/images/generations`,传入参考图时调用 multipart `/images/edits`。MiniMax 始终调用 `/image_generation`,并把单张参考图映射为 `subject_reference`。
|
|
618
|
+
|
|
619
|
+
智谱首版仅支持同步文生图,不支持参考图和 `edit_image`。传入 `reference_images` 时会在读取参考文件和发起请求前明确报错;`output_format` 对智谱不生效。下载图片时不携带 Authorization,最终 MCP MIME 类型以实际图片内容为准。
|
|
620
|
+
|
|
621
|
+
智谱 `glm-image`,不覆盖供应商默认质量和水印行为:
|
|
622
|
+
|
|
623
|
+
```json
|
|
624
|
+
{
|
|
625
|
+
"provider": "zhipu",
|
|
626
|
+
"model": "glm-image",
|
|
627
|
+
"prompt": "日出时分的手绘湖畔村庄,暖色光线,无文字",
|
|
628
|
+
"size": "1280x1280",
|
|
629
|
+
"quality": "auto"
|
|
630
|
+
}
|
|
631
|
+
```
|
|
632
|
+
|
|
633
|
+
智谱 `glm-image` 请求关闭供应商水印:
|
|
634
|
+
|
|
635
|
+
```json
|
|
636
|
+
{
|
|
637
|
+
"provider": "zhipu",
|
|
638
|
+
"model": "glm-image",
|
|
639
|
+
"prompt": "中性背景上的干净棚拍产品渲染,无文字",
|
|
640
|
+
"size": "1280x1280",
|
|
641
|
+
"quality": "hd",
|
|
642
|
+
"watermark_enabled": false,
|
|
643
|
+
"output_path": "outputs/zhipu-product.png"
|
|
644
|
+
}
|
|
645
|
+
```
|
|
646
|
+
|
|
647
|
+
CogView 使用供应商标准质量快速生成:
|
|
648
|
+
|
|
649
|
+
```json
|
|
650
|
+
{
|
|
651
|
+
"provider": "zhipu",
|
|
652
|
+
"model": "cogview-4",
|
|
653
|
+
"prompt": "色彩丰富的现代城市公园编辑插画,无文字",
|
|
654
|
+
"size": "1024x1024",
|
|
655
|
+
"quality": "standard"
|
|
656
|
+
}
|
|
657
|
+
```
|
|
658
|
+
|
|
659
|
+
智谱失败会作为 MCP 工具错误返回,包含 HTTP 状态和最多 500 个字符的供应商错误摘要。认证失败必须修正配置而不是重试;HTTP 429 且业务错误码为 `1113` 表示账户欠费,其他 429 错误也可能表示限流、模型繁忙或套餐限制。ImageForge 不会自动重试可能产生费用的生图请求。业务错误码的当前含义以[智谱官方错误码文档](https://docs.bigmodel.cn/cn/faq/api-code)为准。
|
|
660
|
+
|
|
661
|
+
MiniMax 文生图示例:
|
|
662
|
+
|
|
663
|
+
```json
|
|
664
|
+
{
|
|
665
|
+
"provider": "minimax",
|
|
666
|
+
"model": "image-01",
|
|
667
|
+
"prompt": "日出时宁静的海滨村庄,电影光线,无文字",
|
|
668
|
+
"size": "1536x1024",
|
|
669
|
+
"output_format": "jpeg",
|
|
670
|
+
"output_path": "outputs/minimax-village.jpeg"
|
|
671
|
+
}
|
|
672
|
+
```
|
|
286
673
|
|
|
287
|
-
|
|
674
|
+
MiniMax 单主体参考图示例:
|
|
675
|
+
|
|
676
|
+
```json
|
|
677
|
+
{
|
|
678
|
+
"provider": "minimax",
|
|
679
|
+
"model": "image-01",
|
|
680
|
+
"prompt": "保持参考人物特征,将人物置于安静的图书馆,自然光",
|
|
681
|
+
"reference_images": ["/参考人物图片的绝对路径/character.jpg"],
|
|
682
|
+
"output_format": "jpeg"
|
|
683
|
+
}
|
|
684
|
+
```
|
|
685
|
+
|
|
686
|
+
该模式的 `reference_images` 必须恰好一张;`image-01-live` 会把 `size` 转成精确支持的宽高比,而不是发送自定义尺寸。
|
|
288
687
|
|
|
289
688
|
## `edit_image`
|
|
290
689
|
|
|
@@ -295,7 +694,7 @@ npm run build
|
|
|
295
694
|
| `prompt` | 是 | 编辑指令 |
|
|
296
695
|
| `input_images` | 是 | 1–16 张输入图片,支持本地绝对路径或 HTTP(S) URL |
|
|
297
696
|
|
|
298
|
-
本地图片会直接读取;URL
|
|
697
|
+
本地图片会直接读取;URL 图片会经过下载和安全校验后再上传。每次重定向都会重新校验目标地址,非公网地址会被拒绝,同时会将校验后的 DNS 结果固定到实际连接,防止校验与下载之间发生 DNS Rebinding。
|
|
299
698
|
|
|
300
699
|
配置优先级为:工具参数、环境变量、内置默认值。
|
|
301
700
|
|
|
@@ -303,6 +702,22 @@ npm run build
|
|
|
303
702
|
|
|
304
703
|
部分 OpenAI 兼容网关可能不会严格遵循请求中的 `size`,应以实际返回文件的尺寸为准。
|
|
305
704
|
|
|
705
|
+
## 维护者发布脚本
|
|
706
|
+
|
|
707
|
+
发布流程应在本仓库的 Git checkout 中执行:
|
|
708
|
+
|
|
709
|
+
```bash
|
|
710
|
+
# 只读检查;工作区不干净时会警告,但继续检查。
|
|
711
|
+
bash script/release.sh
|
|
712
|
+
|
|
713
|
+
# 实际发布到 npm。
|
|
714
|
+
bash script/release.sh --publish
|
|
715
|
+
```
|
|
716
|
+
|
|
717
|
+
默认检查模式会验证版本一致性、Git 空白、TypeScript 构建、全部测试、生产依赖审计、npm 打包文件列表、npm 发布 dry-run、可用时的 npm 登录状态,以及当前版本是否已经存在于 Registry。如果版本已存在但 Registry shasum 与本地包不一致,检查会失败并要求先升级版本号。
|
|
718
|
+
|
|
719
|
+
`--publish` 还会强制要求当前分支为 `main`、工作区干净、本地 `HEAD` 与 `origin/main` 完全一致、npm 已登录且版本尚未发布;随后以 public access 和 `latest` tag 发布,等待 Registry 可查询到准确版本和 `latest` tag,再输出 Registry shasum。脚本不会修改版本号、创建 Git 提交、推送分支、创建 Tag、自动重试失败发布或覆盖已存在的 npm 版本。
|
|
720
|
+
|
|
306
721
|
## 验证
|
|
307
722
|
|
|
308
723
|
```bash
|