indoxrouter 0.1.25__py3-none-any.whl → 0.1.26__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/constants.py CHANGED
@@ -1,38 +1,38 @@
1
- """
2
- Constants for the IndoxRouter client.
3
- """
4
-
5
- # API settings
6
- DEFAULT_API_VERSION = "v1"
7
- DEFAULT_BASE_URL = "https://api.indoxrouter.com" # Production server URL with HTTPS
8
- # DEFAULT_BASE_URL = "http://localhost:8000" # Local development server
9
- DEFAULT_TIMEOUT = 60
10
- USE_COOKIES = True # Always use cookie-based authentication
11
-
12
- # Default models
13
- DEFAULT_MODEL = "openai/gpt-4o-mini"
14
- DEFAULT_EMBEDDING_MODEL = "openai/text-embedding-3-small"
15
- DEFAULT_IMAGE_MODEL = "openai/dall-e-3"
16
- DEFAULT_TTS_MODEL = "openai/tts-1"
17
- GOOGLE_IMAGE_MODEL = "google/imagen-3.0-generate-002"
18
- XAI_IMAGE_MODEL = "xai/grok-2-image"
19
- XAI_IMAGE_LATEST_MODEL = "xai/grok-2-image-latest"
20
- XAI_IMAGE_SPECIFIC_MODEL = "xai/grok-2-image-1212"
21
-
22
- # API endpoints
23
- CHAT_ENDPOINT = "chat/completions"
24
- COMPLETION_ENDPOINT = "completions"
25
- EMBEDDING_ENDPOINT = "embeddings"
26
- IMAGE_ENDPOINT = "images/generations"
27
- TTS_ENDPOINT = "tts/generations"
28
- MODEL_ENDPOINT = "models"
29
- USAGE_ENDPOINT = "user/usage"
30
-
31
- # Error messages
32
- ERROR_INVALID_API_KEY = "API key must be provided either as an argument or as the INDOXROUTER_API_KEY environment variable"
33
- ERROR_NETWORK = "Network error occurred while communicating with the IndoxRouter API"
34
- ERROR_RATE_LIMIT = "Rate limit exceeded for the IndoxRouter API"
35
- ERROR_PROVIDER_NOT_FOUND = "Provider not found"
36
- ERROR_MODEL_NOT_FOUND = "Model not found"
37
- ERROR_INVALID_PARAMETERS = "Invalid parameters provided"
38
- ERROR_INSUFFICIENT_CREDITS = "Insufficient credits"
1
+ """
2
+ Constants for the IndoxRouter client.
3
+ """
4
+
5
+ # API settings
6
+ DEFAULT_API_VERSION = "v1"
7
+ DEFAULT_BASE_URL = "https://api.indoxrouter.com" # Production server URL with HTTPS
8
+ # DEFAULT_BASE_URL = "http://localhost:8000" # Local development server
9
+ DEFAULT_TIMEOUT = 60
10
+ USE_COOKIES = True # Always use cookie-based authentication
11
+
12
+ # Default models
13
+ DEFAULT_MODEL = "openai/gpt-4o-mini"
14
+ DEFAULT_EMBEDDING_MODEL = "openai/text-embedding-3-small"
15
+ DEFAULT_IMAGE_MODEL = "openai/dall-e-3"
16
+ DEFAULT_TTS_MODEL = "openai/tts-1"
17
+ GOOGLE_IMAGE_MODEL = "google/imagen-3.0-generate-002"
18
+ XAI_IMAGE_MODEL = "xai/grok-2-image"
19
+ XAI_IMAGE_LATEST_MODEL = "xai/grok-2-image-latest"
20
+ XAI_IMAGE_SPECIFIC_MODEL = "xai/grok-2-image-1212"
21
+
22
+ # API endpoints
23
+ CHAT_ENDPOINT = "chat/completions"
24
+ COMPLETION_ENDPOINT = "completions"
25
+ EMBEDDING_ENDPOINT = "embeddings"
26
+ IMAGE_ENDPOINT = "images/generations"
27
+ TTS_ENDPOINT = "tts/generations"
28
+ MODEL_ENDPOINT = "models"
29
+ USAGE_ENDPOINT = "user/usage"
30
+
31
+ # Error messages
32
+ ERROR_INVALID_API_KEY = "API key must be provided either as an argument or as the INDOXROUTER_API_KEY environment variable"
33
+ ERROR_NETWORK = "Network error occurred while communicating with the IndoxRouter API"
34
+ ERROR_RATE_LIMIT = "Rate limit exceeded for the IndoxRouter API"
35
+ ERROR_PROVIDER_NOT_FOUND = "Provider not found"
36
+ ERROR_MODEL_NOT_FOUND = "Model not found"
37
+ ERROR_INVALID_PARAMETERS = "Invalid parameters provided"
38
+ ERROR_INSUFFICIENT_CREDITS = "Insufficient credits"
indoxrouter/exceptions.py CHANGED
@@ -1,86 +1,86 @@
1
- """
2
- Exceptions for the IndoxRouter client.
3
- """
4
-
5
- from datetime import datetime
6
- from typing import Optional
7
-
8
-
9
- class IndoxRouterError(Exception):
10
- """Base exception for all IndoxRouter errors."""
11
-
12
- pass
13
-
14
-
15
- class AuthenticationError(IndoxRouterError):
16
- """Raised when authentication fails."""
17
-
18
- pass
19
-
20
-
21
- class NetworkError(IndoxRouterError):
22
- """Raised when a network error occurs."""
23
-
24
- pass
25
-
26
-
27
- class RateLimitError(IndoxRouterError):
28
- """Raised when rate limits are exceeded."""
29
-
30
- def __init__(self, message: str, reset_time: Optional[datetime] = None):
31
- super().__init__(message)
32
- self.reset_time = reset_time
33
-
34
-
35
- class ProviderError(IndoxRouterError):
36
- """Raised when a provider returns an error."""
37
-
38
- pass
39
-
40
-
41
- class ProviderNotFoundError(ProviderError):
42
- """Raised when a requested provider is not found."""
43
-
44
- pass
45
-
46
-
47
- class ModelNotFoundError(ProviderError):
48
- """Raised when a requested model is not found."""
49
-
50
- pass
51
-
52
-
53
- class ModelNotAvailableError(ProviderError):
54
- """Raised when a model is disabled or not supported by the provider."""
55
-
56
- pass
57
-
58
-
59
- class InvalidParametersError(IndoxRouterError):
60
- """Raised when invalid parameters are provided."""
61
-
62
- pass
63
-
64
-
65
- class RequestError(IndoxRouterError):
66
- """Raised when a request to a provider fails."""
67
-
68
- pass
69
-
70
-
71
- class InsufficientCreditsError(IndoxRouterError):
72
- """Raised when the user doesn't have enough credits."""
73
-
74
- pass
75
-
76
-
77
- class ValidationError(IndoxRouterError):
78
- """Raised when request validation fails."""
79
-
80
- pass
81
-
82
-
83
- class APIError(IndoxRouterError):
84
- """Raised when the API returns an error."""
85
-
86
- pass
1
+ """
2
+ Exceptions for the IndoxRouter client.
3
+ """
4
+
5
+ from datetime import datetime
6
+ from typing import Optional
7
+
8
+
9
+ class IndoxRouterError(Exception):
10
+ """Base exception for all IndoxRouter errors."""
11
+
12
+ pass
13
+
14
+
15
+ class AuthenticationError(IndoxRouterError):
16
+ """Raised when authentication fails."""
17
+
18
+ pass
19
+
20
+
21
+ class NetworkError(IndoxRouterError):
22
+ """Raised when a network error occurs."""
23
+
24
+ pass
25
+
26
+
27
+ class RateLimitError(IndoxRouterError):
28
+ """Raised when rate limits are exceeded."""
29
+
30
+ def __init__(self, message: str, reset_time: Optional[datetime] = None):
31
+ super().__init__(message)
32
+ self.reset_time = reset_time
33
+
34
+
35
+ class ProviderError(IndoxRouterError):
36
+ """Raised when a provider returns an error."""
37
+
38
+ pass
39
+
40
+
41
+ class ProviderNotFoundError(ProviderError):
42
+ """Raised when a requested provider is not found."""
43
+
44
+ pass
45
+
46
+
47
+ class ModelNotFoundError(ProviderError):
48
+ """Raised when a requested model is not found."""
49
+
50
+ pass
51
+
52
+
53
+ class ModelNotAvailableError(ProviderError):
54
+ """Raised when a model is disabled or not supported by the provider."""
55
+
56
+ pass
57
+
58
+
59
+ class InvalidParametersError(IndoxRouterError):
60
+ """Raised when invalid parameters are provided."""
61
+
62
+ pass
63
+
64
+
65
+ class RequestError(IndoxRouterError):
66
+ """Raised when a request to a provider fails."""
67
+
68
+ pass
69
+
70
+
71
+ class InsufficientCreditsError(IndoxRouterError):
72
+ """Raised when the user doesn't have enough credits."""
73
+
74
+ pass
75
+
76
+
77
+ class ValidationError(IndoxRouterError):
78
+ """Raised when request validation fails."""
79
+
80
+ pass
81
+
82
+
83
+ class APIError(IndoxRouterError):
84
+ """Raised when the API returns an error."""
85
+
86
+ pass
@@ -1,179 +1,179 @@
1
- Metadata-Version: 2.4
2
- Name: indoxrouter
3
- Version: 0.1.25
4
- Summary: A unified client for various AI providers
5
- Author-email: indoxRouter Team <ashkan.eskandari.dev@gmail.com>
6
- License: MIT
7
- Project-URL: Homepage, https://github.com/indoxrouter/indoxrouter
8
- Project-URL: Repository, https://github.com/indoxrouter/indoxrouter
9
- Project-URL: Issues, https://github.com/indoxrouter/indoxrouter/issues
10
- Keywords: ai,api,client,openai,anthropic,google,mistral,xai,imagen,grok,image-generation,text-to-speech,tts,audio
11
- Classifier: Development Status :: 3 - Alpha
12
- Classifier: Intended Audience :: Developers
13
- Classifier: Programming Language :: Python :: 3
14
- Classifier: Programming Language :: Python :: 3.8
15
- Classifier: Programming Language :: Python :: 3.9
16
- Classifier: Programming Language :: Python :: 3.10
17
- Classifier: Programming Language :: Python :: 3.11
18
- Classifier: Programming Language :: Python :: 3.12
19
- Requires-Python: >=3.8
20
- Description-Content-Type: text/markdown
21
- License-File: LICENSE
22
- Requires-Dist: requests>=2.25.0
23
- Requires-Dist: python-dotenv>=1.0.0
24
- Dynamic: license-file
25
-
26
- # IndoxRouter
27
-
28
- A unified client for various AI providers, including OpenAI, anthropic, Google, and Mistral.
29
-
30
- ## Features
31
-
32
- - **Unified API**: Access multiple AI providers through a single API
33
- - **Simple Interface**: Easy-to-use methods for chat, completion, embeddings, image generation, and text-to-speech
34
- - **Error Handling**: Standardized error handling across providers
35
- - **Authentication**: Secure cookie-based authentication
36
-
37
- ## Installation
38
-
39
- ```bash
40
- pip install indoxrouter
41
- ```
42
-
43
- ## Usage
44
-
45
- ### Initialization
46
-
47
- ```python
48
- from indoxrouter import Client
49
-
50
- # Initialize with API key
51
- client = Client(api_key="your_api_key")
52
-
53
- # Using environment variables
54
- # Set INDOX_ROUTER_API_KEY environment variable
55
- import os
56
- os.environ["INDOX_ROUTER_API_KEY"] = "your_api_key"
57
- client = Client()
58
- ```
59
-
60
- ### Authentication
61
-
62
- IndoxRouter uses cookie-based authentication with JWT tokens. The client handles this automatically by:
63
-
64
- 1. Taking your API key and exchanging it for JWT tokens using the server's authentication endpoints
65
- 2. Storing the JWT tokens in cookies
66
- 3. Using the cookies for subsequent requests
67
- 4. Automatically refreshing tokens when they expire
68
-
69
- ```python
70
- # Authentication is handled automatically when creating the client
71
- client = Client(api_key="your_api_key")
72
- ```
73
-
74
- ### Chat Completions
75
-
76
- ```python
77
- response = client.chat(
78
- messages=[
79
- {"role": "system", "content": "You are a helpful assistant."},
80
- {"role": "user", "content": "Tell me a joke."}
81
- ],
82
- model="openai/gpt-4o-mini", # Provider/model format
83
- temperature=0.7
84
- )
85
-
86
- print(response["data"])
87
- ```
88
-
89
- ### Text Completions
90
-
91
- ```python
92
- response = client.completion(
93
- prompt="Once upon a time,",
94
- model="openai/gpt-4o-mini",
95
- max_tokens=100
96
- )
97
-
98
- print(response["data"])
99
- ```
100
-
101
- ### Embeddings
102
-
103
- ```python
104
- response = client.embeddings(
105
- text=["Hello world", "AI is amazing"],
106
- model="openai/text-embedding-3-small"
107
- )
108
-
109
- print(f"Dimensions: {len(response['data'][0]['embedding'])}")
110
- print(f"First embedding: {response['data'][0]['embedding'][:5]}...")
111
- ```
112
-
113
- ### Image Generation
114
-
115
- ```python
116
- # OpenAI Image Generation
117
- response = client.images(
118
- prompt="A serene landscape with mountains and a lake",
119
- model="openai/dall-e-3",
120
- size="1024x1024",
121
- quality="standard", # Options: standard, hd
122
- style="vivid" # Options: vivid, natural
123
- )
124
-
125
- print(f"Image URL: {response['data'][0]['url']}")
126
-
127
-
128
- # Access base64 encoded image data
129
- if "b64_json" in response["data"][0]:
130
- b64_data = response["data"][0]["b64_json"]
131
- # Use the base64 data (e.g., to display in HTML or save to file)
132
- ```
133
-
134
- ### Text-to-Speech
135
-
136
- ```python
137
- # Generate audio from text
138
- response = client.text_to_speech(
139
- input="Hello, welcome to IndoxRouter!",
140
- model="openai/tts-1",
141
- voice="alloy", # Options: alloy, echo, fable, onyx, nova, shimmer
142
- response_format="mp3", # Options: mp3, opus, aac, flac
143
- speed=1.0 # Range: 0.25 to 4.0
144
- )
145
-
146
- print(f"Audio generated successfully: {response['success']}")
147
- print(f"Audio data available: {'data' in response}")
148
- ```
149
-
150
- ### Streaming Responses
151
-
152
- ```python
153
- for chunk in client.chat(
154
- messages=[{"role": "user", "content": "Write a short story."}],
155
- model="openai/gpt-4o-mini",
156
- stream=True
157
- ):
158
- if chunk.choices[0].delta.content:
159
- print(chunk.choices[0].delta.content, end="", flush=True)
160
- ```
161
-
162
- ### Getting Available Models
163
-
164
- ```python
165
- # Get all providers and models
166
- providers = client.models()
167
- for provider in providers:
168
- print(f"Provider: {provider['name']}")
169
- for model in provider["models"]:
170
- print(f" - {model['id']}: {model['description'] or ''}")
171
-
172
- # Get models for a specific provider
173
- openai_provider = client.models("openai")
174
- print(f"OpenAI models: {[m['id'] for m in openai_provider['models']]}")
175
- ```
176
-
177
- ## License
178
-
179
- This project is licensed under the MIT License - see the LICENSE file for details.
1
+ Metadata-Version: 2.4
2
+ Name: indoxrouter
3
+ Version: 0.1.26
4
+ Summary: A unified client for various AI providers
5
+ Author-email: indoxRouter Team <ashkan.eskandari.dev@gmail.com>
6
+ License: MIT
7
+ Project-URL: Homepage, https://github.com/indoxrouter/indoxrouter
8
+ Project-URL: Repository, https://github.com/indoxrouter/indoxrouter
9
+ Project-URL: Issues, https://github.com/indoxrouter/indoxrouter/issues
10
+ Keywords: ai,api,client,openai,anthropic,google,mistral,xai,imagen,grok,image-generation,text-to-speech,tts,audio
11
+ Classifier: Development Status :: 3 - Alpha
12
+ Classifier: Intended Audience :: Developers
13
+ Classifier: Programming Language :: Python :: 3
14
+ Classifier: Programming Language :: Python :: 3.8
15
+ Classifier: Programming Language :: Python :: 3.9
16
+ Classifier: Programming Language :: Python :: 3.10
17
+ Classifier: Programming Language :: Python :: 3.11
18
+ Classifier: Programming Language :: Python :: 3.12
19
+ Requires-Python: >=3.8
20
+ Description-Content-Type: text/markdown
21
+ License-File: LICENSE
22
+ Requires-Dist: requests>=2.25.0
23
+ Requires-Dist: python-dotenv>=1.0.0
24
+ Dynamic: license-file
25
+
26
+ # IndoxRouter
27
+
28
+ A unified client for various AI providers, including OpenAI, anthropic, Google, and Mistral.
29
+
30
+ ## Features
31
+
32
+ - **Unified API**: Access multiple AI providers through a single API
33
+ - **Simple Interface**: Easy-to-use methods for chat, completion, embeddings, image generation, and text-to-speech
34
+ - **Error Handling**: Standardized error handling across providers
35
+ - **Authentication**: Secure cookie-based authentication
36
+
37
+ ## Installation
38
+
39
+ ```bash
40
+ pip install indoxrouter
41
+ ```
42
+
43
+ ## Usage
44
+
45
+ ### Initialization
46
+
47
+ ```python
48
+ from indoxrouter import Client
49
+
50
+ # Initialize with API key
51
+ client = Client(api_key="your_api_key")
52
+
53
+ # Using environment variables
54
+ # Set INDOX_ROUTER_API_KEY environment variable
55
+ import os
56
+ os.environ["INDOX_ROUTER_API_KEY"] = "your_api_key"
57
+ client = Client()
58
+ ```
59
+
60
+ ### Authentication
61
+
62
+ IndoxRouter uses cookie-based authentication with JWT tokens. The client handles this automatically by:
63
+
64
+ 1. Taking your API key and exchanging it for JWT tokens using the server's authentication endpoints
65
+ 2. Storing the JWT tokens in cookies
66
+ 3. Using the cookies for subsequent requests
67
+ 4. Automatically refreshing tokens when they expire
68
+
69
+ ```python
70
+ # Authentication is handled automatically when creating the client
71
+ client = Client(api_key="your_api_key")
72
+ ```
73
+
74
+ ### Chat Completions
75
+
76
+ ```python
77
+ response = client.chat(
78
+ messages=[
79
+ {"role": "system", "content": "You are a helpful assistant."},
80
+ {"role": "user", "content": "Tell me a joke."}
81
+ ],
82
+ model="openai/gpt-4o-mini", # Provider/model format
83
+ temperature=0.7
84
+ )
85
+
86
+ print(response["data"])
87
+ ```
88
+
89
+ ### Text Completions
90
+
91
+ ```python
92
+ response = client.completion(
93
+ prompt="Once upon a time,",
94
+ model="openai/gpt-4o-mini",
95
+ max_tokens=100
96
+ )
97
+
98
+ print(response["data"])
99
+ ```
100
+
101
+ ### Embeddings
102
+
103
+ ```python
104
+ response = client.embeddings(
105
+ text=["Hello world", "AI is amazing"],
106
+ model="openai/text-embedding-3-small"
107
+ )
108
+
109
+ print(f"Dimensions: {len(response['data'][0]['embedding'])}")
110
+ print(f"First embedding: {response['data'][0]['embedding'][:5]}...")
111
+ ```
112
+
113
+ ### Image Generation
114
+
115
+ ```python
116
+ # OpenAI Image Generation
117
+ response = client.images(
118
+ prompt="A serene landscape with mountains and a lake",
119
+ model="openai/dall-e-3",
120
+ size="1024x1024",
121
+ quality="standard", # Options: standard, hd
122
+ style="vivid" # Options: vivid, natural
123
+ )
124
+
125
+ print(f"Image URL: {response['data'][0]['url']}")
126
+
127
+
128
+ # Access base64 encoded image data
129
+ if "b64_json" in response["data"][0]:
130
+ b64_data = response["data"][0]["b64_json"]
131
+ # Use the base64 data (e.g., to display in HTML or save to file)
132
+ ```
133
+
134
+ ### Text-to-Speech
135
+
136
+ ```python
137
+ # Generate audio from text
138
+ response = client.text_to_speech(
139
+ input="Hello, welcome to IndoxRouter!",
140
+ model="openai/tts-1",
141
+ voice="alloy", # Options: alloy, echo, fable, onyx, nova, shimmer
142
+ response_format="mp3", # Options: mp3, opus, aac, flac
143
+ speed=1.0 # Range: 0.25 to 4.0
144
+ )
145
+
146
+ print(f"Audio generated successfully: {response['success']}")
147
+ print(f"Audio data available: {'data' in response}")
148
+ ```
149
+
150
+ ### Streaming Responses
151
+
152
+ ```python
153
+ for chunk in client.chat(
154
+ messages=[{"role": "user", "content": "Write a short story."}],
155
+ model="openai/gpt-4o-mini",
156
+ stream=True
157
+ ):
158
+ if chunk.choices[0].delta.content:
159
+ print(chunk.choices[0].delta.content, end="", flush=True)
160
+ ```
161
+
162
+ ### Getting Available Models
163
+
164
+ ```python
165
+ # Get all providers and models
166
+ providers = client.models()
167
+ for provider in providers:
168
+ print(f"Provider: {provider['name']}")
169
+ for model in provider["models"]:
170
+ print(f" - {model['id']}: {model['description'] or ''}")
171
+
172
+ # Get models for a specific provider
173
+ openai_provider = client.models("openai")
174
+ print(f"OpenAI models: {[m['id'] for m in openai_provider['models']]}")
175
+ ```
176
+
177
+ ## License
178
+
179
+ This project is licensed under the MIT License - see the LICENSE file for details.
@@ -0,0 +1,9 @@
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,,