Generate images from Python through Codex's Responses API bridge.
Project description
codex-image-gen
Python helpers for generating images through codex responses.
This package uses the Codex CLI as the transport. It sends a raw Responses API
JSON payload to codex responses, which means authentication is handled by your
existing Codex login rather than by an OPENAI_API_KEY.
Install
uv add codex-image-gen
For local development:
uv sync --dev
Usage
from pathlib import Path
from codex_image_gen import generate_image
result = generate_image(
"Draw a small lighthouse on a cliff at sunrise",
size="1024x1024",
quality="medium",
)
image = result.images[0]
Path("lighthouse.png").write_bytes(image.data)
Reference images can be passed as local paths, http(s) URLs, data: URLs, or
file IDs. Mapping inputs also support the Responses input_image.detail field:
result = generate_image(
"Edit the reference image into a watercolor postcard",
images=["reference.png", {"file_id": "file_123", "detail": "high"}],
action="edit",
)
All Responses image generation tool options are exposed:
result = generate_image(
"Edit the logo area and keep the product shape",
images=["product.png"],
input_image_mask="mask.png",
moderation="low",
partial_images=2,
size="2048x2048",
quality="high",
output_format="webp",
output_compression=70,
background="opaque",
action="edit",
)
for partial in result.partial_images:
Path(f"partial-{partial.index}.webp").write_bytes(partial.data)
Notes
codexmust be installed and logged in.- The default Responses model is
gpt-5.4. - The image generation tool is fixed to
gpt-image-2. codex responsesrequiresstore=false, so prior response/item references are not exposed by this library. Use image bytes or file IDs as inputs for follow-up edits.gpt-image-2does not supportbackground="transparent"orinput_fidelity; the library does not exposeinput_fidelityand rejects transparent backgrounds before calling Codex.partial_imagesare collected and returned aftercodex responsesexits. This function does not expose a live streaming callback.- The package returns image bytes and metadata; it does not write files.
- Tests mock
codex responsesand do not make live API calls.
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 codex_image_gen-0.1.0.tar.gz.
File metadata
- Download URL: codex_image_gen-0.1.0.tar.gz
- Upload date:
- Size: 18.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1b92e430dbdd9d400923ac17fdd70cbde0a84caf3b4bc0fcceca858015b6270d
|
|
| MD5 |
b473f14f4b8375f1054474d6ef02be3d
|
|
| BLAKE2b-256 |
a1b945b9b0617c560b71281356040d2ac62dda63124588732bc6f2723956f80c
|
Provenance
The following attestation bundles were made for codex_image_gen-0.1.0.tar.gz:
Publisher:
workflow.yml on smturtle2/codex-image-gen
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
codex_image_gen-0.1.0.tar.gz -
Subject digest:
1b92e430dbdd9d400923ac17fdd70cbde0a84caf3b4bc0fcceca858015b6270d - Sigstore transparency entry: 1362895511
- Sigstore integration time:
-
Permalink:
smturtle2/codex-image-gen@ea2003e6d7cd1074c0dd7c4fc0c55b31f6e3d432 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/smturtle2
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
workflow.yml@ea2003e6d7cd1074c0dd7c4fc0c55b31f6e3d432 -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file codex_image_gen-0.1.0-py3-none-any.whl.
File metadata
- Download URL: codex_image_gen-0.1.0-py3-none-any.whl
- Upload date:
- Size: 7.9 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 |
2c103ed712457b120fd691d12cbe52d8febf743ca873d11e1d898e3f779496f4
|
|
| MD5 |
7446bfcbacc1c09d2e5035cc165437b0
|
|
| BLAKE2b-256 |
ba733415e59b0e7a57517ba9780779205217df773e773ae57df578ccd45608a1
|
Provenance
The following attestation bundles were made for codex_image_gen-0.1.0-py3-none-any.whl:
Publisher:
workflow.yml on smturtle2/codex-image-gen
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
codex_image_gen-0.1.0-py3-none-any.whl -
Subject digest:
2c103ed712457b120fd691d12cbe52d8febf743ca873d11e1d898e3f779496f4 - Sigstore transparency entry: 1362895587
- Sigstore integration time:
-
Permalink:
smturtle2/codex-image-gen@ea2003e6d7cd1074c0dd7c4fc0c55b31f6e3d432 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/smturtle2
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
workflow.yml@ea2003e6d7cd1074c0dd7c4fc0c55b31f6e3d432 -
Trigger Event:
workflow_dispatch
-
Statement type: