instructor-js
instructor-js copied to clipboard
[Feature Request] Support Azure Client
Would it be possible to have this library work with Azure's OpenAI client as well?
https://learn.microsoft.com/en-us/azure/ai-services/openai/how-to/switching-endpoints
+1
Azure OpenAI endpoints work if you use the AzureOpenAI client wrapper from the official OpenAI TypeScript/JavaScript client and pass it to Instructor. I had to create an OpenAI deployment in Azure and a model deployment for the model I wanted to use. When I did that the Azure console showed the API version to use.
Example code:
import { AzureOpenAI } from "openai";
import Instructor from "@instructor-ai/instructor";
const endpointUrl = "https://your-endpoint.openai.azure.com";
const apiKey = "your key";
const apiVersion = "2023-03-15-preview";
const deployment = "gpt-4o";
const client = new AzureOpenAI({ apiVersion, apiKey, endpoint, deployment });
const instructor = Instructor({ client, mode: "TOOLS" });
const user = await instructor.chat.completions.create({
model: "gpt-4o",
// ...
});