Quickstart
Quickstart
Pick your language and have a working voice session in under five minutes.
All three SDKs speak the same wire protocol and follow the same three-tier model: a client holds your credential, an agent is a reusable persona (instructions, voice, tools), and a session is one live run.
| Package | Language | Entry point |
|---|---|---|
cosmo-ai | TypeScript / React | new RealtimeClient({...}) → client.agent({...}).start() |
cosmo-ai-sdk | Python (asyncio) | CosmoRealtime(api_key=...) → client.agent(...).start() |
CosmoRealtime | Swift | RealtimeSession.start(.init(apiKey:baseURL:), config:) |
Every quickstart needs a workspace API key with the realtime:use scope — see API keys. The key scopes your workspace server-side; there is no project ID to pass.
TypeScript / React
npm install cosmo-aiimport { RealtimeClient } from 'cosmo-ai';
const client = new RealtimeClient({ baseUrl: 'https://app.askcosmo.ai', apiKey });
const session = await client
.agent({ instructions: 'You are a terse voice assistant.' })
.start();
session.on('transcript', (item) => {
if (item.isFinal) console.log(`[${item.role}] ${item.text}`);
});Python
pip install cosmo-ai-sdkasync with CosmoRealtime(api_key=os.environ["COSMO_API_KEY"]) as client:
agent = client.agent(instructions="You are a terse voice assistant.")
async with agent.start() as session:
await session.set_microphone_enabled(True)
await session.set_speaker_enabled(True)
async for event in session:
...Swift (macOS / iOS)
// Package.swift dependency:
// .package(url: "https://github.com/socratic-ai/cosmo-swift-sdk", from: "0.1.0")let session = try await RealtimeSession.start(
.init(apiKey: apiKey, baseURL: URL(string: "https://app.askcosmo.ai")!),
config: SessionConfig(instructions: "You are a terse voice assistant.")
)
for try await event in session.events {
// .ready, .transcript, .error, .sessionEnded, …
}