Pinecall

REST API

Static helpers for the Pinecall management API. No WebSocket needed.

import {
  fetchVoices,
  fetchPhones,
  createToken,
  fetchTwilioBalance,
} from "@pinecall/sdk";

fetchVoices(opts?)#

List available TTS voices. Filter by provider and language.

import { fetchVoices } from "@pinecall/sdk";

// All voices
const voices = await fetchVoices();

// Spanish Cartesia voices only
const es = await fetchVoices({ provider: "cartesia", language: "es" });

voices.forEach((v) => console.log(`${v.name} (${v.provider}:${v.id})`));
// → "Rachel (elevenlabs:21m00Tcm4TlvDq8ikWAM)"

Returns: Voice[] — each voice has id, name, provider, gender, style, languages[], previewUrl.

OptionTypeDescription
providerstringFilter by provider name
languagestringFilter by language (BCP-47)
apiUrlstringCustom server URL

fetchPhones(opts)#

List phone numbers on your Pinecall account.

const phones = await fetchPhones({ apiKey: "pk_..." });
phones.forEach((p) => console.log(`${p.name} → ${p.number}`));
// → "(318) 633-0963 → +13186330963"

Returns: Phone[] — each phone has number (E.164), name, sid, isSdk.

OptionTypeRequiredDescription
apiKeystringYour Pinecall API key
apiUrlstringCustom server URL

createToken(opts)#

Generate a short-lived, single-use token for browser WebRTC or chat connections. Requires API key — call from your backend, never the browser.

import { createToken } from "@pinecall/sdk";

const token = await createToken({
  channel: "webrtc",
  agentId: "florencia",
  apiKey: process.env.PINECALL_API_KEY!,
});

Or via instance methods (preferred when you have a Pinecall or Agent instance):

const token = await pc.createToken("webrtc", "florencia");
const token = await agent.createToken("webrtc");

Returns: { token: string, server: string, expiresIn: number }.

OptionTypeRequiredDescription
channel"webrtc" | "chat"Token type
agentIdstringAgent slug
apiKeystringAPI key for authentication
apiUrlstringCustom server URL

See Security for the full token security model.

fetchTwilioBalance(opts?)#

Check your Twilio account balance.

const balance = await fetchTwilioBalance({ apiKey: "pk_..." });
if (balance) console.log(`$${balance.balance} ${balance.currency}`);

Returns: { balance: string, currency: string } | null.

OptionTypeRequiredDescription
apiKeystringAPI key
apiUrlstringCustom server URL

Custom server URL#

All helpers accept an apiUrl option for self-hosted or staging servers:

fetchVoices({ apiUrl: "http://localhost:1337" });
fetchPhones({ apiKey: "pk_...", apiUrl: "http://localhost:1337" });

What's next#