Skip to content

Commit 90da2d3

Browse files
author
PixelAPI
committed
Initial release v0.1.0 - PixelAPI Python SDK
0 parents  commit 90da2d3

6 files changed

Lines changed: 729 additions & 0 deletions

File tree

README.md

Lines changed: 204 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,204 @@
1+
# PixelAPI Python SDK
2+
3+
Official Python SDK for [PixelAPI](https://pixelapi.dev) - AI-powered image processing API.
4+
5+
[![PyPI version](https://badge.fury.io/py/pixelapi.svg)](https://pypi.org/project/pixelapi/)
6+
[![Python 3.8+](https://img.shields.io/badge/python-3.8+-blue.svg)](https://www.python.org/downloads/)
7+
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
8+
9+
## Features
10+
11+
- 🎨 **Image Generation** - FLUX, SDXL text-to-image
12+
- ✂️ **Background Removal** - Instant, accurate cutouts
13+
- 🔍 **4x Upscaling** - AI-powered resolution enhancement
14+
- 👤 **Face Restoration** - Fix blurry/damaged faces
15+
- 🧹 **Object Removal** - Erase unwanted elements
16+
- 📝 **Text Removal** - Remove watermarks/text
17+
- 🌅 **Outpainting** - Extend images beyond borders
18+
- 🎭 **AI Shadows** - Add realistic product shadows
19+
- 📦 **Batch Processing** - Process up to 100 images
20+
21+
## Installation
22+
23+
```bash
24+
pip install pixelapi
25+
```
26+
27+
## Quick Start
28+
29+
```python
30+
from pixelapi import PixelAPI
31+
32+
# Initialize client
33+
client = PixelAPI("your_api_key")
34+
35+
# Remove background
36+
result = client.remove_background("photo.jpg")
37+
result.save("cutout.png")
38+
39+
# Generate image
40+
result = client.generate("A golden retriever on a beach, sunset")
41+
result.save("generated.png")
42+
43+
# Upscale image
44+
result = client.upscale("low_res.jpg", scale=4)
45+
result.save("high_res.png")
46+
```
47+
48+
## Usage Examples
49+
50+
### Background Removal
51+
52+
```python
53+
# From file
54+
result = client.remove_background("product.jpg")
55+
56+
# From URL
57+
result = client.remove_background("https://example.com/image.jpg")
58+
59+
# From bytes
60+
with open("image.png", "rb") as f:
61+
result = client.remove_background(f.read())
62+
63+
# Save result
64+
result.save("output.png")
65+
print(f"Credits used: {result.credits_used}")
66+
```
67+
68+
### Image Generation
69+
70+
```python
71+
# Basic generation
72+
result = client.generate("A futuristic cityscape at night")
73+
74+
# With parameters
75+
result = client.generate(
76+
prompt="A serene Japanese garden",
77+
model="flux-schnell", # or "sdxl"
78+
width=1024,
79+
height=1024,
80+
negative_prompt="blurry, low quality",
81+
seed=42
82+
)
83+
```
84+
85+
### Replace Background
86+
87+
```python
88+
# With another image
89+
result = client.replace_background(
90+
image="portrait.jpg",
91+
background="beach.jpg"
92+
)
93+
94+
# With AI-generated background
95+
result = client.replace_background(
96+
image="portrait.jpg",
97+
prompt="professional office environment"
98+
)
99+
```
100+
101+
### Face Restoration
102+
103+
```python
104+
result = client.restore_face("old_photo.jpg")
105+
result.save("restored.png")
106+
```
107+
108+
### Object Removal
109+
110+
```python
111+
# Remove object using mask
112+
result = client.remove_object(
113+
image="photo.jpg",
114+
mask="mask.png" # White = remove
115+
)
116+
```
117+
118+
### Outpainting (Extend Image)
119+
120+
```python
121+
result = client.outpaint(
122+
image="landscape.jpg",
123+
direction="all", # left, right, up, down, all
124+
pixels=256,
125+
prompt="continue the mountain scenery"
126+
)
127+
```
128+
129+
### AI Shadow
130+
131+
```python
132+
result = client.add_shadow(
133+
image="product.png",
134+
shadow_opacity=0.5,
135+
shadow_blur=20,
136+
shadow_offset_x=10,
137+
shadow_offset_y=15
138+
)
139+
```
140+
141+
### Batch Processing
142+
143+
```python
144+
# Process multiple images
145+
images = ["img1.jpg", "img2.jpg", "img3.jpg"]
146+
batch = client.batch("remove-bg", images)
147+
148+
# Wait for completion
149+
results = batch.wait()
150+
for i, result in enumerate(results):
151+
result.save(f"output_{i}.png")
152+
```
153+
154+
### Check Usage
155+
156+
```python
157+
usage = client.get_usage()
158+
print(f"Credits remaining: {usage['credits_remaining']}")
159+
print(f"Credits used: {usage['credits_used']}")
160+
```
161+
162+
## Pricing
163+
164+
| Operation | Credits | ~USD |
165+
|-----------|---------|------|
166+
| Background Removal | 10 | $0.01 |
167+
| Image Generation | 12 | $0.012 |
168+
| Premium Generation | 25 | $0.025 |
169+
| 4x Upscale | 50 | $0.05 |
170+
| Face Restoration | 25 | $0.025 |
171+
| Object Removal | 20 | $0.02 |
172+
| Text Removal | 20 | $0.02 |
173+
| Add Shadow | 10 | $0.01 |
174+
| Outpaint | 25 | $0.025 |
175+
176+
## Error Handling
177+
178+
```python
179+
from pixelapi import PixelAPI, AuthenticationError, InsufficientCreditsError
180+
181+
try:
182+
result = client.remove_background("image.jpg")
183+
except AuthenticationError:
184+
print("Invalid API key")
185+
except InsufficientCreditsError:
186+
print("Not enough credits - top up at pixelapi.dev")
187+
except PixelAPIError as e:
188+
print(f"API error: {e.message}")
189+
```
190+
191+
## Get API Key
192+
193+
Sign up at [pixelapi.dev](https://pixelapi.dev) to get your free API key with 100 credits.
194+
195+
## Links
196+
197+
- [Documentation](https://pixelapi.dev/docs)
198+
- [API Reference](https://api.pixelapi.dev/docs)
199+
- [Pricing](https://pixelapi.dev/#pricing)
200+
- [GitHub](https://github.com/pixelapi/pixelapi-python)
201+
202+
## License
203+
204+
MIT License - see [LICENSE](LICENSE) for details.

pixelapi/__init__.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
"""PixelAPI Python SDK - AI Image Processing API"""
2+
3+
__version__ = "0.1.0"
4+
5+
from .client import PixelAPI
6+
from .exceptions import PixelAPIError, AuthenticationError, RateLimitError, ValidationError
7+
8+
__all__ = ["PixelAPI", "PixelAPIError", "AuthenticationError", "RateLimitError", "ValidationError"]

0 commit comments

Comments
 (0)