indoxrouter 0.1.2__tar.gz → 0.1.4__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.
Files changed (48) hide show
  1. indoxrouter-0.1.4/MANIFEST.in +4 -0
  2. indoxrouter-0.1.4/PKG-INFO +195 -0
  3. indoxrouter-0.1.4/README.md +157 -0
  4. indoxrouter-0.1.4/cookbook/README.md +44 -0
  5. indoxrouter-0.1.4/cookbook/indoxRouter_cookbook.ipynb +1276 -0
  6. indoxrouter-0.1.4/indoxrouter.egg-info/PKG-INFO +195 -0
  7. indoxrouter-0.1.4/indoxrouter.egg-info/SOURCES.txt +10 -0
  8. indoxrouter-0.1.4/indoxrouter.egg-info/requires.txt +10 -0
  9. indoxrouter-0.1.4/indoxrouter.egg-info/top_level.txt +1 -0
  10. {indoxrouter-0.1.2 → indoxrouter-0.1.4}/setup.py +6 -23
  11. indoxrouter-0.1.2/LICENSE +0 -21
  12. indoxrouter-0.1.2/PKG-INFO +0 -259
  13. indoxrouter-0.1.2/README.md +0 -209
  14. indoxrouter-0.1.2/indoxRouter/__init__.py +0 -83
  15. indoxrouter-0.1.2/indoxRouter/client.py +0 -632
  16. indoxrouter-0.1.2/indoxRouter/client_resourses/__init__.py +0 -20
  17. indoxrouter-0.1.2/indoxRouter/client_resourses/base.py +0 -67
  18. indoxrouter-0.1.2/indoxRouter/client_resourses/chat.py +0 -144
  19. indoxrouter-0.1.2/indoxRouter/client_resourses/completion.py +0 -138
  20. indoxrouter-0.1.2/indoxRouter/client_resourses/embedding.py +0 -83
  21. indoxrouter-0.1.2/indoxRouter/client_resourses/image.py +0 -116
  22. indoxrouter-0.1.2/indoxRouter/client_resourses/models.py +0 -114
  23. indoxrouter-0.1.2/indoxRouter/config.py +0 -151
  24. indoxrouter-0.1.2/indoxRouter/constants/__init__.py +0 -81
  25. indoxrouter-0.1.2/indoxRouter/exceptions/__init__.py +0 -70
  26. indoxrouter-0.1.2/indoxRouter/models/__init__.py +0 -111
  27. indoxrouter-0.1.2/indoxRouter/providers/__init__.py +0 -108
  28. indoxrouter-0.1.2/indoxRouter/providers/ai21labs.json +0 -128
  29. indoxrouter-0.1.2/indoxRouter/providers/base_provider.py +0 -101
  30. indoxrouter-0.1.2/indoxRouter/providers/claude.json +0 -164
  31. indoxrouter-0.1.2/indoxRouter/providers/cohere.json +0 -116
  32. indoxrouter-0.1.2/indoxRouter/providers/databricks.json +0 -110
  33. indoxrouter-0.1.2/indoxRouter/providers/deepseek.json +0 -110
  34. indoxrouter-0.1.2/indoxRouter/providers/google.json +0 -128
  35. indoxrouter-0.1.2/indoxRouter/providers/meta.json +0 -128
  36. indoxrouter-0.1.2/indoxRouter/providers/mistral.json +0 -146
  37. indoxrouter-0.1.2/indoxRouter/providers/nvidia.json +0 -110
  38. indoxrouter-0.1.2/indoxRouter/providers/openai.json +0 -308
  39. indoxrouter-0.1.2/indoxRouter/providers/openai.py +0 -521
  40. indoxrouter-0.1.2/indoxRouter/providers/qwen.json +0 -110
  41. indoxrouter-0.1.2/indoxRouter/utils/__init__.py +0 -240
  42. indoxrouter-0.1.2/indoxRouter.egg-info/PKG-INFO +0 -259
  43. indoxrouter-0.1.2/indoxRouter.egg-info/SOURCES.txt +0 -42
  44. indoxrouter-0.1.2/indoxRouter.egg-info/requires.txt +0 -24
  45. indoxrouter-0.1.2/indoxRouter.egg-info/top_level.txt +0 -1
  46. indoxrouter-0.1.2/tests/test_client.py +0 -136
  47. {indoxrouter-0.1.2/indoxRouter.egg-info → indoxrouter-0.1.4/indoxrouter.egg-info}/dependency_links.txt +0 -0
  48. {indoxrouter-0.1.2 → indoxrouter-0.1.4}/setup.cfg +0 -0
@@ -0,0 +1,4 @@
1
+ include README.md
2
+ include LICENSE
3
+ recursive-include cookbook *.md *.ipynb
4
+ recursive-include examples *.py
@@ -0,0 +1,195 @@
1
+ Metadata-Version: 2.2
2
+ Name: indoxrouter
3
+ Version: 0.1.4
4
+ Summary: A unified client for various AI 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
+ Classifier: Programming Language :: Python :: 3.12
17
+ Requires-Python: >=3.8
18
+ Description-Content-Type: text/markdown
19
+ Requires-Dist: requests>=2.25.0
20
+ Requires-Dist: python-dotenv>=1.0.0
21
+ Provides-Extra: dev
22
+ Requires-Dist: pytest>=7.0.0; extra == "dev"
23
+ Requires-Dist: pytest-cov>=4.0.0; extra == "dev"
24
+ Requires-Dist: black>=23.0.0; extra == "dev"
25
+ Requires-Dist: isort>=5.0.0; extra == "dev"
26
+ Requires-Dist: flake8>=6.0.0; extra == "dev"
27
+ Requires-Dist: mypy>=1.0.0; extra == "dev"
28
+ Dynamic: author
29
+ Dynamic: author-email
30
+ Dynamic: classifier
31
+ Dynamic: description
32
+ Dynamic: description-content-type
33
+ Dynamic: home-page
34
+ Dynamic: provides-extra
35
+ Dynamic: requires-dist
36
+ Dynamic: requires-python
37
+ Dynamic: summary
38
+
39
+ # IndoxRouter Client
40
+
41
+ A unified client for various AI providers, including OpenAI, Anthropic, Google, and Mistral.
42
+
43
+ ## Features
44
+
45
+ - **Unified API**: Access multiple AI providers through a single API
46
+ - **Simple Interface**: Easy-to-use methods for chat, completion, embeddings, and image generation
47
+ - **Error Handling**: Standardized error handling across providers
48
+ - **Authentication**: Automatic token management
49
+
50
+ ## Installation
51
+
52
+ ```bash
53
+ pip install indoxrouter
54
+ ```
55
+
56
+ ## Usage
57
+
58
+ ### Initialization
59
+
60
+ ```python
61
+ from indoxrouter import Client
62
+
63
+ # Initialize with API key (default connects to localhost:8000)
64
+ client = Client(api_key="your_api_key")
65
+
66
+ # Or specify a custom server URL
67
+ client = Client(
68
+ api_key="your_api_key",
69
+ base_url="http://your-server-url:8000"
70
+ )
71
+
72
+ # Connect to Docker container inside the Docker network
73
+ client = Client(
74
+ api_key="your_api_key",
75
+ base_url="http://indoxrouter-server:8000"
76
+ )
77
+
78
+ # Using environment variables
79
+ # Set INDOX_ROUTER_API_KEY environment variable
80
+ import os
81
+ os.environ["INDOX_ROUTER_API_KEY"] = "your_api_key"
82
+ client = Client()
83
+ ```
84
+
85
+ ### Chat Completions
86
+
87
+ ```python
88
+ response = client.chat(
89
+ messages=[
90
+ {"role": "system", "content": "You are a helpful assistant."},
91
+ {"role": "user", "content": "Tell me a joke."}
92
+ ],
93
+ model="openai/gpt-4o-mini", # Provider/model format
94
+ temperature=0.7
95
+ )
96
+
97
+ print(response["choices"][0]["message"]["content"])
98
+ ```
99
+
100
+ ### Text Completions
101
+
102
+ ```python
103
+ response = client.completion(
104
+ prompt="Once upon a time,",
105
+ model="openai/gpt-4o-mini",
106
+ max_tokens=100
107
+ )
108
+
109
+ print(response["choices"][0]["text"])
110
+ ```
111
+
112
+ ### Embeddings
113
+
114
+ ```python
115
+ response = client.embeddings(
116
+ text=["Hello world", "AI is amazing"],
117
+ model="openai/text-embedding-3-small"
118
+ )
119
+
120
+ print(f"Dimensions: {len(response['data'][0]['embedding'])}")
121
+ print(f"First embedding: {response['data'][0]['embedding'][:5]}...")
122
+ ```
123
+
124
+ ### Image Generation
125
+
126
+ ```python
127
+ response = client.images(
128
+ prompt="A serene landscape with mountains and a lake",
129
+ model="openai/dall-e-3",
130
+ size="1024x1024"
131
+ )
132
+
133
+ print(f"Image URL: {response['data'][0]['url']}")
134
+ ```
135
+
136
+ ### Streaming Responses
137
+
138
+ ```python
139
+ for chunk in client.chat(
140
+ messages=[{"role": "user", "content": "Write a short story."}],
141
+ model="openai/gpt-4o-mini",
142
+ stream=True
143
+ ):
144
+ if chunk.get("choices") and len(chunk["choices"]) > 0:
145
+ content = chunk["choices"][0].get("delta", {}).get("content", "")
146
+ print(content, end="", flush=True)
147
+ ```
148
+
149
+ ### Getting Available Models
150
+
151
+ ```python
152
+ # Get all providers and models
153
+ providers = client.models()
154
+ for provider in providers:
155
+ print(f"Provider: {provider['name']}")
156
+ for model in provider["models"]:
157
+ print(f" - {model['id']}: {model['description'] or ''}")
158
+
159
+ # Get models for a specific provider
160
+ openai_provider = client.models("openai")
161
+ print(f"OpenAI models: {[m['id'] for m in openai_provider['models']]}")
162
+ ```
163
+
164
+ ## Error Handling
165
+
166
+ ```python
167
+ from indoxrouter import Client, ModelNotFoundError, ProviderError
168
+
169
+ try:
170
+ client = Client(api_key="your_api_key")
171
+ response = client.chat(
172
+ messages=[{"role": "user", "content": "Hello"}],
173
+ model="nonexistent-provider/nonexistent-model"
174
+ )
175
+ except ModelNotFoundError as e:
176
+ print(f"Model not found: {e}")
177
+ except ProviderError as e:
178
+ print(f"Provider error: {e}")
179
+ ```
180
+
181
+ ## Context Manager
182
+
183
+ ```python
184
+ with Client(api_key="your_api_key") as client:
185
+ response = client.chat(
186
+ messages=[{"role": "user", "content": "Hello!"}],
187
+ model="openai/gpt-4o-mini"
188
+ )
189
+ print(response["choices"][0]["message"]["content"])
190
+ # Client is automatically closed when exiting the block
191
+ ```
192
+
193
+ ## License
194
+
195
+ This project is licensed under the MIT License - see the LICENSE file for details.
@@ -0,0 +1,157 @@
1
+ # IndoxRouter Client
2
+
3
+ A unified client for various AI providers, including OpenAI, Anthropic, Google, and Mistral.
4
+
5
+ ## Features
6
+
7
+ - **Unified API**: Access multiple AI providers through a single API
8
+ - **Simple Interface**: Easy-to-use methods for chat, completion, embeddings, and image generation
9
+ - **Error Handling**: Standardized error handling across providers
10
+ - **Authentication**: Automatic token management
11
+
12
+ ## Installation
13
+
14
+ ```bash
15
+ pip install indoxrouter
16
+ ```
17
+
18
+ ## Usage
19
+
20
+ ### Initialization
21
+
22
+ ```python
23
+ from indoxrouter import Client
24
+
25
+ # Initialize with API key (default connects to localhost:8000)
26
+ client = Client(api_key="your_api_key")
27
+
28
+ # Or specify a custom server URL
29
+ client = Client(
30
+ api_key="your_api_key",
31
+ base_url="http://your-server-url:8000"
32
+ )
33
+
34
+ # Connect to Docker container inside the Docker network
35
+ client = Client(
36
+ api_key="your_api_key",
37
+ base_url="http://indoxrouter-server:8000"
38
+ )
39
+
40
+ # Using environment variables
41
+ # Set INDOX_ROUTER_API_KEY environment variable
42
+ import os
43
+ os.environ["INDOX_ROUTER_API_KEY"] = "your_api_key"
44
+ client = Client()
45
+ ```
46
+
47
+ ### Chat Completions
48
+
49
+ ```python
50
+ response = client.chat(
51
+ messages=[
52
+ {"role": "system", "content": "You are a helpful assistant."},
53
+ {"role": "user", "content": "Tell me a joke."}
54
+ ],
55
+ model="openai/gpt-4o-mini", # Provider/model format
56
+ temperature=0.7
57
+ )
58
+
59
+ print(response["choices"][0]["message"]["content"])
60
+ ```
61
+
62
+ ### Text Completions
63
+
64
+ ```python
65
+ response = client.completion(
66
+ prompt="Once upon a time,",
67
+ model="openai/gpt-4o-mini",
68
+ max_tokens=100
69
+ )
70
+
71
+ print(response["choices"][0]["text"])
72
+ ```
73
+
74
+ ### Embeddings
75
+
76
+ ```python
77
+ response = client.embeddings(
78
+ text=["Hello world", "AI is amazing"],
79
+ model="openai/text-embedding-3-small"
80
+ )
81
+
82
+ print(f"Dimensions: {len(response['data'][0]['embedding'])}")
83
+ print(f"First embedding: {response['data'][0]['embedding'][:5]}...")
84
+ ```
85
+
86
+ ### Image Generation
87
+
88
+ ```python
89
+ response = client.images(
90
+ prompt="A serene landscape with mountains and a lake",
91
+ model="openai/dall-e-3",
92
+ size="1024x1024"
93
+ )
94
+
95
+ print(f"Image URL: {response['data'][0]['url']}")
96
+ ```
97
+
98
+ ### Streaming Responses
99
+
100
+ ```python
101
+ for chunk in client.chat(
102
+ messages=[{"role": "user", "content": "Write a short story."}],
103
+ model="openai/gpt-4o-mini",
104
+ stream=True
105
+ ):
106
+ if chunk.get("choices") and len(chunk["choices"]) > 0:
107
+ content = chunk["choices"][0].get("delta", {}).get("content", "")
108
+ print(content, end="", flush=True)
109
+ ```
110
+
111
+ ### Getting Available Models
112
+
113
+ ```python
114
+ # Get all providers and models
115
+ providers = client.models()
116
+ for provider in providers:
117
+ print(f"Provider: {provider['name']}")
118
+ for model in provider["models"]:
119
+ print(f" - {model['id']}: {model['description'] or ''}")
120
+
121
+ # Get models for a specific provider
122
+ openai_provider = client.models("openai")
123
+ print(f"OpenAI models: {[m['id'] for m in openai_provider['models']]}")
124
+ ```
125
+
126
+ ## Error Handling
127
+
128
+ ```python
129
+ from indoxrouter import Client, ModelNotFoundError, ProviderError
130
+
131
+ try:
132
+ client = Client(api_key="your_api_key")
133
+ response = client.chat(
134
+ messages=[{"role": "user", "content": "Hello"}],
135
+ model="nonexistent-provider/nonexistent-model"
136
+ )
137
+ except ModelNotFoundError as e:
138
+ print(f"Model not found: {e}")
139
+ except ProviderError as e:
140
+ print(f"Provider error: {e}")
141
+ ```
142
+
143
+ ## Context Manager
144
+
145
+ ```python
146
+ with Client(api_key="your_api_key") as client:
147
+ response = client.chat(
148
+ messages=[{"role": "user", "content": "Hello!"}],
149
+ model="openai/gpt-4o-mini"
150
+ )
151
+ print(response["choices"][0]["message"]["content"])
152
+ # Client is automatically closed when exiting the block
153
+ ```
154
+
155
+ ## License
156
+
157
+ This project is licensed under the MIT License - see the LICENSE file for details.
@@ -0,0 +1,44 @@
1
+ # IndoxRouter Cookbook
2
+
3
+ This directory contains examples and recipes for using the IndoxRouter client to interact with various AI providers.
4
+
5
+ ## Examples
6
+
7
+ - [Chat Completion](chat_completion.md): Examples of generating chat completions
8
+ - [Embeddings](embeddings.md): Examples of generating embeddings
9
+ - [Image Generation](image_generation.md): Examples of generating images
10
+
11
+ ## Jupyter Notebook
12
+
13
+ - [IndoxRouter Cookbook](indoxRouter_cookbook.ipynb): A comprehensive Jupyter notebook with examples of using the IndoxRouter client
14
+
15
+ ## Getting Started
16
+
17
+ To run these examples, you'll need to:
18
+
19
+ 1. Install the IndoxRouter client:
20
+
21
+ ```bash
22
+ pip install indoxrouter
23
+ ```
24
+
25
+ 2. Set your API key:
26
+
27
+ ```bash
28
+ # Set environment variable
29
+ export INDOXROUTER_API_KEY=your-api-key
30
+
31
+ # Or provide it directly in your code
32
+ from indoxrouter import Client
33
+ client = Client(api_key="your-api-key")
34
+ ```
35
+
36
+ 3. Run the examples:
37
+
38
+ ```bash
39
+ python -c "from indoxrouter import Client; client = Client(api_key='your_api_key'); print(client.chat([{'role': 'user', 'content': 'Hello!'}]))"
40
+ ```
41
+
42
+ ## Note on API Keys
43
+
44
+ The IndoxRouter API key is used to authenticate with the IndoxRouter server. You don't need to provide individual API keys for each provider (like OpenAI, Anthropic, etc.) as the IndoxRouter server handles that for you.