Skip to content

Commit a330c06

Browse files
authored
Merge pull request #31 from ebowwa/feature/app-store-internationalization-v0.4.0
feat: GPT-4o Image Generation Provider v0.4.0
2 parents a48a009 + 95a37c2 commit a330c06

23 files changed

Lines changed: 1464 additions & 5 deletions

CHANGELOG.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,29 @@
11
# Changelog
22

3+
## [0.4.0] - 2025-08-19
4+
### Added
5+
- **Image Generation Support**: New GPT4oImageProvider for DALL-E 3 image generation
6+
- Support for multiple image sizes (SQUARE, LANDSCAPE, PORTRAIT)
7+
- Image quality options (STANDARD, HD)
8+
- Style options (VIVID, NATURAL)
9+
- Image editing capabilities with optional masks
10+
- Azure OpenAI image generation support
11+
- Localized image generation for app internationalization
12+
- C2PA metadata extraction for AI-generated content authenticity
13+
- Comprehensive test suite for image generation
14+
15+
### Changed
16+
- Updated package structure to include image providers
17+
- Enhanced README with image generation examples
18+
19+
### Technical
20+
- Abstract provider pattern for future image generation services
21+
- Integration with existing BaseCompletions architecture
22+
- Full compatibility with uv package manager
23+
24+
## [0.3.9] - 2025-08-09
25+
- Version bump for PyPI release
26+
327
## [0.3.8] - 2025-08-09
428
- Add `/api/models` endpoint for listing available models
529
- Fix GoogleCompletions to query actual Google Gemini API for model list (60+ models!)

README.md

Lines changed: 76 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# AI Proxy Core
22

3-
A unified Python package providing a single interface for AI completions across multiple providers (OpenAI, Gemini, Ollama). Features intelligent model management, automatic provider routing, and zero-config setup.
3+
A unified Python package providing a single interface for AI completions across multiple providers (OpenAI, Gemini, Ollama), plus **image generation capabilities** (v0.4.0+). Features intelligent model management, automatic provider routing, zero-config setup, and abstract image generation with DALL-E 3.
44

55
> 💡 **Why not LangChain?** Read our [philosophy and architectural rationale](https://github.com/ebowwa/ai-proxy-core/issues/13) for choosing simplicity over complexity.
66
@@ -15,7 +15,7 @@ pip install ai-proxy-core
1515

1616
With specific providers (optional dependencies):
1717
```bash
18-
pip install ai-proxy-core[openai] # OpenAI support
18+
pip install ai-proxy-core[openai] # OpenAI support (includes image generation)
1919
pip install ai-proxy-core[anthropic] # Anthropic support (coming soon)
2020
pip install ai-proxy-core[telemetry] # OpenTelemetry support
2121
pip install ai-proxy-core[all] # Everything
@@ -148,6 +148,80 @@ response = await ollama.create_completion(
148148

149149
See [examples/ollama_complete_guide.py](examples/ollama_complete_guide.py) for comprehensive examples including error handling, streaming, and advanced features.
150150

151+
## Image Generation (v0.4.0+)
152+
153+
### Generate Images with DALL-E 3
154+
155+
```python
156+
from ai_proxy_core import GPT4oImageProvider, ImageSize, ImageQuality, ImageStyle
157+
158+
# Initialize the provider
159+
provider = GPT4oImageProvider(api_key="your-openai-api-key")
160+
161+
# Generate an image
162+
response = provider.generate(
163+
prompt="A modern app icon with turquoise background and camera symbol",
164+
size=ImageSize.SQUARE, # 1024x1024, LANDSCAPE, or PORTRAIT
165+
quality=ImageQuality.HD, # HD or STANDARD
166+
style=ImageStyle.VIVID # VIVID or NATURAL
167+
)
168+
169+
# Save the image
170+
with open("generated_icon.png", "wb") as f:
171+
f.write(response["image"])
172+
173+
# Access metadata
174+
print(f"Image URL: {response['url']}")
175+
print(f"Revised prompt: {response['revised_prompt']}")
176+
```
177+
178+
### Edit Existing Images
179+
180+
```python
181+
# Edit an existing image
182+
with open("original.png", "rb") as f:
183+
original_image = f.read()
184+
185+
response = provider.edit(
186+
image=original_image,
187+
prompt="Change the background to sunset colors",
188+
mask=mask_bytes # Optional mask for inpainting
189+
)
190+
```
191+
192+
### Localized Image Generation
193+
194+
```python
195+
# Generate app icons with localized text
196+
locales = {
197+
"en": "CleanShots",
198+
"ja": "クリーンショット",
199+
"es": "FotosLimpias"
200+
}
201+
202+
for locale, text in locales.items():
203+
response = provider.generate(
204+
prompt=f"App icon with text '{text}' in {locale} style",
205+
size=ImageSize.SQUARE,
206+
quality=ImageQuality.HD
207+
)
208+
# Save localized icon
209+
with open(f"icon_{locale}.png", "wb") as f:
210+
f.write(response["image"])
211+
```
212+
213+
### Azure OpenAI Support
214+
215+
```python
216+
from ai_proxy_core import AzureGPT4oImageProvider
217+
218+
provider = AzureGPT4oImageProvider(
219+
api_key="your-azure-key",
220+
resource_name="your-resource",
221+
deployment_name="dall-e-3"
222+
)
223+
```
224+
151225
## Advanced Usage
152226

153227
### Provider-Specific Completions

README_v0.4.0.md

Lines changed: 157 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,157 @@
1+
# ai-proxy-core v0.4.0
2+
## Abstract GPT-4o Image Generation Provider
3+
4+
### Overview
5+
This release adds abstract wrapper support for OpenAI's GPT-4o native image generation capabilities (March 2025), maintaining consistency with ai-proxy-core's design philosophy of providing abstract, extensible AI provider interfaces.
6+
7+
### Installation
8+
```bash
9+
pip install ai-proxy-core==0.4.0
10+
```
11+
12+
### Quick Start
13+
14+
```python
15+
from ai_proxy_core import GPT4oImageProvider, ImageSize, ImageQuality
16+
17+
# Initialize provider
18+
provider = GPT4oImageProvider(api_key="your-api-key")
19+
20+
# Generate image
21+
response = provider.generate(
22+
prompt="A modern minimalist app icon",
23+
size=ImageSize.SQUARE,
24+
quality=ImageQuality.HD
25+
)
26+
27+
# Access image data
28+
image_bytes = response.image_data
29+
c2pa_metadata = response.c2pa_metadata
30+
```
31+
32+
### Abstract Models
33+
34+
The library provides abstract models that work across providers:
35+
36+
```python
37+
from ai_proxy_core import ImageGenerationRequest, ImageGenerationResponse
38+
39+
# Create abstract request
40+
request = ImageGenerationRequest(
41+
prompt="Generate an image",
42+
provider="openai",
43+
model="gpt-4o",
44+
size="1024x1024",
45+
context={"previous_messages": [...]}
46+
)
47+
48+
# Convert to provider format
49+
provider_request = request.to_provider_format("openai")
50+
```
51+
52+
### Provider Implementations
53+
54+
#### OpenAI GPT-4o
55+
```python
56+
from ai_proxy_core import GPT4oImageProvider
57+
58+
provider = GPT4oImageProvider(api_key="sk-...")
59+
```
60+
61+
#### Azure OpenAI
62+
```python
63+
from ai_proxy_core import AzureGPT4oImageProvider
64+
65+
provider = AzureGPT4oImageProvider(
66+
api_key="...",
67+
resource_name="myresource",
68+
deployment_name="gpt-image-1",
69+
api_version="2025-04-15"
70+
)
71+
```
72+
73+
### Image Editing
74+
75+
```python
76+
# Edit existing image
77+
edited = provider.edit(
78+
image=original_bytes,
79+
prompt="Change the background to turquoise",
80+
mask=mask_bytes # Optional
81+
)
82+
```
83+
84+
### Context-Aware Generation
85+
86+
```python
87+
# Generate with context
88+
response = provider.generate(
89+
prompt="Create a similar style icon",
90+
context={
91+
"images": [reference_image_bytes],
92+
"messages": previous_chat_history
93+
}
94+
)
95+
```
96+
97+
### C2PA Metadata
98+
99+
All generated images include C2PA (Content Authenticity) metadata:
100+
101+
```python
102+
metadata = provider.extract_c2pa_metadata(response)
103+
print(metadata["generator"]) # "OpenAI GPT-4o"
104+
print(metadata["is_ai_generated"]) # True
105+
```
106+
107+
### Extending the Abstract Provider
108+
109+
Create your own implementation:
110+
111+
```python
112+
from ai_proxy_core import GPT4oImageProvider
113+
114+
class CustomImageProvider(GPT4oImageProvider):
115+
def generate(self, prompt, **kwargs):
116+
# Add custom preprocessing
117+
prompt = self.preprocess_prompt(prompt)
118+
119+
# Call parent implementation
120+
response = super().generate(prompt, **kwargs)
121+
122+
# Add custom postprocessing
123+
return self.postprocess_response(response)
124+
```
125+
126+
### What's New in v0.4.0
127+
128+
- **GPT-4o Native Generation**: Not DALL-E, uses autoregressive method
129+
- **Image Editing**: Modify existing images with natural language
130+
- **Context Awareness**: Use chat history and reference images
131+
- **C2PA Metadata**: Built-in content authenticity
132+
- **Azure Support**: Full Azure OpenAI integration
133+
- **Abstract Models**: Provider-agnostic request/response models
134+
135+
### Migration from v0.3.x
136+
137+
```python
138+
# Old (v0.3.x)
139+
from ai_proxy_core import DallEProvider
140+
provider = DallEProvider(api_key="key")
141+
142+
# New (v0.4.0)
143+
from ai_proxy_core import GPT4oImageProvider
144+
provider = GPT4oImageProvider(api_key="key")
145+
```
146+
147+
### License
148+
MIT
149+
150+
### Contributing
151+
See [CONTRIBUTING.md](CONTRIBUTING.md)
152+
153+
---
154+
155+
**Branch**: `feature/app-store-internationalization-v0.4.0`
156+
**Release**: v0.4.0
157+
**Issue**: #30

ai_proxy_core/__init__.py

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
"""
2+
ai-proxy-core v0.4.0
3+
Abstract AI provider wrapper with unified interface
4+
"""
5+
6+
__version__ = "0.4.0"
7+
8+
# Core providers
9+
from .providers.openai.gpt4o_image import (
10+
GPT4oImageProvider,
11+
AzureGPT4oImageProvider,
12+
ImageSize,
13+
ImageQuality,
14+
ImageStyle
15+
)
16+
17+
# Abstract models
18+
from .models.image import (
19+
ImageGenerationRequest,
20+
ImageEditRequest,
21+
ImageGenerationResponse,
22+
BatchImageRequest,
23+
LocalizationConfig
24+
)
25+
26+
# Base classes
27+
from .base import BaseProvider, ProviderRegistry
28+
29+
# Utilities
30+
from .utils import encode_image, decode_response
31+
32+
__all__ = [
33+
# Version
34+
"__version__",
35+
36+
# Providers
37+
"GPT4oImageProvider",
38+
"AzureGPT4oImageProvider",
39+
40+
# Enums
41+
"ImageSize",
42+
"ImageQuality",
43+
"ImageStyle",
44+
45+
# Models
46+
"ImageGenerationRequest",
47+
"ImageEditRequest",
48+
"ImageGenerationResponse",
49+
"BatchImageRequest",
50+
"LocalizationConfig",
51+
52+
# Base
53+
"BaseProvider",
54+
"ProviderRegistry",
55+
56+
# Utils
57+
"encode_image",
58+
"decode_response"
59+
]

0 commit comments

Comments
 (0)