Leverage OpenAI Compatibility with Outspeed Live API
Outspeed Live API offers a seamless integration experience by being compatible with OpenAI’s Realtime API. This means you can often use similar integration patterns and even reuse existing code.You can connect to Outspeed Live API in your applications using WebRTC. The process mirrors the one described in OpenAI’s Realtime API WebRTC Guide.The key difference is the API endpoint:
First, your backend needs to obtain an ephemeral key from Outspeed. This process is similar to OpenAI’s. You’ll make a POST request to the Outspeed sessions endpoint.Example: Creating a session and obtaining a key
Copy
Ask AI
const outspeedApiHost = "api.outspeed.com"; // Or your model provider's URLconst apiKey = "YOUR_OUTSPEED_API_KEY"; // Replace with your actual API keyasync function createRealtimeSession(sessionRequestBody) { const url = `https://${outspeedApiHost}/v1/realtime/sessions`; console.log(`👉 Creating session using: ${url}`); try { const response = await fetch(url, { method: "POST", headers: { "Authorization": `Bearer ${apiKey}`, "Content-Type": "application/json", }, body: JSON.stringify(sessionRequestBody), }); if (!response.ok) { const errorText = await response.text(); console.error("Session creation failed:", response.status, errorText); // Handle error appropriately in your application throw new Error(`Failed to create session: ${errorText}`); } const sessionData = await response.json(); console.log("🎉 Session created successfully!", sessionData); return sessionData; // This contains the ephemeral_key } catch (error) { console.error("Error during session creation:", error); throw error; }}
Remember to replace YOUR_OUTSPEED_API_KEY with your actual Outspeed API key.
Once you have the ephemeral key, use it on your application’s frontend to establish a WebRTC connection with Outspeed Live API.You can find a client-side code snippet demonstrating this in our Voice Devtools repository on GitHub.
A significant advantage of Outspeed’s OpenAI compatibility is that the Live API emits the same events as OpenAI’s Realtime API. This allows you to retain your existing event handling logic if you are migrating from or familiar with OpenAI’s API.For more details on the specific events and API specifications, please refer to the Outspeed Live API documentation.