import{O as f,r as m,i as u,b as l}from"./client-BUNURIGV.mjs";import{A as we,P as ve,t as Ne}from"./client-BUNURIGV.mjs";import{K as a}from"./index-CWMjvWgF.mjs";import{N as Re,P as Te,L as Ue,Q as Se,Y as xe,X as De,U as Ke,Z as Le,a1 as Ve,R as Ze,$ as qe,W as Ye,a0 as $e}from"./index-CWMjvWgF.mjs";import"crypto";import"worker_threads";import"./Keychain-CuE0MP5_.mjs";import"./constants-DED7MIJj.mjs";import"path";import"os";import"url";import"./index-7t_wvw7g.mjs";import"fs";import"./util-4MLVQf5_.mjs";import"./_commonjsHelpers-CLLqo0NO.mjs";import"node:util";import"node:stream";import"child_process";import"node:child_process";import"node:crypto";import"node:path";import"node:events";import"node:os";import"./sentry-common-ai21LIAw.mjs";import"./package-uaSG8XjZ.mjs";import"tty";import"better-sqlite3";import"node:url";import"./logger-D_9t6p_W.mjs";import"./startup-checkpoints-BHncfdsM.mjs";import"./AsyncSqlite-8sGv3lfc.mjs";import"./machine-id-D3_purtu.mjs";import"perf_hooks";import"./index-Cl8VihPn.mjs";import"timers/promises";import"async_hooks";import"./index-B8MOUWcP.mjs";import"assert";import"events";import"buffer";import"stream";import"util";import"node:fs";import"node:module";import"http";import"zlib";import"https";import"net";import"tls";import"stream/promises";import"./index-D758D3ss.mjs";import"./index-CCdwJKwk.mjs";import"node:fs/promises";import"node:string_decoder";import"fs/promises";import"./rolling-logger-H_IO3gVC.mjs";import"./got-BLig4ziO.mjs";import"dns";import"http2";import"module";import"./empty-DKR6Lw6w.mjs";import"node:worker_threads";(function(){try{var r=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{};r.SENTRY_RELEASE={id:"4.2.860"}}catch{}})();try{(function(){var r=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},e=new r.Error().stack;e&&(r._sentryDebugIds=r._sentryDebugIds||{},r._sentryDebugIds[e]="cfd4f763-a8c1-47cb-9f30-33275bdaec4b",r._sentryDebugIdIdentifier="sentry-dbid-cfd4f763-a8c1-47cb-9f30-33275bdaec4b")})()}catch{}class _e extends f{constructor({baseURL:e=m("OPENAI_BASE_URL"),apiKey:i=m("AZURE_OPENAI_API_KEY"),apiVersion:t=m("OPENAI_API_VERSION"),endpoint:o,deployment:d,azureADTokenProvider:n,dangerouslyAllowBrowser:s,...p}={}){if(!t)throw new a("The OPENAI_API_VERSION environment variable is missing or empty; either provide it, or instantiate the AzureOpenAI client with an apiVersion option, like new AzureOpenAI({ apiVersion: 'My API Version' }).");if(typeof n=="function"&&(s=!0),!n&&!i)throw new a("Missing credentials. Please pass one of `apiKey` and `azureADTokenProvider`, or set the `AZURE_OPENAI_API_KEY` environment variable.");if(n&&i)throw new a("The `apiKey` and `azureADTokenProvider` arguments are mutually exclusive; only one can be passed at a time.");if(p.defaultQuery={...p.defaultQuery,"api-version":t},e){if(o)throw new a("baseURL and endpoint are mutually exclusive")}else{if(o||(o=process.env.AZURE_OPENAI_ENDPOINT),!o)throw new a("Must provide one of the `baseURL` or `endpoint` arguments, or the `AZURE_OPENAI_ENDPOINT` environment variable");e=`${o}/openai`}super({apiKey:n??i,baseURL:e,...p,...s!==void 0?{dangerouslyAllowBrowser:s}:{}}),this.apiVersion="",this.apiVersion=t,this.deploymentName=d}async buildRequest(e,i={}){if(c.has(e.path)&&e.method==="post"&&e.body!==void 0){if(!u(e.body))throw new Error("Expected request body to be an object");const t=this.deploymentName||e.body.model||e.__metadata?.model;t!==void 0&&!this.baseURL.includes("/deployments")&&(e.path=`/deployments/${t}${e.path}`)}return super.buildRequest(e,i)}async authHeaders(e){return typeof this._options.apiKey=="string"?l([{"api-key":this.apiKey}]):super.authHeaders(e)}}const c=new Set(["/completions","/chat/completions","/embeddings","/audio/transcriptions","/audio/translations","/audio/speech","/images/generations","/batches","/images/edits"]);export{Re as APIConnectionError,Te as APIConnectionTimeoutError,Ue as APIError,we as APIPromise,Se as APIUserAbortError,xe as AuthenticationError,_e as AzureOpenAI,De as BadRequestError,Ke as ConflictError,Le as InternalServerError,Ve as InvalidWebhookSignatureError,Ze as NotFoundError,f as OpenAI,a as OpenAIError,ve as PagePromise,qe as PermissionDeniedError,Ye as RateLimitError,$e as UnprocessableEntityError,f as default,Ne as toFile};
//# sourceMappingURL=index-Cc5Isoc7.mjs.map
