How to add 1:1 video calls to a Flutter app (no backend needed)
Three steps with the titli_video_sdk package: get your App Key, install the package, then TitliVideo.init() and start or join a call. No server and no tokens to begin with; server tokens are an optional hardening step at the end. Billing is metered on our servers, per second.
What you will build
Two people in a metered 1:1 video call, started from your Flutter app with only the App Key. One phone starts the call and shares its call id with the other person (your push, your chat, or Titli Chat calls); the other phone joins; both show the prebuilt call screen. You do not need a server to do this.
The App Key (tak_…) is publishable and lives in the app. A project key secret (ts_…) is different: it is only for an optional server, never for the app, because anyone who unpacks the APK can read it.
The Flutter package is tested on Android. iOS works through the underlying livekit_client package but is not yet tested by us, so for iPhone apps use the native iOS SDK or the React Native SDK (both in beta). Product details: Flutter video call SDK.
Prerequisites
- A console account. Sign-up is self-serve. A new account starts with a welcome credit of ₹100 (INR accounts) or $1.20 (USD accounts), once per person or company, so your first test calls need no recharge.
- No backend. Quick mode needs only the App Key in your app. A server of your own is optional, for production hardening.
- Flutter 3.19 or later, building for Android with
minSdkVersion21 or higher, and Java 17. - The Flutter package from pub.dev (
titli_video_sdk).
Quick mode: add your App Key, make a call in 5 minutes
No backend needed: add your App Key in the app and start calling. A server is optional, for production hardening.
- Get your App Key. In the console, open Projects → Quick mode and add your app's package name (Android) and bundle ID (iOS). Your App Key is shown there.
- Install the package from pub.dev (the console download is only a fallback).terminal
flutter pub add titli_video_sdk # or in pubspec.yaml dependencies: titli_video_sdk: ^0.2.0 - Init with the App Key, then start or join a call. That is all: no server, no tokens.lib/main.dart
import 'package:titli_video_sdk/titli_video_sdk.dart'; // 1. Once, at app start: your App Key and your own user id. No server needed. await TitliVideo.init(appKey: 'tak_…', userId: 'user-42', userName: 'Asha'); // 2. Start a video call (you are the caller and the payer)... final call = await TitliVideo.startCall(type: TitliCallType.video); // share call.callId with the other person your own way (push, your chat, Titli Chat) // 3. ...and on the other phone, join it. await TitliVideo.joinCall(callId);
The App Key is publishable, not a secret: it can only reach the app-facing routes, it is bound to your package name, bundle ID or website, and spend and usage caps fence it. The binding is a deterrent, not a lock (a determined attacker can copy an app's identity), so the caps are what limit the damage. For strict control, add server tokens (production hardening below). Quick mode: bindings, caps and error codes · Read the Client API (Quick mode).
Android permissions (before you start a call)
Declare these in android/app/src/main/AndroidManifest.xml:
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.RECORD_AUDIO" />
<uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.BLUETOOTH" android:maxSdkVersion="30" />
<uses-permission android:name="android.permission.BLUETOOTH_CONNECT" />Set minSdkVersion to 21 or higher in android/app/build.gradle, and ask for camera and microphone permission at runtime before startCall or joinCall, for example with the permission_handler package. The prebuilt screen does not ask for you; without the permission the call still connects with that device off.
import 'package:permission_handler/permission_handler.dart';
// Ask before joining. For an audio call, request only the microphone.
final granted = await [Permission.camera, Permission.microphone].request();
if (granted.values.any((s) => !s.isGranted)) return; // explain and stopShow the call screen
startCall and joinCall return a connected TitliCall with its callId. Push the prebuilt screen with it. It has video tiles, mute, camera on and off, camera flip and hang-up, and you can set the title and an accentColor.
import 'package:titli_video_sdk/titli_video_sdk.dart';
// Phone A: start the call (this user is the caller and the payer).
final call = await TitliVideo.startCall(type: TitliCallType.video);
sendToTheOtherPerson(call.callId!); // your push, your chat, or Titli Chat calls
// Phone B: join the same call.
// final call = await TitliVideo.joinCall(callId);
await Navigator.of(context).push(MaterialPageRoute(
builder: (_) => TitliCallScreen(
call: call,
title: 'Asha',
onEnded: (reason) {
// reason == TitliCallEndReason.endedByServer when the call was ended for everyone,
// the balance reached zero, or the call hit its time limit.
},
),
));joinCall(callId, role: TitliRole.host) joins as the host instead of a user. TitliVideo.setUser(userId, userName) switches the signed-in user, for example after sign-out.
Build your own call UI (optional)
TitliCall exposes its state as ValueNotifiers, so any widget can listen and rebuild:
| Property | Type | Meaning |
|---|---|---|
state | TitliCallState | connecting, connected, reconnecting, ended |
participants | List<TitliParticipant> | The other people in the call, with identity, name, isHost, microphoneEnabled, videoTrack |
microphoneEnabled, cameraEnabled | bool | This device's media |
localVideoTrack | VideoTrack? | Self view |
duration | Duration | Time since the other person joined. Display only |
endReason | TitliCallEndReason? | Set when the call ends |
Actions: toggleMicrophone(), setMicrophoneEnabled(bool), toggleCamera(), setCameraEnabled(bool), switchCamera(), hangUp() and dispose(). Render video with VideoTrackRenderer(track), which the package re-exports.
Audio calls
Start the call with the audio type. Audio calls can publish only the microphone; the prebuilt screen then shows an avatar layout without camera buttons.
// Audio only: the microphone, no camera. The prebuilt screen shows the avatar layout.
final call = await TitliVideo.startCall(type: TitliCallType.audio);End the call and keep the receipt
Either person hangs up from the call screen. To end the call for everyone from the app, a participant calls TitliVideo.calls.end(callId). A call also ends by itself 30 seconds after everyone has left (a quick reconnect inside that window continues the same call), when its maximum length is reached (in Quick mode the project's Quick-mode call limit applies), or when your balance reaches zero.
Every ended call has an Ed25519-signed receipt you can keep for disputes. Receipts, like balance and usage reports, are read with the project key, so they are server-only; you also see every call in the console. With a server (production hardening), your backend can end any call and fetch its receipt:
curl -s -u "$AUTH" -X POST $API/v1/calls/<call_id>/end
curl -s -u "$AUTH" $API/v1/calls/<call_id>/receiptMore in Webhooks and signed receipts.
How billing applies
- Measured on our servers. Minutes come from the media server's own join and leave events. Nothing the app reports changes the bill.
- Per participant-minute by default: ₹0.05 for audio and ₹0.20 for video (up to 720p). A 10-minute 1:1 video call is 2 × 10 = 20 participant-minutes, so 20 × ₹0.20 = ₹4.00.
- Billed per second, and only while at least two people are connected. A person waiting alone is not billed.
- Free seconds for your users (first call and daily), if you set them on your account, are used before your balance.
- Prepaid balance. A new call or token is refused with
402when the balance cannot cover it, and live calls end when the balance runs out. It never goes below zero. - Quick-mode caps. With the App Key, the project's Quick-mode daily spend cap and each user's daily minutes, both set in the console, fence what one app or one user can spend.
The arithmetic, including call-minute billing, is worked through in Per-minute pricing explained. The rules are in Billing and usage and the price list is on the pricing page.
Troubleshooting
When a call ends, the SDK tells you why:
TitliCallEndReason | When |
|---|---|
hungUp | This device called hangUp(). |
endedByServer | The call was ended for everyone (by a participant, or by your backend with POST /v1/calls/{call_id}/end if you use one), the balance reached zero, the call reached its maximum length or a Quick-mode limit, or an operator ended it. |
removed | The call's creator (or your backend) removed this participant. |
joinedElsewhere | The same user id joined from another device. |
connectionLost | The network dropped and did not recover. |
failedToConnect | The join token was invalid or expired, or there was no network. |
In Quick mode, every failed request raises one error type (TitliVideoError) carrying errorCode, userCode, userMessage (and the Hindi userMessageHi), a developer message and httpStatus. Show userMessage to your user as it is. The Quick-mode codes:
| Error code | Shown as | HTTP | When |
|---|---|---|---|
APP_KEY_INVALID | AK-401 | 401 | The App Key is missing, wrong, rotated away or disabled. |
QUICK_MODE_OFF | QM-403 | 403 | Quick mode is switched off for the project. |
APP_NOT_ALLOWED | AB-403 | 403 | This package name, bundle ID, website or signing certificate is not on the App Key's list. Add it under Projects → Quick mode. |
QUICK_DAILY_CAP_REACHED | QC-402 | 402 | The project's Quick-mode daily spend cap is reached. |
END_USER_DAILY_LIMIT | UM-429 | 429 | This user has used today's minutes. |
FORBIDDEN | FB-403 | 403 | Acting as another user, or on a call this user is not in. |
RATE_LIMITED | RL-429 | 429 | Too many requests from one device or network; wait for Retry-After. |
Retry only 429 (after Retry-After) and server errors (back off 1, 2 and 4 seconds); never retry the others. With server tokens, the API answers your server with { "error": { "code", "message" } }. The codes you are most likely to meet there:
| HTTP | Code | What to do |
|---|---|---|
401 | invalid_api_key, key_revoked, key_expired | The key ID or secret is wrong, or the key was revoked or has expired. unauthorized means no Basic auth header was sent. Check the key ID and secret on your server. |
402 | insufficient_balance, project_cap_reached | The balance is too low and the payer has no free seconds, or the project reached the daily spending cap set in the console. |
403 | calls_disabled, audio_disabled, video_disabled | The account, project or call type is switched off. |
409 | call_ended | You asked for a token on a call that has ended. Create a new call. |
429 | concurrency_limit, rate_limited | Up to 5 calls at once per account unless support raises it; 20 requests per second per key (burst 40). |
The full list is in the REST API reference and on Errors.
Production hardening (optional): server tokens
You do not need a server to start: Quick mode works with the App Key alone. Add a server when you want strict control over every call (who joins which call, for how long, in which role): keep the project key on your server and mint a short-lived join token per person there. The app uses the same SDK and hands it a token instead of the App Key. Both ways can run side by side.
Nothing above changes: the app keeps the same SDK and call screen. Only where the join token comes from changes.
Create a project key
Server tokens use a project key, not the App Key. In the console, open Projects. Each project has these server values:
| Value | Where it goes |
|---|---|
App ID (app_…) | Identifies the project. Safe to log. |
Key ID (tk_…) and key secret (ts_…) | Your backend only. The secret is shown once. |
Webhook secret (whsec_…) | Your backend only, to verify webhooks. |
A project can hold two active keys, so you can rotate without downtime: create the new key, deploy it, then revoke the old one. More in Authentication and tokens.
Create the call and mint tokens on your server
When a user starts a call, your backend talks to the REST API. The REST API base is https://api-videosdk.titliapp.com and it uses HTTP Basic auth with key_id:key_secret. Two requests do the work: POST /v1/calls creates the call and POST /v1/calls/{call_id}/tokens mints one join token per person.
API=https://api-videosdk.titliapp.com
AUTH="$TITLI_KEY_ID:$TITLI_KEY_SECRET" # server only, never in the app
# Optional pre-call check: free seconds left, and can the call start?
curl -s -u "$AUTH" $API/v1/end-users/user_1001
# 1. Create the call. The payer is the end user whose free seconds are used first.
curl -s -u "$AUTH" -H 'Content-Type: application/json' \
-d '{"type":"video","payer_end_user_id":"user_1001","max_duration_seconds":600}' \
$API/v1/calls
# -> { "id": "<call_id>", "status": "created", "livekit_url": "wss://…", ... }
# 2. One token per participant
curl -s -u "$AUTH" -H 'Content-Type: application/json' \
-d '{"end_user_id":"user_1001","role":"user","name":"Ravi"}' $API/v1/calls/<call_id>/tokens
curl -s -u "$AUTH" -H 'Content-Type: application/json' \
-d '{"end_user_id":"host_42","role":"host","name":"Asha"}' $API/v1/calls/<call_id>/tokens
# -> { "token": "eyJ…", "livekit_url": "wss://…", "expires_at": "…", ... }// server.js (Node 20+), optional production hardening: create a call and hand tokens to your app
import { TitliClient } from 'titli-video-sdk/server'; // npm i titli-video-sdk
const titli = new TitliClient({
keyId: process.env.TITLI_KEY_ID,
keySecret: process.env.TITLI_KEY_SECRET,
});
app.post('/api/calls', requireLogin, async (req, res) => {
const call = await titli.createCall({ type: 'video', payerEndUserId: req.user.id });
const me = await titli.token(call.id, { endUserId: req.user.id, name: req.user.name });
const host = await titli.token(call.id, { endUserId: req.body.hostId, role: 'host' });
// Each person gets only their own token: deliver the host's to the host (push, socket, ...).
await notifyHost(req.body.hostId, { callId: call.id, url: host.livekit_url, token: host.token });
res.json({ callId: call.id, url: me.livekit_url, token: me.token });
});Three details save trouble later:
end_user_idis your own id for the person: 1 to 128 characters of letters, digits and_ . : @ -. Use a stable, pseudonymous id, not a phone number or email.- Tokens expire after 10 minutes by default (
ttl_seconds, from 30 seconds up to your project's limit, normally 3600). That only limits when a person can join, not how long they can stay. max_duration_seconds(10 to 86400) makes the server end the call after that much connected time. It is the simplest way to cap what one call can cost.
Send each person their token and the livekit_url. Every field is in the REST API reference, and the Node client used above is described on the Node.js server SDK page.
Fetch the token in the app and join
The app asks your own backend for a token. This endpoint is yours, so shape it as you like; the app only needs the token and the livekit_url.
import 'dart:convert';
import 'package:http/http.dart' as http;
// Calls YOUR backend, which holds the API key and returns { token, livekit_url }.
Future<({String token, String livekitUrl})> fetchJoin() async {
final res = await http.post(
Uri.parse('https://your-server.example/titli/token'),
headers: {'Content-Type': 'application/json'},
body: jsonEncode({'type': 'video'}),
);
final j = jsonDecode(res.body) as Map<String, dynamic>;
return (token: j['token'] as String, livekitUrl: j['livekit_url'] as String);
}Then connect with the token and push the same prebuilt screen:
import 'package:titli_video_sdk/titli_video_sdk.dart';
// `token` and `livekitUrl` come from YOUR backend.
final call = await TitliCall.connect(
url: livekitUrl,
token: token,
video: true, // false for audio calls
);
await Navigator.of(context).push(MaterialPageRoute(
builder: (_) => TitliCallScreen(
call: call,
title: 'Asha',
onEnded: (reason) {
// reason == TitliCallEndReason.endedByServer when your backend ended the call,
// the account balance reached zero, or the call hit its time limit.
},
),
));For an audio call, create it with "type": "audio" on your server and pass video: false to connect:
import 'package:titli_video_sdk/titli_video_sdk.dart';
// An audio call. Quick mode: TitliVideo.startCall(type: TitliCallType.audio).
// With server tokens (optional), the token was minted for a call created with type "audio".
final call = await TitliCall.connect(url: livekitUrl, token: token, video: false);
await call.toggleMicrophone(); // mute / unmute
call.participants.addListener(() { // who is in the call
print(call.participants.value.map((p) => p.name));
});
await call.hangUp();FAQ
Do I need a backend to add video calls to a Flutter app?
No. Get your App Key from the console (Projects, then Quick mode), add your package name and bundle ID, install the package, init with the App Key and start a call. A server is optional: add one later for production hardening with server tokens.
Is it safe to put the App Key in my app?
Yes, it is publishable, not a secret. It can only start and join calls and use the other app-facing features, it is bound to your package name, bundle ID or website, and the spend and usage caps you set in the console fence it. The binding is a deterrent, not a lock, so the caps are what limit any damage. For strict control, add server tokens.
What does a test call cost?
Nothing out of pocket at first: a new account gets a welcome credit of ₹100 or $1.20, once per person or company. After that, video is ₹0.20 and audio ₹0.05 per participant-minute, billed per second, only while two people are connected.
When should I add server tokens?
When you want strict control over who joins which call, for how long and in which role, or when your app charges its users per minute from a wallet. Wallet debits belong on a server you trust, not in the app. Calls themselves work with the App Key alone.
Next steps
- See the package overview and FAQ on the Flutter video call SDK page.
- Everything the app can do with the App Key (calls, Live Hosts, live streams, gifts): the Client API (Quick mode).
- Optional, with a server endpoint: verify webhooks and store receipts. See Webhooks and signed receipts and the webhooks reference.
- Read the quickstart, and the REST API reference for the server routes.
- Let your users call verified hosts without running hosts yourself: the Live Hosts API uses the same join code.
- Other platforms: all SDKs, including the web SDK.
