pixbridge 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.
Files changed (49) hide show
  1. pixbridge-0.1.0/.envrc.example +5 -0
  2. pixbridge-0.1.0/.github/workflows/ci.yml +42 -0
  3. pixbridge-0.1.0/.gitignore +56 -0
  4. pixbridge-0.1.0/CHANGELOG.md +42 -0
  5. pixbridge-0.1.0/CLAUDE.md +49 -0
  6. pixbridge-0.1.0/CONTRIBUTING.md +58 -0
  7. pixbridge-0.1.0/LICENSE +202 -0
  8. pixbridge-0.1.0/NOTICE +10 -0
  9. pixbridge-0.1.0/PKG-INFO +144 -0
  10. pixbridge-0.1.0/README.md +113 -0
  11. pixbridge-0.1.0/SECURITY.md +25 -0
  12. pixbridge-0.1.0/examples/prompt.yaml +160 -0
  13. pixbridge-0.1.0/justfile +41 -0
  14. pixbridge-0.1.0/model_config.yaml +14 -0
  15. pixbridge-0.1.0/pyproject.toml +108 -0
  16. pixbridge-0.1.0/src/pixbridge/__init__.py +24 -0
  17. pixbridge-0.1.0/src/pixbridge/_usage_log.py +14 -0
  18. pixbridge-0.1.0/src/pixbridge/cli.py +697 -0
  19. pixbridge-0.1.0/src/pixbridge/client.py +420 -0
  20. pixbridge-0.1.0/src/pixbridge/config.py +54 -0
  21. pixbridge-0.1.0/src/pixbridge/consistency_check.py +153 -0
  22. pixbridge-0.1.0/src/pixbridge/integrity_check.py +110 -0
  23. pixbridge-0.1.0/src/pixbridge/models.py +34 -0
  24. pixbridge-0.1.0/src/pixbridge/providers/__init__.py +103 -0
  25. pixbridge-0.1.0/src/pixbridge/providers/base.py +352 -0
  26. pixbridge-0.1.0/src/pixbridge/providers/gemini.py +304 -0
  27. pixbridge-0.1.0/src/pixbridge/providers/openai.py +584 -0
  28. pixbridge-0.1.0/src/pixbridge/providers/vertex.py +47 -0
  29. pixbridge-0.1.0/src/pixbridge/providers/xai.py +155 -0
  30. pixbridge-0.1.0/src/pixbridge/size_resolver.py +65 -0
  31. pixbridge-0.1.0/tests/live/__init__.py +0 -0
  32. pixbridge-0.1.0/tests/live/test_providers_live.py +146 -0
  33. pixbridge-0.1.0/tests/live/vision_verifier.py +170 -0
  34. pixbridge-0.1.0/tests/pixbridge/conftest.py +111 -0
  35. pixbridge-0.1.0/tests/pixbridge/test_capability_surface.py +128 -0
  36. pixbridge-0.1.0/tests/pixbridge/test_cli.py +822 -0
  37. pixbridge-0.1.0/tests/pixbridge/test_client.py +588 -0
  38. pixbridge-0.1.0/tests/pixbridge/test_config.py +66 -0
  39. pixbridge-0.1.0/tests/pixbridge/test_consistency_check.py +442 -0
  40. pixbridge-0.1.0/tests/pixbridge/test_gemini_provider.py +289 -0
  41. pixbridge-0.1.0/tests/pixbridge/test_integrity_check.py +195 -0
  42. pixbridge-0.1.0/tests/pixbridge/test_models.py +140 -0
  43. pixbridge-0.1.0/tests/pixbridge/test_openai_provider.py +510 -0
  44. pixbridge-0.1.0/tests/pixbridge/test_providers_base.py +214 -0
  45. pixbridge-0.1.0/tests/pixbridge/test_providers_registry.py +58 -0
  46. pixbridge-0.1.0/tests/pixbridge/test_size_resolver.py +89 -0
  47. pixbridge-0.1.0/tests/pixbridge/test_usage_log.py +24 -0
  48. pixbridge-0.1.0/tests/pixbridge/test_vertex_provider.py +70 -0
  49. pixbridge-0.1.0/tests/pixbridge/test_xai_provider.py +194 -0
@@ -0,0 +1,5 @@
1
+ # Copy to .envrc (gitignored) and fill in your own provider API keys.
2
+ # Then run `direnv allow`, or source this file manually.
3
+ export GOOGLE_API_KEY="your-google-genai-key"
4
+ export OPENAI_API_KEY="your-openai-key"
5
+ export XAI_API_KEY="your-xai-key"
@@ -0,0 +1,42 @@
1
+ name: CI
2
+
3
+ on:
4
+ push:
5
+ branches: [main]
6
+ pull_request:
7
+ branches: [main]
8
+
9
+ concurrency:
10
+ group: ci-${{ github.ref }}
11
+ cancel-in-progress: true
12
+
13
+ jobs:
14
+ check:
15
+ runs-on: ubuntu-latest
16
+ strategy:
17
+ fail-fast: false
18
+ matrix:
19
+ python-version: ["3.11", "3.12", "3.13"]
20
+
21
+ steps:
22
+ - uses: actions/checkout@v4
23
+
24
+ - name: Install uv
25
+ uses: astral-sh/setup-uv@v5
26
+ with:
27
+ enable-cache: true
28
+
29
+ - name: Set up Python ${{ matrix.python-version }}
30
+ run: uv python install ${{ matrix.python-version }}
31
+
32
+ - name: Install dependencies
33
+ run: uv sync --python ${{ matrix.python-version }}
34
+
35
+ - name: Lint (ruff)
36
+ run: uv run ruff check src/ tests/
37
+
38
+ - name: Type-check (mypy)
39
+ run: uv run mypy src/pixbridge
40
+
41
+ - name: Test (pytest)
42
+ run: uv run pytest tests/
@@ -0,0 +1,56 @@
1
+ # Python
2
+ __pycache__/
3
+ *.py[cod]
4
+ *$py.class
5
+ *.so
6
+ .Python
7
+ build/
8
+ develop-eggs/
9
+ dist/
10
+ downloads/
11
+ eggs/
12
+ .eggs/
13
+ lib/
14
+ lib64/
15
+ parts/
16
+ sdist/
17
+ var/
18
+ wheels/
19
+ *.egg-info/
20
+ .installed.cfg
21
+ *.egg
22
+
23
+ # Virtual environments
24
+ .venv/
25
+ venv/
26
+ ENV/
27
+ env/
28
+
29
+ # Environment variables
30
+ .env
31
+ .env.local
32
+ .envrc
33
+
34
+ # IDE
35
+ .idea/
36
+ .vscode/
37
+ *.swp
38
+ *.swo
39
+ *~
40
+
41
+ # OS
42
+ .DS_Store
43
+ Thumbs.db
44
+
45
+ # Coverage
46
+ .coverage
47
+ htmlcov/
48
+
49
+ # uv
50
+ .python-version
51
+ uv.lock
52
+
53
+ # Output
54
+ output/
55
+ generated/
56
+ usage.jsonl
@@ -0,0 +1,42 @@
1
+ # Changelog
2
+
3
+ All notable changes to pixbridge are documented in this file.
4
+
5
+ ## [Unreleased]
6
+
7
+ ### Changed (breaking) — OpenAI size handling
8
+
9
+ - **`--aspect-ratio 9:16` now resolves to `1152x2048`** (was `1024x1536`, which is
10
+ actually 2:3). Callers wanting the previous behavior should pass
11
+ `--aspect-ratio 2:3` or an explicit `--size 1024x1536`.
12
+ - **`--aspect-ratio 16:9` now resolves to `2048x1152`** (was `1536x1024`, which is
13
+ actually 3:2). Callers wanting the previous behavior should pass
14
+ `--aspect-ratio 3:2` or an explicit `--size 1536x1024`.
15
+ - Cost impact for callers consuming the new defaults: roughly 50% more pixels,
16
+ ~50% higher token cost (e.g. ~$0.005 → ~$0.008 per low-quality 9:16 image).
17
+
18
+ ### Changed — OpenAI size validation is now rule-based
19
+
20
+ - `OpenAIProvider.validate_params` no longer checks `size` against a hardcoded
21
+ five-element allowlist. Any WxH meeting gpt-image-2's actual rules is
22
+ accepted:
23
+ - both dimensions divisible by 16,
24
+ - aspect ratio in `[1:3, 3:1]`,
25
+ - `max(W, H) ≤ 3840`.
26
+ - `ProviderCapabilities.sizes` for OpenAI now lists *recommended* sizes (for
27
+ docs/autocompletion); validation accepts any rule-conformant size beyond the
28
+ list.
29
+ - `size_resolver._resolve_wxh` for the OpenAI provider no longer silently snaps
30
+ invalid sizes to the nearest allowed one. Invalid sizes now raise
31
+ `ValueError`. The silent-snap behavior had been masking a bug where
32
+ `1080x1920` (and other 9:16-ish but non-/16 dimensions) was downgraded to
33
+ `1024x1536` (which is actually 2:3).
34
+
35
+ ### Added
36
+
37
+ - `pixbridge.providers.openai.validate_openai_size(size)` and
38
+ `is_valid_openai_size(size)` helpers exposed at the module level.
39
+ - Explicit `"3:2"` and `"2:3"` aspect-ratio aliases for the legacy
40
+ `1536x1024` / `1024x1536` mappings.
41
+ - True 9:16 (`1152x2048`) and 16:9 (`2048x1152`) recommended sizes in
42
+ `OpenAIProvider.capabilities.sizes`.
@@ -0,0 +1,49 @@
1
+ # CLAUDE.md
2
+
3
+ ## Project Purpose
4
+
5
+ Standalone multi-provider AI image generation library. Supports Gemini, OpenAI, and xAI providers through a unified `ImageClient` API.
6
+
7
+ ## Project Structure
8
+
9
+ ```
10
+ src/pixbridge/
11
+ __init__.py
12
+ _usage_log.py # Thread-safe JSONL usage logging (inlined)
13
+ client.py # ImageClient — unified generation API
14
+ cli.py # CLI entry point (pixbridge command)
15
+ config.py # YAML loader for model_config.yaml
16
+ models.py # Pydantic models (ImagePrompt, GenerationNotes)
17
+ size_resolver.py # Resolves preset/WxH sizes to provider-native sizes
18
+ integrity_check.py # Image integrity validation
19
+ consistency_check.py # Multi-image consistency testing
20
+ providers/
21
+ __init__.py # Provider registry (get_provider, list_providers)
22
+ base.py # BaseImageProvider ABC, GenerationResult, ProviderCapabilities
23
+ gemini.py
24
+ openai.py
25
+ xai.py
26
+ vertex.py
27
+ model_config.yaml # Per-provider default model (auto-discovered from cwd)
28
+ tests/pixbridge/ # Unit tests (no __init__.py — avoids shadowing the package)
29
+ ```
30
+
31
+ ## Development
32
+
33
+ ```bash
34
+ uv sync # Install dependencies
35
+ just test # Run tests
36
+ just build # Alias for uv sync
37
+ ```
38
+
39
+ ## Style Presets
40
+
41
+ `client.py` resolves style presets via `Path("prompts/style-transfer")` relative to cwd. When no preset directory exists, styles are treated as raw prompt text.
42
+
43
+ ## Key Design Decisions
44
+
45
+ - `_usage_log.py` is inlined from the original `common.usage_log` module to avoid external dependencies
46
+ - Provider instances are lazily initialized (no API key needed until first generation call)
47
+ - Tests do not have an `__init__.py` in `tests/pixbridge/` to prevent namespace shadowing with the installed package
48
+ - Model selection uses a flat `model_config.yaml` schema (`providers.<name>.default_model`). There is no per-model whitelist or capability metadata — any model string flows through to the provider SDK. Users switch models with `--model`; invalid combinations (e.g. `gpt-image-1.5` + `2560x1440`) surface as SDK errors at runtime, not local `ValueError`s.
49
+ - OpenAI provider capabilities list the union of sizes across all `gpt-image-*` models (`1024x1024`, `1024x1536`, `1536x1024`, `2560x1440`, `3840x2160`). The 2K/4K sizes require `gpt-image-2`; `gpt-image-1.x` will reject them at the API level.
@@ -0,0 +1,58 @@
1
+ # Contributing to pixbridge
2
+
3
+ Thanks for your interest in contributing. This project is a small, unified
4
+ multi-provider image generation library; contributions that keep the provider
5
+ surface consistent are especially welcome.
6
+
7
+ ## Development setup
8
+
9
+ ```bash
10
+ uv sync # install dependencies into .venv
11
+ just test # run the offline test suite
12
+ just check # lint + type-check + test (run this before opening a PR)
13
+ ```
14
+
15
+ If you don't use [`just`](https://github.com/casey/just), the underlying
16
+ commands are:
17
+
18
+ ```bash
19
+ uv run ruff check src/ tests/
20
+ uv run mypy src/pixbridge
21
+ uv run pytest tests/
22
+ ```
23
+
24
+ ## Provider API keys
25
+
26
+ Generation calls need provider credentials. Copy the example env file and fill
27
+ in your own keys (the real `.envrc` is gitignored):
28
+
29
+ ```bash
30
+ cp .envrc.example .envrc # then edit with your keys
31
+ ```
32
+
33
+ Live provider tests are opt-in and hit real APIs (and cost money):
34
+
35
+ ```bash
36
+ just test-live
37
+ ```
38
+
39
+ ## Pull requests
40
+
41
+ - Keep the change focused; one logical change per PR.
42
+ - Add or update tests for any behaviour change. The suite runs offline with
43
+ mocked SDKs — new code should too unless it is explicitly a `live` test.
44
+ - Run `just check` locally; CI runs the same on Python 3.11, 3.12, and 3.13.
45
+ - Update `CHANGELOG.md` under an `Unreleased` heading.
46
+ - When adding a provider or capability, keep the `ProviderCapabilities` surface
47
+ uniform (see the capability table in the README) so callers don't have to
48
+ branch on provider name.
49
+
50
+ ## Reporting bugs
51
+
52
+ Open an issue with a minimal reproduction: the provider, model, prompt/size,
53
+ and the full error. Please redact API keys.
54
+
55
+ ## License
56
+
57
+ By contributing, you agree that your contributions will be licensed under the
58
+ [Apache License 2.0](LICENSE), the same license that covers this project.
@@ -0,0 +1,202 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright [yyyy] [name of copyright owner]
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.
pixbridge-0.1.0/NOTICE ADDED
@@ -0,0 +1,10 @@
1
+ pixbridge
2
+ Copyright 2026 Jörn Dinkla
3
+
4
+ This product includes software developed by Jörn Dinkla.
5
+
6
+ Licensed under the Apache License, Version 2.0 (the "License");
7
+ you may not use this software except in compliance with the License.
8
+ You may obtain a copy of the License at
9
+
10
+ http://www.apache.org/licenses/LICENSE-2.0
@@ -0,0 +1,144 @@
1
+ Metadata-Version: 2.4
2
+ Name: pixbridge
3
+ Version: 0.1.0
4
+ Summary: Unified multi-provider AI image generation library (Gemini, OpenAI, xAI)
5
+ Project-URL: Homepage, https://github.com/jdinkla/pixbridge
6
+ Project-URL: Repository, https://github.com/jdinkla/pixbridge
7
+ Project-URL: Issues, https://github.com/jdinkla/pixbridge/issues
8
+ Project-URL: Changelog, https://github.com/jdinkla/pixbridge/blob/main/CHANGELOG.md
9
+ Author-email: Jörn Dinkla <joern@dinkla.net>
10
+ License-Expression: Apache-2.0
11
+ License-File: LICENSE
12
+ License-File: NOTICE
13
+ Keywords: ai,dall-e,gemini,image-generation,imagen,openai,xai
14
+ Classifier: Development Status :: 4 - Beta
15
+ Classifier: Intended Audience :: Developers
16
+ Classifier: Programming Language :: Python :: 3
17
+ Classifier: Programming Language :: Python :: 3.11
18
+ Classifier: Programming Language :: Python :: 3.12
19
+ Classifier: Programming Language :: Python :: 3.13
20
+ Classifier: Topic :: Multimedia :: Graphics
21
+ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
22
+ Classifier: Typing :: Typed
23
+ Requires-Python: >=3.11
24
+ Requires-Dist: google-genai>=1.0.0
25
+ Requires-Dist: openai>=1.0.0
26
+ Requires-Dist: pillow>=10.0
27
+ Requires-Dist: pydantic>=2.0
28
+ Requires-Dist: pyyaml>=6.0
29
+ Requires-Dist: requests>=2.28
30
+ Description-Content-Type: text/markdown
31
+
32
+ # pixbridge
33
+
34
+ [![CI](https://github.com/jdinkla/pixbridge/actions/workflows/ci.yml/badge.svg)](https://github.com/jdinkla/pixbridge/actions/workflows/ci.yml)
35
+ [![License: Apache 2.0](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](LICENSE)
36
+ [![Python 3.11+](https://img.shields.io/badge/python-3.11%2B-blue.svg)](https://www.python.org/downloads/)
37
+
38
+ Multi-provider AI image generation library supporting Gemini, OpenAI, and xAI.
39
+
40
+ ## Features
41
+
42
+ - Unified `ImageClient` API across providers
43
+ - Image generation from structured YAML prompts
44
+ - Style transfer (Gemini)
45
+ - Reference image support for identity consistency (Gemini)
46
+ - Consistency checking (generate N images from the same prompt for comparison)
47
+ - Image integrity checks (transparency, corruption, truncation)
48
+ - Thread-safe usage logging (JSONL)
49
+
50
+ ## Setup
51
+
52
+ ```bash
53
+ uv sync
54
+ ```
55
+
56
+ ## CLI
57
+
58
+ ```bash
59
+ pixbridge providers # List available providers
60
+ pixbridge generate prompt.yaml # Generate from YAML prompt
61
+ pixbridge style-transfer img.png --style anime-dark
62
+ pixbridge consistency-check anime-dark -n 5
63
+ pixbridge check output/ # Check image integrity
64
+ ```
65
+
66
+ ## Usage as library
67
+
68
+ ```python
69
+ from pixbridge.client import ImageClient
70
+ from pixbridge.models import ImagePrompt, GenerationNotes
71
+
72
+ client = ImageClient(provider="gemini")
73
+ prompt = ImagePrompt(
74
+ full_prompt="A mountain landscape at sunset",
75
+ generation_notes=GenerationNotes(
76
+ aspect_ratio="16:9",
77
+ key_requirements=["photorealistic"],
78
+ ),
79
+ )
80
+ path = client.generate_image(prompt, output_dir="output")
81
+ ```
82
+
83
+ ## Providers
84
+
85
+ | Provider | Models | Style Transfer | Reference Images |
86
+ |----------|--------|:-:|:-:|
87
+ | Gemini | gemini-3-pro-image-preview | yes | yes |
88
+ | OpenAI | gpt-image-2 (default), gpt-image-1.5, gpt-image-1, gpt-image-1-mini | no | no |
89
+ | xAI | grok-imagine-image | no | no |
90
+
91
+ Any model can be selected at runtime with `--model`. The CLI also accepts size presets `720p`, `1080p`, `2160p`, or a raw `WxH` string (resolved per-provider). OpenAI (`gpt-image-2`) validates sizes by rule — any `WxH` where both dimensions are divisible by 16, the ratio is within `[1:3, 3:1]`, and `max(W, H) ≤ 3840` — so true `9:16` (`1152x2048`) and `16:9` (`2048x1152`) work; `1024x1024`, `1024x1536`, `1536x1024`, `2560x1440`, `3840x2160` are recommended values surfaced for autocompletion.
92
+
93
+ ### Provider capability surface
94
+
95
+ Each provider exposes a uniform capability surface via `provider.capabilities` (a `ProviderCapabilities`), so callers can reason about size rules without branching on the provider name:
96
+
97
+ | Method | Returns | OpenAI | Gemini / Vertex | xAI |
98
+ |--------|---------|--------|-----------------|-----|
99
+ | `validate_size(size)` | raises `ValueError` if invalid | rule-based (÷16, ratio, max-dim) | must be `1K`/`2K` | no-op (unconstrained) |
100
+ | `recommended_sizes()` | `list[str]` for docs/autocomplete | 7 sizes incl. true 9:16/16:9 | `["1K", "2K"]` | `[]` |
101
+ | `aspect_to_size(ratio)` | `str \| None` (named ratio → `WxH`) | e.g. `"9:16" → "1152x2048"` | `None` (ratio passed to API) | `None` |
102
+ | `max_dim()` | `int \| None` (px ceiling) | `3840` | `None` | `None` |
103
+ | `native_size(w, h)` | `str \| None` (raw `WxH` → native size) | validates + passes `WxH` through | buckets to `1K`/`2K` | `None` |
104
+
105
+ To read a provider's capabilities **without instantiating it or supplying credentials** (e.g. for offline size resolution), use the registry:
106
+
107
+ ```python
108
+ from pixbridge.providers import get_capabilities
109
+
110
+ caps = get_capabilities("openai") # also "gemini", "xai", "vertex"; None if unknown
111
+ caps.validate_size("1152x2048") # passes; raises ValueError on invalid sizes
112
+ caps.native_size(2048, 1152) # -> "2048x1152"
113
+ ```
114
+
115
+ `get_capabilities("vertex")` returns Gemini's surface (Vertex shares it) and never requires `GOOGLE_CLOUD_PROJECT`.
116
+
117
+ ## Configuration
118
+
119
+ Per-provider defaults live in `model_config.yaml` (auto-discovered from the current working directory, or pass `--config path/to/file.yaml`). Resolution order: `--model` CLI flag > config file > hardcoded provider default.
120
+
121
+ ```yaml
122
+ providers:
123
+ openai:
124
+ default_model: gpt-image-2
125
+ gemini:
126
+ default_model: gemini-3.1-flash-image-preview
127
+ ```
128
+
129
+ ## Testing
130
+
131
+ ```bash
132
+ just test
133
+ ```
134
+
135
+ ## Contributing
136
+
137
+ Contributions are welcome — see [CONTRIBUTING.md](CONTRIBUTING.md) for the
138
+ development setup and PR guidelines. To report a security issue, see
139
+ [SECURITY.md](SECURITY.md).
140
+
141
+ ## License
142
+
143
+ Licensed under the [Apache License 2.0](LICENSE). See the [NOTICE](NOTICE) file
144
+ for attribution requirements.