omniai-kit 1.0.0__tar.gz → 1.0.1__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 (37) hide show
  1. omniai_kit-1.0.1/PKG-INFO +380 -0
  2. omniai_kit-1.0.1/README.md +331 -0
  3. omniai_kit-1.0.1/omniai_kit.egg-info/PKG-INFO +380 -0
  4. {omniai_kit-1.0.0 → omniai_kit-1.0.1}/pyproject.toml +2 -2
  5. omniai_kit-1.0.0/PKG-INFO +0 -270
  6. omniai_kit-1.0.0/README.md +0 -221
  7. omniai_kit-1.0.0/omniai_kit.egg-info/PKG-INFO +0 -270
  8. {omniai_kit-1.0.0 → omniai_kit-1.0.1}/LICENSE +0 -0
  9. {omniai_kit-1.0.0 → omniai_kit-1.0.1}/omniai/__init__.py +0 -0
  10. {omniai_kit-1.0.0 → omniai_kit-1.0.1}/omniai/_base.py +0 -0
  11. {omniai_kit-1.0.0 → omniai_kit-1.0.1}/omniai/_constants.py +0 -0
  12. {omniai_kit-1.0.0 → omniai_kit-1.0.1}/omniai/_version.py +0 -0
  13. {omniai_kit-1.0.0 → omniai_kit-1.0.1}/omniai/client.py +0 -0
  14. {omniai_kit-1.0.0 → omniai_kit-1.0.1}/omniai/exceptions.py +0 -0
  15. {omniai_kit-1.0.0 → omniai_kit-1.0.1}/omniai/py.typed +0 -0
  16. {omniai_kit-1.0.0 → omniai_kit-1.0.1}/omniai/resources/__init__.py +0 -0
  17. {omniai_kit-1.0.0 → omniai_kit-1.0.1}/omniai/resources/chat.py +0 -0
  18. {omniai_kit-1.0.0 → omniai_kit-1.0.1}/omniai/resources/livekit.py +0 -0
  19. {omniai_kit-1.0.0 → omniai_kit-1.0.1}/omniai/resources/models.py +0 -0
  20. {omniai_kit-1.0.0 → omniai_kit-1.0.1}/omniai/resources/router.py +0 -0
  21. {omniai_kit-1.0.0 → omniai_kit-1.0.1}/omniai/resources/tasks.py +0 -0
  22. {omniai_kit-1.0.0 → omniai_kit-1.0.1}/omniai/types/__init__.py +0 -0
  23. {omniai_kit-1.0.0 → omniai_kit-1.0.1}/omniai/types/chat.py +0 -0
  24. {omniai_kit-1.0.0 → omniai_kit-1.0.1}/omniai/types/livekit.py +0 -0
  25. {omniai_kit-1.0.0 → omniai_kit-1.0.1}/omniai/types/models.py +0 -0
  26. {omniai_kit-1.0.0 → omniai_kit-1.0.1}/omniai/types/tasks.py +0 -0
  27. {omniai_kit-1.0.0 → omniai_kit-1.0.1}/omniai_kit.egg-info/SOURCES.txt +0 -0
  28. {omniai_kit-1.0.0 → omniai_kit-1.0.1}/omniai_kit.egg-info/dependency_links.txt +0 -0
  29. {omniai_kit-1.0.0 → omniai_kit-1.0.1}/omniai_kit.egg-info/requires.txt +0 -0
  30. {omniai_kit-1.0.0 → omniai_kit-1.0.1}/omniai_kit.egg-info/top_level.txt +0 -0
  31. {omniai_kit-1.0.0 → omniai_kit-1.0.1}/setup.cfg +0 -0
  32. {omniai_kit-1.0.0 → omniai_kit-1.0.1}/tests/test_async_client.py +0 -0
  33. {omniai_kit-1.0.0 → omniai_kit-1.0.1}/tests/test_client.py +0 -0
  34. {omniai_kit-1.0.0 → omniai_kit-1.0.1}/tests/test_exceptions.py +0 -0
  35. {omniai_kit-1.0.0 → omniai_kit-1.0.1}/tests/test_providers.py +0 -0
  36. {omniai_kit-1.0.0 → omniai_kit-1.0.1}/tests/test_retry.py +0 -0
  37. {omniai_kit-1.0.0 → omniai_kit-1.0.1}/tests/test_router.py +0 -0
@@ -0,0 +1,380 @@
1
+ Metadata-Version: 2.4
2
+ Name: omniai-kit
3
+ Version: 1.0.1
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
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 Kit (`omniai-kit`) 🚀
51
+
52
+ [![PyPI version](https://img.shields.io/pypi/v/omniai-kit.svg?color=blue)](https://pypi.org/project/omniai-kit/)
53
+ [![GitHub repository](https://img.shields.io/badge/GitHub-omniai--sdk-181717?logo=github)](https://github.com/jayeeed/omniai-sdk)
54
+ [![Python versions](https://img.shields.io/pypi/pyversions/omniai-kit.svg)](https://pypi.org/project/omniai-kit/)
55
+ [![License: MIT](https://img.shields.io/badge/License-MIT-green.svg)](https://opensource.org/licenses/MIT)
56
+ [![Type Checked: PEP 561](https://img.shields.io/badge/typing-PEP%20561-blue.svg)](https://peps.python.org/pep-0561/)
57
+ [![Status: Production/Stable](https://img.shields.io/badge/status-production-success.svg)](https://omniai.go-agents.app)
58
+
59
+ Official Python Client SDK for the **OmniAI Platform & AI Gateway** — providing zero-config multi-provider LLM routing, real-time token streaming, native Pydantic structured outputs, background task queues, and WebRTC multimodal live voice/video sessions.
60
+
61
+ ---
62
+
63
+ ## ⚡ Features
64
+
65
+ - **Zero-Configuration Setup:** Automatically loads credentials (`OMNIAI_API_KEY`, `OMNI_API_KEY`, `X_API_KEY`) and defaults to `https://omniai.go-agents.app`.
66
+ - **Modern Resource Architecture:** Clean OpenAI-style resource hierarchy (`client.chat.completions.create`, `client.models.list`, `client.tasks.submit`, `client.livekit.create_session`) plus ergonomic top-level shortcuts (`client.chat`, `client.stream`).
67
+ - **Synchronous & Asynchronous:** Identical API surfaces for both synchronous (`OmniaiClient`) and async (`AsyncOmniaiClient`) applications.
68
+ - **Strongly Typed Pydantic Schemas:** Pass Pydantic models directly to `response_model` for guaranteed schema validation and markdown JSON stripping.
69
+ - **Resilient Real-Time Streaming:** Server-Sent Events (SSE) streaming engine with auto-reconnect and keep-alive handling.
70
+ - **Enterprise Fault Tolerance:** Built-in exponential backoff with full jitter, honoring upstream `Retry-After` headers on 429 and 5xx errors.
71
+ - **Background Tasks:** Submit compute-heavy completions to the Celery background queue and poll reliably with `job.wait()`.
72
+ - **LiveKit Multimodal Sessions:** Generate signed WebRTC access tokens for ultra-low latency Gemini Live audio and video agents.
73
+
74
+ ---
75
+
76
+ ## 📦 Installation
77
+
78
+ ```bash
79
+ pip install omniai-kit
80
+ ```
81
+
82
+ ### Optional Provider Dependencies (for direct standalone routing)
83
+ ```bash
84
+ pip install "omniai-kit[all]" # Installs all upstream provider SDKs
85
+ pip install "omniai-kit[openai]" # Installs OpenAI SDK
86
+ pip install "omniai-kit[gemini]" # Installs Google GenAI SDK
87
+ pip install "omniai-kit[anthropic]" # Installs Anthropic SDK
88
+ ```
89
+
90
+ ---
91
+
92
+ ## 🏛️ Supported Model Providers
93
+
94
+ OmniAI natively routes and normalizes parameters across the following providers:
95
+
96
+ | Provider | Schema | Example Models |
97
+ | :--- | :--- | :--- |
98
+ | **OpenAI** | `openai:<model>` | `openai:gpt-4o`, `openai:o3-mini`, `openai:gpt-4o-mini` |
99
+ | **Google Gemini** | `gemini:<model>` | `gemini:gemini-2.5-flash`, `gemini:gemini-3.7-flash` |
100
+ | **Anthropic** | `anthropic:<model>` | `anthropic:claude-3-5-sonnet-20241022`, `anthropic:claude-3-opus` |
101
+ | **vLLM (Self-Hosted)** | `vllm:<model>` | `vllm:meta-llama/Llama-3.1-8B-Instruct` |
102
+ | **OpenRouter** | `openrouter:<model>` | `openrouter:anthropic/claude-3.5-sonnet` |
103
+ | **Ollama (Local)** | `ollama:<model>` | `ollama:qwen2.5-coder:7b` |
104
+
105
+ ---
106
+
107
+ ## 🚀 Quickstart
108
+
109
+ ### 1. Basic Chat Completion
110
+
111
+ ```python
112
+ from omniai import OmniaiClient
113
+
114
+ # Automatically discovers OMNIAI_API_KEY from environment or .env
115
+ client = OmniaiClient()
116
+
117
+ response = client.chat(
118
+ model="gemini:gemini-2.5-flash",
119
+ prompt="Explain distributed event streaming in two concise sentences.",
120
+ )
121
+ print(response)
122
+ ```
123
+
124
+ Both direct shortcut and resource styles are supported:
125
+ ```python
126
+ # Shortcut style
127
+ response = client.chat(model="gemini:gemini-2.5-flash", prompt="Hello!")
128
+
129
+ # Resource hierarchy style (OpenAI-compatible)
130
+ response = client.chat.completions.create(model="gemini:gemini-2.5-flash", prompt="Hello!")
131
+ ```
132
+
133
+ ---
134
+
135
+ ### 2. Real-Time Token Streaming
136
+
137
+ ```python
138
+ from omniai import OmniaiClient
139
+
140
+ client = OmniaiClient()
141
+
142
+ print("Assistant: ", end="", flush=True)
143
+ for token in client.stream(
144
+ model="gemini:gemini-2.5-flash",
145
+ prompt="List 3 key architectural benefits of event-driven microservices.",
146
+ ):
147
+ print(token, end="", flush=True)
148
+ print()
149
+ ```
150
+
151
+ ---
152
+
153
+ ### 3. Strongly Typed Structured Outputs (Pydantic V2)
154
+
155
+ Pass any Pydantic class to `response_model`. The SDK extracts JSON schema, enforces structured output from the model, and automatically parses and validates the response into your Python model:
156
+
157
+ ```python
158
+ from typing import List
159
+ from pydantic import BaseModel, Field
160
+ from omniai import OmniaiClient
161
+
162
+ class ServiceArchitecture(BaseModel):
163
+ service_name: str = Field(description="Name of the service")
164
+ patterns: List[str] = Field(description="Design patterns applied")
165
+ availability_sla: float = Field(description="Target SLA percentage")
166
+
167
+ client = OmniaiClient()
168
+
169
+ analysis: ServiceArchitecture = client.chat(
170
+ model="gemini:gemini-2.5-flash",
171
+ prompt="Design a high-throughput payment processing service.",
172
+ response_model=ServiceArchitecture,
173
+ )
174
+
175
+ print(f"Service: {analysis.service_name}")
176
+ print(f"Patterns: {analysis.patterns}")
177
+ print(f"Target SLA: {analysis.availability_sla}%")
178
+ ```
179
+
180
+ ---
181
+
182
+ ### 4. Asynchronous Client (`AsyncOmniaiClient`)
183
+
184
+ Full async/await parity for high-concurrency microservices, FastAPI, and async workers:
185
+
186
+ ```python
187
+ import asyncio
188
+ from omniai import AsyncOmniaiClient
189
+
190
+ async def main():
191
+ async with AsyncOmniaiClient() as client:
192
+ # Async chat
193
+ res = await client.chat(
194
+ model="gemini:gemini-2.5-flash",
195
+ prompt="Summarize CQRS in 20 words.",
196
+ )
197
+ print("Response:", res)
198
+
199
+ # Async streaming
200
+ print("Streaming: ", end="", flush=True)
201
+ async for chunk in client.stream(
202
+ model="gemini:gemini-2.5-flash",
203
+ prompt="Count from 1 to 5.",
204
+ ):
205
+ print(chunk, end="", flush=True)
206
+ print()
207
+
208
+ asyncio.run(main())
209
+ ```
210
+
211
+ ---
212
+
213
+ ### 5. Background Task Queue (Celery Integration)
214
+
215
+ Queue long-running jobs to the background Celery cluster with fault-tolerant polling that survives transient network dropouts:
216
+
217
+ ```python
218
+ from omniai import OmniaiClient
219
+ from pydantic import BaseModel
220
+
221
+ class ComprehensiveAudit(BaseModel):
222
+ vulnerabilities: list[str]
223
+ risk_score: int
224
+
225
+ client = OmniaiClient()
226
+
227
+ # 1. Submit task asynchronously
228
+ job = client.submit_task(
229
+ model="gemini:gemini-2.5-flash",
230
+ prompt="Perform in-depth threat modeling for an open S3 bucket with public access.",
231
+ response_model=ComprehensiveAudit,
232
+ )
233
+ print(f"Dispatched Celery Task ID: {job.task_id}")
234
+
235
+ # 2. Poll until complete with automatic error-tolerance
236
+ result: ComprehensiveAudit = job.wait(timeout=120.0, interval=2.0)
237
+ print("Task finished successfully!")
238
+ print(f"Risk Score: {result.risk_score}")
239
+ ```
240
+
241
+ ---
242
+
243
+ ### 6. LiveKit Multimodal Real-Time Voice & Video
244
+
245
+ Create WebRTC sessions for sub-second bidirectional voice and vision agents:
246
+
247
+ ```python
248
+ from omniai import OmniaiClient
249
+
250
+ client = OmniaiClient()
251
+
252
+ session = client.create_live_session(
253
+ model="gemini:gemini-2.5-flash",
254
+ voice="Aoede",
255
+ video_input=True,
256
+ )
257
+
258
+ print(f"LiveKit Server: {session.server_url}")
259
+ print(f"Room: {session.room_name}")
260
+ print(f"Token: {session.participant_token}")
261
+ ```
262
+
263
+ ---
264
+
265
+ ### 7. Model Discovery & Catalog
266
+
267
+ Query available models dynamically from the gateway:
268
+
269
+ ```python
270
+ from omniai import OmniaiClient
271
+
272
+ client = OmniaiClient()
273
+
274
+ models = client.models.list()
275
+ print(f"Total available models: {len(models.data)}")
276
+ for m in models.data[:5]:
277
+ print(f" • {m.id} (provider: {m.provider}, release: {m.release_date})")
278
+ ```
279
+
280
+ ---
281
+
282
+ ## 🔑 Authentication & Configuration
283
+
284
+ `OmniaiClient` and `AsyncOmniaiClient` resolve configuration in the following order:
285
+
286
+ | Setting | 1. Explicit Argument | 2. Environment Variables (`.env`) | 3. Default Fallback |
287
+ | :--- | :--- | :--- | :--- |
288
+ | **`api_key`** | `OmniaiClient(api_key="...")` | `OMNIAI_API_KEY` &rarr; `OMNI_API_KEY` &rarr; `X_API_KEY` | `""` |
289
+ | **`base_url`** | `OmniaiClient(base_url="...")` | `OMNIAI_BASE_URL` &rarr; `OMNI_BASE_URL` &rarr; `GATEWAY_URL` | `"https://omniai.go-agents.app"` |
290
+ | **`timeout`** | `OmniaiClient(timeout=30.0)` | — | `60.0` seconds |
291
+ | **`max_retries`**| `OmniaiClient(max_retries=5)`| — | `3` attempts |
292
+
293
+ Create a `.env` file in your project directory:
294
+ ```env
295
+ OMNIAI_API_KEY=sk-or-v1-your-api-key-here
296
+ ```
297
+
298
+ ---
299
+
300
+ ## 🛡️ Exception Hierarchy
301
+
302
+ All SDK exceptions inherit from `OmniaiError`:
303
+
304
+ ```text
305
+ OmniaiError
306
+ ├── OmniaiAuthError # HTTP 401 / 403 (Invalid or revoked API key)
307
+ ├── OmniaiPaymentRequiredError # HTTP 402 (Prepaid credit balance exhausted)
308
+ ├── OmniaiNotFoundError # HTTP 404 (Resource or model not found)
309
+ ├── OmniaiRateLimitError # HTTP 429 (Rate limit exceeded; includes .retry_after)
310
+ ├── OmniaiTimeoutError # Request or polling timeout
311
+ ├── OmniaiConnectionError # DNS, connection drop, network failure
312
+ ├── OmniaiExecutionError # HTTP 5xx or upstream provider execution failure
313
+ ├── OmniaiValidationError # Output failed Pydantic schema validation
314
+ └── OmniaiUnsupportedProviderError # Request for an unsupported provider prefix
315
+ ```
316
+
317
+ ---
318
+
319
+ ## 📂 Repository Directory Pattern
320
+
321
+ ```text
322
+ omniai-sdk/
323
+ ├── .github/
324
+ │ └── workflows/
325
+ │ └── pypi-publish.yml # PyPI publishing workflow
326
+ ├── omniai/
327
+ │ ├── resources/ # Modular resource namespaces
328
+ │ │ ├── chat.py
329
+ │ │ ├── livekit.py
330
+ │ │ ├── models.py
331
+ │ │ ├── router.py
332
+ │ │ └── tasks.py
333
+ │ ├── types/ # Typed Pydantic schemas
334
+ │ │ ├── chat.py
335
+ │ │ ├── livekit.py
336
+ │ │ ├── models.py
337
+ │ │ └── tasks.py
338
+ │ ├── __init__.py # Top-level exports
339
+ │ ├── _base.py # Base HTTP transport & retry policy
340
+ │ ├── _constants.py # Default constants & endpoints
341
+ │ ├── _version.py # Package version (1.0.0)
342
+ │ ├── client.py # OmniaiClient & AsyncOmniaiClient
343
+ │ ├── exceptions.py # Typed exception hierarchy
344
+ │ └── py.typed # PEP 561 typing compliance
345
+ ├── examples/
346
+ │ ├── quickstart.py
347
+ │ ├── streaming.py
348
+ │ ├── structured_output.py
349
+ │ └── async_chat.py
350
+ ├── tests/ # Unit and integration test suite
351
+ ├── .env.example
352
+ ├── .gitignore
353
+ ├── LICENSE # MIT License
354
+ ├── README.md # Documentation & Guides
355
+ ├── pyproject.toml # PEP 517/621 packaging metadata
356
+ ├── requirements.txt # Core dependencies (httpx, pydantic)
357
+ └── test.py # Root test script for quick validation
358
+ ```
359
+
360
+ ---
361
+
362
+ ## 🧪 Testing
363
+
364
+ Run the test suite with `pytest`:
365
+
366
+ ```bash
367
+ pytest tests
368
+ ```
369
+
370
+ Or run the quick root validation script:
371
+
372
+ ```bash
373
+ python test.py
374
+ ```
375
+
376
+ ---
377
+
378
+ ## 📄 License
379
+
380
+ MIT © [OmniAI Team](https://omniai.go-agents.app) — Jayed Bin Jahangir