indoxrouter 0.1.22__py3-none-any.whl → 0.1.23__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 +86 -4
- {indoxrouter-0.1.22.dist-info → indoxrouter-0.1.23.dist-info}/METADATA +1 -1
- indoxrouter-0.1.23.dist-info/RECORD +8 -0
- indoxrouter-0.1.22.dist-info/RECORD +0 -8
- {indoxrouter-0.1.22.dist-info → indoxrouter-0.1.23.dist-info}/WHEEL +0 -0
- {indoxrouter-0.1.22.dist-info → indoxrouter-0.1.23.dist-info}/top_level.txt +0 -0
indoxrouter/client.py
CHANGED
@@ -673,6 +673,15 @@ class Client:
|
|
673
673
|
if provider.lower() == "google":
|
674
674
|
# For Google, use aspect_ratio instead of size
|
675
675
|
if aspect_ratio is not None:
|
676
|
+
# Google's imagen-3 has specific supported aspect ratios
|
677
|
+
if model_name == "imagen-3.0-generate-002" and aspect_ratio not in [
|
678
|
+
"1:1",
|
679
|
+
"3:4",
|
680
|
+
"4:3",
|
681
|
+
"9:16",
|
682
|
+
"16:9",
|
683
|
+
]:
|
684
|
+
aspect_ratio = "1:1" # Default to 1:1 if not supported
|
676
685
|
data["aspect_ratio"] = aspect_ratio
|
677
686
|
elif size is not None:
|
678
687
|
# Convert size to aspect_ratio
|
@@ -686,7 +695,7 @@ class Client:
|
|
686
695
|
elif provider.lower() == "xai":
|
687
696
|
# xAI doesn't support size parameter - do not include it
|
688
697
|
pass
|
689
|
-
elif size is not None:
|
698
|
+
elif size is not None and provider.lower() != "xai":
|
690
699
|
# For other providers (like OpenAI), use size as is
|
691
700
|
data["size"] = size
|
692
701
|
|
@@ -697,7 +706,9 @@ class Client:
|
|
697
706
|
|
698
707
|
# Add standard parameters if provided
|
699
708
|
if response_format is not None:
|
709
|
+
# Only add response_format if explicitly provided by the user
|
700
710
|
data["response_format"] = response_format
|
711
|
+
|
701
712
|
if user is not None:
|
702
713
|
data["user"] = user
|
703
714
|
|
@@ -739,14 +750,85 @@ class Client:
|
|
739
750
|
if filtered_kwargs:
|
740
751
|
data["additional_params"] = filtered_kwargs
|
741
752
|
|
742
|
-
# Special case handling for specific models
|
753
|
+
# Special case handling for specific models and providers
|
754
|
+
# Only include parameters supported by each model based on their JSON definitions
|
743
755
|
if provider.lower() == "openai" and "gpt-image" in model_name.lower():
|
744
|
-
#
|
745
|
-
if response_format
|
756
|
+
# For OpenAI's gpt-image models, don't automatically add response_format
|
757
|
+
if "response_format" in data and response_format is None:
|
746
758
|
del data["response_format"]
|
747
759
|
|
760
|
+
if provider.lower() == "xai" and "grok-2-image" in model_name.lower():
|
761
|
+
# For xAI's grok-2-image models, ensure size is not included
|
762
|
+
if "size" in data:
|
763
|
+
del data["size"]
|
764
|
+
|
765
|
+
# Clean up any parameters that shouldn't be sent to specific providers
|
766
|
+
# This ensures we only send parameters that each provider supports
|
767
|
+
supported_params = self._get_supported_parameters_for_model(
|
768
|
+
provider, model_name
|
769
|
+
)
|
770
|
+
if supported_params:
|
771
|
+
for param in list(data.keys()):
|
772
|
+
if param not in ["prompt", "model"] and param not in supported_params:
|
773
|
+
del data[param]
|
774
|
+
|
748
775
|
return self._request("POST", IMAGE_ENDPOINT, data)
|
749
776
|
|
777
|
+
def _get_supported_parameters_for_model(
|
778
|
+
self, provider: str, model_name: str
|
779
|
+
) -> List[str]:
|
780
|
+
"""
|
781
|
+
Get the list of supported parameters for a specific model.
|
782
|
+
This helps avoid sending unsupported parameters to providers.
|
783
|
+
|
784
|
+
Args:
|
785
|
+
provider: The provider name (e.g., 'openai', 'google', 'xai')
|
786
|
+
model_name: The model name (e.g., 'gpt-image-1', 'imagen-3.0-generate-002')
|
787
|
+
|
788
|
+
Returns:
|
789
|
+
List of parameter names supported by the model
|
790
|
+
"""
|
791
|
+
# Define supported parameters for specific models
|
792
|
+
if provider.lower() == "openai" and "gpt-image" in model_name.lower():
|
793
|
+
return [
|
794
|
+
"prompt",
|
795
|
+
"size",
|
796
|
+
"quality",
|
797
|
+
"n",
|
798
|
+
"user",
|
799
|
+
"background",
|
800
|
+
"moderation",
|
801
|
+
"output_compression",
|
802
|
+
"output_format",
|
803
|
+
"style",
|
804
|
+
]
|
805
|
+
|
806
|
+
elif provider.lower() == "google" and "imagen" in model_name.lower():
|
807
|
+
return [
|
808
|
+
"prompt",
|
809
|
+
"n",
|
810
|
+
"negative_prompt",
|
811
|
+
"aspect_ratio",
|
812
|
+
"guidance_scale",
|
813
|
+
"seed",
|
814
|
+
"safety_filter_level",
|
815
|
+
"person_generation",
|
816
|
+
"include_safety_attributes",
|
817
|
+
"include_rai_reason",
|
818
|
+
"language",
|
819
|
+
"output_mime_type",
|
820
|
+
"output_compression_quality",
|
821
|
+
"add_watermark",
|
822
|
+
"enhance_prompt",
|
823
|
+
"response_format",
|
824
|
+
]
|
825
|
+
|
826
|
+
elif provider.lower() == "xai" and "grok-2-image" in model_name.lower():
|
827
|
+
return ["prompt", "n", "response_format"]
|
828
|
+
|
829
|
+
# Default case - allow all parameters
|
830
|
+
return []
|
831
|
+
|
750
832
|
def models(self, provider: Optional[str] = None) -> Dict[str, Any]:
|
751
833
|
"""
|
752
834
|
Get available models.
|
@@ -0,0 +1,8 @@
|
|
1
|
+
indoxrouter/__init__.py,sha256=kwGvH8F5oqm2O4kLs-UtPfcY0AYiy5ZDUg-Sh3iYJA4,1627
|
2
|
+
indoxrouter/client.py,sha256=GwdZJiUARBGcD-A_VI1vFXWtvhQTF-3dDCBz-1qtrhk,41632
|
3
|
+
indoxrouter/constants.py,sha256=GezZ9nuwK3A37xpWlcfXCrMsIIlCdP7xnvEkPBMyn5g,1383
|
4
|
+
indoxrouter/exceptions.py,sha256=qs7f9AnJ7SkOyf9N5qRaZIKpECE8uBq1Pvcg19Jif-U,1718
|
5
|
+
indoxrouter-0.1.23.dist-info/METADATA,sha256=xUem08HFj7X3WWvcbqg70fOW4W4f04-Yb7BSw13zBb0,6639
|
6
|
+
indoxrouter-0.1.23.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
7
|
+
indoxrouter-0.1.23.dist-info/top_level.txt,sha256=v6FGWkw0QAnXhyYtnXLI1cxzna0iveNvZUotVzCWabM,12
|
8
|
+
indoxrouter-0.1.23.dist-info/RECORD,,
|
@@ -1,8 +0,0 @@
|
|
1
|
-
indoxrouter/__init__.py,sha256=kwGvH8F5oqm2O4kLs-UtPfcY0AYiy5ZDUg-Sh3iYJA4,1627
|
2
|
-
indoxrouter/client.py,sha256=oAUpx_RDpEIHav_dgb4sc7f_Agji3UXPlvMWLFCnQwE,38437
|
3
|
-
indoxrouter/constants.py,sha256=GezZ9nuwK3A37xpWlcfXCrMsIIlCdP7xnvEkPBMyn5g,1383
|
4
|
-
indoxrouter/exceptions.py,sha256=qs7f9AnJ7SkOyf9N5qRaZIKpECE8uBq1Pvcg19Jif-U,1718
|
5
|
-
indoxrouter-0.1.22.dist-info/METADATA,sha256=aULhnVEH964jtJCoedkHH1SMCGZMkAJl3FK6CYsE-KY,6639
|
6
|
-
indoxrouter-0.1.22.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
7
|
-
indoxrouter-0.1.22.dist-info/top_level.txt,sha256=v6FGWkw0QAnXhyYtnXLI1cxzna0iveNvZUotVzCWabM,12
|
8
|
-
indoxrouter-0.1.22.dist-info/RECORD,,
|
File without changes
|
File without changes
|