ChatImg image generation package
Project description
ChatImg
ChatImg 是 ChatArch 的图片生成包,承接原 chattool image 中已经解耦的 provider 实现。
当前支持:
openai/crs:OpenAI-compatible Images API,走OPENAI_API_KEY,请求/v1/images/generations。codex/openai-codex:ChatGPT/Codex OAuth image bridge,走CODEX_ACCESS_TOKEN,支持gpt-image-2-*preset。pollinations:Pollinations.ai image URL generation and model listing。siliconflow:SiliconFlow OpenAI-compatible image generation。huggingface:Hugging Face Inference image generation。liblib:LiblibAI signed API generation。tongyi:通义万相 / DashScope image generation。
安装
开发安装:
pip install -e ".[dev]"
通义万相 SDK 可选依赖:
pip install -e ".[images]"
CLI
chatimg --help
chatimg --version
chatimg openai generate "a small red apple icon" -o apple.png
chatimg codex list-models
chatimg pollinations list-models
生成示例:
chatimg openai generate "a watercolor fox in the snow" --model gpt-image-2-medium --size 1024x1024 -o fox.png
chatimg codex generate "a watercolor fox in the snow" --aspect-ratio square -o fox-codex.png
chatimg pollinations generate "a cyberpunk cat" --model flux --width 512 --height 512 -o cat.png
chatimg siliconflow generate "a cute dog" --size 1024x1024 -o dog.png
chatimg huggingface generate "A futuristic city at night" -o city.png
chatimg liblib generate "A cute dog" --model-id liblib-sdxl-model -o dog.png
chatimg tongyi generate "一只赛博朋克猫" --size "1024*1024" -o cat.png
OpenAI-compatible / CRS Images API
openai provider 对齐 OpenAI 官方 Images API:POST {OPENAI_API_BASE}/images/generations。官方 base 是 https://api.openai.com/v1,因此完整官方接口是 https://api.openai.com/v1/images/generations。CRS 兼容服务可用自己的带 /v1 base,例如 https://crs.example/openai/v1。
常用配置字段:
OPENAI_API_BASE:OpenAI-compatible API base,必须包含/v1。OPENAI_API_KEY:API key;不会 fallback 到 access token。OPENAI_IMAGE_MODEL:默认 image preset,例如gpt-image-2-medium,会拆成model=gpt-image-2与quality=medium。
chatenv use -t oai apple
chatimg openai generate "a small red apple icon" -o apple.png
Codex / GPT Image2 实测示例
codex provider 走 ChatGPT/Codex OAuth-backed Responses API,请求里的 image tool model 是 gpt-image-2。它不是外部 Codex CLI。
常用配置字段:
CODEX_ACCESS_TOKEN:Codex OAuth access token。CODEX_REFRESH_TOKEN:Codex OAuth refresh token,用于刷新 access token。CODEX_ACCESS_TOKEN_EXPIRES_AT:access token 的 UTC ISO 过期时间。CODEX_OAUTH_BASE_URL:Codex OAuth auth server base URL,默认https://auth.openai.com。CODEX_API_BASE:Codex backend base URL,默认https://chatgpt.com/backend-api/codex。CODEX_HOST_MODEL:承载image_generationtool 的 host model,默认gpt-5.4。CODEX_IMAGE_MODEL:默认 image preset,默认gpt-image-2-medium。
codex provider 不再读取 ~/.hermes/auth.json,也不再维护 OPENAI_CODEX_* 变量。--timeout 和 --aspect-ratio 是命令级参数,不写入长期 env。
基础验收图:
chatimg codex generate \
"A clean minimal ChatImg acceptance test illustration: a friendly robot holding a small picture frame, modern flat design, white background, no text" \
--image-model gpt-image-2-low \
--aspect-ratio square \
-o generated/chatimg-gpt-image2-basic.png \
--timeout 300
快速排序流程图:
chatimg codex generate \
"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." \
--image-model gpt-image-2-medium \
--aspect-ratio landscape \
-o generated/chatimg-gpt-image2-quicksort-flowchart.png \
--timeout 300
Python API
from chatimg.image import create_generator
generator = create_generator("codex")
result = generator.generate("A cute cat astronaut")
配置
ChatImg 注册了 chatenv.configs entry point:
chatimg = "chatimg.config"
支持的主要环境变量:
OPENAI_API_BASE,OPENAI_API_KEY,OPENAI_IMAGE_MODELCODEX_ACCESS_TOKEN,CODEX_REFRESH_TOKEN,CODEX_ACCESS_TOKEN_EXPIRES_AT,CODEX_OAUTH_BASE_URL,CODEX_API_BASE,CODEX_HOST_MODEL,CODEX_IMAGE_MODELPOLLINATIONS_API_KEY,POLLINATIONS_MODEL_IDSILICONFLOW_API_KEY,SILICONFLOW_MODEL_IDHUGGINGFACE_HUB_TOKENLIBLIB_ACCESS_KEY,LIBLIB_SECRET_KEY,LIBLIB_MODEL_IDDASHSCOPE_API_KEY
开发验证
PYTHONPATH=src python -m pytest -q
PYTHONPATH=src python -m chatimg.cli --help
PYTHONPATH=src python -m chatimg.cli codex list-models
python -m build
python -m twine check dist/*
发布状态
PyPI ChatImg 从 0.1.x 开始发布功能版本;0.1.2 是 Codex 配置边界清理 patch 版本。
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file chatimg-0.1.2.tar.gz.
File metadata
- Download URL: chatimg-0.1.2.tar.gz
- Upload date:
- Size: 23.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0e31ac162c336fe1aa04df4abed0b350087752ac8730f3b88536ecc195d1a01d
|
|
| MD5 |
c72c384a397d417aa0c0f9838dbd7a73
|
|
| BLAKE2b-256 |
8deb776a980e00b4b6e3c8be5f517c0a49b9ebe8fba6b199c84219b7eca7f4cd
|
Provenance
The following attestation bundles were made for chatimg-0.1.2.tar.gz:
Publisher:
publish.yml on ChatArch/ChatImg
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
chatimg-0.1.2.tar.gz -
Subject digest:
0e31ac162c336fe1aa04df4abed0b350087752ac8730f3b88536ecc195d1a01d - Sigstore transparency entry: 2088417594
- Sigstore integration time:
-
Permalink:
ChatArch/ChatImg@18df556b4cf87cac0e9987432c9b5ac1d632408a -
Branch / Tag:
refs/tags/v0.1.2 - Owner: https://github.com/ChatArch
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@18df556b4cf87cac0e9987432c9b5ac1d632408a -
Trigger Event:
push
-
Statement type:
File details
Details for the file chatimg-0.1.2-py3-none-any.whl.
File metadata
- Download URL: chatimg-0.1.2-py3-none-any.whl
- Upload date:
- Size: 26.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5cd686dd6523a3328cef40483cb47c7ace968e0885fadecfdccd2414c84ae535
|
|
| MD5 |
bdaa17f2fb244fd6a7bd69846a26cb21
|
|
| BLAKE2b-256 |
0e12114a7d3c8971dd3ce4a00ee17435d345b5859b8f08c9b882bffcbcd9bf9a
|
Provenance
The following attestation bundles were made for chatimg-0.1.2-py3-none-any.whl:
Publisher:
publish.yml on ChatArch/ChatImg
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
chatimg-0.1.2-py3-none-any.whl -
Subject digest:
5cd686dd6523a3328cef40483cb47c7ace968e0885fadecfdccd2414c84ae535 - Sigstore transparency entry: 2088417767
- Sigstore integration time:
-
Permalink:
ChatArch/ChatImg@18df556b4cf87cac0e9987432c9b5ac1d632408a -
Branch / Tag:
refs/tags/v0.1.2 - Owner: https://github.com/ChatArch
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@18df556b4cf87cac0e9987432c9b5ac1d632408a -
Trigger Event:
push
-
Statement type: