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

Azure OpenAI support #1643

Closed
aalhayali opened this issue May 18, 2024 · 2 comments
Closed

Azure OpenAI support #1643

aalhayali opened this issue May 18, 2024 · 2 comments

Comments

@aalhayali
Copy link

aalhayali commented May 18, 2024

Description

Using Azure OpenAI API via the createOpenAI method, and following the tutorial published by Vercel: https://sdk.vercel.ai/providers/ai-sdk-providers/openai

I tried different API versions, based on this doc: https://learn.microsoft.com/en-us/azure/ai-services/openai/reference along with different Auzre OpenAI models (gpt-35-turbo and gpt-4).

Code example

'use server';

import { createOpenAI } from "@ai-sdk/openai";
import { generateObject } from "ai";
import { generateText } from "ai";
import { z } from "zod";

const openai = createOpenAI({
  apiKey: process.env.AZURE_OPENAI_API_KEY,
  baseURL:
    "https://{resource}.openai.azure.com/openai/deployments/{deployment}/chat/completions?api-version=2024-02-01",
});

export async function getNotifications(input: string) {
  "use server";

  const { object: notifications } = await generateObject({
    model: openai("gpt-4"),
    system: "You generate three notifications for a messages app.",
    prompt: input,
    schema: z.object({
      notifications: z.array(
        z.object({
          name: z.string().describe("Name of a fictional person."),
          message: z.string().describe("Do not use emojis or links."),
          minutesAgo: z.number(),
        })
      ),
    }),
  });

  return { notifications };
}

Additional context

The above code generates responseBody: '{"error":{"code":"404","message": "Resource not found"}}' error message.

@lgrammel lgrammel changed the title 404: Resource not found error message Azure OpenAI support May 23, 2024
@lgrammel
Copy link
Collaborator

Azure OpenAI is not supported as a provider for AI SDK Core yet.

@lgrammel
Copy link
Collaborator

Duplicates #1675

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

No branches or pull requests

2 participants