indoxrouter 0.1.26__py3-none-any.whl → 0.1.27__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/__init__.py CHANGED
@@ -47,7 +47,7 @@ from .exceptions import (
47
47
  APIError,
48
48
  )
49
49
 
50
- __version__ = "0.1.26"
50
+ __version__ = "0.1.27"
51
51
  __all__ = [
52
52
  "Client",
53
53
  "IndoxRouter",
indoxrouter/client.py CHANGED
@@ -14,6 +14,7 @@ The Client class offers methods for:
14
14
  - Accessing AI capabilities: chat completions, text completions, embeddings, image generation, and text-to-speech
15
15
  - Retrieving information about available providers and models
16
16
  - Monitoring usage statistics and credit consumption
17
+ - BYOK (Bring Your Own Key) support for using your own provider API keys
17
18
 
18
19
  Usage example:
19
20
  ```python
@@ -37,6 +38,11 @@ Usage example:
37
38
  # Generate text-to-speech audio
38
39
  audio = client.text_to_speech("Hello, welcome to IndoxRouter!", model="openai/tts-1", voice="alloy")
39
40
 
41
+ # Using BYOK (Bring Your Own Key)
42
+ response = client.chat([
43
+ {"role": "user", "content": "Hello!"}
44
+ ], model="openai/gpt-4", byok_api_key="sk-your-openai-key-here")
45
+
40
46
  # Clean up resources when done
41
47
  client.close()
42
48
  ```
@@ -46,6 +52,21 @@ The client can also be used as a context manager:
46
52
  with Client(api_key="your_api_key") as client:
47
53
  response = client.chat([{"role": "user", "content": "Hello!"}], model="openai/gpt-4o-mini")
48
54
  ```
55
+
56
+ BYOK (Bring Your Own Key) Support:
57
+ The client supports BYOK, allowing you to use your own API keys for AI providers:
58
+
59
+ - No credit deduction from your IndoxRouter account
60
+ - No rate limiting from the platform
61
+ - Direct provider access with your own API keys
62
+ - Cost control - you pay providers directly at their rates
63
+
64
+ Example:
65
+ response = client.chat(
66
+ messages=[{"role": "user", "content": "Hello!"}],
67
+ model="openai/gpt-4",
68
+ byok_api_key="sk-your-openai-key-here"
69
+ )
49
70
  """
50
71
 
51
72
  import os
@@ -459,6 +480,7 @@ class Client:
459
480
  temperature: float = 0.7,
460
481
  max_tokens: Optional[int] = None,
461
482
  stream: bool = False,
483
+ byok_api_key: Optional[str] = None,
462
484
  **kwargs,
463
485
  ) -> Dict[str, Any]:
464
486
  """
@@ -470,6 +492,7 @@ class Client:
470
492
  temperature: Sampling temperature
471
493
  max_tokens: Maximum number of tokens to generate
472
494
  stream: Whether to stream the response
495
+ byok_api_key: Your own API key for the provider (BYOK - Bring Your Own Key)
473
496
  **kwargs: Additional parameters to pass to the API
474
497
 
475
498
  Returns:
@@ -490,6 +513,7 @@ class Client:
490
513
  "temperature": temperature,
491
514
  "max_tokens": max_tokens,
492
515
  "stream": stream,
516
+ "byok_api_key": byok_api_key,
493
517
  "additional_params": filtered_kwargs,
494
518
  }
495
519
 
@@ -506,6 +530,7 @@ class Client:
506
530
  temperature: float = 0.7,
507
531
  max_tokens: Optional[int] = None,
508
532
  stream: bool = False,
533
+ byok_api_key: Optional[str] = None,
509
534
  **kwargs,
510
535
  ) -> Dict[str, Any]:
511
536
  """
@@ -517,6 +542,7 @@ class Client:
517
542
  temperature: Sampling temperature
518
543
  max_tokens: Maximum number of tokens to generate
519
544
  stream: Whether to stream the response
545
+ byok_api_key: Your own API key for the provider (BYOK - Bring Your Own Key)
520
546
  **kwargs: Additional parameters to pass to the API
521
547
 
522
548
  Returns:
@@ -537,6 +563,7 @@ class Client:
537
563
  "temperature": temperature,
538
564
  "max_tokens": max_tokens,
539
565
  "stream": stream,
566
+ "byok_api_key": byok_api_key,
540
567
  "additional_params": filtered_kwargs,
541
568
  }
542
569
 
@@ -550,6 +577,7 @@ class Client:
550
577
  self,
551
578
  text: Union[str, List[str]],
552
579
  model: str = DEFAULT_EMBEDDING_MODEL,
580
+ byok_api_key: Optional[str] = None,
553
581
  **kwargs,
554
582
  ) -> Dict[str, Any]:
555
583
  """
@@ -558,6 +586,7 @@ class Client:
558
586
  Args:
559
587
  text: Text to embed (string or list of strings)
560
588
  model: Model to use in the format "provider/model" (e.g., "openai/text-embedding-ada-002")
589
+ byok_api_key: Your own API key for the provider (BYOK - Bring Your Own Key)
561
590
  **kwargs: Additional parameters to pass to the API
562
591
 
563
592
  Returns:
@@ -575,6 +604,7 @@ class Client:
575
604
  data = {
576
605
  "text": text if isinstance(text, list) else [text],
577
606
  "model": formatted_model,
607
+ "byok_api_key": byok_api_key,
578
608
  "additional_params": filtered_kwargs,
579
609
  }
580
610
 
@@ -610,6 +640,7 @@ class Client:
610
640
  enhance_prompt: Optional[bool] = None,
611
641
  # Google-specific direct parameters
612
642
  aspect_ratio: Optional[str] = None,
643
+ byok_api_key: Optional[str] = None,
613
644
  **kwargs,
614
645
  ) -> Dict[str, Any]:
615
646
  """
@@ -650,6 +681,8 @@ class Client:
650
681
  enhance_prompt: Whether to use prompt rewriting logic
651
682
  aspect_ratio: Aspect ratio for Google models (e.g., "1:1", "16:9") - preferred over size
652
683
 
684
+ byok_api_key: Your own API key for the provider (BYOK - Bring Your Own Key)
685
+
653
686
  **kwargs: Additional parameters to pass to the API
654
687
 
655
688
  Returns:
@@ -674,6 +707,7 @@ class Client:
674
707
  data = {
675
708
  "prompt": prompt,
676
709
  "model": formatted_model,
710
+ "byok_api_key": byok_api_key,
677
711
  }
678
712
 
679
713
  # Add optional parameters only if they are explicitly provided
@@ -793,6 +827,7 @@ class Client:
793
827
  response_format: Optional[str] = None,
794
828
  speed: Optional[float] = None,
795
829
  instructions: Optional[str] = None,
830
+ byok_api_key: Optional[str] = None,
796
831
  **kwargs,
797
832
  ) -> Dict[str, Any]:
798
833
  """
@@ -805,6 +840,7 @@ class Client:
805
840
  response_format: Format of the audio response (e.g., "mp3", "opus", "aac", "flac")
806
841
  speed: Speed of the generated audio (0.25 to 4.0)
807
842
  instructions: Optional instructions for the TTS generation
843
+ byok_api_key: Your own API key for the provider (BYOK - Bring Your Own Key)
808
844
  **kwargs: Additional parameters to pass to the API
809
845
 
810
846
  Returns:
@@ -829,6 +865,13 @@ class Client:
829
865
  model="provider/model-name",
830
866
  voice="provider-specific-voice"
831
867
  )
868
+
869
+ Using BYOK (Bring Your Own Key):
870
+ response = client.text_to_speech(
871
+ "Hello, world!",
872
+ model="openai/tts-1",
873
+ byok_api_key="sk-your-openai-key-here"
874
+ )
832
875
  """
833
876
  # Format the model string
834
877
  formatted_model = self._format_model_string(model)
@@ -859,6 +902,10 @@ class Client:
859
902
  if filtered_kwargs:
860
903
  data["additional_params"] = filtered_kwargs
861
904
 
905
+ # Add BYOK API key if provided
906
+ if byok_api_key:
907
+ data["byok_api_key"] = byok_api_key
908
+
862
909
  return self._request("POST", TTS_ENDPOINT, data)
863
910
 
864
911
  def _get_supported_parameters_for_model(
@@ -875,7 +922,6 @@ class Client:
875
922
  Returns:
876
923
  List of parameter names supported by the model
877
924
  """
878
- # Define supported parameters for specific models
879
925
  if provider.lower() == "openai" and "gpt-image" in model_name.lower():
880
926
  return [
881
927
  "prompt",
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: indoxrouter
3
- Version: 0.1.26
3
+ Version: 0.1.27
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
@@ -33,6 +33,7 @@ A unified client for various AI providers, including OpenAI, anthropic, Google,
33
33
  - **Simple Interface**: Easy-to-use methods for chat, completion, embeddings, image generation, and text-to-speech
34
34
  - **Error Handling**: Standardized error handling across providers
35
35
  - **Authentication**: Secure cookie-based authentication
36
+ - **BYOK Support**: Bring Your Own Key support for using your own provider API keys
36
37
 
37
38
  ## Installation
38
39
 
@@ -131,6 +132,34 @@ if "b64_json" in response["data"][0]:
131
132
  # Use the base64 data (e.g., to display in HTML or save to file)
132
133
  ```
133
134
 
135
+ ### BYOK (Bring Your Own Key) Support
136
+
137
+ IndoxRouter supports BYOK, allowing you to use your own API keys for AI providers:
138
+
139
+ ```python
140
+ # Use your own OpenAI API key
141
+ response = client.chat(
142
+ messages=[{"role": "user", "content": "Hello!"}],
143
+ model="openai/gpt-4",
144
+ byok_api_key="sk-your-openai-key-here"
145
+ )
146
+
147
+ # Use your own Google API key for image generation
148
+ response = client.images(
149
+ prompt="A beautiful sunset",
150
+ model="google/imagen-3.0-generate-002",
151
+ aspect_ratio="16:9",
152
+ byok_api_key="your-google-api-key-here"
153
+ )
154
+ ```
155
+
156
+ **BYOK Benefits:**
157
+
158
+ - No credit deduction from your IndoxRouter account
159
+ - No platform rate limiting
160
+ - Direct provider access with your own API keys
161
+ - Cost control - pay providers directly at their rates
162
+
134
163
  ### Text-to-Speech
135
164
 
136
165
  ```python
@@ -0,0 +1,9 @@
1
+ indoxrouter/__init__.py,sha256=P_2eiiAi-DrkkeeJndQdEMqnVheWzOZIjWkDayrwxuk,1561
2
+ indoxrouter/client.py,sha256=AirPauY2kFqpR46LWOtDBKs--_9ilFTc2RQHb7vsLnM,45694
3
+ indoxrouter/constants.py,sha256=HqTXfNpL_UvWsR5mod8YZgWOs1W6x6itr1BSbmyYEHY,1451
4
+ indoxrouter/exceptions.py,sha256=cGlXNF8dd4X8UBWgxTA099nRhEkIjcqE_4iGOlIVVp8,1632
5
+ indoxrouter-0.1.27.dist-info/licenses/LICENSE,sha256=5n28CfoynFakg-QJIHnecEXcveN8gq-ZwhC0h7ATse0,24232
6
+ indoxrouter-0.1.27.dist-info/METADATA,sha256=5bZ0cAhmLFMuRP8h_5uNOEPwu39xjIqUaT_6CEjyi_k,5740
7
+ indoxrouter-0.1.27.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
8
+ indoxrouter-0.1.27.dist-info/top_level.txt,sha256=v6FGWkw0QAnXhyYtnXLI1cxzna0iveNvZUotVzCWabM,12
9
+ indoxrouter-0.1.27.dist-info/RECORD,,
@@ -1,9 +0,0 @@
1
- indoxrouter/__init__.py,sha256=NhFlmJxbxcM3XCF21YZv9QsOk-k50rsqzw5Bk3mmr6E,1561
2
- indoxrouter/client.py,sha256=KQpOFaTntNYmPgYjBJHq0z921vgKlyeUcaTYgZX7axM,43764
3
- indoxrouter/constants.py,sha256=HqTXfNpL_UvWsR5mod8YZgWOs1W6x6itr1BSbmyYEHY,1451
4
- indoxrouter/exceptions.py,sha256=cGlXNF8dd4X8UBWgxTA099nRhEkIjcqE_4iGOlIVVp8,1632
5
- indoxrouter-0.1.26.dist-info/licenses/LICENSE,sha256=5n28CfoynFakg-QJIHnecEXcveN8gq-ZwhC0h7ATse0,24232
6
- indoxrouter-0.1.26.dist-info/METADATA,sha256=nzfcnbrzEJznKEPA1gAG34-C5KjemPqUavXO2e8-3fs,4909
7
- indoxrouter-0.1.26.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
8
- indoxrouter-0.1.26.dist-info/top_level.txt,sha256=v6FGWkw0QAnXhyYtnXLI1cxzna0iveNvZUotVzCWabM,12
9
- indoxrouter-0.1.26.dist-info/RECORD,,