Created
September 3, 2025 16:58
-
-
Save Aestheticsuraj234/4c0b48080f06dcdf75f9b7919d6e5316 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { NextResponse } from "next/server"; | |
| import axios from "axios"; | |
| export async function GET() { | |
| try { | |
| // Ask OpenAI for a temporary client_secret | |
| const response = await axios.post( | |
| "https://api.openai.com/v1/realtime/client_secrets", | |
| { | |
| model: "gpt-4o-realtime-preview-2025-06-03", | |
| }, | |
| { | |
| headers: { | |
| Authorization: `Bearer ${process.env.OPENAI_API_KEY}`, | |
| "Content-Type": "application/json", | |
| }, | |
| } | |
| ); | |
| return NextResponse.json({ | |
| tempApiKey: response.data.client_secret.value, | |
| }); | |
| } catch (err: any) { | |
| console.error("Error creating client_secret:", err.response?.data || err); | |
| return NextResponse.json({ error: "Failed to create client_secret" }, { status: 500 }); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment