Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for Azure OpenAI Service (AOAI) #24

Open
doggy8088 opened this issue Feb 14, 2024 · 0 comments
Open

Support for Azure OpenAI Service (AOAI) #24

doggy8088 opened this issue Feb 14, 2024 · 0 comments

Comments

@doggy8088
Copy link
Contributor

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant