Spaces:
Running
Running
File size: 1,090 Bytes
c331dad |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# Flux Kontext Image Generator Library
A Python library for interacting with the Kontext Chat image generation API.
## Installation
```bash
pip install requests
```
## Usage
```python
from flux_kontext_lib import generate_image
# Using file path
result = generate_image("close her eyes", "path/to/image.jpg")
# Using image bytes
with open("path/to/image.jpg", "rb") as f:
image_bytes = f.read()
result = generate_image("add sunglasses", image_bytes)
# Custom headers
custom_headers = {"Authorization": "Bearer YOUR_TOKEN"}
result = generate_image("make it sunny", "path/to/image.jpg", headers=custom_headers)
```
## Parameters
- `prompt_text` (str): Text prompt for image modification
- `image_input` (str or bytes): Image file path or bytes content
- `headers` (dict, optional): Custom request headers
## Returns
- dict: API response on success
- None: On request failure
## Error Handling
Raises:
- `FileNotFoundError`: If image file doesn't exist
- `ValueError`: For unsupported input types
## Example
See [example_usage.py](example_usage.py) for a complete usage example.
|