Quickstart

Get started with rtAV in minutes. This guide will walk you through creating your first realtime AI avatar session.

1. Get Your API Key

Sign up at platform.rtav.io/signup and create an API key from your dashboard.

After signing up, navigate to API Keys in your dashboard to create a new key. Copy the key immediately as it won't be shown again.

2. Choose Your Integration Method

rtAV supports two main integration methods:

  • WebSocket - Best for server-to-server integrations and web applications
  • WebRTC - Best for low-latency browser applications with direct peer-to-peer streaming

See the WebSocket guide or WebRTC guide for detailed examples.

3. WebSocket Quickstart

For WebSocket integration, create a session and connect:

// Browser JavaScript
// 1. Create a session
const response = await fetch('https://api.rtav.io/v1/sessions', {
  method: 'POST',
  headers: {
    'Authorization': 'Bearer rtav_ak_your_api_key_here',
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
    model: 'gpt-5.2',
    voice: 'default',
    instructions: 'You are a helpful assistant.'
  })
});

const { id: sessionId } = await response.json();

// 2. Connect via WebSocket
const ws = new WebSocket(`wss://api.rtav.io/v1/realtime?session_id=${sessionId}`);

ws.onopen = () => {
  // Send auth message (browser WebSocket can't set Authorization header)
  ws.send(JSON.stringify({
    type: 'auth',
    api_key: 'rtav_ak_your_api_key_here'
  }));
  
  // Send a text message
  ws.send(JSON.stringify({
    type: 'conversation.item.create',
    item: {
      type: 'message',
      role: 'user',
      content: [{ type: 'input_text', text: 'Hello!' }]
    }
  }));
};

ws.onmessage = (event) => {
  const data = JSON.parse(event.data);
  console.log('Received:', data);
  
  // Handle audio/video deltas
  if (data.type === 'response.output_audio.delta') {
    // Decode base64 audio and play
  }
  if (data.type === 'response.output_image.delta') {
    // Decode base64 image and display
  }
};

4. WebRTC Quickstart

For WebRTC integration, create a call with SDP negotiation:

// Browser JavaScript
// 1. Get ephemeral key (client secret)
const tokenResponse = await fetch('https://api.rtav.io/v1/realtime/client_secrets', {
  method: 'POST',
  headers: {
    'Authorization': 'Bearer rtav_ak_your_api_key_here',
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
    session: {
      type: 'realtime'
    }
  })
});

const { client_secret } = await tokenResponse.json();

// 2. Create WebRTC peer connection
const pc = new RTCPeerConnection({
  iceServers: [{ urls: 'stun:stun.l.google.com:19302' }]
});

// Set up audio/video tracks
const localStream = await navigator.mediaDevices.getUserMedia({ audio: true, video: false });
localStream.getAudioTracks().forEach(track => pc.addTrack(track, localStream));

// Create data channel for control events
const dataChannel = pc.createDataChannel('realtime');

// 3. Create offer and send to API
const offer = await pc.createOffer();
await pc.setLocalDescription(offer);

const formData = new FormData();
formData.append('sdp', offer.sdp);
formData.append('session', JSON.stringify({
  type: 'realtime',
  model: 'gpt-5.2',
  voice: 'default',
  instructions: 'You are a helpful assistant.'
}));

const callResponse = await fetch('https://api.rtav.io/v1/realtime/calls', {
  method: 'POST',
  headers: {
    'Authorization': `Bearer ${client_secret}`
  },
  body: formData
});

const answerSdp = await callResponse.text();
await pc.setRemoteDescription({ type: 'answer', sdp: answerSdp });

// 4. Handle data channel messages
dataChannel.onmessage = (event) => {
  const data = JSON.parse(event.data);
  console.log('Received:', data);
};

// 5. Handle incoming audio/video
pc.ontrack = (event) => {
  // Play remote audio/video tracks
  const audioElement = document.getElementById('audio');
  audioElement.srcObject = event.streams[0];
};

5. Next Steps

6. Pricing

rtAV charges $6/hour for active sessions. You only pay for the time your sessions are running. New users receive 10 free minutes ($1 credit) after email verification.

See Pricing for more details.