indoxrouter 0.1.2__py3-none-any.whl → 0.1.3__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-0.1.3.dist-info/METADATA +188 -0
- indoxrouter-0.1.3.dist-info/RECORD +4 -0
- indoxrouter-0.1.3.dist-info/top_level.txt +1 -0
- indoxRouter/__init__.py +0 -83
- indoxRouter/client.py +0 -632
- indoxRouter/client_resourses/__init__.py +0 -20
- indoxRouter/client_resourses/base.py +0 -67
- indoxRouter/client_resourses/chat.py +0 -144
- indoxRouter/client_resourses/completion.py +0 -138
- indoxRouter/client_resourses/embedding.py +0 -83
- indoxRouter/client_resourses/image.py +0 -116
- indoxRouter/client_resourses/models.py +0 -114
- indoxRouter/config.py +0 -151
- indoxRouter/constants/__init__.py +0 -81
- indoxRouter/exceptions/__init__.py +0 -70
- indoxRouter/models/__init__.py +0 -111
- indoxRouter/providers/__init__.py +0 -108
- indoxRouter/providers/ai21labs.json +0 -128
- indoxRouter/providers/base_provider.py +0 -101
- indoxRouter/providers/claude.json +0 -164
- indoxRouter/providers/cohere.json +0 -116
- indoxRouter/providers/databricks.json +0 -110
- indoxRouter/providers/deepseek.json +0 -110
- indoxRouter/providers/google.json +0 -128
- indoxRouter/providers/meta.json +0 -128
- indoxRouter/providers/mistral.json +0 -146
- indoxRouter/providers/nvidia.json +0 -110
- indoxRouter/providers/openai.json +0 -308
- indoxRouter/providers/openai.py +0 -521
- indoxRouter/providers/qwen.json +0 -110
- indoxRouter/utils/__init__.py +0 -240
- indoxrouter-0.1.2.dist-info/LICENSE +0 -21
- indoxrouter-0.1.2.dist-info/METADATA +0 -259
- indoxrouter-0.1.2.dist-info/RECORD +0 -33
- indoxrouter-0.1.2.dist-info/top_level.txt +0 -1
- {indoxrouter-0.1.2.dist-info → indoxrouter-0.1.3.dist-info}/WHEEL +0 -0
indoxRouter/utils/__init__.py
DELETED
@@ -1,240 +0,0 @@
|
|
1
|
-
"""
|
2
|
-
Utilities module for indoxRouter.
|
3
|
-
This module contains utility functions used throughout the application.
|
4
|
-
"""
|
5
|
-
|
6
|
-
import os
|
7
|
-
import json
|
8
|
-
import time
|
9
|
-
import datetime
|
10
|
-
from typing import Dict, List, Any, Optional, Union
|
11
|
-
from datetime import datetime
|
12
|
-
from pathlib import Path
|
13
|
-
|
14
|
-
from ..exceptions import ProviderNotFoundError, ModelNotFoundError
|
15
|
-
|
16
|
-
|
17
|
-
def load_provider_models(provider_name: str) -> List[Dict[str, Any]]:
|
18
|
-
"""
|
19
|
-
Load models for a specific provider from the JSON file.
|
20
|
-
|
21
|
-
Args:
|
22
|
-
provider_name: The name of the provider.
|
23
|
-
|
24
|
-
Returns:
|
25
|
-
A list of model dictionaries.
|
26
|
-
|
27
|
-
Raises:
|
28
|
-
ProviderNotFoundError: If the provider JSON file is not found.
|
29
|
-
"""
|
30
|
-
# Get the directory of the current file
|
31
|
-
current_dir = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
32
|
-
providers_dir = os.path.join(current_dir, "providers")
|
33
|
-
provider_file = os.path.join(providers_dir, f"{provider_name}.json")
|
34
|
-
if not os.path.exists(provider_file):
|
35
|
-
raise ProviderNotFoundError(f"Provider '{provider_name}' not found.")
|
36
|
-
|
37
|
-
with open(provider_file, "r") as f:
|
38
|
-
return json.load(f)
|
39
|
-
|
40
|
-
|
41
|
-
def get_model_info(provider_name: str, model_name: str) -> Dict[str, Any]:
|
42
|
-
"""
|
43
|
-
Get information about a specific model from a provider.
|
44
|
-
|
45
|
-
Args:
|
46
|
-
provider_name: The name of the provider.
|
47
|
-
model_name: The name of the model.
|
48
|
-
|
49
|
-
Returns:
|
50
|
-
A dictionary containing information about the model.
|
51
|
-
|
52
|
-
Raises:
|
53
|
-
ProviderNotFoundError: If the provider is not found.
|
54
|
-
ModelNotFoundError: If the model is not found.
|
55
|
-
"""
|
56
|
-
models = load_provider_models(provider_name)
|
57
|
-
|
58
|
-
for model in models:
|
59
|
-
if model.get("modelName") == model_name:
|
60
|
-
return model
|
61
|
-
|
62
|
-
raise ModelNotFoundError(
|
63
|
-
f"Model '{model_name}' not found for provider '{provider_name}'."
|
64
|
-
)
|
65
|
-
|
66
|
-
|
67
|
-
# def calculate_cost(
|
68
|
-
# provider_name: str, model_name: str, input_tokens: int, output_tokens: int
|
69
|
-
# ) -> float:
|
70
|
-
# """
|
71
|
-
# Calculate the cost of a request based on the provider, model, and token counts.
|
72
|
-
|
73
|
-
# Args:
|
74
|
-
# provider_name: The name of the provider.
|
75
|
-
# model_name: The name of the model.
|
76
|
-
# input_tokens: The number of input tokens.
|
77
|
-
# output_tokens: The number of output tokens.
|
78
|
-
|
79
|
-
# Returns:
|
80
|
-
# The cost of the request.
|
81
|
-
|
82
|
-
# Raises:
|
83
|
-
# ProviderNotFoundError: If the provider is not found.
|
84
|
-
# ModelNotFoundError: If the model is not found.
|
85
|
-
# """
|
86
|
-
# model_info = get_model_info(provider_name, model_name)
|
87
|
-
|
88
|
-
# input_cost = model_info.get("inputPricePer1KTokens", 0) * (input_tokens / 1000)
|
89
|
-
# output_cost = model_info.get("outputPricePer1KTokens", 0) * (output_tokens / 1000)
|
90
|
-
|
91
|
-
# return input_cost + output_cost
|
92
|
-
|
93
|
-
|
94
|
-
def list_available_providers() -> List[str]:
|
95
|
-
"""
|
96
|
-
List all available providers.
|
97
|
-
|
98
|
-
Returns:
|
99
|
-
A list of provider names.
|
100
|
-
"""
|
101
|
-
current_dir = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
102
|
-
providers_dir = os.path.join(current_dir, "providers")
|
103
|
-
|
104
|
-
providers = []
|
105
|
-
for file in os.listdir(providers_dir):
|
106
|
-
if file.endswith(".json"):
|
107
|
-
providers.append(file[:-5]) # Remove .json extension
|
108
|
-
|
109
|
-
return providers
|
110
|
-
|
111
|
-
|
112
|
-
def list_available_models(
|
113
|
-
provider_name: Optional[str] = None,
|
114
|
-
) -> Dict[str, List[Dict[str, Any]]]:
|
115
|
-
"""
|
116
|
-
List all available models, optionally filtered by provider.
|
117
|
-
|
118
|
-
Args:
|
119
|
-
provider_name: The name of the provider to filter by. If None, lists models from all providers.
|
120
|
-
|
121
|
-
Returns:
|
122
|
-
A dictionary mapping provider names to lists of model dictionaries.
|
123
|
-
|
124
|
-
Raises:
|
125
|
-
ProviderNotFoundError: If the specified provider is not found.
|
126
|
-
"""
|
127
|
-
if provider_name:
|
128
|
-
return {provider_name: load_provider_models(provider_name)}
|
129
|
-
|
130
|
-
providers = list_available_providers()
|
131
|
-
models = {}
|
132
|
-
|
133
|
-
for provider in providers:
|
134
|
-
try:
|
135
|
-
models[provider] = load_provider_models(provider)
|
136
|
-
except ProviderNotFoundError:
|
137
|
-
continue
|
138
|
-
|
139
|
-
return models
|
140
|
-
|
141
|
-
|
142
|
-
def count_tokens(text: Union[str, List[Dict[str, str]]]) -> int:
|
143
|
-
"""
|
144
|
-
Count the number of tokens in a text or list of messages.
|
145
|
-
|
146
|
-
This is a simplified placeholder implementation for development mode.
|
147
|
-
In a production environment, you would use a proper tokenizer.
|
148
|
-
|
149
|
-
Args:
|
150
|
-
text: The text or list of messages to count tokens for.
|
151
|
-
|
152
|
-
Returns:
|
153
|
-
The estimated number of tokens.
|
154
|
-
"""
|
155
|
-
if isinstance(text, str):
|
156
|
-
# Very rough approximation: 1 token ≈ 4 characters
|
157
|
-
return len(text) // 4
|
158
|
-
elif isinstance(text, list):
|
159
|
-
# For chat messages, count tokens in each message
|
160
|
-
total = 0
|
161
|
-
for message in text:
|
162
|
-
if isinstance(message, dict) and "content" in message:
|
163
|
-
total += len(message["content"]) // 4
|
164
|
-
elif hasattr(message, "content"):
|
165
|
-
total += len(message.content) // 4
|
166
|
-
return total
|
167
|
-
return 0
|
168
|
-
|
169
|
-
|
170
|
-
def calculate_cost(model: str, input_tokens: int, output_tokens: int = 0) -> float:
|
171
|
-
"""
|
172
|
-
Calculate the cost of a request based on the provider/model and token counts.
|
173
|
-
|
174
|
-
Args:
|
175
|
-
model: Provider and model name in format "provider/model_name"
|
176
|
-
input_tokens: Number of input tokens used
|
177
|
-
output_tokens: Number of output tokens used
|
178
|
-
|
179
|
-
Returns:
|
180
|
-
The calculated cost in USD
|
181
|
-
"""
|
182
|
-
try:
|
183
|
-
provider, model_name = model.split("/", 1)
|
184
|
-
except ValueError:
|
185
|
-
raise ValueError(
|
186
|
-
f"Invalid model format: {model}. Expected 'provider/model_name'"
|
187
|
-
)
|
188
|
-
|
189
|
-
# # Load provider's model data
|
190
|
-
# json_path = Path(__file__).parent / "providers" / f"{provider}.json"
|
191
|
-
# try:
|
192
|
-
# with open(json_path, "r") as f:
|
193
|
-
# models = json.load(f)
|
194
|
-
# except FileNotFoundError:
|
195
|
-
# raise ValueError(f"Provider not found: {provider}")
|
196
|
-
models = load_provider_models(provider_name=provider)
|
197
|
-
|
198
|
-
# Find model in JSON data
|
199
|
-
model_info: Optional[dict] = next(
|
200
|
-
(m for m in models if m.get("modelName") == model_name), None
|
201
|
-
)
|
202
|
-
|
203
|
-
if not model_info:
|
204
|
-
raise ValueError(f"Model not found: {model_name} in provider {provider}")
|
205
|
-
|
206
|
-
# Handle different model types
|
207
|
-
model_type = model_info.get("type", "Text Generation").lower()
|
208
|
-
|
209
|
-
if "image" in model_type:
|
210
|
-
# Image models - price per image
|
211
|
-
# Assume inputPricePer1KTokens is price per image
|
212
|
-
return input_tokens * model_info.get("inputPricePer1KTokens", 0.0)
|
213
|
-
|
214
|
-
# Text models - price per token
|
215
|
-
input_cost = (input_tokens / 1000) * model_info.get("inputPricePer1KTokens", 0.0)
|
216
|
-
output_cost = (output_tokens / 1000) * model_info.get("outputPricePer1KTokens", 0.0)
|
217
|
-
return input_cost + output_cost
|
218
|
-
|
219
|
-
|
220
|
-
def format_timestamp(timestamp: Union[int, float, datetime, None] = None) -> str:
|
221
|
-
"""
|
222
|
-
Format a timestamp as a human-readable string.
|
223
|
-
|
224
|
-
Args:
|
225
|
-
timestamp: The timestamp to format. If None, uses the current time.
|
226
|
-
|
227
|
-
Returns:
|
228
|
-
A formatted timestamp string.
|
229
|
-
"""
|
230
|
-
if timestamp is None:
|
231
|
-
timestamp = time.time()
|
232
|
-
|
233
|
-
if isinstance(timestamp, (int, float)):
|
234
|
-
dt = datetime.fromtimestamp(timestamp)
|
235
|
-
elif isinstance(timestamp, datetime):
|
236
|
-
dt = timestamp
|
237
|
-
else:
|
238
|
-
dt = datetime.now()
|
239
|
-
|
240
|
-
return dt.strftime("%Y-%m-%d %H:%M:%S")
|
@@ -1,21 +0,0 @@
|
|
1
|
-
MIT License
|
2
|
-
|
3
|
-
Copyright (c) 2025 indoxRouter Team
|
4
|
-
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
7
|
-
in the Software without restriction, including without limitation the rights
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
10
|
-
furnished to do so, subject to the following conditions:
|
11
|
-
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
13
|
-
copies or substantial portions of the Software.
|
14
|
-
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
-
SOFTWARE.
|
@@ -1,259 +0,0 @@
|
|
1
|
-
Metadata-Version: 2.2
|
2
|
-
Name: indoxrouter
|
3
|
-
Version: 0.1.2
|
4
|
-
Summary: A unified interface for various LLM providers
|
5
|
-
Home-page: https://github.com/indoxrouter/indoxrouter
|
6
|
-
Author: indoxRouter Team
|
7
|
-
Author-email: ashkan.eskandari.dev@gmail.com
|
8
|
-
Classifier: Development Status :: 3 - Alpha
|
9
|
-
Classifier: Intended Audience :: Developers
|
10
|
-
Classifier: License :: OSI Approved :: MIT License
|
11
|
-
Classifier: Programming Language :: Python :: 3
|
12
|
-
Classifier: Programming Language :: Python :: 3.8
|
13
|
-
Classifier: Programming Language :: Python :: 3.9
|
14
|
-
Classifier: Programming Language :: Python :: 3.10
|
15
|
-
Classifier: Programming Language :: Python :: 3.11
|
16
|
-
Requires-Python: >=3.8
|
17
|
-
Description-Content-Type: text/markdown
|
18
|
-
License-File: LICENSE
|
19
|
-
Requires-Dist: requests>=2.25.0
|
20
|
-
Requires-Dist: openai>=1.0.0
|
21
|
-
Requires-Dist: PyJWT>=2.0.0
|
22
|
-
Requires-Dist: tiktoken>=0.4.0
|
23
|
-
Provides-Extra: dev
|
24
|
-
Requires-Dist: pytest>=7.0.0; extra == "dev"
|
25
|
-
Requires-Dist: pytest-cov>=4.0.0; extra == "dev"
|
26
|
-
Requires-Dist: black>=23.0.0; extra == "dev"
|
27
|
-
Requires-Dist: isort>=5.0.0; extra == "dev"
|
28
|
-
Requires-Dist: flake8>=6.0.0; extra == "dev"
|
29
|
-
Requires-Dist: mypy>=1.0.0; extra == "dev"
|
30
|
-
Provides-Extra: postgres
|
31
|
-
Requires-Dist: psycopg2-binary>=2.9.5; extra == "postgres"
|
32
|
-
Provides-Extra: all
|
33
|
-
Requires-Dist: pytest>=7.0.0; extra == "all"
|
34
|
-
Requires-Dist: pytest-cov>=4.0.0; extra == "all"
|
35
|
-
Requires-Dist: black>=23.0.0; extra == "all"
|
36
|
-
Requires-Dist: isort>=5.0.0; extra == "all"
|
37
|
-
Requires-Dist: flake8>=6.0.0; extra == "all"
|
38
|
-
Requires-Dist: mypy>=1.0.0; extra == "all"
|
39
|
-
Requires-Dist: psycopg2-binary>=2.9.5; extra == "all"
|
40
|
-
Dynamic: author
|
41
|
-
Dynamic: author-email
|
42
|
-
Dynamic: classifier
|
43
|
-
Dynamic: description
|
44
|
-
Dynamic: description-content-type
|
45
|
-
Dynamic: home-page
|
46
|
-
Dynamic: provides-extra
|
47
|
-
Dynamic: requires-dist
|
48
|
-
Dynamic: requires-python
|
49
|
-
Dynamic: summary
|
50
|
-
|
51
|
-
# indoxRouter
|
52
|
-
|
53
|
-
<p align="center">
|
54
|
-
<img src="https://raw.githubusercontent.com/indoxrouter/indoxrouter/main/docs/assets/logo.png" alt="indoxRouter Logo" width="200"/>
|
55
|
-
</p>
|
56
|
-
|
57
|
-
<p align="center">
|
58
|
-
<strong>A unified interface for various LLM providers</strong>
|
59
|
-
</p>
|
60
|
-
|
61
|
-
<p align="center">
|
62
|
-
<a href="https://pypi.org/project/indoxRouter/"><img src="https://img.shields.io/pypi/v/indoxRouter.svg" alt="PyPI version"></a>
|
63
|
-
<a href="https://github.com/indoxrouter/indoxrouter/blob/main/LICENSE"><img src="https://img.shields.io/github/license/indoxrouter/indoxrouter" alt="License"></a>
|
64
|
-
<a href="https://github.com/indoxrouter/indoxrouter/stargazers"><img src="https://img.shields.io/github/stars/indoxrouter/indoxrouter" alt="GitHub stars"></a>
|
65
|
-
</p>
|
66
|
-
|
67
|
-
## Overview
|
68
|
-
|
69
|
-
indoxRouter is a powerful Python library that provides a unified interface to interact with various Large Language Model (LLM) providers. With a single API key, you can access models from OpenAI, Anthropic, Mistral, Google, and more, without having to manage multiple provider-specific API keys and implementations.
|
70
|
-
|
71
|
-
### Key Features
|
72
|
-
|
73
|
-
- **Single API for Multiple Providers**: Access models from OpenAI, Anthropic, Mistral, Google, and more with a single API key
|
74
|
-
- **Standardized Response Format**: Consistent response format across all providers
|
75
|
-
- **Streaming Support**: Stream responses for real-time applications
|
76
|
-
- **Cost Tracking**: Track token usage and costs across providers
|
77
|
-
- **Rate Limiting**: Built-in rate limiting to prevent exceeding provider quotas
|
78
|
-
- **Error Handling**: Comprehensive error handling with detailed error messages
|
79
|
-
- **Authentication**: Secure authentication with JWT tokens
|
80
|
-
- **Type Hints**: Full type hints for better IDE support
|
81
|
-
|
82
|
-
## Installation
|
83
|
-
|
84
|
-
```bash
|
85
|
-
pip install indoxRouter
|
86
|
-
```
|
87
|
-
|
88
|
-
For development:
|
89
|
-
|
90
|
-
```bash
|
91
|
-
pip install indoxRouter[dev]
|
92
|
-
```
|
93
|
-
|
94
|
-
## Quick Start
|
95
|
-
|
96
|
-
```python
|
97
|
-
from indoxRouter import Client
|
98
|
-
from indoxRouter.models import ChatMessage
|
99
|
-
|
100
|
-
# Initialize the client with your API key
|
101
|
-
client = Client(api_key="your-api-key")
|
102
|
-
|
103
|
-
# Chat completion with OpenAI
|
104
|
-
response = client.chat(
|
105
|
-
messages=[
|
106
|
-
{"role": "user", "content": "What are three fun activities to do in New York?"}
|
107
|
-
],
|
108
|
-
model="openai/gpt-4o-mini",
|
109
|
-
temperature=0.7,
|
110
|
-
max_tokens=500,
|
111
|
-
)
|
112
|
-
|
113
|
-
print(response.data)
|
114
|
-
```
|
115
|
-
|
116
|
-
## Available Providers
|
117
|
-
|
118
|
-
indoxRouter supports the following providers:
|
119
|
-
|
120
|
-
- OpenAI
|
121
|
-
- Anthropic (Claude)
|
122
|
-
- Mistral
|
123
|
-
- Google
|
124
|
-
- Cohere
|
125
|
-
|
126
|
-
## Core Features
|
127
|
-
|
128
|
-
### Chat Completion
|
129
|
-
|
130
|
-
```python
|
131
|
-
response = client.chat(
|
132
|
-
messages=[
|
133
|
-
{"role": "user", "content": "What are three fun activities to do in New York?"}
|
134
|
-
],
|
135
|
-
model="openai/gpt-4o-mini",
|
136
|
-
temperature=0.7,
|
137
|
-
max_tokens=500,
|
138
|
-
)
|
139
|
-
```
|
140
|
-
|
141
|
-
### Text Completion
|
142
|
-
|
143
|
-
```python
|
144
|
-
response = client.completion(
|
145
|
-
prompt="Write a short story about a robot learning to paint.",
|
146
|
-
model="anthropic/claude-3-haiku",
|
147
|
-
temperature=0.7,
|
148
|
-
max_tokens=500,
|
149
|
-
)
|
150
|
-
```
|
151
|
-
|
152
|
-
### Embeddings
|
153
|
-
|
154
|
-
```python
|
155
|
-
response = client.embeddings(
|
156
|
-
text="This is a sample text to embed.",
|
157
|
-
model="openai/text-embedding-3-small",
|
158
|
-
)
|
159
|
-
```
|
160
|
-
|
161
|
-
### Image Generation
|
162
|
-
|
163
|
-
```python
|
164
|
-
response = client.image(
|
165
|
-
prompt="A futuristic city with flying cars and neon lights",
|
166
|
-
model="openai/dall-e-3",
|
167
|
-
size="1024x1024",
|
168
|
-
)
|
169
|
-
```
|
170
|
-
|
171
|
-
### Streaming
|
172
|
-
|
173
|
-
```python
|
174
|
-
generator = client.chat(
|
175
|
-
messages=[
|
176
|
-
{"role": "user", "content": "Write a short story about a robot learning to paint."}
|
177
|
-
],
|
178
|
-
model="openai/gpt-4o-mini",
|
179
|
-
temperature=0.7,
|
180
|
-
max_tokens=500,
|
181
|
-
stream=True,
|
182
|
-
return_generator=True,
|
183
|
-
)
|
184
|
-
|
185
|
-
for chunk in generator:
|
186
|
-
if isinstance(chunk, dict) and chunk.get("is_usage_info"):
|
187
|
-
# This is the final usage info
|
188
|
-
usage_info = chunk
|
189
|
-
else:
|
190
|
-
# This is a content chunk
|
191
|
-
print(chunk, end="", flush=True)
|
192
|
-
```
|
193
|
-
|
194
|
-
## Provider and Model Information
|
195
|
-
|
196
|
-
```python
|
197
|
-
# List all available providers
|
198
|
-
providers = client.providers()
|
199
|
-
|
200
|
-
# List all available models
|
201
|
-
models = client.models()
|
202
|
-
|
203
|
-
# List models for a specific provider
|
204
|
-
openai_models = client.models(provider="openai")
|
205
|
-
|
206
|
-
# Get information about a specific model
|
207
|
-
model_info = client.model_info(provider="openai", model="gpt-4o-mini")
|
208
|
-
```
|
209
|
-
|
210
|
-
## Configuration
|
211
|
-
|
212
|
-
indoxRouter can be configured using environment variables or a configuration file:
|
213
|
-
|
214
|
-
```python
|
215
|
-
# Set API key via environment variable
|
216
|
-
import os
|
217
|
-
os.environ["INDOX_ROUTER_API_KEY"] = "your-api-key"
|
218
|
-
|
219
|
-
# Or provide it directly to the client
|
220
|
-
client = Client(api_key="your-api-key")
|
221
|
-
```
|
222
|
-
|
223
|
-
## Error Handling
|
224
|
-
|
225
|
-
indoxRouter provides comprehensive error handling:
|
226
|
-
|
227
|
-
```python
|
228
|
-
from indoxRouter import Client
|
229
|
-
from indoxRouter.exceptions import AuthenticationError, RateLimitError, ProviderError
|
230
|
-
|
231
|
-
try:
|
232
|
-
client = Client(api_key="invalid-api-key")
|
233
|
-
except AuthenticationError as e:
|
234
|
-
print(f"Authentication error: {e}")
|
235
|
-
|
236
|
-
try:
|
237
|
-
response = client.chat(
|
238
|
-
messages=[{"role": "user", "content": "Hello"}],
|
239
|
-
model="nonexistent-model",
|
240
|
-
)
|
241
|
-
except ProviderError as e:
|
242
|
-
print(f"Provider error: {e}")
|
243
|
-
```
|
244
|
-
|
245
|
-
## Documentation
|
246
|
-
|
247
|
-
For detailed documentation, visit [https://docs.indoxrouter.com](https://docs.indoxrouter.com).
|
248
|
-
|
249
|
-
## Examples
|
250
|
-
|
251
|
-
Check out the [examples](https://github.com/indoxrouter/indoxrouter/tree/main/examples) directory for more examples.
|
252
|
-
|
253
|
-
## Contributing
|
254
|
-
|
255
|
-
Contributions are welcome! Please feel free to submit a Pull Request.
|
256
|
-
|
257
|
-
## License
|
258
|
-
|
259
|
-
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
|
@@ -1,33 +0,0 @@
|
|
1
|
-
indoxRouter/__init__.py,sha256=ef8oDKpOUhY4S49x-Eg1K-icOecp5RaqcgubGkqCrwU,1824
|
2
|
-
indoxRouter/client.py,sha256=zrKhWPvWM78ez8Ns_Fte5HMpAv_KYBLLj9EP3Kc1Wgc,23966
|
3
|
-
indoxRouter/config.py,sha256=xteXenUUevWzUZtyFr42QhTSQox9fKZS-Vq24NUjJjo,4743
|
4
|
-
indoxRouter/client_resourses/__init__.py,sha256=lSZ5g4w-kgPgV0IoZcdZLCbdrjwqr-pADMygTijyUss,419
|
5
|
-
indoxRouter/client_resourses/base.py,sha256=8DgdH7KamL-nMNDWo14aL2AYi_lyd1F-ZEJF7dBcxpk,2005
|
6
|
-
indoxRouter/client_resourses/chat.py,sha256=mN91qH7H4hwflzPyJL1_Ms4B3zhLnllebchxJU2rFGc,5879
|
7
|
-
indoxRouter/client_resourses/completion.py,sha256=sURd_zezP8_mym9n3FlVc6vsKK_XobC5YfJJWaRULg0,5540
|
8
|
-
indoxRouter/client_resourses/embedding.py,sha256=aEYWeNAeIW44E9-l8Ny3I1wcIE2qxKMvF7puzrSknoE,3019
|
9
|
-
indoxRouter/client_resourses/image.py,sha256=ekb1kFU_tM7A3ooUAImssQkxhbQy4nNfoGW1uzARfhU,4125
|
10
|
-
indoxRouter/client_resourses/models.py,sha256=9fmCclmi8qwR4do9tE1LtpdodK9mp4IDiVW6QjDYThY,4408
|
11
|
-
indoxRouter/constants/__init__.py,sha256=6WZOK7l2dPM3092SoHhCrRJATig6ivRPTQk7nbdlXtg,2526
|
12
|
-
indoxRouter/exceptions/__init__.py,sha256=7Mr8QIk7kIb9bFAd1-0EyCo9MiO0N8FvEjgSW9Fjaus,1348
|
13
|
-
indoxRouter/models/__init__.py,sha256=Cueovar4aQkFHnww2E1nONZGpBFykxdiSnTqTSG6sOs,2655
|
14
|
-
indoxRouter/providers/__init__.py,sha256=fjQcH2OQ_4fQ1jQdOuKe7VM2sX7cyqUUnH2hb82gs1M,2682
|
15
|
-
indoxRouter/providers/ai21labs.json,sha256=r4U51otfBLV_-c_zlOdmN5nt1FhiK9bBATpUo6Hdn8s,4989
|
16
|
-
indoxRouter/providers/base_provider.py,sha256=2q9kAiMZRGvE_TAQ6m6s16gDHeEeVbIdpYaqNcg3klA,2864
|
17
|
-
indoxRouter/providers/claude.json,sha256=gwzrLR-qCXq3IhEW0m8LWTaNi0flZWgXHZHphmB7JrU,6910
|
18
|
-
indoxRouter/providers/cohere.json,sha256=20Jg0ZliyqLlFEi1FBgdDxDuEnVcjbr4uCMS0krh9Y4,4118
|
19
|
-
indoxRouter/providers/databricks.json,sha256=-eLQPofwxjA8r9kZUqO0kcOlM9TIoAay4tRVOT-_60U,4425
|
20
|
-
indoxRouter/providers/deepseek.json,sha256=APDn9il3DwxZMEMpBC8YA1m7BjYi-NFRuaHR6RtTJ80,4394
|
21
|
-
indoxRouter/providers/google.json,sha256=T_hdsXh9Hhc2GAMc_8sUtQPGyN5VBqUl6dW2hjZPamo,5175
|
22
|
-
indoxRouter/providers/meta.json,sha256=Ww7vvg3mXMgC9qRljOmfRHG0KluJiudIPJTst-XysTc,5118
|
23
|
-
indoxRouter/providers/mistral.json,sha256=U_IVyaJIax4emtcCRLX-sKpcfMolGqe0yST2IZ6x6uM,6132
|
24
|
-
indoxRouter/providers/nvidia.json,sha256=6Wgak1dK-1XSIXkUGXRQ9x_31690_iyfUAFB_Vk6EGA,4449
|
25
|
-
indoxRouter/providers/openai.json,sha256=KottFrhRwPtH2-dG1ZkV_CwugIwP91Vz_JIL5vD2uoc,12898
|
26
|
-
indoxRouter/providers/openai.py,sha256=txYxP6vn7mDKrqiT2q_7VkHfxBaQn9UDOmiPg13Ec_E,19539
|
27
|
-
indoxRouter/providers/qwen.json,sha256=ZCLI0F1EhADMJbZLrQblaF2Tdk2dQRuqiUc28CUQ-F0,4299
|
28
|
-
indoxRouter/utils/__init__.py,sha256=6Q23YJ-rcv4i9KEio-k8_wxWqSUb7sz68FuO938XbG0,7557
|
29
|
-
indoxrouter-0.1.2.dist-info/LICENSE,sha256=nuibjVB_tq0uUGN2C60mkjAP0Fdz73mNKO4ucT3aIJg,1093
|
30
|
-
indoxrouter-0.1.2.dist-info/METADATA,sha256=v8sYAlH05n-W4OEbq5od2NsEWLQncnrPH7o_rkZ08_4,7403
|
31
|
-
indoxrouter-0.1.2.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
|
32
|
-
indoxrouter-0.1.2.dist-info/top_level.txt,sha256=m_uFNrFxPIq7tGC2XYm2tw2Xx3cxEAkv1l_4lH-RmlQ,12
|
33
|
-
indoxrouter-0.1.2.dist-info/RECORD,,
|
@@ -1 +0,0 @@
|
|
1
|
-
indoxRouter
|
File without changes
|