1. Get a client
hybridai.py (Python 3.8 or newer, standard library only) and hybridai.mjs (Node 18 or newer, Deno, Bun or a browser). You can read each file before you use it; they are short.
In a notebook such as Google Colab run this in a cell:
!curl -sO https://hybridai.cloud/sdk/hybridai.pyOr in any terminal:
curl -O https://hybridai.cloud/sdk/hybridai.py
curl -O https://hybridai.cloud/sdk/hybridai.mjs2. Use it (Python)
from hybridai import HybridAI
ai = HybridAI("YOUR_KEY") # or set the HYBRIDAI_KEY environment variable
r = ai.chat("Say hi in 5 words")
print(r) # the answer
print(r.route, r.model, r.privacy) # where it went
# Stream the answer as it is written
for piece in ai.chat_stream("Tell me a short story"):
print(piece, end="", flush=True)
# Hide private details on your side, ask, and put them back in the answer
r = ai.chat_private("Draft a reply to jane@acme.com about invoice 4417")
print(r.redacted_prompt) # what the model saw
print(r) # answer with the real email put back
# Redact and restore
h = ai.redact("My password is sunshine", strict=True)
print(h["redacted"], h["complete"])
# Voice
text = ai.transcribe("hello.mp3", redact=True)
ai.speak("Hello from HybridAI", out_path="hello.mp3")
# A person says yes or no (prints a link, then waits)
a = ai.ask_approval("Send the refund email?", "Refund 40 dollars to order 1182")
if a["approved"]:
print("go ahead", a["receipt"])
# Webhooks (the owner switches them on for your key first): your server hears when an approval is decided
print(ai.set_webhook("https://example.org/hooks/hybridai")) # the first time this shows your signing secret once
print(ai.test_webhook())
# on your server: verify_webhook(secret, request_signature_header, raw_body) is True for a real call
# Agent keys (the owner switches them on for your key first): hand a script its own limited key
agent = ai.create_agent_key("nightly scraper", daily_limit=50, burst_per_min=20) # the key is shown once
print(agent["key"], ai.agent_keys())
# if a loop locks it: ai.unlock_agent_key(agent["id"]) to stop it for good: ai.revoke_agent_key(agent["id"])
# Saved endpoint (owner switches custom endpoints on for your key first): your own provider as the last resort
ai.set_fallback("https://api.example.com/v1", "YOUR_PROVIDER_KEY", "gpt-4o-mini")
print(ai.fallback(), ai.test_fallback())
# Output guard: hide emails, phones, cards and keys the model writes (or output_guard="block" to hold the answer back)
r = ai.chat("Write a made-up customer record with an email", output_guard="redact")
print(r, r.output_guard) # r.output_guard says what was hidden, e.g. "redact: email"
# Private memory: notes only your key can read
ai.remember("favourite-colour", "green", tags=["prefs"])
print(ai.recall("favourite-colour"), ai.memories(tag="prefs"))3. Use it (JavaScript)
import { HybridAI } from "./hybridai.mjs";
const ai = new HybridAI("YOUR_KEY"); // or set HYBRIDAI_KEY
const r = await ai.chat("Say hi in 5 words");
console.log(r.text, r.route, r.model, r.privacy);
const s = await ai.chatStream("Tell me a short story"); // answer arrives piece by piece
for await (const piece of s) process.stdout.write(piece);
const p = await ai.chatPrivate("Draft a reply to jane@acme.com about invoice 4417");
console.log(p.redactedPrompt, p.text);
const a = await ai.askApproval("Send the refund email?", { details: "Refund 40 dollars to order 1182" });
if (a.approved) console.log("go ahead", a.receipt);
await ai.setWebhook("https://example.org/hooks/hybridai"); // owner switches webhooks on first; the secret is shown once
console.log(await ai.testWebhook()); // on your server: await verifyWebhook(secret, signatureHeader, rawBody)
const agent = await ai.createAgentKey("nightly scraper", { dailyLimit: 50, burstPerMin: 20 }); // owner switches agent keys on first; the key is shown once
console.log(agent.key, await ai.agentKeys()); // later: ai.unlockAgentKey(agent.id) or ai.revokeAgentKey(agent.id)
await ai.setFallback("https://api.example.com/v1", "YOUR_PROVIDER_KEY", "gpt-4o-mini"); // your own provider as the last resort
console.log(await ai.fallback(), await ai.testFallback());
const r = await ai.chat("Write a made-up customer record with an email", { outputGuard: "redact" }); // or "block"
console.log(r.text, r.outputGuard); // outputGuard says what was hidden, e.g. "redact: email"
await ai.remember("favourite-colour", "green", { tags: ["prefs"] }); // private memory
console.log(await ai.recall("favourite-colour"), await ai.memories({ tag: "prefs" }));Your own provider keys for one call each: HybridAI("KEY", byok={"groq": "gsk_..."}) in Python, new HybridAI("KEY", { byok: { groq: "gsk_..." } }) in JavaScript. Errors raise HybridAIError with the status and message. Do not put a key you want to keep private in a web page; call HybridAI from your server.
Licence and support
The two client files are free to use, change and share under the MIT licence: keep the copyright line in the file. They come as they are, with no warranty. The HybridAI gateway itself is a hosted service and its code is not shared; running your own copy is not offered at the moment. The names HybridAI and hybridai.cloud are reserved.
The clients only talk to HybridAI, so changes at OpenAI, Groq and the other providers are handled inside the gateway and do not need a new client. We keep the /v1 calls stable and only add to them. Needs Python 3.8 or newer, or Node 18 or newer.