Closed aalhayali closed 4 months ago
Using Azure OpenAI API via the createOpenAI method, and following the tutorial published by Vercel: https://sdk.vercel.ai/providers/ai-sdk-providers/openai
createOpenAI
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).
'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 }; }
The above code generates responseBody: '{"error":{"code":"404","message": "Resource not found"}}' error message.
responseBody: '{"error":{"code":"404","message": "Resource not found"}}'
Azure OpenAI is not supported as a provider for AI SDK Core yet.
Duplicates #1675
Description
Using Azure OpenAI API via the
createOpenAI
method, and following the tutorial published by Vercel: https://sdk.vercel.ai/providers/ai-sdk-providers/openaiI 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
Additional context
The above code generates
responseBody: '{"error":{"code":"404","message": "Resource not found"}}'
error message.