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

[Feature Request] Support Azure Client #126

Open
calclavia opened this issue Feb 26, 2024 · 2 comments
Open

[Feature Request] Support Azure Client #126

calclavia opened this issue Feb 26, 2024 · 2 comments

Comments

@calclavia
Copy link

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

@CGSLivv
Copy link

CGSLivv commented Jul 17, 2024

+1

@pdlug
Copy link

pdlug commented Aug 8, 2024

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",
  // ...
});

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

3 participants