Unified SDK for AI services with OpenAI compatibility
Project description
SDKRouter
Unified Python SDK for AI services. Access 300+ LLM models, vision, audio, image generation, search, translation, and more through a single interface.
Installation
pip install sdkrouter
Quick Start
from sdkrouter import SDKRouter, Model
client = SDKRouter(api_key="your-api-key")
response = client.chat.completions.create(
model=Model.cheap(),
messages=[{"role": "user", "content": "Hello!"}]
)
print(response.choices[0].message.content)
Features
| Feature | Description | Docs |
|---|---|---|
| Chat | OpenAI-compatible completions, streaming | @docs/01-chat.md |
| Structured Output | Pydantic models, JSON extraction | @docs/02-structured-output.md |
| Audio | TTS, STT, Deepgram streaming | @docs/03-audio.md |
| Vision | Image analysis, OCR | @docs/04-vision.md |
| Image Gen | AI image generation | @docs/05-image-gen.md |
| Search | Web search with modes | @docs/06-search.md |
| CDN | File storage | @docs/07-cdn.md |
| Translator | JSON/text translation | @docs/08-translator.md |
| Payments | Crypto payments | @docs/09-payments.md |
| Proxies | Proxy management | @docs/10-proxies.md |
| Embeddings | Text embeddings | @docs/11-embeddings.md |
| Other | Shortlinks, cleaner, models API | @docs/12-other.md |
Model Routing
Smart model selection with IDE autocomplete:
from sdkrouter import Model
Model.cheap() # Lowest cost
Model.smart() # Highest quality
Model.balanced() # Best value
Model.fast() # Fastest
# With capabilities
Model.cheap(vision=True) # + vision
Model.smart(tools=True) # + function calling
Model.balanced(json=True) # + JSON mode
# Categories
Model.smart(code=True) # Coding
Model.cheap(reasoning=True) # Problem solving
Async Support
from sdkrouter import AsyncSDKRouter, Model
import asyncio
async def main():
client = AsyncSDKRouter(api_key="your-api-key")
response = await client.chat.completions.create(
model=Model.cheap(),
messages=[{"role": "user", "content": "Hello!"}]
)
# Parallel requests
results = await asyncio.gather(
client.vision.analyze(image_url="..."),
client.audio.speech(input="Hello!"),
)
asyncio.run(main())
Audio Example
from sdkrouter import SDKRouter, AudioModel
client = SDKRouter()
# Text-to-Speech
response = client.audio.speech(
input="Hello!",
model=AudioModel.cheap(),
voice="nova",
)
Path("output.mp3").write_bytes(response.audio_bytes)
# Speech-to-Text
result = client.audio.transcribe(file=audio_bytes)
print(result.text)
Deepgram Streaming
from sdkrouter import AsyncSDKRouter
from sdkrouter.tools.audio.stt import DeepgramConfig
sdk = AsyncSDKRouter()
config = DeepgramConfig(
model="nova-3",
endpointing=300, # VAD: silence threshold (ms)
vad_events=True, # Enable VAD events
)
async with sdk.audio.stt.stream_deepgram(config) as session:
await session.send(audio_chunk)
async for segment in session.transcripts():
print(segment.text)
Configuration
# Environment variables (auto-loaded)
# SDKROUTER_API_KEY
# SDKROUTER_LLM_URL
# SDKROUTER_API_URL
# SDKROUTER_AUDIO_URL
client = SDKRouter(
api_key="your-key",
timeout=60.0,
max_retries=3,
)
Supported Providers
- OpenAI: GPT-4.5, GPT-4o, o3, o1
- Anthropic: Claude Opus 4.5, Claude Sonnet 4
- Google: Gemini 2.5 Pro, Gemini 2.0 Flash
- Meta: Llama 4, Llama 3.3
- Mistral: Mistral Large, Codestral
- DeepSeek: DeepSeek V3, R1
- And 300+ more via OpenRouter
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
sdkrouter-0.1.23.tar.gz
(164.2 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
sdkrouter-0.1.23-py3-none-any.whl
(249.9 kB
view details)
File details
Details for the file sdkrouter-0.1.23.tar.gz.
File metadata
- Download URL: sdkrouter-0.1.23.tar.gz
- Upload date:
- Size: 164.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.18
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1ef8c7c6e000cc0a99d48715cc7cb6375988226bf79a6e1b10cfa5d408764e5c
|
|
| MD5 |
17b08336c4797cc05d7142d7f34aa9f0
|
|
| BLAKE2b-256 |
98e0b1b31a9e04d133c1307b34c2dbbe9e365b175de69587c0cb2cfc350ef696
|
File details
Details for the file sdkrouter-0.1.23-py3-none-any.whl.
File metadata
- Download URL: sdkrouter-0.1.23-py3-none-any.whl
- Upload date:
- Size: 249.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.18
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c6d197014545d7a841d967adeb66034f11610b5b9fbfab537f2f7ef9b894413f
|
|
| MD5 |
3ca626b1a8430d131e0b475ee708a280
|
|
| BLAKE2b-256 |
9f91ad3641d7aaafd894fa5495fbf0283eb978b0c0d50eb42cca749a946027ad
|