indoxrouter 0.1.16__tar.gz → 0.1.18__tar.gz

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.
@@ -1,16 +1,15 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: indoxrouter
3
- Version: 0.1.16
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
@@ -110,13 +110,43 @@ print(f"First embedding: {response['data'][0]['embedding'][:5]}...")
110
110
  ### Image Generation
111
111
 
112
112
  ```python
113
+ # OpenAI Image Generation
113
114
  response = client.images(
114
115
  prompt="A serene landscape with mountains and a lake",
115
116
  model="openai/dall-e-3",
116
- size="1024x1024"
117
+ size="1024x1024",
118
+ quality="standard", # Options: standard, hd
119
+ style="vivid" # Options: vivid, natural
117
120
  )
118
121
 
119
122
  print(f"Image URL: {response['data'][0]['url']}")
123
+
124
+ # Google Imagen Image Generation
125
+ from indoxrouter.constants import GOOGLE_IMAGE_MODEL
126
+
127
+ response = client.images(
128
+ prompt="A robot holding a red skateboard in a futuristic city",
129
+ model=GOOGLE_IMAGE_MODEL,
130
+ n=2, # Generate 2 images
131
+ negative_prompt="broken, damaged, low quality",
132
+ guidance_scale=7.5, # Control adherence to prompt
133
+ seed=42, # For reproducible results
134
+ )
135
+
136
+ # xAI Grok Image Generation
137
+ from indoxrouter.constants import XAI_IMAGE_MODEL
138
+
139
+ response = client.images(
140
+ prompt="A cat in a tree",
141
+ model=XAI_IMAGE_MODEL,
142
+ n=1,
143
+ response_format="b64_json" # Get base64 encoded image
144
+ )
145
+
146
+ # Access base64 encoded image data
147
+ if "b64_json" in response["data"][0]:
148
+ b64_data = response["data"][0]["b64_json"]
149
+ # Use the base64 data (e.g., to display in HTML or save to file)
120
150
  ```
121
151
 
122
152
  ### Streaming Responses
@@ -206,14 +206,15 @@
206
206
  "metadata": {},
207
207
  "outputs": [],
208
208
  "source": [
209
+ "from indoxrouter import Client\n",
210
+ "client = Client(api_key=\"your-api-key\")\n",
211
+ "\n",
209
212
  "response = client.chat(\n",
210
213
  " messages=[\n",
211
214
  " {\"role\": \"system\", \"content\": \"You are a helpful assistant.\"},\n",
212
- " {\"role\": \"user\", \"content\": \"Write a short poem about AI.\"}\n",
215
+ " {\"role\": \"user\", \"content\": \"What is the capital of France?\"}\n",
213
216
  " ],\n",
214
- " model=\"deepseek/deepseek-chat\",\n",
215
- " temperature=0.8,\n",
216
- " max_tokens=500\n",
217
+ " model=\"openai/gpt-4o-mini\" \n",
217
218
  ")\n",
218
219
  "\n",
219
220
  "print(\"Response:\", response[\"data\"])\n",
@@ -531,10 +531,30 @@ class Client:
531
531
  self,
532
532
  prompt: str,
533
533
  model: str = DEFAULT_IMAGE_MODEL,
534
- size: str = "1024x1024",
535
- n: int = 1,
536
- quality: str = "standard",
537
- style: str = "vivid",
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
- size: Image size (e.g., "1024x1024")
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]:
@@ -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.16
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
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "indoxrouter"
7
- version = "0.1.16"
7
+ version = "0.1.18"
8
8
  authors = [
9
9
  {name = "indoxRouter Team", email = "ashkan.eskandari.dev@gmail.com"},
10
10
  ]
@@ -12,11 +12,10 @@ description = "A unified client for various AI providers"
12
12
  readme = "README.md"
13
13
  requires-python = ">=3.8"
14
14
  license = {text = "MIT"}
15
- keywords = ["ai", "api", "client", "openai", "anthropic", "google", "mistral"]
15
+ keywords = ["ai", "api", "client", "openai", "anthropic", "google", "mistral", "xai", "imagen", "grok", "image-generation"]
16
16
  classifiers = [
17
17
  "Development Status :: 3 - Alpha",
18
18
  "Intended Audience :: Developers",
19
- "License :: OSI Approved :: MIT License",
20
19
  "Programming Language :: Python :: 3",
21
20
  "Programming Language :: Python :: 3.8",
22
21
  "Programming Language :: Python :: 3.9",
File without changes
File without changes