Migrating/From Twilio / metered
Migrating from Twilio / metered providers
Replace the provider's token/credential fetch with one call to Baton. The response is the standard iceServers shape, so the client side barely changes.
Swap the credential fetch
// Twilio: NTS token → token.ice_servers (snake_case, per-GB metered)
const token = await twilioClient.tokens.create();
const iceServers = token.iceServers; // provider-shaped// Baton: one POST, standard iceServers, flat-rate
const { iceServers } = await fetch("https://api.usebaton.io/v1/credentials", {
method: "POST",
headers: { Authorization: `Bearer ${process.env.BATON_API_KEY}` },
body: JSON.stringify({ ttl: 3600, region: "eu-central" })
}).then(r => r.json());What changes
| Concern | Twilio / metered | Baton |
|---|---|---|
| Billing | Per-GB of relayed traffic — variable, hard to forecast. | Flat monthly by concurrency tier — the bill is the same whether you relay 10 GB or 10 TB. |
| Response shape | Provider-specific field names. | Standard iceServers array. |
| Relay IPs | Rotating pool. | Stable, allowlistable IPs. |
| Region control | Limited. | You pick the region; media stays there. |
Keep the credential fetch server-side in both cases — you're replacing one server-side call with another, not changing where secrets live.