AI Studio libraries

Official clients for JavaScript/TypeScript and Python.

Before you start

Get a key on the Developers page of the Studio and keep it in AISTUDIO_API_KEY. A key that starts vs_test_ is a test key: calls, bookings, campaigns and voice-overs are simulated, webhooks arrive marked "test": true, and nothing is dialled or charged (Test mode). A key can only do what its scopes allow, test or live.

What every library does for you

Every operationEach operation in the reference is a typed method, grouped the same way (generated from the OpenAPI file).
RetriesRate limits (429) wait for Retry-After and try again; gateway errors and dropped connections are retried only when resending is safe. Default 2 retries.
Idempotency keysEvery create that accepts one (a call, a campaign, adding leads) gets an Idempotency-Key and a retry reuses it, so nobody is called twice.
Paginationpaginate("listCalls", ...) walks every page; listAll / list_all collects them.
ErrorsAIStudioError with status, code (no_credits, outside_calling_hours, dnd, insufficient_scope...) and the body.
WebhooksChecks the signature and the timestamp and gives you the event.

JavaScript and TypeScript

Node.js 18+, no dependencies, full TypeScript types.

Install

npm install https://aistudio.housystan.com/docs/sdk/aistudio-js.tgz

First call

import { AIStudio } from '@housystan/aistudio';

const studio = new AIStudio({ apiKey: process.env.AISTUDIO_API_KEY });
const { agents } = await studio.agents.listAgents();
const call = await studio.calls.place({ agentId: agents[0].id, phone: '+919876543210', name: 'Ravi' });
const done = await studio.calls.waitForEnd(call.log_id);
console.log(done.status, done.summary);

Common jobs

// book a call for later (placed inside your calling hours)
const { booking } = await studio.calls.book({ agentId, phone: '+919876543211', at: '2026-10-21T17:00:00+05:30', reference: 'CRM-42' });

// upload leads and start a campaign
const { campaign } = await studio.campaigns.launch({ name: 'Diwali offer', agentId, leads: [{ phone: '+919876543210', name: 'Ravi' }] });
const stats = await studio.campaigns.getCampaignStats({ id: campaign.id });

// every call, page by page
for await (const c of studio.paginate('listCalls', { status: 'completed' })) console.log(c.id);

// a voice-over, and the wallet
const audio = await studio.voices.voiceOver({ text: 'Welcome to our store.' });   // audio.data is the mp3
const { credits } = await studio.credits.get();

Webhooks

import express from 'express';
import { verifyWebhook } from '@housystan/aistudio';

app.post('/aistudio/webhook', express.raw({ type: 'application/json' }), (req, res) => {
  const event = verifyWebhook(req.body, req.headers, process.env.AISTUDIO_WEBHOOK_SECRET);
  if (event.event === 'lead.interested') { /* ... */ }
  res.sendStatus(200);
});

Runnable examples come inside the package, in examples/ (place-call.mjs, book-call.mjs, campaign.mjs, webhooks-express.mjs, voice-over.mjs): place a call, book a call, upload leads and start a campaign, receive webhooks, make a voice-over.

Python

Python 3.8+, standard library only, typed. Path parameters are positional, everything else is a keyword (from is from_).

Install

pip install https://aistudio.housystan.com/docs/sdk/aistudio-python.tar.gz

First call

from aistudio import AIStudio

studio = AIStudio()  # reads AISTUDIO_API_KEY
agents = studio.agents.list_agents()["agents"]
call = studio.calls.place(agent_id=agents[0]["id"], phone="+919876543210", name="Ravi")
done = studio.calls.wait_for_end(call["log_id"])
print(done["status"], done.get("summary"))

Common jobs

from datetime import datetime, timedelta, timezone
IST = timezone(timedelta(hours=5, minutes=30))

booking = studio.calls.book(agent_id=agent_id, phone="+919876543211", at=datetime(2026, 10, 21, 17, 0, tzinfo=IST), reference="CRM-42")
result = studio.campaigns.launch(name="Diwali offer", agent_id=agent_id, leads=[{"phone": "+919876543210", "name": "Ravi"}])
stats = studio.campaigns.get_campaign_stats(result["campaign"]["id"])
for c in studio.paginate("listCalls", status="completed"): print(c["id"])
studio.voices.voice_over("Welcome to our store.").save("welcome.mp3")
print(studio.credits.get()["credits"])

Webhooks

from fastapi import FastAPI, Request, HTTPException
from aistudio import verify_webhook, WebhookVerificationError

@app.post("/aistudio/webhook")
async def hook(request: Request):
    try:
        event = verify_webhook(await request.body(), request.headers, SECRET)
    except WebhookVerificationError as e:
        raise HTTPException(400, e.reason)
    return {"ok": True}

Runnable examples come inside the package, in examples/ (place_call.py, book_call.py, campaign.py, webhooks_fastapi.py, voice_over.py): place a call, book a call, upload leads and start a campaign, receive webhooks, make a voice-over.

More

AI assistants: the MCP package lets Claude Desktop and other apps use your workspace (setup).

npx -y https://aistudio.housystan.com/docs/sdk/aistudio-mcp.tgz

No library: every example on Common jobs has a curl tab. Postman: aistudio.postman_collection.json. The spec: /docs/openapi.yaml.