API
Generate images from your own code or AI agents: the GPTImagesPrompt.com REST API and MCP server for GPT Image 2 and GPT Image 2.5, billed in credits.
最近更新: 2026-11-25
Access
API access comes with the plans that list API Access on /pricing. Keys are made in Settings → API Keys; pass yours in the Authorization header as a bearer token. A key stops working when your plan no longer includes API access. Treat keys like passwords: anyone holding one can spend your credits.
Authorization: Bearer sk-...
API runs cost the same credits as the generator on the site, follow your plan's resolution limits and the same content rules, and return their credits automatically if a run fails.
Start a job
POST /api/v1/images
| Field | Type | Notes |
|---|---|---|
model or models | string / string[] | gpt-image-2 or gpt-image-2-5; both at once in models on Folio and up |
prompt | string | required, up to 3,000 characters |
references | string[] | up to 8 public https:// image URLs, for edits and photo templates |
resolution | 1K | 2K | 4K | output size |
aspectRatio | string | e.g. 1:1, 4:5, 16:9, 9:16 |
curl https://gptimagesprompt.com/api/v1/images \
-H "Authorization: Bearer $GIP_API_KEY" \
-H "Content-Type: application/json" \
-d '{"model":"gpt-image-2-5","prompt":"A one-page cafe menu, title \"Morning Ink\" at the top, three sections: Coffee, Pastries, Sandwiches","resolution":"2K","aspectRatio":"4:5"}'
The response (201) is { "data": [ { "id", "model", "status", "credits", ... } ] }, with one job per model.
Poll a job
GET /api/v1/images/{id} returns { "data": { "status", "outputs": [url], "error" } }. status is pending, processing, success or failed. Poll every few seconds until the status is success or failed.
Models
gpt-image-2 (GPT Image 2) and gpt-image-2-5 (GPT Image 2.5), image models by OpenAI. Credits per resolution for each are listed on /pricing.
Errors
A failed call returns { "error": { "message" } } and one of these statuses: 400 invalid body or a plan limit, 401 unknown key, 402 balance too low, 403 no API access on the plan, 429 rate limited.
MCP server for AI agents (Claude, ChatGPT, Cursor)
GPTImagesPrompt.com also runs a remote Model Context Protocol server, so AI assistants can make images with your account. No API key is needed and any plan can use it. Sign in, approve the assistant once, and its images draw on your usual balance under your plan's limits.
Server URL: https://gptimagesprompt.com/mcp
- Claude: open Settings → Connectors, choose Add custom connector and paste the server URL.
- ChatGPT: turn on Developer mode under Settings → Apps, choose Create app and paste the server URL.
- Claude Code:
claude mcp add --transport http gptimagesprompt-com https://gptimagesprompt.com/mcp - Cursor / VS Code / others: add a remote (Streamable HTTP) server with the URL above.
| Tool | What it does |
|---|---|
generate_image | Text-to-image or reference edit (max 8 references); replies with image links |
get_generation | Checks on a run that had not finished and returns its links when done |
list_image_models | GPT Image 2 and 2.5 with per-size credit costs, ratios and your plan's limits |
list_my_images | Your recent images |
get_credit_balance | Credits left and plan limits |
Transport is Streamable HTTP, answering in JSON. Spec versions: 2026-07-28 (stateless, with server/discover), plus the older initialize handshake up to 2025-11-25. Hosts that render MCP Apps get a result card.
Step-by-step setup for each app: MCP server guide.
Authorization uses OAuth 2.1 with S256 PKCE. Each app is approved on a consent screen naming the app and its redirect target. A client either presents a Client ID Metadata Document (its client_id is an https URL) or registers dynamically. Tokens are bound to this site's /mcp as the resource (RFC 8707), every redirect carries iss (RFC 9207), refresh tokens rotate, and /api/auth/mcp/revoke revokes them (RFC 7009). A 401 challenge points clients to the metadata:
/.well-known/oauth-protected-resource(RFC 9728)/.well-known/oauth-authorization-server(RFC 8414)/mcp/server-card(MCP Server Card)/.well-known/ai-catalog.jsonand/.well-known/api-catalog(RFC 9727)
To disconnect an assistant, use Settings → Connected apps. Its access stops immediately.