Open doggy8088 opened 7 months ago
The endpoint between Azure OpenAI Service (AOAI) and OpenAI API has a little bit different, but the API spec are the same.
Azure OpenAI Service
OpenAI API
Just change app/api/route.ts file from:
app/api/route.ts
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
The endpoint between
Azure OpenAI Service
(AOAI) andOpenAI API
has a little bit different, but the API spec are the same.Just change
app/api/route.ts
file from:to
See also: Azure OpenAI Service REST API reference - Azure OpenAI | Microsoft Learn