omniai-kit 1.0.0__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 (34) hide show
  1. omniai_kit-1.0.0/LICENSE +21 -0
  2. omniai_kit-1.0.0/PKG-INFO +270 -0
  3. omniai_kit-1.0.0/README.md +221 -0
  4. omniai_kit-1.0.0/omniai/__init__.py +117 -0
  5. omniai_kit-1.0.0/omniai/_base.py +386 -0
  6. omniai_kit-1.0.0/omniai/_constants.py +39 -0
  7. omniai_kit-1.0.0/omniai/_version.py +4 -0
  8. omniai_kit-1.0.0/omniai/client.py +316 -0
  9. omniai_kit-1.0.0/omniai/exceptions.py +113 -0
  10. omniai_kit-1.0.0/omniai/py.typed +1 -0
  11. omniai_kit-1.0.0/omniai/resources/__init__.py +26 -0
  12. omniai_kit-1.0.0/omniai/resources/chat.py +403 -0
  13. omniai_kit-1.0.0/omniai/resources/livekit.py +71 -0
  14. omniai_kit-1.0.0/omniai/resources/models.py +63 -0
  15. omniai_kit-1.0.0/omniai/resources/router.py +1040 -0
  16. omniai_kit-1.0.0/omniai/resources/tasks.py +171 -0
  17. omniai_kit-1.0.0/omniai/types/__init__.py +27 -0
  18. omniai_kit-1.0.0/omniai/types/chat.py +48 -0
  19. omniai_kit-1.0.0/omniai/types/livekit.py +17 -0
  20. omniai_kit-1.0.0/omniai/types/models.py +30 -0
  21. omniai_kit-1.0.0/omniai/types/tasks.py +208 -0
  22. omniai_kit-1.0.0/omniai_kit.egg-info/PKG-INFO +270 -0
  23. omniai_kit-1.0.0/omniai_kit.egg-info/SOURCES.txt +32 -0
  24. omniai_kit-1.0.0/omniai_kit.egg-info/dependency_links.txt +1 -0
  25. omniai_kit-1.0.0/omniai_kit.egg-info/requires.txt +25 -0
  26. omniai_kit-1.0.0/omniai_kit.egg-info/top_level.txt +1 -0
  27. omniai_kit-1.0.0/pyproject.toml +81 -0
  28. omniai_kit-1.0.0/setup.cfg +4 -0
  29. omniai_kit-1.0.0/tests/test_async_client.py +75 -0
  30. omniai_kit-1.0.0/tests/test_client.py +138 -0
  31. omniai_kit-1.0.0/tests/test_exceptions.py +54 -0
  32. omniai_kit-1.0.0/tests/test_providers.py +76 -0
  33. omniai_kit-1.0.0/tests/test_retry.py +107 -0
  34. omniai_kit-1.0.0/tests/test_router.py +73 -0
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 OmniAI 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.
@@ -0,0 +1,270 @@
1
+ Metadata-Version: 2.4
2
+ Name: omniai-kit
3
+ Version: 1.0.0
4
+ Summary: Official Python client SDK for OmniAI Gateway and Dynamic Multi-Provider LLM Router
5
+ Author-email: OmniAI Team <dev@omniai.ai>, Jayed Bin Jahangir <jayedbinjahangir@gmail.com>
6
+ Maintainer-email: Jayed Bin Jahangir <jayedbinjahangir@gmail.com>
7
+ License-Expression: MIT
8
+ Project-URL: Homepage, https://omniai.go-agents.app
9
+ Project-URL: Documentation, https://omniai.go-agents.app/docs
10
+ Project-URL: Repository, https://github.com/jayeeed/omniai-sdk
11
+ Project-URL: Issues, https://github.com/jayeeed/omniai-sdk/issues
12
+ Project-URL: Changelog, https://github.com/jayeeed/omniai-sdk/blob/main/CHANGELOG.md
13
+ Keywords: omniai,llm,ai,gateway,router,openai,gemini,anthropic,vllm,livekit,sdk
14
+ Classifier: Development Status :: 5 - Production/Stable
15
+ Classifier: Intended Audience :: Developers
16
+ Classifier: Operating System :: OS Independent
17
+ Classifier: Programming Language :: Python :: 3
18
+ Classifier: Programming Language :: Python :: 3.9
19
+ Classifier: Programming Language :: Python :: 3.10
20
+ Classifier: Programming Language :: Python :: 3.11
21
+ Classifier: Programming Language :: Python :: 3.12
22
+ Classifier: Programming Language :: Python :: 3.13
23
+ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
24
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
25
+ Classifier: Typing :: Typed
26
+ Requires-Python: >=3.9
27
+ Description-Content-Type: text/markdown
28
+ License-File: LICENSE
29
+ Requires-Dist: httpx>=0.27.0
30
+ Requires-Dist: pydantic>=2.0.0
31
+ Provides-Extra: all
32
+ Requires-Dist: openai>=1.0.0; extra == "all"
33
+ Requires-Dist: google-genai>=0.1.0; extra == "all"
34
+ Requires-Dist: anthropic>=0.20.0; extra == "all"
35
+ Provides-Extra: openai
36
+ Requires-Dist: openai>=1.0.0; extra == "openai"
37
+ Provides-Extra: gemini
38
+ Requires-Dist: google-genai>=0.1.0; extra == "gemini"
39
+ Provides-Extra: anthropic
40
+ Requires-Dist: anthropic>=0.20.0; extra == "anthropic"
41
+ Provides-Extra: vllm
42
+ Requires-Dist: openai>=1.0.0; extra == "vllm"
43
+ Provides-Extra: dev
44
+ Requires-Dist: pytest>=7.0.0; extra == "dev"
45
+ Requires-Dist: pytest-asyncio>=0.21.0; extra == "dev"
46
+ Requires-Dist: build>=1.0.0; extra == "dev"
47
+ Requires-Dist: twine>=5.0.0; extra == "dev"
48
+ Dynamic: license-file
49
+
50
+ # OmniAI Python Client SDK (`omniai`)
51
+
52
+ [![PyPI version](https://img.shields.io/pypi/v/omniai.svg)](https://pypi.org/project/omniai/)
53
+ [![Python versions](https://img.shields.io/pypi/pyversions/omniai.svg)](https://pypi.org/project/omniai/)
54
+ [![License: MIT](https://img.shields.io/badge/License-MIT-green.svg)](https://opensource.org/licenses/MIT)
55
+ [![Type Checked: PEP 561](https://img.shields.io/badge/typing-PEP%20561-blue.svg)](https://peps.python.org/pep-0561/)
56
+
57
+ Official, production-ready Python client SDK for the **OmniAI AI Gateway** and **Dynamic Multi-Provider LLM Router**.
58
+
59
+ ---
60
+
61
+ ## 🏛️ Supported Providers
62
+
63
+ The OmniAI SDK is strictly engineered and validated for the following **4 model providers**:
64
+
65
+ | Provider | Identifier Schema | Description & Examples |
66
+ | :--- | :--- | :--- |
67
+ | **OpenAI** | `openai:<model>` | Standard and reasoning models (`openai:gpt-4o`, `openai:o3-mini`) |
68
+ | **Google Gemini** | `gemini:<model>` | Google AI Multimodal models (`gemini:gemini-2.5-flash`, `gemini:gemini-3.7-flash`) |
69
+ | **Anthropic** | `anthropic:<model>` | Claude reasoning & coding models (`anthropic:claude-3-5-sonnet`, `anthropic:claude-3-opus`) |
70
+ | **vLLM (Self-Hosted)** | `vllm:<model>` | High-throughput self-hosted inference servers (`vllm:meta-llama/Llama-3.1-8B-Instruct`) |
71
+
72
+ ---
73
+
74
+ ## 📦 Installation
75
+
76
+ Install the lightweight client from PyPI:
77
+
78
+ ```bash
79
+ pip install omniai
80
+ ```
81
+
82
+ ### Optional Provider Dependencies (for direct local routing)
83
+ If you wish to use the standalone `RouterEngine` directly within your Python process without an external gateway:
84
+
85
+ ```bash
86
+ pip install "omniai[all]" # Installs all provider SDKs (openai, google-genai)
87
+ pip install "omniai[openai]" # Installs openai
88
+ pip install "omniai[gemini]" # Installs google-genai
89
+ ```
90
+
91
+ ---
92
+
93
+ ## 🚀 Quickstart
94
+
95
+ ### 1. Synchronous Client (`OmniaiClient`)
96
+
97
+ ```python
98
+ from omniai import OmniaiClient
99
+
100
+ # Automatically defaults base_url="https://omniai.go-agents.app"
101
+ # and auto-loads OMNI_API_KEY from your .env file
102
+ client = OmniaiClient()
103
+
104
+ # Or pass parameters explicitly:
105
+ # client = OmniaiClient(api_key="your-api-key")
106
+
107
+ # Call flagship model openai:gpt-5.6-luna
108
+ response = client.chat(
109
+ model="openai:gpt-5.6-luna",
110
+ prompt="Explain quantum entanglement in 2 sentences.",
111
+ temperature=0.7,
112
+ )
113
+ print(response)
114
+ ```
115
+
116
+ ### 2. Real-Time Token Streaming
117
+
118
+ The SDK features a resilient Server-Sent Events (SSE) streaming engine with automatic frame filtering and clean termination:
119
+
120
+ ```python
121
+ from omniai import OmniaiClient
122
+
123
+ client = OmniaiClient()
124
+
125
+ for token in client.stream(
126
+ model="openai:gpt-5.6-luna",
127
+ prompt="Write a haiku about high-availability microservices.",
128
+ ):
129
+ print(token, end="", flush=True)
130
+ ```
131
+
132
+ ### 3. Strongly-Typed Structured Outputs with Pydantic
133
+
134
+ Pass your Pydantic model directly into `response_model`. The SDK extracts JSON schemas automatically, instructs the upstream provider, and parses the returned JSON into a validated Python instance:
135
+
136
+ ```python
137
+ from pydantic import BaseModel, Field
138
+ from omniai import OmniaiClient
139
+
140
+ class SecurityAudit(BaseModel):
141
+ summary: str = Field(..., description="High-level assessment")
142
+ vulnerabilities: list[str] = Field(..., description="Discovered vulnerability IDs")
143
+ passed: bool = Field(..., description="Overall security compliance status")
144
+
145
+ client = OmniaiClient()
146
+
147
+ audit: SecurityAudit = client.chat(
148
+ model="openai:gpt-5.6-luna",
149
+ prompt="Audit this configuration: CORS allowed * with credentials enabled.",
150
+ response_model=SecurityAudit,
151
+ )
152
+
153
+ print(audit.summary)
154
+ print(f"Passed: {audit.passed}")
155
+ ```
156
+
157
+ ### 4. Self-Hosted vLLM Inference
158
+
159
+ Connect seamlessly to any self-hosted or cloud vLLM server:
160
+
161
+ ```python
162
+ from omniai import OmniaiClient
163
+
164
+ # Point to your internal vLLM cluster (or route through OmniAI Gateway)
165
+ client = OmniaiClient(
166
+ base_url="http://vllm-node.internal:8000/v1",
167
+ api_key="EMPTY",
168
+ )
169
+
170
+ response = client.chat(
171
+ model="vllm:meta-llama/Llama-3.1-8B-Instruct",
172
+ prompt="Hello from OmniAI!",
173
+ )
174
+ print(response)
175
+ ```
176
+
177
+ ### 5. Asynchronous Client (`AsyncOmniaiClient`)
178
+
179
+ Full `async`/`await` parity for high-concurrency applications:
180
+
181
+ ```python
182
+ import asyncio
183
+ from omniai import AsyncOmniaiClient
184
+
185
+ async def main():
186
+ async with AsyncOmniaiClient() as client:
187
+ # Async chat
188
+ result = await client.chat(
189
+ model="openai:gpt-5.6-luna",
190
+ prompt="Hello async world!",
191
+ )
192
+ print(result)
193
+
194
+ # Async streaming
195
+ async for chunk in client.stream(model="openai:gpt-5.6-luna", prompt="Count to 3."):
196
+ print(chunk, end="", flush=True)
197
+
198
+ asyncio.run(main())
199
+ ```
200
+
201
+ ### 6. Fault-Tolerant Background Celery Tasks
202
+
203
+ Queue long-running jobs to the background Celery cluster with automatic polling resilience:
204
+
205
+ ```python
206
+ from omniai import OmniaiClient
207
+
208
+ client = OmniaiClient()
209
+
210
+ # Submit task asynchronously to the queue
211
+ job = client.submit_task(
212
+ model="openai:gpt-5.6-luna",
213
+ prompt="Analyze 50 pages of financial records.",
214
+ )
215
+ print(f"Dispatched task ID: {job.task_id}")
216
+
217
+ # Fault-tolerant polling that survives temporary network dropouts
218
+ result = job.wait(timeout=180.0, interval=2.0)
219
+ print(result)
220
+ ```
221
+
222
+ ### 7. LiveKit Multimodal Real-Time Voice & Video
223
+
224
+ Generate signed WebRTC credentials on the fly:
225
+
226
+ ```python
227
+ from omniai import OmniaiClient
228
+
229
+ client = OmniaiClient()
230
+
231
+ session = client.create_live_session(
232
+ model="gemini:gemini-3.1-flash-live-preview",
233
+ voice="Aoede",
234
+ participant_identity="agent-caller-01",
235
+ )
236
+ print(f"Connect to room '{session.room_name}' at {session.server_url}")
237
+ print(f"JWT Token: {session.participant_token}")
238
+ ```
239
+
240
+ ---
241
+
242
+ ## 🛡️ Production Reliability & Fault Tolerance
243
+
244
+ The SDK includes enterprise resilience patterns built-in:
245
+
246
+ 1. **Exponential Backoff with Full Jitter**:
247
+ - Automatically retries transient failures: HTTP 429 (Rate Limit), 500, 502, 503, 504, connection timeouts, and connection reset errors.
248
+ - Respects upstream `Retry-After` headers.
249
+ - Configurable via `max_retries: int = 3` and `backoff_factor: float = 0.5`.
250
+
251
+ 2. **Connection Pooling**:
252
+ - Pre-configured with `httpx.Limits(max_keepalive_connections=20, max_connections=100)`.
253
+ - Supports explicit lifecycle management via `client.close()` and context managers (`with OmniaiClient() as client:`).
254
+
255
+ 3. **Granular Exception Hierarchy**:
256
+ - `OmniaiAuthError`: HTTP 401 / 403 invalid or expired credentials.
257
+ - `OmniaiPaymentRequiredError`: HTTP 402 insufficient prepaid balance.
258
+ - `OmniaiRateLimitError`: HTTP 429 rate limit exceeded (includes `.retry_after` attribute).
259
+ - `OmniaiExecutionError`: HTTP 5xx or upstream LLM provider error.
260
+ - `OmniaiValidationError`: Model output failed schema validation.
261
+ - `OmniaiTimeoutError`: Polling or network timeout.
262
+ - `OmniaiConnectionError`: Network drops, DNS resolution failures.
263
+ - `OmniaiUnsupportedProviderError`: Raised if attempting to route to an unsupported provider.
264
+
265
+
266
+ ---
267
+
268
+ ## 📄 License
269
+
270
+ MIT © [OmniAI Team](https://omniai.go-agents.app)
@@ -0,0 +1,221 @@
1
+ # OmniAI Python Client SDK (`omniai`)
2
+
3
+ [![PyPI version](https://img.shields.io/pypi/v/omniai.svg)](https://pypi.org/project/omniai/)
4
+ [![Python versions](https://img.shields.io/pypi/pyversions/omniai.svg)](https://pypi.org/project/omniai/)
5
+ [![License: MIT](https://img.shields.io/badge/License-MIT-green.svg)](https://opensource.org/licenses/MIT)
6
+ [![Type Checked: PEP 561](https://img.shields.io/badge/typing-PEP%20561-blue.svg)](https://peps.python.org/pep-0561/)
7
+
8
+ Official, production-ready Python client SDK for the **OmniAI AI Gateway** and **Dynamic Multi-Provider LLM Router**.
9
+
10
+ ---
11
+
12
+ ## 🏛️ Supported Providers
13
+
14
+ The OmniAI SDK is strictly engineered and validated for the following **4 model providers**:
15
+
16
+ | Provider | Identifier Schema | Description & Examples |
17
+ | :--- | :--- | :--- |
18
+ | **OpenAI** | `openai:<model>` | Standard and reasoning models (`openai:gpt-4o`, `openai:o3-mini`) |
19
+ | **Google Gemini** | `gemini:<model>` | Google AI Multimodal models (`gemini:gemini-2.5-flash`, `gemini:gemini-3.7-flash`) |
20
+ | **Anthropic** | `anthropic:<model>` | Claude reasoning & coding models (`anthropic:claude-3-5-sonnet`, `anthropic:claude-3-opus`) |
21
+ | **vLLM (Self-Hosted)** | `vllm:<model>` | High-throughput self-hosted inference servers (`vllm:meta-llama/Llama-3.1-8B-Instruct`) |
22
+
23
+ ---
24
+
25
+ ## 📦 Installation
26
+
27
+ Install the lightweight client from PyPI:
28
+
29
+ ```bash
30
+ pip install omniai
31
+ ```
32
+
33
+ ### Optional Provider Dependencies (for direct local routing)
34
+ If you wish to use the standalone `RouterEngine` directly within your Python process without an external gateway:
35
+
36
+ ```bash
37
+ pip install "omniai[all]" # Installs all provider SDKs (openai, google-genai)
38
+ pip install "omniai[openai]" # Installs openai
39
+ pip install "omniai[gemini]" # Installs google-genai
40
+ ```
41
+
42
+ ---
43
+
44
+ ## 🚀 Quickstart
45
+
46
+ ### 1. Synchronous Client (`OmniaiClient`)
47
+
48
+ ```python
49
+ from omniai import OmniaiClient
50
+
51
+ # Automatically defaults base_url="https://omniai.go-agents.app"
52
+ # and auto-loads OMNI_API_KEY from your .env file
53
+ client = OmniaiClient()
54
+
55
+ # Or pass parameters explicitly:
56
+ # client = OmniaiClient(api_key="your-api-key")
57
+
58
+ # Call flagship model openai:gpt-5.6-luna
59
+ response = client.chat(
60
+ model="openai:gpt-5.6-luna",
61
+ prompt="Explain quantum entanglement in 2 sentences.",
62
+ temperature=0.7,
63
+ )
64
+ print(response)
65
+ ```
66
+
67
+ ### 2. Real-Time Token Streaming
68
+
69
+ The SDK features a resilient Server-Sent Events (SSE) streaming engine with automatic frame filtering and clean termination:
70
+
71
+ ```python
72
+ from omniai import OmniaiClient
73
+
74
+ client = OmniaiClient()
75
+
76
+ for token in client.stream(
77
+ model="openai:gpt-5.6-luna",
78
+ prompt="Write a haiku about high-availability microservices.",
79
+ ):
80
+ print(token, end="", flush=True)
81
+ ```
82
+
83
+ ### 3. Strongly-Typed Structured Outputs with Pydantic
84
+
85
+ Pass your Pydantic model directly into `response_model`. The SDK extracts JSON schemas automatically, instructs the upstream provider, and parses the returned JSON into a validated Python instance:
86
+
87
+ ```python
88
+ from pydantic import BaseModel, Field
89
+ from omniai import OmniaiClient
90
+
91
+ class SecurityAudit(BaseModel):
92
+ summary: str = Field(..., description="High-level assessment")
93
+ vulnerabilities: list[str] = Field(..., description="Discovered vulnerability IDs")
94
+ passed: bool = Field(..., description="Overall security compliance status")
95
+
96
+ client = OmniaiClient()
97
+
98
+ audit: SecurityAudit = client.chat(
99
+ model="openai:gpt-5.6-luna",
100
+ prompt="Audit this configuration: CORS allowed * with credentials enabled.",
101
+ response_model=SecurityAudit,
102
+ )
103
+
104
+ print(audit.summary)
105
+ print(f"Passed: {audit.passed}")
106
+ ```
107
+
108
+ ### 4. Self-Hosted vLLM Inference
109
+
110
+ Connect seamlessly to any self-hosted or cloud vLLM server:
111
+
112
+ ```python
113
+ from omniai import OmniaiClient
114
+
115
+ # Point to your internal vLLM cluster (or route through OmniAI Gateway)
116
+ client = OmniaiClient(
117
+ base_url="http://vllm-node.internal:8000/v1",
118
+ api_key="EMPTY",
119
+ )
120
+
121
+ response = client.chat(
122
+ model="vllm:meta-llama/Llama-3.1-8B-Instruct",
123
+ prompt="Hello from OmniAI!",
124
+ )
125
+ print(response)
126
+ ```
127
+
128
+ ### 5. Asynchronous Client (`AsyncOmniaiClient`)
129
+
130
+ Full `async`/`await` parity for high-concurrency applications:
131
+
132
+ ```python
133
+ import asyncio
134
+ from omniai import AsyncOmniaiClient
135
+
136
+ async def main():
137
+ async with AsyncOmniaiClient() as client:
138
+ # Async chat
139
+ result = await client.chat(
140
+ model="openai:gpt-5.6-luna",
141
+ prompt="Hello async world!",
142
+ )
143
+ print(result)
144
+
145
+ # Async streaming
146
+ async for chunk in client.stream(model="openai:gpt-5.6-luna", prompt="Count to 3."):
147
+ print(chunk, end="", flush=True)
148
+
149
+ asyncio.run(main())
150
+ ```
151
+
152
+ ### 6. Fault-Tolerant Background Celery Tasks
153
+
154
+ Queue long-running jobs to the background Celery cluster with automatic polling resilience:
155
+
156
+ ```python
157
+ from omniai import OmniaiClient
158
+
159
+ client = OmniaiClient()
160
+
161
+ # Submit task asynchronously to the queue
162
+ job = client.submit_task(
163
+ model="openai:gpt-5.6-luna",
164
+ prompt="Analyze 50 pages of financial records.",
165
+ )
166
+ print(f"Dispatched task ID: {job.task_id}")
167
+
168
+ # Fault-tolerant polling that survives temporary network dropouts
169
+ result = job.wait(timeout=180.0, interval=2.0)
170
+ print(result)
171
+ ```
172
+
173
+ ### 7. LiveKit Multimodal Real-Time Voice & Video
174
+
175
+ Generate signed WebRTC credentials on the fly:
176
+
177
+ ```python
178
+ from omniai import OmniaiClient
179
+
180
+ client = OmniaiClient()
181
+
182
+ session = client.create_live_session(
183
+ model="gemini:gemini-3.1-flash-live-preview",
184
+ voice="Aoede",
185
+ participant_identity="agent-caller-01",
186
+ )
187
+ print(f"Connect to room '{session.room_name}' at {session.server_url}")
188
+ print(f"JWT Token: {session.participant_token}")
189
+ ```
190
+
191
+ ---
192
+
193
+ ## 🛡️ Production Reliability & Fault Tolerance
194
+
195
+ The SDK includes enterprise resilience patterns built-in:
196
+
197
+ 1. **Exponential Backoff with Full Jitter**:
198
+ - Automatically retries transient failures: HTTP 429 (Rate Limit), 500, 502, 503, 504, connection timeouts, and connection reset errors.
199
+ - Respects upstream `Retry-After` headers.
200
+ - Configurable via `max_retries: int = 3` and `backoff_factor: float = 0.5`.
201
+
202
+ 2. **Connection Pooling**:
203
+ - Pre-configured with `httpx.Limits(max_keepalive_connections=20, max_connections=100)`.
204
+ - Supports explicit lifecycle management via `client.close()` and context managers (`with OmniaiClient() as client:`).
205
+
206
+ 3. **Granular Exception Hierarchy**:
207
+ - `OmniaiAuthError`: HTTP 401 / 403 invalid or expired credentials.
208
+ - `OmniaiPaymentRequiredError`: HTTP 402 insufficient prepaid balance.
209
+ - `OmniaiRateLimitError`: HTTP 429 rate limit exceeded (includes `.retry_after` attribute).
210
+ - `OmniaiExecutionError`: HTTP 5xx or upstream LLM provider error.
211
+ - `OmniaiValidationError`: Model output failed schema validation.
212
+ - `OmniaiTimeoutError`: Polling or network timeout.
213
+ - `OmniaiConnectionError`: Network drops, DNS resolution failures.
214
+ - `OmniaiUnsupportedProviderError`: Raised if attempting to route to an unsupported provider.
215
+
216
+
217
+ ---
218
+
219
+ ## 📄 License
220
+
221
+ MIT © [OmniAI Team](https://omniai.go-agents.app)
@@ -0,0 +1,117 @@
1
+ """OmniAI: Official Python Client SDK for OmniAI Gateway & Multi-Provider LLM Router."""
2
+
3
+ from omniai._version import __version__, VERSION
4
+ from omniai._constants import DEFAULT_BASE_URL, SUPPORTED_PROVIDERS
5
+ from omniai.client import (
6
+ OmniaiClient,
7
+ AsyncOmniaiClient,
8
+ OmniAIClient,
9
+ AsyncOmniAIClient,
10
+ OmniClient,
11
+ AsyncOmniClient,
12
+ )
13
+ from omniai.resources.router import RouterEngine
14
+ from omniai._base import RetryPolicy
15
+ from omniai.exceptions import (
16
+ OmniaiError,
17
+ OmniaiAuthError,
18
+ OmniaiAuthenticationError,
19
+ OmniaiPermissionDeniedError,
20
+ OmniaiAPIError,
21
+ OmniaiBadRequestError,
22
+ OmniaiNotFoundError,
23
+ OmniaiRateLimitError,
24
+ OmniaiTimeoutError,
25
+ OmniaiConnectionError,
26
+ OmniaiExecutionError,
27
+ OmniaiValidationError,
28
+ OmniaiPaymentRequiredError,
29
+ OmniaiUnsupportedProviderError,
30
+ OmniAIError,
31
+ OmniAIAuthError,
32
+ OmniAIAuthenticationError,
33
+ OmniAIAPIError,
34
+ OmniAIRateLimitError,
35
+ OmniAITimeoutError,
36
+ OmniAIConnectionError,
37
+ OmniAIValidationError,
38
+ OmniError,
39
+ OmniAuthError,
40
+ OmniExecutionError,
41
+ OmniTimeoutError,
42
+ OmniRateLimitError,
43
+ )
44
+ from omniai.types import (
45
+ ChatMessage,
46
+ ChatCompletionChoice,
47
+ ChatCompletionUsage,
48
+ ChatCompletionResponse,
49
+ ChatCompletionChunk,
50
+ ModelInfo,
51
+ ModelList,
52
+ LiveSessionInfo,
53
+ TaskStatus,
54
+ TaskJob,
55
+ AsyncTaskJob,
56
+ )
57
+ from omniai import resources, types
58
+
59
+ __all__ = [
60
+ "__version__",
61
+ "VERSION",
62
+ "DEFAULT_BASE_URL",
63
+ "SUPPORTED_PROVIDERS",
64
+ # Clients
65
+ "OmniaiClient",
66
+ "AsyncOmniaiClient",
67
+ "OmniAIClient",
68
+ "AsyncOmniAIClient",
69
+ "OmniClient",
70
+ "AsyncOmniClient",
71
+ # Engine & Policies
72
+ "RouterEngine",
73
+ "RetryPolicy",
74
+ # Exceptions
75
+ "OmniaiError",
76
+ "OmniaiAuthError",
77
+ "OmniaiAuthenticationError",
78
+ "OmniaiPermissionDeniedError",
79
+ "OmniaiAPIError",
80
+ "OmniaiBadRequestError",
81
+ "OmniaiNotFoundError",
82
+ "OmniaiRateLimitError",
83
+ "OmniaiTimeoutError",
84
+ "OmniaiConnectionError",
85
+ "OmniaiExecutionError",
86
+ "OmniaiValidationError",
87
+ "OmniaiPaymentRequiredError",
88
+ "OmniaiUnsupportedProviderError",
89
+ "OmniAIError",
90
+ "OmniAIAuthError",
91
+ "OmniAIAuthenticationError",
92
+ "OmniAIAPIError",
93
+ "OmniAIRateLimitError",
94
+ "OmniAITimeoutError",
95
+ "OmniAIConnectionError",
96
+ "OmniAIValidationError",
97
+ "OmniError",
98
+ "OmniAuthError",
99
+ "OmniExecutionError",
100
+ "OmniTimeoutError",
101
+ "OmniRateLimitError",
102
+ # Types
103
+ "ChatMessage",
104
+ "ChatCompletionChoice",
105
+ "ChatCompletionUsage",
106
+ "ChatCompletionResponse",
107
+ "ChatCompletionChunk",
108
+ "ModelInfo",
109
+ "ModelList",
110
+ "LiveSessionInfo",
111
+ "TaskStatus",
112
+ "TaskJob",
113
+ "AsyncTaskJob",
114
+ # Modules
115
+ "resources",
116
+ "types",
117
+ ]