indoxrouter 0.1.16__py3-none-any.whl → 0.1.18__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 +110 -13
- indoxrouter/constants.py +4 -0
- {indoxrouter-0.1.16.dist-info → indoxrouter-0.1.18.dist-info}/METADATA +33 -4
- indoxrouter-0.1.18.dist-info/RECORD +8 -0
- {indoxrouter-0.1.16.dist-info → indoxrouter-0.1.18.dist-info}/WHEEL +1 -1
- indoxrouter-0.1.16.dist-info/RECORD +0 -8
- {indoxrouter-0.1.16.dist-info → indoxrouter-0.1.18.dist-info}/top_level.txt +0 -0
indoxrouter/client.py
CHANGED
@@ -531,10 +531,30 @@ class Client:
|
|
531
531
|
self,
|
532
532
|
prompt: str,
|
533
533
|
model: str = DEFAULT_IMAGE_MODEL,
|
534
|
-
size: str =
|
535
|
-
n: int =
|
536
|
-
quality: str =
|
537
|
-
style: str =
|
534
|
+
size: Optional[str] = None,
|
535
|
+
n: Optional[int] = None,
|
536
|
+
quality: Optional[str] = None,
|
537
|
+
style: Optional[str] = None,
|
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,38 @@ 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")
|
546
|
-
|
565
|
+
model: Model to use in the format "provider/model" (e.g., "openai/dall-e-3", "google/imagen-3.0-generate-002")
|
566
|
+
|
567
|
+
# Provider-specific parameters - will only be included if explicitly provided
|
568
|
+
# Note: Different providers support different parameters
|
569
|
+
size: Image size - For OpenAI: "1024x1024", "512x512", etc. For Google: "1:1", "4:3", etc.
|
547
570
|
n: Number of images to generate
|
548
|
-
quality: Image quality (e.g., "standard", "hd")
|
549
|
-
style: Image style (e.g., "vivid", "natural")
|
571
|
+
quality: Image quality (e.g., "standard", "hd") - supported by some providers
|
572
|
+
style: Image style (e.g., "vivid", "natural") - supported by some providers
|
573
|
+
|
574
|
+
# Standard parameters
|
575
|
+
response_format: Format of the response - "url" or "b64_json"
|
576
|
+
user: A unique identifier for the end-user
|
577
|
+
|
578
|
+
# OpenAI-specific parameters
|
579
|
+
background: Background style - "transparent", "opaque", or "auto"
|
580
|
+
moderation: Moderation level - "low" or "auto"
|
581
|
+
output_compression: Compression quality for output images (0-100)
|
582
|
+
output_format: Output format - "png", "jpeg", or "webp"
|
583
|
+
|
584
|
+
# Google-specific parameters
|
585
|
+
negative_prompt: Description of what to discourage in the generated images
|
586
|
+
guidance_scale: Controls how much the model adheres to the prompt
|
587
|
+
seed: Random seed for image generation
|
588
|
+
safety_filter_level: Filter level for safety filtering
|
589
|
+
person_generation: Controls generation of people ("dont_allow", "allow_adult", "allow_all")
|
590
|
+
include_safety_attributes: Whether to report safety scores of generated images
|
591
|
+
include_rai_reason: Whether to include filter reason if the image is filtered
|
592
|
+
language: Language of the text in the prompt
|
593
|
+
output_mime_type: MIME type of the generated image
|
594
|
+
add_watermark: Whether to add a watermark to the generated images
|
595
|
+
enhance_prompt: Whether to use prompt rewriting logic
|
596
|
+
|
550
597
|
**kwargs: Additional parameters to pass to the API
|
551
598
|
|
552
599
|
Returns:
|
@@ -561,16 +608,66 @@ class Client:
|
|
561
608
|
if key not in ["return_generator"]: # List of parameters to exclude
|
562
609
|
filtered_kwargs[key] = value
|
563
610
|
|
611
|
+
# Create the base request data with only the required parameters
|
564
612
|
data = {
|
565
613
|
"prompt": prompt,
|
566
614
|
"model": formatted_model,
|
567
|
-
"n": n,
|
568
|
-
"size": size,
|
569
|
-
"quality": quality,
|
570
|
-
"style": style,
|
571
|
-
"additional_params": filtered_kwargs,
|
572
615
|
}
|
573
616
|
|
617
|
+
# Add optional parameters only if they are explicitly provided
|
618
|
+
if n is not None:
|
619
|
+
data["n"] = n
|
620
|
+
if size is not None:
|
621
|
+
data["size"] = size
|
622
|
+
if quality is not None:
|
623
|
+
data["quality"] = quality
|
624
|
+
if style is not None:
|
625
|
+
data["style"] = style
|
626
|
+
|
627
|
+
# Add standard parameters if provided
|
628
|
+
if response_format is not None:
|
629
|
+
data["response_format"] = response_format
|
630
|
+
if user is not None:
|
631
|
+
data["user"] = user
|
632
|
+
|
633
|
+
# Add OpenAI-specific parameters if provided
|
634
|
+
if background is not None:
|
635
|
+
data["background"] = background
|
636
|
+
if moderation is not None:
|
637
|
+
data["moderation"] = moderation
|
638
|
+
if output_compression is not None:
|
639
|
+
data["output_compression"] = output_compression
|
640
|
+
if output_format is not None:
|
641
|
+
data["output_format"] = output_format
|
642
|
+
|
643
|
+
# Add Google-specific parameters if provided
|
644
|
+
if negative_prompt is not None:
|
645
|
+
data["negative_prompt"] = negative_prompt
|
646
|
+
if guidance_scale is not None:
|
647
|
+
data["guidance_scale"] = guidance_scale
|
648
|
+
if seed is not None:
|
649
|
+
data["seed"] = seed
|
650
|
+
if safety_filter_level is not None:
|
651
|
+
data["safety_filter_level"] = safety_filter_level
|
652
|
+
if person_generation is not None:
|
653
|
+
data["person_generation"] = person_generation
|
654
|
+
if include_safety_attributes is not None:
|
655
|
+
data["include_safety_attributes"] = include_safety_attributes
|
656
|
+
if include_rai_reason is not None:
|
657
|
+
data["include_rai_reason"] = include_rai_reason
|
658
|
+
if language is not None:
|
659
|
+
data["language"] = language
|
660
|
+
if output_mime_type is not None:
|
661
|
+
data["output_mime_type"] = output_mime_type
|
662
|
+
if add_watermark is not None:
|
663
|
+
data["add_watermark"] = add_watermark
|
664
|
+
if enhance_prompt is not None:
|
665
|
+
data["enhance_prompt"] = enhance_prompt
|
666
|
+
|
667
|
+
# Add any remaining parameters
|
668
|
+
if filtered_kwargs:
|
669
|
+
data["additional_params"] = filtered_kwargs
|
670
|
+
|
574
671
|
return self._request("POST", IMAGE_ENDPOINT, data)
|
575
672
|
|
576
673
|
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.18
|
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=j1ESSti83R9_fDiYEop0FJqtho0e2FuYes92XY7iImI,35263
|
3
|
+
indoxrouter/constants.py,sha256=GezZ9nuwK3A37xpWlcfXCrMsIIlCdP7xnvEkPBMyn5g,1383
|
4
|
+
indoxrouter/exceptions.py,sha256=qs7f9AnJ7SkOyf9N5qRaZIKpECE8uBq1Pvcg19Jif-U,1718
|
5
|
+
indoxrouter-0.1.18.dist-info/METADATA,sha256=2K3ms5FkCR1L_PkApVOwzF10AHZWh-nn6yi9GvqDlQE,6639
|
6
|
+
indoxrouter-0.1.18.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
7
|
+
indoxrouter-0.1.18.dist-info/top_level.txt,sha256=v6FGWkw0QAnXhyYtnXLI1cxzna0iveNvZUotVzCWabM,12
|
8
|
+
indoxrouter-0.1.18.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
|