srt-ai
srt-ai copied to clipboard
Support for Azure OpenAI Service (AOAI)
The endpoint between Azure OpenAI Service
(AOAI) and OpenAI API
has a little bit different, but the API spec are the same.
Just change app/api/route.ts
file from:
const response = await fetch("https://api.openai.com/v1/chat/completions", {
headers: {
"Content-Type": "application/json",
Authorization: `Bearer ${process.env.OPENAI_API_KEY}`,
},
method: "POST",
body: JSON.stringify({
model: "gpt-3.5-turbo-0125",
to
const response = await fetch(`https://${YOUR_RESOURCE_NAME}.openai.azure.com/openai/deployments/${YOUR_DEPLOYMENT_NAME}/chat/completions?api-version=2023-05-15`, {
headers: {
"Content-Type": "application/json",
"api-key": `${process.env.OPENAI_API_KEY}`,
},
method: "POST",
body: JSON.stringify({
model: "gpt-35-turbo",
See also: Azure OpenAI Service REST API reference - Azure OpenAI | Microsoft Learn