Free multi-provider AI SDK with OpenAI-compatible server and 27+ provider routing
Project description
AI Synapse
Free multi-provider AI SDK with drop-in OpenAI compatibility, intelligent routing across 27+ providers, and an optional local server. Use it as a Python library, run your own OpenAI-compatible API, or add the terminal chat UI on top.
pip install ai-synapse # SDK — routing, failover, OpenAI client
pip install ai-synapse[server] # SDK + local OpenAI-compatible server
pip install ai-synapse[all] # SDK + server + terminal chat (TUI)
Python SDK
Drop-in OpenAI client that routes requests across free-tier and self-hosted providers with automatic failover, key rotation, and model caching.
from ai_engine import OpenAI
client = OpenAI()
response = client.chat.completions.create(
model="gpt-4",
messages=[{"role": "user", "content": "Hello!"}],
)
print(response.choices[0].message.content)
CLI (included with the SDK):
ai-engine chat "Explain quantum tunneling"
ai-engine providers
ai-engine version
More examples: examples/sdk/
Local server
Run an OpenAI-compatible HTTP API on your machine — same routing engine as the SDK, plus a web dashboard, provider management, metrics, and chat persistence.
mkdir -p ~/.ai-engine && cp .env.example ~/.ai-engine/.env
# edit ~/.ai-engine/.env — add provider API keys
pip install ai-synapse[server]
python -m ai_engine serve
| Endpoint | URL |
|---|---|
| OpenAI API | http://localhost:8000/v1/ |
| Swagger UI | http://localhost:8000/docs |
| Health | http://localhost:8000/health |
Point any OpenAI SDK or tool at base_url="http://localhost:8000/v1":
from openai import OpenAI
client = OpenAI(base_url="http://localhost:8000/v1", api_key="dummy")
response = client.chat.completions.create(
model="gpt-4",
messages=[{"role": "user", "content": "Routed through AI Synapse server"}],
)
Server docs: API reference · Server guide · Deployment
Configuration
Provider API keys and settings load in layers. When the same variable appears in multiple places, the higher layer wins. Different names are merged.
| Priority | Source | Typical use |
|---|---|---|
| 1 (highest) | Shell / container env (export GROQ_API_KEY=…) |
CI, Docker, secrets managers |
| 2 | AI_SYNAPSE_ENV=/path/to/profile.env |
Named profiles (work.env, personal.env) |
| 3 | ./.env in the current working directory |
Git clone, venv, per-project overrides |
| 4 (lowest) | ~/.ai-engine/.env |
Global config after pip install (any cwd) |
Global setup (pip install)
mkdir -p ~/.ai-engine
cp .env.example ~/.ai-engine/.env
# edit ~/.ai-engine/.env — GROQ_API_KEY, OPENROUTER_API_KEY, etc.
Project overrides (venv / git clone)
# ~/.ai-engine/.env → shared keys
# ./.env → overrides only what differs in this project
pip install -e ".[server]"
python -m ai_engine serve
Explicit profile
AI_SYNAPSE_ENV=~/configs/ai-work.env python -m ai_engine serve
Optional paths
| File | Purpose |
|---|---|
~/.ai-engine/config.json |
Provider priorities / enable flags |
~/.ai-engine/data/ |
Model cache, CDN config cache |
See .env.example and provider keys guide.
Terminal chat (optional)
A Textual-based terminal UI for interactive chat — built on the same SDK routing layer. Install only if you want a local chat app in the terminal.
pip install ai-synapse[tui] # or ai-synapse[all]
python -m ai_engine tui
Sidebar history, model/provider routing, slash commands, @ file attach, and vision support. Full walkthrough: docs/TUI.md.
Documentation
| Doc | Contents |
|---|---|
| API reference | HTTP endpoints (server) |
| Server guide | Dashboard, providers, metrics |
| User guide | Web dashboard & chat UI |
| Architecture | Routing, failover, caching |
| Provider keys | Free-tier signup |
| Deployment | Docker, production |
| TUI guide | Terminal chat (optional) |
Development
git clone https://github.com/mihir0209/AI_engine.git
cd AI_engine
python -m venv .venv && source .venv/bin/activate
pip install -e ".[dev,all]"
pytest tests/
License
MIT — see LICENSE.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
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
File details
Details for the file ai_synapse-1.0.2.tar.gz.
File metadata
- Download URL: ai_synapse-1.0.2.tar.gz
- Upload date:
- Size: 255.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f6b9dcb60353d99f3ebc2fc4473ebe328404e80fb3bc268b86586fe5d6e33645
|
|
| MD5 |
620a3f0c3eb54c24cb0014806c6b6db5
|
|
| BLAKE2b-256 |
8447d1db44fc6980953a6e945d2ecb57dfea79ea96df565e7395e63c9fe38f47
|
File details
Details for the file ai_synapse-1.0.2-py3-none-any.whl.
File metadata
- Download URL: ai_synapse-1.0.2-py3-none-any.whl
- Upload date:
- Size: 246.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d6632f6e6b6895fdad87e54ac2dc7c00ab6a2c68691cef5b16ec78fe2bcd89d3
|
|
| MD5 |
d9782e765fbd064c0663a282e957e3dc
|
|
| BLAKE2b-256 |
7c809078c882055931a9193b7ebad3afc0fbdf5d502dca3d88bc57ad3e565763
|