GPTImage
Image generation for Claude Code via ChatGPT subscription token. No API key needed.
README
<div align="center">
<img src="assets/mascot.png" width="220" alt="GPTImage mascot" />
GPTImage
Image generation for Claude Code — powered by GPT Image 2, through your ChatGPT subscription.
No API key. No per-image bill. You sign in with your ChatGPT account once, and Claude Code can generate & edit images in any project.
</div>
⚠️ Grey area, by design. "Sign in with ChatGPT" is officially meant for Codex. GPTImage reuses that token to reach GPT Image 2 (ChatGPT Images 2.0). It works and is widely done, but it is not an officially sanctioned API. Keep usage personal/local. Heavy use can trigger plan rate-limits (429) or, worst case, account restrictions. You accept that risk by using this.
What you get
- A local MCP server Claude Code talks to (
generate_image,image_auth_status). - A Claude Code skill (
/gptimage) that teaches the agent when and how to use it. - A CLI for login and one-shot generation.
- No API key. No password ever handled by the tool — you log in yourself in the browser.
Requirements
- Node.js ≥ 20 (tested on v22)
- A ChatGPT account with an active plan (Plus / Pro / etc.)
Install — one flow
git clone https://github.com/Connected-Mate/gptimage.git
cd gptimage
npm install
./install.sh
./install.sh registers the tool globally with Claude Code, then opens your
browser to sign in with ChatGPT. When you see the success screen, you're done.
Because the tool is registered at the user level, it works in every Claude Code project on your machine — you only set it up once. (Restart Claude Code if it was already open, so it picks up the new tool.)
Check it any time:
npm run status # show plan, account, token expiry
npm run logout # remove stored credentials
npm run login # sign in again
Use it in Claude Code
Open Claude Code in any project and just ask:
Generate a watercolor red fox in snow and save it to fox.png using the gptimage tool.
Claude Code calls generate_image and saves the PNG.
Or from the terminal
npm run gen -- --prompt "a red fox in snow, watercolor" --out fox.png --size 1024x1024
npm run gen -- -p "apply Image 1's style to Image 2" -o out.png --ref style.png --ref subject.png
How it works
your prompt
│
▼
generate_image (MCP tool)
│ reads your ChatGPT token from ~/.gptimage/auth.json (or ~/.codex/auth.json)
│ refreshes via auth.openai.com/oauth/token if expired
▼
POST https://chatgpt.com/backend-api/codex/responses
model: gpt-5.5, tools:[{ type: image_generation }] ← GPT Image 2
headers: Authorization: Bearer <subscription token>, chatgpt-account-id
▼
SSE stream → "image_generation_call" → base64 PNG
▼
saved to disk (auto-versioned, never overwrites)
| File | Role |
|---|---|
src/auth.js |
OAuth token storage, refresh, account-id extraction, Codex fallback |
src/login.js |
Interactive PKCE login + --status / --logout |
src/codex.js |
The responses request + SSE image parsing |
src/images.js |
Reference-image encoding + safe PNG saving |
src/server.js |
MCP server (stdio) |
src/gen.js |
One-shot CLI |
Configuration (env vars)
| Var | Purpose |
|---|---|
GPTIMAGE_MODEL |
Override the subscription model slug (default gpt-5.5) if OpenAI rotates it |
GPTIMAGE_ORIGINATOR |
Client identifier sent to the backend (default codex_cli_rs) |
GPTIMAGE_PROJECT_DIR |
Base dir for relative paths (MCP server) |
GPTIMAGE_ACCESS_TOKEN |
Provide a token directly (CI / escape hatch) |
Roadmap
- [ ]
edit_image— first-class image editing endpoint - [ ]
inpaint_with_mask— pixel-precise zone editing via PNG alpha masks - [ ] Multiple-output / variations in one call
- [ ] Optional OpenAI API-key backend as a fallback when the plan is rate-limited
Credits / prior art
- yuji-hatakeyama/opencode-gpt-imagegen — the OpenCode plugin this mirrors
- numman-ali/opencode-openai-codex-auth — OAuth/PKCE flow reference
- EvanZhouDev/openai-oauth — Codex OAuth proxy reference
Not affiliated with OpenAI. Use at your own risk, in accordance with OpenAI's terms.
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。