azure.d.mts 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. import type { RequestInit } from "./internal/builtin-types.mjs";
  2. import type { NullableHeaders } from "./internal/headers.mjs";
  3. import { FinalRequestOptions } from "./internal/request-options.mjs";
  4. import { ClientOptions, OpenAI } from "./client.mjs";
  5. /** API Client for interfacing with the Azure OpenAI API. */
  6. export interface AzureClientOptions extends ClientOptions {
  7. /**
  8. * Defaults to process.env['OPENAI_API_VERSION'].
  9. */
  10. apiVersion?: string | undefined;
  11. /**
  12. * Your Azure endpoint, including the resource, e.g. `https://example-resource.azure.openai.com/`
  13. */
  14. endpoint?: string | undefined;
  15. /**
  16. * A model deployment, if given, sets the base client URL to include `/deployments/{deployment}`.
  17. * Note: this means you won't be able to use non-deployment endpoints. Not supported with Assistants APIs.
  18. */
  19. deployment?: string | undefined;
  20. /**
  21. * Defaults to process.env['AZURE_OPENAI_API_KEY'].
  22. */
  23. apiKey?: string | undefined;
  24. /**
  25. * A function that returns an access token for Microsoft Entra (formerly known as Azure Active Directory),
  26. * which will be invoked on every request.
  27. */
  28. azureADTokenProvider?: (() => Promise<string>) | undefined;
  29. }
  30. /** API Client for interfacing with the Azure OpenAI API. */
  31. export declare class AzureOpenAI extends OpenAI {
  32. deploymentName: string | undefined;
  33. apiVersion: string;
  34. /**
  35. * API Client for interfacing with the Azure OpenAI API.
  36. *
  37. * @param {string | undefined} [opts.apiVersion=process.env['OPENAI_API_VERSION'] ?? undefined]
  38. * @param {string | undefined} [opts.endpoint=process.env['AZURE_OPENAI_ENDPOINT'] ?? undefined] - Your Azure endpoint, including the resource, e.g. `https://example-resource.azure.openai.com/`
  39. * @param {string | undefined} [opts.apiKey=process.env['AZURE_OPENAI_API_KEY'] ?? undefined]
  40. * @param {string | undefined} opts.deployment - A model deployment, if given, sets the base client URL to include `/deployments/{deployment}`.
  41. * @param {string | null | undefined} [opts.organization=process.env['OPENAI_ORG_ID'] ?? null]
  42. * @param {string} [opts.baseURL=process.env['OPENAI_BASE_URL']] - Sets the base URL for the API, e.g. `https://example-resource.azure.openai.com/openai/`.
  43. * @param {number} [opts.timeout=10 minutes] - The maximum amount of time (in milliseconds) the client will wait for a response before timing out.
  44. * @param {number} [opts.httpAgent] - An HTTP agent used to manage HTTP(s) connections.
  45. * @param {Fetch} [opts.fetch] - Specify a custom `fetch` function implementation.
  46. * @param {number} [opts.maxRetries=2] - The maximum number of times the client will retry a request.
  47. * @param {Headers} opts.defaultHeaders - Default headers to include with every request to the API.
  48. * @param {DefaultQuery} opts.defaultQuery - Default query parameters to include with every request to the API.
  49. * @param {boolean} [opts.dangerouslyAllowBrowser=false] - By default, client-side use of this library is not allowed, as it risks exposing your secret API credentials to attackers.
  50. */
  51. constructor({ baseURL, apiKey, apiVersion, endpoint, deployment, azureADTokenProvider, dangerouslyAllowBrowser, ...opts }?: AzureClientOptions);
  52. buildRequest(options: FinalRequestOptions, props?: {
  53. retryCount?: number;
  54. }): Promise<{
  55. req: RequestInit & {
  56. headers: Headers;
  57. };
  58. url: string;
  59. timeout: number;
  60. }>;
  61. protected authHeaders(opts: FinalRequestOptions): Promise<NullableHeaders | undefined>;
  62. }
  63. //# sourceMappingURL=azure.d.mts.map