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()
async with sdk.audio.stt.stream_deepgram() 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.22.tar.gz
(163.6 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.22-py3-none-any.whl
(249.4 kB
view details)
File details
Details for the file sdkrouter-0.1.22.tar.gz.
File metadata
- Download URL: sdkrouter-0.1.22.tar.gz
- Upload date:
- Size: 163.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.18
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5b5de61a4edea6f2f146ba2ad00d0844d77c613a9448cbbc626c971fe0dc39a4
|
|
| MD5 |
130038ae9473e60b134bb8ad97aeb76f
|
|
| BLAKE2b-256 |
77f0e60d6b98221df203f258643a45512bf37bf8f0542dbfdcf8e214ef03ea44
|
File details
Details for the file sdkrouter-0.1.22-py3-none-any.whl.
File metadata
- Download URL: sdkrouter-0.1.22-py3-none-any.whl
- Upload date:
- Size: 249.4 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 |
e4ef86943d30152e57b3744dbf6e487b5b593958e273299672f633a9514206ad
|
|
| MD5 |
6220e283f4fe46de541975c6b25975ca
|
|
| BLAKE2b-256 |
583441e9d3eaf612a6cd02158bb41643a9727111e030c27af38d5f89a96fc516
|