Free multi-provider AI SDK — drop-in OpenAI & Anthropic compatibility with 27 free providers
Project description
AI Synapse — Free Multi-Provider AI SDK
Stop paying for AI inference. Drop-in
from ai_engine import OpenAI— routes through 27+ free providers with automatic failover and intelligent routing.
Free Providers
No API Key Required (Truly Free)
| Provider | Model | Endpoint |
|---|---|---|
| Pollinations | openai | text.pollinations.ai/openai |
| Hermes | Hermes-3-Llama | hermes.ai.unturf.com/v1 |
| G4F Groq | llama-3.3-70b | g4f.space/api/groq |
| G4F Gemini | gemini-2.5-flash | g4f.space/api/gemini |
| G4F NVIDIA | nemotron-3 | g4f.space/api/nvidia |
| OpenCode Zen | north-mini-code | opencode.ai/zen/v1 |
Free Tier APIs (Signup Required)
| Provider | Free Tier | Signup |
|---|---|---|
| Groq | 30 RPM, 14,400 RPD | console.groq.com |
| OpenRouter | 23 free models | openrouter.ai |
| Gemini | 5-30 RPM | aistudio.google.com |
| NVIDIA | 40 RPM | build.nvidia.com |
| Cerebras | 30 RPM | cloud.cerebras.ai |
| Cloudflare | 10K neurons/day | dash.cloudflare.com |
| GitHub | Varies | github.com/marketplace |
| Vercel | $5/month free | vercel.com |
| Cohere | 20 RPM, 1K/month | cohere.com |
| Mistral | 1 RPS, 500K tokens/min | console.mistral.ai |
| HuggingFace | $0.10/month | huggingface.co |
| Kilo | Auto free routing | app.kilo.ai |
Custom Providers (Your Keys)
| Provider | Models | Signup |
|---|---|---|
| hcnsec | Various | api.hcnsec.cn |
| LLM7 | Various | llm7.io |
| PaxSenix | Various | api.paxsenix.org |
Self-Hosted Options
| Provider | Setup | Models |
|---|---|---|
| GPT4Free | docker run -p 8080:8080 hlohaus789/g4f |
GPT-4o, Claude, Gemini |
| Ollama | curl -fsSL https://ollama.com/install.sh | sh |
Llama, Mistral, etc. |
Quick Start
Option 1: Free Tier APIs (Recommended)
# 1. Copy environment template
cp .env.example .env
# 2. Get free API keys (see guide below)
# 3. Add keys to .env file
# 4. Start server
python server.py
Option 2: Self-Hosted (No API Keys Needed)
# Start g4f server
docker run -d -p 8080:8080 hlohaus789/g4f
# Start AI Engine
python server.py
For Developers
OpenAI SDK Compatible
from openai import OpenAI
client = OpenAI(
base_url="http://localhost:8000/v1",
api_key="dummy" # Not needed for free providers
)
# Chat completion
response = client.chat.completions.create(
model="gpt-4",
messages=[{"role": "user", "content": "Hello!"}]
)
print(response.choices[0].message.content)
# Streaming
stream = client.chat.completions.create(
model="gpt-4",
messages=[{"role": "user", "content": "Tell me a story"}],
stream=True
)
for chunk in stream:
if chunk.choices[0].delta.content:
print(chunk.choices[0].delta.content, end="")
cURL
curl http://localhost:8000/v1/chat/completions \
-H "Content-Type: application/json" \
-d '{"model": "gpt-4", "messages": [{"role": "user", "content": "Hello!"}]}'
JavaScript
import OpenAI from 'openai';
const client = new OpenAI({
baseURL: 'http://localhost:8000/v1',
apiKey: 'dummy'
});
const response = await client.chat.completions.create({
model: 'gpt-4',
messages: [{ role: 'user', content: 'Hello!' }]
});
Features
Core
- OpenAI-compatible API with streaming
- Automatic provider failover
- Intelligent key rotation
- Response caching with TTL
Intelligence
- Task-based model selection
- Cost optimization
- Latency tracking
- A/B testing
Enterprise
- Multi-tenancy with quotas
- RBAC (Admin/User/Viewer)
- Audit logging
- Billing tracking
Platform
- Plugin system
- Workflow engine
- CLI tool
- Docker deployment
API Endpoints
| Endpoint | Method | Description |
|---|---|---|
/v1/chat/completions |
POST | Chat completions (OpenAI-compatible, supports stream: true) |
/v1/models |
GET/POST | List all models |
/api/providers |
GET | List providers |
/api/health/{name}/ping |
POST | Live health ping for a provider |
/api/capabilities |
GET | Provider/model capabilities (vision, etc.) |
/api/status |
GET | Engine status |
/api/statistics |
GET | Usage statistics |
/health |
GET | Health check |
/metrics |
GET | Prometheus metrics |
/docs |
GET | Swagger UI (interactive API explorer) |
/redoc |
GET | ReDoc API documentation |
Rate Limit Headers
All API responses include:
X-RateLimit-Limit— Max requests per minuteX-RateLimit-Remaining— Remaining requests in current window
Documentation
Contributing
See CONTRIBUTING.md for guidelines.
License
MIT License - See LICENSE
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
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-4.1.3.tar.gz.
File metadata
- Download URL: ai_synapse-4.1.3.tar.gz
- Upload date:
- Size: 232.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e9684aa71f440eddaed39bf544a4d2f3e7422701448310d9535f36151697d795
|
|
| MD5 |
323e3a074add5d0643aa4fa2e3c163ec
|
|
| BLAKE2b-256 |
c2dc0fc67bb3d55607286dd5f8ae7456399426718aaa2d88a37fce8fea6ae080
|
File details
Details for the file ai_synapse-4.1.3-py3-none-any.whl.
File metadata
- Download URL: ai_synapse-4.1.3-py3-none-any.whl
- Upload date:
- Size: 223.3 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 |
255c1dd1d894cb02f4d7f46608cf22e27fba475623d4536a3c94941395324561
|
|
| MD5 |
ceb8304e0533b071a9d093d21096f66c
|
|
| BLAKE2b-256 |
92d804917f24117a9891aeab9bce8b3f5ef5cd1006d41c5777daed4b326c1463
|