import { getDefaultPropagateContext } from "../propagation.js";
import { BaseAIProvider } from "./base.js";
import { OPENAI_AVAILABLE, WrappedCompletions, _OpenAIModule } from "./openai.js";

//#region src/providers/azure-openai.ts
var AzureOpenAI = class extends BaseAIProvider {
	_client;
	_propagateContext;
	chat;
	constructor(options) {
		super({
			amplitude: options.amplitude,
			privacyConfig: options.privacyConfig,
			providerName: "azure-openai"
		});
		const mod = options.openaiModule ?? _OpenAIModule;
		if (mod == null) throw new Error("openai package is required for Azure OpenAI. Install it with: npm install openai — or pass the module directly via the openaiModule option.");
		const AzureOpenAISDK = mod.AzureOpenAI;
		const clientOpts = {};
		if (options.apiKey) clientOpts.apiKey = options.apiKey;
		if (options.azureEndpoint) clientOpts.baseURL = options.azureEndpoint;
		if (options.apiVersion) clientOpts.defaultQuery = { "api-version": options.apiVersion };
		this._client = new AzureOpenAISDK(clientOpts);
		this._propagateContext = options.propagateContext ?? getDefaultPropagateContext();
		const originalCompletions = this._client.chat.completions;
		const wrappedCompletions = new WrappedCompletions(originalCompletions, this.trackFn(), this._amplitude, this._privacyConfig, this._propagateContext, "azure-openai");
		this.chat = { completions: {
			create: (params, amplitudeOverrides) => wrappedCompletions.create(params, amplitudeOverrides),
			parse: (params, amplitudeOverrides) => wrappedCompletions.parse(params, amplitudeOverrides)
		} };
	}
	get client() {
		return this._client;
	}
};

//#endregion
export { OPENAI_AVAILABLE as AZURE_OPENAI_AVAILABLE, AzureOpenAI };
//# sourceMappingURL=azure-openai.js.map