Skip to content

Instantly share code, notes, and snippets.

@Aestheticsuraj234
Created September 3, 2025 16:58
Show Gist options
  • Select an option

  • Save Aestheticsuraj234/4c0b48080f06dcdf75f9b7919d6e5316 to your computer and use it in GitHub Desktop.

Select an option

Save Aestheticsuraj234/4c0b48080f06dcdf75f9b7919d6e5316 to your computer and use it in GitHub Desktop.
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