indoxrouter 0.1.16__py3-none-any.whl → 0.1.17__py3-none-any.whl
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.
- indoxrouter/client.py +90 -2
- indoxrouter/constants.py +4 -0
- {indoxrouter-0.1.16.dist-info → indoxrouter-0.1.17.dist-info}/METADATA +33 -4
- indoxrouter-0.1.17.dist-info/RECORD +8 -0
- {indoxrouter-0.1.16.dist-info → indoxrouter-0.1.17.dist-info}/WHEEL +1 -1
- indoxrouter-0.1.16.dist-info/RECORD +0 -8
- {indoxrouter-0.1.16.dist-info → indoxrouter-0.1.17.dist-info}/top_level.txt +0 -0
indoxrouter/client.py
CHANGED
@@ -535,6 +535,26 @@ class Client:
|
|
535
535
|
n: int = 1,
|
536
536
|
quality: str = "standard",
|
537
537
|
style: str = "vivid",
|
538
|
+
# Standard parameters
|
539
|
+
response_format: Optional[str] = None,
|
540
|
+
user: Optional[str] = None,
|
541
|
+
# OpenAI-specific parameters
|
542
|
+
background: Optional[str] = None,
|
543
|
+
moderation: Optional[str] = None,
|
544
|
+
output_compression: Optional[int] = None,
|
545
|
+
output_format: Optional[str] = None,
|
546
|
+
# Google-specific parameters
|
547
|
+
negative_prompt: Optional[str] = None,
|
548
|
+
guidance_scale: Optional[float] = None,
|
549
|
+
seed: Optional[int] = None,
|
550
|
+
safety_filter_level: Optional[str] = None,
|
551
|
+
person_generation: Optional[str] = None,
|
552
|
+
include_safety_attributes: Optional[bool] = None,
|
553
|
+
include_rai_reason: Optional[bool] = None,
|
554
|
+
language: Optional[str] = None,
|
555
|
+
output_mime_type: Optional[str] = None,
|
556
|
+
add_watermark: Optional[bool] = None,
|
557
|
+
enhance_prompt: Optional[bool] = None,
|
538
558
|
**kwargs,
|
539
559
|
) -> Dict[str, Any]:
|
540
560
|
"""
|
@@ -542,11 +562,35 @@ class Client:
|
|
542
562
|
|
543
563
|
Args:
|
544
564
|
prompt: Text prompt
|
545
|
-
model: Model to use in the format "provider/model" (e.g., "openai/dall-e-3")
|
565
|
+
model: Model to use in the format "provider/model" (e.g., "openai/dall-e-3", "google/imagen-3.0-generate-002")
|
546
566
|
size: Image size (e.g., "1024x1024")
|
547
567
|
n: Number of images to generate
|
548
568
|
quality: Image quality (e.g., "standard", "hd")
|
549
569
|
style: Image style (e.g., "vivid", "natural")
|
570
|
+
|
571
|
+
# Standard parameters
|
572
|
+
response_format: Format of the response - "url" or "b64_json"
|
573
|
+
user: A unique identifier for the end-user
|
574
|
+
|
575
|
+
# OpenAI-specific parameters
|
576
|
+
background: Background style - "transparent", "opaque", or "auto"
|
577
|
+
moderation: Moderation level - "low" or "auto"
|
578
|
+
output_compression: Compression quality for output images (0-100)
|
579
|
+
output_format: Output format - "png", "jpeg", or "webp"
|
580
|
+
|
581
|
+
# Google-specific parameters
|
582
|
+
negative_prompt: Description of what to discourage in the generated images
|
583
|
+
guidance_scale: Controls how much the model adheres to the prompt
|
584
|
+
seed: Random seed for image generation
|
585
|
+
safety_filter_level: Filter level for safety filtering
|
586
|
+
person_generation: Controls generation of people ("dont_allow", "allow_adult", "allow_all")
|
587
|
+
include_safety_attributes: Whether to report safety scores of generated images
|
588
|
+
include_rai_reason: Whether to include filter reason if the image is filtered
|
589
|
+
language: Language of the text in the prompt
|
590
|
+
output_mime_type: MIME type of the generated image
|
591
|
+
add_watermark: Whether to add a watermark to the generated images
|
592
|
+
enhance_prompt: Whether to use prompt rewriting logic
|
593
|
+
|
550
594
|
**kwargs: Additional parameters to pass to the API
|
551
595
|
|
552
596
|
Returns:
|
@@ -561,6 +605,7 @@ class Client:
|
|
561
605
|
if key not in ["return_generator"]: # List of parameters to exclude
|
562
606
|
filtered_kwargs[key] = value
|
563
607
|
|
608
|
+
# Create the base request data
|
564
609
|
data = {
|
565
610
|
"prompt": prompt,
|
566
611
|
"model": formatted_model,
|
@@ -568,9 +613,52 @@ class Client:
|
|
568
613
|
"size": size,
|
569
614
|
"quality": quality,
|
570
615
|
"style": style,
|
571
|
-
"additional_params": filtered_kwargs,
|
572
616
|
}
|
573
617
|
|
618
|
+
# Add standard parameters if provided
|
619
|
+
if response_format is not None:
|
620
|
+
data["response_format"] = response_format
|
621
|
+
if user is not None:
|
622
|
+
data["user"] = user
|
623
|
+
|
624
|
+
# Add OpenAI-specific parameters if provided
|
625
|
+
if background is not None:
|
626
|
+
data["background"] = background
|
627
|
+
if moderation is not None:
|
628
|
+
data["moderation"] = moderation
|
629
|
+
if output_compression is not None:
|
630
|
+
data["output_compression"] = output_compression
|
631
|
+
if output_format is not None:
|
632
|
+
data["output_format"] = output_format
|
633
|
+
|
634
|
+
# Add Google-specific parameters if provided
|
635
|
+
if negative_prompt is not None:
|
636
|
+
data["negative_prompt"] = negative_prompt
|
637
|
+
if guidance_scale is not None:
|
638
|
+
data["guidance_scale"] = guidance_scale
|
639
|
+
if seed is not None:
|
640
|
+
data["seed"] = seed
|
641
|
+
if safety_filter_level is not None:
|
642
|
+
data["safety_filter_level"] = safety_filter_level
|
643
|
+
if person_generation is not None:
|
644
|
+
data["person_generation"] = person_generation
|
645
|
+
if include_safety_attributes is not None:
|
646
|
+
data["include_safety_attributes"] = include_safety_attributes
|
647
|
+
if include_rai_reason is not None:
|
648
|
+
data["include_rai_reason"] = include_rai_reason
|
649
|
+
if language is not None:
|
650
|
+
data["language"] = language
|
651
|
+
if output_mime_type is not None:
|
652
|
+
data["output_mime_type"] = output_mime_type
|
653
|
+
if add_watermark is not None:
|
654
|
+
data["add_watermark"] = add_watermark
|
655
|
+
if enhance_prompt is not None:
|
656
|
+
data["enhance_prompt"] = enhance_prompt
|
657
|
+
|
658
|
+
# Add any remaining parameters
|
659
|
+
if filtered_kwargs:
|
660
|
+
data["additional_params"] = filtered_kwargs
|
661
|
+
|
574
662
|
return self._request("POST", IMAGE_ENDPOINT, data)
|
575
663
|
|
576
664
|
def models(self, provider: Optional[str] = None) -> Dict[str, Any]:
|
indoxrouter/constants.py
CHANGED
@@ -13,6 +13,10 @@ USE_COOKIES = True # Always use cookie-based authentication
|
|
13
13
|
DEFAULT_MODEL = "openai/gpt-4o-mini"
|
14
14
|
DEFAULT_EMBEDDING_MODEL = "openai/text-embedding-3-small"
|
15
15
|
DEFAULT_IMAGE_MODEL = "openai/dall-e-3"
|
16
|
+
GOOGLE_IMAGE_MODEL = "google/imagen-3.0-generate-002"
|
17
|
+
XAI_IMAGE_MODEL = "xai/grok-2-image"
|
18
|
+
XAI_IMAGE_LATEST_MODEL = "xai/grok-2-image-latest"
|
19
|
+
XAI_IMAGE_SPECIFIC_MODEL = "xai/grok-2-image-1212"
|
16
20
|
|
17
21
|
# API endpoints
|
18
22
|
CHAT_ENDPOINT = "chat/completions"
|
@@ -1,16 +1,15 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: indoxrouter
|
3
|
-
Version: 0.1.
|
3
|
+
Version: 0.1.17
|
4
4
|
Summary: A unified client for various AI providers
|
5
5
|
Author-email: indoxRouter Team <ashkan.eskandari.dev@gmail.com>
|
6
6
|
License: MIT
|
7
7
|
Project-URL: Homepage, https://github.com/indoxrouter/indoxrouter
|
8
8
|
Project-URL: Repository, https://github.com/indoxrouter/indoxrouter
|
9
9
|
Project-URL: Issues, https://github.com/indoxrouter/indoxrouter/issues
|
10
|
-
Keywords: ai,api,client,openai,anthropic,google,mistral
|
10
|
+
Keywords: ai,api,client,openai,anthropic,google,mistral,xai,imagen,grok,image-generation
|
11
11
|
Classifier: Development Status :: 3 - Alpha
|
12
12
|
Classifier: Intended Audience :: Developers
|
13
|
-
Classifier: License :: OSI Approved :: MIT License
|
14
13
|
Classifier: Programming Language :: Python :: 3
|
15
14
|
Classifier: Programming Language :: Python :: 3.8
|
16
15
|
Classifier: Programming Language :: Python :: 3.9
|
@@ -134,13 +133,43 @@ print(f"First embedding: {response['data'][0]['embedding'][:5]}...")
|
|
134
133
|
### Image Generation
|
135
134
|
|
136
135
|
```python
|
136
|
+
# OpenAI Image Generation
|
137
137
|
response = client.images(
|
138
138
|
prompt="A serene landscape with mountains and a lake",
|
139
139
|
model="openai/dall-e-3",
|
140
|
-
size="1024x1024"
|
140
|
+
size="1024x1024",
|
141
|
+
quality="standard", # Options: standard, hd
|
142
|
+
style="vivid" # Options: vivid, natural
|
141
143
|
)
|
142
144
|
|
143
145
|
print(f"Image URL: {response['data'][0]['url']}")
|
146
|
+
|
147
|
+
# Google Imagen Image Generation
|
148
|
+
from indoxrouter.constants import GOOGLE_IMAGE_MODEL
|
149
|
+
|
150
|
+
response = client.images(
|
151
|
+
prompt="A robot holding a red skateboard in a futuristic city",
|
152
|
+
model=GOOGLE_IMAGE_MODEL,
|
153
|
+
n=2, # Generate 2 images
|
154
|
+
negative_prompt="broken, damaged, low quality",
|
155
|
+
guidance_scale=7.5, # Control adherence to prompt
|
156
|
+
seed=42, # For reproducible results
|
157
|
+
)
|
158
|
+
|
159
|
+
# xAI Grok Image Generation
|
160
|
+
from indoxrouter.constants import XAI_IMAGE_MODEL
|
161
|
+
|
162
|
+
response = client.images(
|
163
|
+
prompt="A cat in a tree",
|
164
|
+
model=XAI_IMAGE_MODEL,
|
165
|
+
n=1,
|
166
|
+
response_format="b64_json" # Get base64 encoded image
|
167
|
+
)
|
168
|
+
|
169
|
+
# Access base64 encoded image data
|
170
|
+
if "b64_json" in response["data"][0]:
|
171
|
+
b64_data = response["data"][0]["b64_json"]
|
172
|
+
# Use the base64 data (e.g., to display in HTML or save to file)
|
144
173
|
```
|
145
174
|
|
146
175
|
### Streaming Responses
|
@@ -0,0 +1,8 @@
|
|
1
|
+
indoxrouter/__init__.py,sha256=kwGvH8F5oqm2O4kLs-UtPfcY0AYiy5ZDUg-Sh3iYJA4,1627
|
2
|
+
indoxrouter/client.py,sha256=0FZ-7mgE_kxbRpmRwJrucpvHme4MQOToX2VqVw9PKQE,34706
|
3
|
+
indoxrouter/constants.py,sha256=GezZ9nuwK3A37xpWlcfXCrMsIIlCdP7xnvEkPBMyn5g,1383
|
4
|
+
indoxrouter/exceptions.py,sha256=qs7f9AnJ7SkOyf9N5qRaZIKpECE8uBq1Pvcg19Jif-U,1718
|
5
|
+
indoxrouter-0.1.17.dist-info/METADATA,sha256=XFpOPo3DdQQuiPzmAOTbQvVc0bJRxPgD6FkNLkEyMFA,6639
|
6
|
+
indoxrouter-0.1.17.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
7
|
+
indoxrouter-0.1.17.dist-info/top_level.txt,sha256=v6FGWkw0QAnXhyYtnXLI1cxzna0iveNvZUotVzCWabM,12
|
8
|
+
indoxrouter-0.1.17.dist-info/RECORD,,
|
@@ -1,8 +0,0 @@
|
|
1
|
-
indoxrouter/__init__.py,sha256=kwGvH8F5oqm2O4kLs-UtPfcY0AYiy5ZDUg-Sh3iYJA4,1627
|
2
|
-
indoxrouter/client.py,sha256=SQ0ulzkHQZBKFK1dyywjZI_vUQfEd0qVBYQx_8mu7uU,30533
|
3
|
-
indoxrouter/constants.py,sha256=tEmfhfCpuKVos1TxVhJfPlv1P0ePWnjnwso4ZHJ0VhM,1190
|
4
|
-
indoxrouter/exceptions.py,sha256=qs7f9AnJ7SkOyf9N5qRaZIKpECE8uBq1Pvcg19Jif-U,1718
|
5
|
-
indoxrouter-0.1.16.dist-info/METADATA,sha256=wE-sWdHgDNp42hULYxQTx5bO-PB_ydwyvZn4iOTIFYM,5692
|
6
|
-
indoxrouter-0.1.16.dist-info/WHEEL,sha256=zaaOINJESkSfm_4HQVc5ssNzHCPXhJm0kEUakpsEHaU,91
|
7
|
-
indoxrouter-0.1.16.dist-info/top_level.txt,sha256=v6FGWkw0QAnXhyYtnXLI1cxzna0iveNvZUotVzCWabM,12
|
8
|
-
indoxrouter-0.1.16.dist-info/RECORD,,
|
File without changes
|