ChatImg 0.1.0__tar.gz

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.
chatimg-0.1.0/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 ChatArch
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
chatimg-0.1.0/PKG-INFO ADDED
@@ -0,0 +1,171 @@
1
+ Metadata-Version: 2.4
2
+ Name: ChatImg
3
+ Version: 0.1.0
4
+ Summary: ChatImg image generation package
5
+ Author-email: ChatArch <1073853456@qq.com>
6
+ License-Expression: MIT
7
+ Project-URL: Homepage, https://github.com/ChatArch/ChatImg
8
+ Project-URL: Repository, https://github.com/ChatArch/ChatImg
9
+ Project-URL: Documentation, https://ChatArch.github.io/ChatImg
10
+ Keywords: chatimg,chatarch,cli
11
+ Classifier: Programming Language :: Python :: 3
12
+ Classifier: Operating System :: OS Independent
13
+ Requires-Python: >=3.10
14
+ Description-Content-Type: text/markdown
15
+ License-File: LICENSE
16
+ Requires-Dist: click>=8.0
17
+ Requires-Dist: chatstyle<0.2.0,>=0.1.0
18
+ Requires-Dist: chatenv<0.3.0,>=0.2.0
19
+ Requires-Dist: requests<3.0,>=2.20
20
+ Requires-Dist: httpx<1.0,>=0.24
21
+ Provides-Extra: dev
22
+ Requires-Dist: build; extra == "dev"
23
+ Requires-Dist: pytest; extra == "dev"
24
+ Requires-Dist: twine; extra == "dev"
25
+ Provides-Extra: images
26
+ Requires-Dist: dashscope<2.0,>=1.0; extra == "images"
27
+ Provides-Extra: docs
28
+ Requires-Dist: mkdocs>=1.4.0; extra == "docs"
29
+ Requires-Dist: mkdocs-material>=9.0.0; extra == "docs"
30
+ Requires-Dist: mike>=2.0.0; extra == "docs"
31
+ Dynamic: license-file
32
+
33
+ <div align="center">
34
+ <a href="https://pypi.python.org/pypi/ChatImg">
35
+ <img src="https://img.shields.io/pypi/v/ChatImg.svg" alt="PyPI version" />
36
+ </a>
37
+ <a href="https://github.com/ChatArch/ChatImg/actions/workflows/ci.yml">
38
+ <img src="https://github.com/ChatArch/ChatImg/actions/workflows/ci.yml/badge.svg" alt="Tests" />
39
+ </a>
40
+ <a href="https://ChatArch.github.io/ChatImg">
41
+ <img src="https://img.shields.io/badge/docs-mkdocs-blue.svg" alt="Documentation" />
42
+ </a>
43
+ </div>
44
+
45
+ <div align="center">
46
+
47
+ [English](README.en.md) | [简体中文](README.md)
48
+ </div>
49
+
50
+ # ChatImg
51
+
52
+ ChatImg 是 ChatArch 的图片生成包,承接原 `chattool image` 中已经解耦的 provider 实现。
53
+
54
+ 当前支持:
55
+
56
+ - `codex` / `openai-codex`:ChatGPT/Codex OAuth image bridge,支持 `gpt-image-2-*` preset。
57
+ - `pollinations`:Pollinations.ai image URL generation and model listing。
58
+ - `siliconflow`:SiliconFlow OpenAI-compatible image generation。
59
+ - `huggingface`:Hugging Face Inference image generation。
60
+ - `liblib`:LiblibAI signed API generation。
61
+ - `tongyi`:通义万相 / DashScope image generation。
62
+
63
+ ## 安装
64
+
65
+ 开发安装:
66
+
67
+ ```bash
68
+ pip install -e ".[dev]"
69
+ ```
70
+
71
+ 通义万相 SDK 可选依赖:
72
+
73
+ ```bash
74
+ pip install -e ".[images]"
75
+ ```
76
+
77
+ ## CLI
78
+
79
+ ```bash
80
+ chatimg --help
81
+ chatimg --version
82
+ chatimg codex list-models
83
+ chatimg pollinations list-models
84
+ ```
85
+
86
+ 生成示例:
87
+
88
+ ```bash
89
+ chatimg codex generate "a watercolor fox in the snow" --aspect-ratio square -o fox.png
90
+ chatimg pollinations generate "a cyberpunk cat" --model flux --width 512 --height 512 -o cat.png
91
+ chatimg siliconflow generate "a cute dog" --size 1024x1024 -o dog.png
92
+ chatimg huggingface generate "A futuristic city at night" -o city.png
93
+ chatimg liblib generate "A cute dog" --model-id liblib-sdxl-model -o dog.png
94
+ chatimg tongyi generate "一只赛博朋克猫" --size "1024*1024" -o cat.png
95
+ ```
96
+
97
+ ### Codex / GPT Image2 实测示例
98
+
99
+ `codex` provider 走 ChatGPT/Codex OAuth-backed Responses API,请求里的 image tool model 是 `gpt-image-2`。它不是外部 Codex CLI。
100
+
101
+ 常用配置字段:
102
+
103
+ - `OPENAI_CODEX_ACCESS_TOKEN`:历史 Codex image access token 变量;也兼容 `OPENAI_ACCESS_TOKEN`。
104
+ - `OPENAI_CODEX_AUTH_JSON`:Hermes auth.json 路径;默认 `~/.hermes/auth.json`,用于复用本机 `openai-codex` 登录态。
105
+ - `OPENAI_CODEX_HOST_MODEL`:承载 `image_generation` tool 的 host model,默认 `gpt-5.4`。
106
+ - `OPENAI_CODEX_BASE_URL`:Codex backend base URL,默认 `https://chatgpt.com/backend-api/codex`。
107
+ - `OPENAI_CODEX_TIMEOUT`:请求超时秒数,默认 `300`。
108
+ - `OPENAI_IMAGE_MODEL`:默认 image preset,默认 `gpt-image-2-medium`。
109
+ - `OPENAI_IMAGE_ASPECT_RATIO`:默认图片比例,默认 `square`。
110
+
111
+ 基础验收图:
112
+
113
+ ```bash
114
+ chatimg codex generate \
115
+ "A clean minimal ChatImg acceptance test illustration: a friendly robot holding a small picture frame, modern flat design, white background, no text" \
116
+ --image-model gpt-image-2-low \
117
+ --aspect-ratio square \
118
+ -o generated/chatimg-gpt-image2-basic.png \
119
+ --timeout 300
120
+ ```
121
+
122
+ 快速排序流程图:
123
+
124
+ ```bash
125
+ chatimg codex generate \
126
+ "Create a clean landscape technical design flowchart explaining quicksort. Use this exact example array: [6, 3, 8, 5, 1, 10, 2]. Pick pivot = 5. Partition correctly: left part [3, 1, 2] labeled < pivot, right part [6, 8, 10] labeled > pivot. Include steps: START, base case length <= 1?, pick pivot, partition array, recursively sort left part, recursively sort right part, concatenate sorted-left + pivot + sorted-right, END. Modern vector style, white background, blue/orange accents, arrows, decision diamond, readable simple English labels. Avoid mathematical mistakes." \
127
+ --image-model gpt-image-2-medium \
128
+ --aspect-ratio landscape \
129
+ -o generated/chatimg-gpt-image2-quicksort-flowchart.png \
130
+ --timeout 300
131
+ ```
132
+
133
+ ## Python API
134
+
135
+ ```python
136
+ from chatimg.image import create_generator
137
+
138
+ generator = create_generator("codex")
139
+ result = generator.generate("A cute cat astronaut")
140
+ ```
141
+
142
+ ## 配置
143
+
144
+ ChatImg 注册了 `chatenv.configs` entry point:
145
+
146
+ ```toml
147
+ chatimg = "chatimg.config"
148
+ ```
149
+
150
+ 支持的主要环境变量:
151
+
152
+ - `OPENAI_ACCESS_TOKEN`, `OPENAI_CODEX_ACCESS_TOKEN`, `OPENAI_CODEX_AUTH_JSON`, `OPENAI_REFRESH_TOKEN`, `OPENAI_OAUTH_BASE_URL`, `OPENAI_ACCESS_TOKEN_EXPIRES_AT`, `OPENAI_IMAGE_MODEL`, `OPENAI_IMAGE_ASPECT_RATIO`, `OPENAI_CODEX_HOST_MODEL`, `OPENAI_CODEX_BASE_URL`, `OPENAI_CODEX_TIMEOUT`
153
+ - `POLLINATIONS_API_KEY`, `POLLINATIONS_MODEL_ID`
154
+ - `SILICONFLOW_API_KEY`, `SILICONFLOW_MODEL_ID`
155
+ - `HUGGINGFACE_HUB_TOKEN`
156
+ - `LIBLIB_ACCESS_KEY`, `LIBLIB_SECRET_KEY`, `LIBLIB_MODEL_ID`
157
+ - `DASHSCOPE_API_KEY`
158
+
159
+ ## 开发验证
160
+
161
+ ```bash
162
+ PYTHONPATH=src python -m pytest -q
163
+ PYTHONPATH=src python -m chatimg.cli --help
164
+ PYTHONPATH=src python -m chatimg.cli codex list-models
165
+ python -m build
166
+ python -m twine check dist/*
167
+ ```
168
+
169
+ ## 发布状态
170
+
171
+ PyPI `chatimg==0.0.1` 是占位版本;`0.1.0` 源码已准备为首个功能版本,但 tag / PyPI 正式发布需单独确认。
@@ -0,0 +1,139 @@
1
+ <div align="center">
2
+ <a href="https://pypi.python.org/pypi/ChatImg">
3
+ <img src="https://img.shields.io/pypi/v/ChatImg.svg" alt="PyPI version" />
4
+ </a>
5
+ <a href="https://github.com/ChatArch/ChatImg/actions/workflows/ci.yml">
6
+ <img src="https://github.com/ChatArch/ChatImg/actions/workflows/ci.yml/badge.svg" alt="Tests" />
7
+ </a>
8
+ <a href="https://ChatArch.github.io/ChatImg">
9
+ <img src="https://img.shields.io/badge/docs-mkdocs-blue.svg" alt="Documentation" />
10
+ </a>
11
+ </div>
12
+
13
+ <div align="center">
14
+
15
+ [English](README.en.md) | [简体中文](README.md)
16
+ </div>
17
+
18
+ # ChatImg
19
+
20
+ ChatImg 是 ChatArch 的图片生成包,承接原 `chattool image` 中已经解耦的 provider 实现。
21
+
22
+ 当前支持:
23
+
24
+ - `codex` / `openai-codex`:ChatGPT/Codex OAuth image bridge,支持 `gpt-image-2-*` preset。
25
+ - `pollinations`:Pollinations.ai image URL generation and model listing。
26
+ - `siliconflow`:SiliconFlow OpenAI-compatible image generation。
27
+ - `huggingface`:Hugging Face Inference image generation。
28
+ - `liblib`:LiblibAI signed API generation。
29
+ - `tongyi`:通义万相 / DashScope image generation。
30
+
31
+ ## 安装
32
+
33
+ 开发安装:
34
+
35
+ ```bash
36
+ pip install -e ".[dev]"
37
+ ```
38
+
39
+ 通义万相 SDK 可选依赖:
40
+
41
+ ```bash
42
+ pip install -e ".[images]"
43
+ ```
44
+
45
+ ## CLI
46
+
47
+ ```bash
48
+ chatimg --help
49
+ chatimg --version
50
+ chatimg codex list-models
51
+ chatimg pollinations list-models
52
+ ```
53
+
54
+ 生成示例:
55
+
56
+ ```bash
57
+ chatimg codex generate "a watercolor fox in the snow" --aspect-ratio square -o fox.png
58
+ chatimg pollinations generate "a cyberpunk cat" --model flux --width 512 --height 512 -o cat.png
59
+ chatimg siliconflow generate "a cute dog" --size 1024x1024 -o dog.png
60
+ chatimg huggingface generate "A futuristic city at night" -o city.png
61
+ chatimg liblib generate "A cute dog" --model-id liblib-sdxl-model -o dog.png
62
+ chatimg tongyi generate "一只赛博朋克猫" --size "1024*1024" -o cat.png
63
+ ```
64
+
65
+ ### Codex / GPT Image2 实测示例
66
+
67
+ `codex` provider 走 ChatGPT/Codex OAuth-backed Responses API,请求里的 image tool model 是 `gpt-image-2`。它不是外部 Codex CLI。
68
+
69
+ 常用配置字段:
70
+
71
+ - `OPENAI_CODEX_ACCESS_TOKEN`:历史 Codex image access token 变量;也兼容 `OPENAI_ACCESS_TOKEN`。
72
+ - `OPENAI_CODEX_AUTH_JSON`:Hermes auth.json 路径;默认 `~/.hermes/auth.json`,用于复用本机 `openai-codex` 登录态。
73
+ - `OPENAI_CODEX_HOST_MODEL`:承载 `image_generation` tool 的 host model,默认 `gpt-5.4`。
74
+ - `OPENAI_CODEX_BASE_URL`:Codex backend base URL,默认 `https://chatgpt.com/backend-api/codex`。
75
+ - `OPENAI_CODEX_TIMEOUT`:请求超时秒数,默认 `300`。
76
+ - `OPENAI_IMAGE_MODEL`:默认 image preset,默认 `gpt-image-2-medium`。
77
+ - `OPENAI_IMAGE_ASPECT_RATIO`:默认图片比例,默认 `square`。
78
+
79
+ 基础验收图:
80
+
81
+ ```bash
82
+ chatimg codex generate \
83
+ "A clean minimal ChatImg acceptance test illustration: a friendly robot holding a small picture frame, modern flat design, white background, no text" \
84
+ --image-model gpt-image-2-low \
85
+ --aspect-ratio square \
86
+ -o generated/chatimg-gpt-image2-basic.png \
87
+ --timeout 300
88
+ ```
89
+
90
+ 快速排序流程图:
91
+
92
+ ```bash
93
+ chatimg codex generate \
94
+ "Create a clean landscape technical design flowchart explaining quicksort. Use this exact example array: [6, 3, 8, 5, 1, 10, 2]. Pick pivot = 5. Partition correctly: left part [3, 1, 2] labeled < pivot, right part [6, 8, 10] labeled > pivot. Include steps: START, base case length <= 1?, pick pivot, partition array, recursively sort left part, recursively sort right part, concatenate sorted-left + pivot + sorted-right, END. Modern vector style, white background, blue/orange accents, arrows, decision diamond, readable simple English labels. Avoid mathematical mistakes." \
95
+ --image-model gpt-image-2-medium \
96
+ --aspect-ratio landscape \
97
+ -o generated/chatimg-gpt-image2-quicksort-flowchart.png \
98
+ --timeout 300
99
+ ```
100
+
101
+ ## Python API
102
+
103
+ ```python
104
+ from chatimg.image import create_generator
105
+
106
+ generator = create_generator("codex")
107
+ result = generator.generate("A cute cat astronaut")
108
+ ```
109
+
110
+ ## 配置
111
+
112
+ ChatImg 注册了 `chatenv.configs` entry point:
113
+
114
+ ```toml
115
+ chatimg = "chatimg.config"
116
+ ```
117
+
118
+ 支持的主要环境变量:
119
+
120
+ - `OPENAI_ACCESS_TOKEN`, `OPENAI_CODEX_ACCESS_TOKEN`, `OPENAI_CODEX_AUTH_JSON`, `OPENAI_REFRESH_TOKEN`, `OPENAI_OAUTH_BASE_URL`, `OPENAI_ACCESS_TOKEN_EXPIRES_AT`, `OPENAI_IMAGE_MODEL`, `OPENAI_IMAGE_ASPECT_RATIO`, `OPENAI_CODEX_HOST_MODEL`, `OPENAI_CODEX_BASE_URL`, `OPENAI_CODEX_TIMEOUT`
121
+ - `POLLINATIONS_API_KEY`, `POLLINATIONS_MODEL_ID`
122
+ - `SILICONFLOW_API_KEY`, `SILICONFLOW_MODEL_ID`
123
+ - `HUGGINGFACE_HUB_TOKEN`
124
+ - `LIBLIB_ACCESS_KEY`, `LIBLIB_SECRET_KEY`, `LIBLIB_MODEL_ID`
125
+ - `DASHSCOPE_API_KEY`
126
+
127
+ ## 开发验证
128
+
129
+ ```bash
130
+ PYTHONPATH=src python -m pytest -q
131
+ PYTHONPATH=src python -m chatimg.cli --help
132
+ PYTHONPATH=src python -m chatimg.cli codex list-models
133
+ python -m build
134
+ python -m twine check dist/*
135
+ ```
136
+
137
+ ## 发布状态
138
+
139
+ PyPI `chatimg==0.0.1` 是占位版本;`0.1.0` 源码已准备为首个功能版本,但 tag / PyPI 正式发布需单独确认。
@@ -0,0 +1,43 @@
1
+ [build-system]
2
+ requires = ["setuptools>=61.0", "wheel"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "ChatImg"
7
+ dynamic = ["version"]
8
+ description = "ChatImg image generation package"
9
+ readme = "README.md"
10
+ requires-python = ">=3.10"
11
+ license = "MIT"
12
+ dependencies = ["click>=8.0", "chatstyle>=0.1.0,<0.2.0", "chatenv>=0.2.0,<0.3.0", "requests>=2.20,<3.0", "httpx>=0.24,<1.0"]
13
+ authors = [{name = "ChatArch", email = "1073853456@qq.com"}]
14
+ keywords = ["chatimg", "chatarch", "cli"]
15
+ classifiers = [
16
+ "Programming Language :: Python :: 3",
17
+ "Operating System :: OS Independent",
18
+ ]
19
+
20
+ [project.urls]
21
+ Homepage = "https://github.com/ChatArch/ChatImg"
22
+ Repository = "https://github.com/ChatArch/ChatImg"
23
+ Documentation = "https://ChatArch.github.io/ChatImg"
24
+
25
+ [project.scripts]
26
+ chatimg = "chatimg.cli:main"
27
+
28
+ [project.entry-points."chatenv.configs"]
29
+ chatimg = "chatimg.config"
30
+
31
+ [project.optional-dependencies]
32
+ dev = ["build", "pytest", "twine"]
33
+ images = ["dashscope>=1.0,<2.0"]
34
+ docs = ["mkdocs>=1.4.0", "mkdocs-material>=9.0.0", "mike>=2.0.0"]
35
+
36
+ [tool.setuptools.dynamic]
37
+ version = {attr = "chatimg.__version__"}
38
+
39
+ [tool.setuptools.packages.find]
40
+ where = ["src"]
41
+
42
+ [tool.setuptools]
43
+ include-package-data = true
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,171 @@
1
+ Metadata-Version: 2.4
2
+ Name: ChatImg
3
+ Version: 0.1.0
4
+ Summary: ChatImg image generation package
5
+ Author-email: ChatArch <1073853456@qq.com>
6
+ License-Expression: MIT
7
+ Project-URL: Homepage, https://github.com/ChatArch/ChatImg
8
+ Project-URL: Repository, https://github.com/ChatArch/ChatImg
9
+ Project-URL: Documentation, https://ChatArch.github.io/ChatImg
10
+ Keywords: chatimg,chatarch,cli
11
+ Classifier: Programming Language :: Python :: 3
12
+ Classifier: Operating System :: OS Independent
13
+ Requires-Python: >=3.10
14
+ Description-Content-Type: text/markdown
15
+ License-File: LICENSE
16
+ Requires-Dist: click>=8.0
17
+ Requires-Dist: chatstyle<0.2.0,>=0.1.0
18
+ Requires-Dist: chatenv<0.3.0,>=0.2.0
19
+ Requires-Dist: requests<3.0,>=2.20
20
+ Requires-Dist: httpx<1.0,>=0.24
21
+ Provides-Extra: dev
22
+ Requires-Dist: build; extra == "dev"
23
+ Requires-Dist: pytest; extra == "dev"
24
+ Requires-Dist: twine; extra == "dev"
25
+ Provides-Extra: images
26
+ Requires-Dist: dashscope<2.0,>=1.0; extra == "images"
27
+ Provides-Extra: docs
28
+ Requires-Dist: mkdocs>=1.4.0; extra == "docs"
29
+ Requires-Dist: mkdocs-material>=9.0.0; extra == "docs"
30
+ Requires-Dist: mike>=2.0.0; extra == "docs"
31
+ Dynamic: license-file
32
+
33
+ <div align="center">
34
+ <a href="https://pypi.python.org/pypi/ChatImg">
35
+ <img src="https://img.shields.io/pypi/v/ChatImg.svg" alt="PyPI version" />
36
+ </a>
37
+ <a href="https://github.com/ChatArch/ChatImg/actions/workflows/ci.yml">
38
+ <img src="https://github.com/ChatArch/ChatImg/actions/workflows/ci.yml/badge.svg" alt="Tests" />
39
+ </a>
40
+ <a href="https://ChatArch.github.io/ChatImg">
41
+ <img src="https://img.shields.io/badge/docs-mkdocs-blue.svg" alt="Documentation" />
42
+ </a>
43
+ </div>
44
+
45
+ <div align="center">
46
+
47
+ [English](README.en.md) | [简体中文](README.md)
48
+ </div>
49
+
50
+ # ChatImg
51
+
52
+ ChatImg 是 ChatArch 的图片生成包,承接原 `chattool image` 中已经解耦的 provider 实现。
53
+
54
+ 当前支持:
55
+
56
+ - `codex` / `openai-codex`:ChatGPT/Codex OAuth image bridge,支持 `gpt-image-2-*` preset。
57
+ - `pollinations`:Pollinations.ai image URL generation and model listing。
58
+ - `siliconflow`:SiliconFlow OpenAI-compatible image generation。
59
+ - `huggingface`:Hugging Face Inference image generation。
60
+ - `liblib`:LiblibAI signed API generation。
61
+ - `tongyi`:通义万相 / DashScope image generation。
62
+
63
+ ## 安装
64
+
65
+ 开发安装:
66
+
67
+ ```bash
68
+ pip install -e ".[dev]"
69
+ ```
70
+
71
+ 通义万相 SDK 可选依赖:
72
+
73
+ ```bash
74
+ pip install -e ".[images]"
75
+ ```
76
+
77
+ ## CLI
78
+
79
+ ```bash
80
+ chatimg --help
81
+ chatimg --version
82
+ chatimg codex list-models
83
+ chatimg pollinations list-models
84
+ ```
85
+
86
+ 生成示例:
87
+
88
+ ```bash
89
+ chatimg codex generate "a watercolor fox in the snow" --aspect-ratio square -o fox.png
90
+ chatimg pollinations generate "a cyberpunk cat" --model flux --width 512 --height 512 -o cat.png
91
+ chatimg siliconflow generate "a cute dog" --size 1024x1024 -o dog.png
92
+ chatimg huggingface generate "A futuristic city at night" -o city.png
93
+ chatimg liblib generate "A cute dog" --model-id liblib-sdxl-model -o dog.png
94
+ chatimg tongyi generate "一只赛博朋克猫" --size "1024*1024" -o cat.png
95
+ ```
96
+
97
+ ### Codex / GPT Image2 实测示例
98
+
99
+ `codex` provider 走 ChatGPT/Codex OAuth-backed Responses API,请求里的 image tool model 是 `gpt-image-2`。它不是外部 Codex CLI。
100
+
101
+ 常用配置字段:
102
+
103
+ - `OPENAI_CODEX_ACCESS_TOKEN`:历史 Codex image access token 变量;也兼容 `OPENAI_ACCESS_TOKEN`。
104
+ - `OPENAI_CODEX_AUTH_JSON`:Hermes auth.json 路径;默认 `~/.hermes/auth.json`,用于复用本机 `openai-codex` 登录态。
105
+ - `OPENAI_CODEX_HOST_MODEL`:承载 `image_generation` tool 的 host model,默认 `gpt-5.4`。
106
+ - `OPENAI_CODEX_BASE_URL`:Codex backend base URL,默认 `https://chatgpt.com/backend-api/codex`。
107
+ - `OPENAI_CODEX_TIMEOUT`:请求超时秒数,默认 `300`。
108
+ - `OPENAI_IMAGE_MODEL`:默认 image preset,默认 `gpt-image-2-medium`。
109
+ - `OPENAI_IMAGE_ASPECT_RATIO`:默认图片比例,默认 `square`。
110
+
111
+ 基础验收图:
112
+
113
+ ```bash
114
+ chatimg codex generate \
115
+ "A clean minimal ChatImg acceptance test illustration: a friendly robot holding a small picture frame, modern flat design, white background, no text" \
116
+ --image-model gpt-image-2-low \
117
+ --aspect-ratio square \
118
+ -o generated/chatimg-gpt-image2-basic.png \
119
+ --timeout 300
120
+ ```
121
+
122
+ 快速排序流程图:
123
+
124
+ ```bash
125
+ chatimg codex generate \
126
+ "Create a clean landscape technical design flowchart explaining quicksort. Use this exact example array: [6, 3, 8, 5, 1, 10, 2]. Pick pivot = 5. Partition correctly: left part [3, 1, 2] labeled < pivot, right part [6, 8, 10] labeled > pivot. Include steps: START, base case length <= 1?, pick pivot, partition array, recursively sort left part, recursively sort right part, concatenate sorted-left + pivot + sorted-right, END. Modern vector style, white background, blue/orange accents, arrows, decision diamond, readable simple English labels. Avoid mathematical mistakes." \
127
+ --image-model gpt-image-2-medium \
128
+ --aspect-ratio landscape \
129
+ -o generated/chatimg-gpt-image2-quicksort-flowchart.png \
130
+ --timeout 300
131
+ ```
132
+
133
+ ## Python API
134
+
135
+ ```python
136
+ from chatimg.image import create_generator
137
+
138
+ generator = create_generator("codex")
139
+ result = generator.generate("A cute cat astronaut")
140
+ ```
141
+
142
+ ## 配置
143
+
144
+ ChatImg 注册了 `chatenv.configs` entry point:
145
+
146
+ ```toml
147
+ chatimg = "chatimg.config"
148
+ ```
149
+
150
+ 支持的主要环境变量:
151
+
152
+ - `OPENAI_ACCESS_TOKEN`, `OPENAI_CODEX_ACCESS_TOKEN`, `OPENAI_CODEX_AUTH_JSON`, `OPENAI_REFRESH_TOKEN`, `OPENAI_OAUTH_BASE_URL`, `OPENAI_ACCESS_TOKEN_EXPIRES_AT`, `OPENAI_IMAGE_MODEL`, `OPENAI_IMAGE_ASPECT_RATIO`, `OPENAI_CODEX_HOST_MODEL`, `OPENAI_CODEX_BASE_URL`, `OPENAI_CODEX_TIMEOUT`
153
+ - `POLLINATIONS_API_KEY`, `POLLINATIONS_MODEL_ID`
154
+ - `SILICONFLOW_API_KEY`, `SILICONFLOW_MODEL_ID`
155
+ - `HUGGINGFACE_HUB_TOKEN`
156
+ - `LIBLIB_ACCESS_KEY`, `LIBLIB_SECRET_KEY`, `LIBLIB_MODEL_ID`
157
+ - `DASHSCOPE_API_KEY`
158
+
159
+ ## 开发验证
160
+
161
+ ```bash
162
+ PYTHONPATH=src python -m pytest -q
163
+ PYTHONPATH=src python -m chatimg.cli --help
164
+ PYTHONPATH=src python -m chatimg.cli codex list-models
165
+ python -m build
166
+ python -m twine check dist/*
167
+ ```
168
+
169
+ ## 发布状态
170
+
171
+ PyPI `chatimg==0.0.1` 是占位版本;`0.1.0` 源码已准备为首个功能版本,但 tag / PyPI 正式发布需单独确认。
@@ -0,0 +1,26 @@
1
+ LICENSE
2
+ README.md
3
+ pyproject.toml
4
+ src/ChatImg.egg-info/PKG-INFO
5
+ src/ChatImg.egg-info/SOURCES.txt
6
+ src/ChatImg.egg-info/dependency_links.txt
7
+ src/ChatImg.egg-info/entry_points.txt
8
+ src/ChatImg.egg-info/requires.txt
9
+ src/ChatImg.egg-info/top_level.txt
10
+ src/chatimg/__init__.py
11
+ src/chatimg/cli.py
12
+ src/chatimg/config.py
13
+ src/chatimg/openai_oauth.py
14
+ src/chatimg/image/__init__.py
15
+ src/chatimg/image/base.py
16
+ src/chatimg/image/cli.py
17
+ src/chatimg/image/codex.py
18
+ src/chatimg/image/helpers.py
19
+ src/chatimg/image/huggingface.py
20
+ src/chatimg/image/liblib.py
21
+ src/chatimg/image/pollinations.py
22
+ src/chatimg/image/siliconflow.py
23
+ src/chatimg/image/tongyi.py
24
+ tests/test_cli.py
25
+ tests/test_image_migration.py
26
+ tests/test_version.py
@@ -0,0 +1,5 @@
1
+ [chatenv.configs]
2
+ chatimg = chatimg.config
3
+
4
+ [console_scripts]
5
+ chatimg = chatimg.cli:main
@@ -0,0 +1,18 @@
1
+ click>=8.0
2
+ chatstyle<0.2.0,>=0.1.0
3
+ chatenv<0.3.0,>=0.2.0
4
+ requests<3.0,>=2.20
5
+ httpx<1.0,>=0.24
6
+
7
+ [dev]
8
+ build
9
+ pytest
10
+ twine
11
+
12
+ [docs]
13
+ mkdocs>=1.4.0
14
+ mkdocs-material>=9.0.0
15
+ mike>=2.0.0
16
+
17
+ [images]
18
+ dashscope<2.0,>=1.0
@@ -0,0 +1 @@
1
+ chatimg
@@ -0,0 +1,5 @@
1
+ """ChatImg package."""
2
+
3
+ __all__ = ["__version__"]
4
+
5
+ __version__ = "0.1.0"
@@ -0,0 +1,9 @@
1
+ """CLI entrypoint for ChatImg."""
2
+
3
+ from chatimg.image.cli import main
4
+
5
+ __all__ = ["main"]
6
+
7
+
8
+ if __name__ == "__main__":
9
+ main()