├── .github └── workflows │ └── test.yml ├── .gitignore ├── .npmignore ├── .openapi-generator-ignore ├── .openapi-generator ├── FILES └── VERSION ├── LICENSE ├── README.md ├── api.ts ├── base.ts ├── common.ts ├── configuration.ts ├── dist ├── api.d.ts ├── api.js ├── base.d.ts ├── base.js ├── common.d.ts ├── common.js ├── configuration.d.ts ├── configuration.js ├── index.d.ts └── index.js ├── index.ts ├── package-lock.json ├── package.json └── tsconfig.json /.github/workflows/test.yml: -------------------------------------------------------------------------------- 1 | name: Node.js CI 2 | 3 | on: 4 | push: 5 | branches: [ master ] 6 | pull_request: 7 | branches: [ master ] 8 | 9 | jobs: 10 | build: 11 | 12 | runs-on: ubuntu-latest 13 | 14 | strategy: 15 | matrix: 16 | node-version: [16.x, 18.x] 17 | steps: 18 | - uses: actions/checkout@v3 19 | - name: Use Node.js ${{ matrix.node-version }} 20 | uses: actions/setup-node@v3 21 | with: 22 | node-version: ${{ matrix.node-version }} 23 | cache: 'npm' 24 | - run: npm ci 25 | - run: npm run build 26 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | /node_modules 2 | -------------------------------------------------------------------------------- /.npmignore: -------------------------------------------------------------------------------- 1 | # empty npmignore to ensure all required files (e.g., in the dist folder) are published by npm -------------------------------------------------------------------------------- /.openapi-generator-ignore: -------------------------------------------------------------------------------- 1 | .gitignore 2 | README.md 3 | git_push.sh 4 | package.json 5 | package-lock.json -------------------------------------------------------------------------------- /.openapi-generator/FILES: -------------------------------------------------------------------------------- 1 | .npmignore 2 | api.ts 3 | base.ts 4 | common.ts 5 | configuration.ts 6 | index.ts 7 | -------------------------------------------------------------------------------- /.openapi-generator/VERSION: -------------------------------------------------------------------------------- 1 | 6.4.0 -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License 2 | 3 | Copyright (c) OpenAI (https://openai.com) 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in 13 | all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | THE SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Azure OpenAI Node.js Library 2 | 3 | This is a fork of the official [OpenAI Node.js library](https://github.com/openai/openai-node) that has been adapted to support the Azure OpenAI API. The objective of this library is to minimize the changes required to migrate from the official OpenAI library to Azure OpenAI or revert back to OpenAI. 4 | 5 | This library allows you to use Azure OpenAI's API without making any changes to your existing OpenAI code. You can simply add Azure information to your configuration and start using the Azure OpenAI model. 6 | 7 | ## Installation 8 | 9 | To install this library, use the following command: 10 | ```bash 11 | $ npm install azure-openai 12 | ``` 13 | 14 | ## Usage 15 | 16 | The library needs to be configured with your Azure OpenAI's key, endpoint and deploymentId. you can obtain these credentials from [Azure Portal](https://portal.azure.com). Please see the below screenshot: 17 | ![image](https://user-images.githubusercontent.com/26411726/225185239-6d1f3058-531c-4c7e-9496-8c2956d23f5d.png) 18 | 19 | To migrate from the official OpenAI model to the Azure OpenAI model, you can just simply add **azure info into configuration** to migrate, that is it. You donot need to change any code. Please see the below steps: 20 | 21 | 1. Install the library by running the following command: 22 | ```bash 23 | npm install azure-openai 24 | ``` 25 | 26 | 2. Update the import statement from "**openai**" to "**azure-openai**": 27 | ```typescript 28 | //import { Configuration, OpenAIApi } from "openai"; 29 | import { Configuration, OpenAIApi } from "azure-openai"; 30 | ``` 31 | 32 | 3. Add the Azure OpenAI information to your project configuration: 33 | ```typescript 34 | this.openAiApi = new OpenAIApi( 35 | new Configuration({ 36 | apiKey: this.apiKey, 37 | // add azure info into configuration 38 | azure: { 39 | apiKey: {your-azure-openai-resource-key}, 40 | endpoint: {your-azure-openai-resource-endpoint}, 41 | // deploymentName is optional, if you donot set it, you need to set it in the request parameter 42 | deploymentName: {your-azure-openai-resource-deployment-name}, 43 | } 44 | }), 45 | ); 46 | ``` 47 | 48 | 4. run your code. That's it. 49 | 50 | 5. optional, if you use stream = true. you may need to change response 51 | ``` 52 | // Azure OpenAI donot response delta data, so you need to change the response to text 53 | // const delta = parsed.choices[0].delta.content; 54 | const delta = parsed.choices[0].text; 55 | ``` 56 | 57 | 6. optional, you can also set your Azure deploymentName by replacing your model with deployment name, like this: 58 | ``` 59 | const response = await this.openAiApi.createCompletion({ 60 | model: {your-azure-openai-resource-deployment-name}, 61 | prompt: prompt, 62 | max_tokens: 100, 63 | top_p: 1, 64 | frequency_penalty: 0, 65 | presence_penalty: 0 66 | }); 67 | ``` 68 | 69 | ## Support 70 | support latest version of OpenAI API, v3.2.0. 71 | 72 | ## Test 73 | | API | Test Status | 74 | | --- | --- | 75 | | createChatCompletion | Pass | 76 | | createCompletion | Pass | 77 | | createEmbedding | Pass | 78 | | createImage | Not Support | 79 | 80 | Check [Azure OpenAI Rest Spec](https://github.com/Azure/azure-rest-api-specs/blob/main/specification/cognitiveservices/data-plane/AzureOpenAI/inference/preview/2023-03-15-preview/inference.json) 81 | 82 | Please feel free to submit your [issues](https://github.com/1openwindow/azure-openai-node/issues) or pull requests to support other APIs. 83 | -------------------------------------------------------------------------------- /base.ts: -------------------------------------------------------------------------------- 1 | /* tslint:disable */ 2 | /* eslint-disable */ 3 | /** 4 | * OpenAI API 5 | * APIs for sampling from and fine-tuning language models 6 | * 7 | * The version of the OpenAPI document: 1.2.0 8 | * 9 | * 10 | * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). 11 | * https://openapi-generator.tech 12 | * Do not edit the class manually. 13 | */ 14 | 15 | 16 | import type { Configuration } from './configuration'; 17 | // Some imports not used depending on template conditions 18 | // @ts-ignore 19 | import type { AxiosPromise, AxiosInstance, AxiosRequestConfig } from 'axios'; 20 | import globalAxios from 'axios'; 21 | 22 | export const BASE_PATH = "https://api.openai.com/v1".replace(/\/+$/, ""); 23 | 24 | /** 25 | * 26 | * @export 27 | */ 28 | export const COLLECTION_FORMATS = { 29 | csv: ",", 30 | ssv: " ", 31 | tsv: "\t", 32 | pipes: "|", 33 | }; 34 | 35 | /** 36 | * 37 | * @export 38 | * @interface RequestArgs 39 | */ 40 | export interface RequestArgs { 41 | url: string; 42 | options: AxiosRequestConfig; 43 | } 44 | 45 | /** 46 | * 47 | * @export 48 | * @class BaseAPI 49 | */ 50 | export class BaseAPI { 51 | protected configuration: Configuration | undefined; 52 | 53 | constructor(configuration?: Configuration, protected basePath: string = BASE_PATH, protected axios: AxiosInstance = globalAxios) { 54 | if (configuration) { 55 | this.configuration = configuration; 56 | this.basePath = configuration.basePath || this.basePath; 57 | } 58 | } 59 | }; 60 | 61 | /** 62 | * 63 | * @export 64 | * @class RequiredError 65 | * @extends {Error} 66 | */ 67 | export class RequiredError extends Error { 68 | constructor(public field: string, msg?: string) { 69 | super(msg); 70 | this.name = "RequiredError" 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /common.ts: -------------------------------------------------------------------------------- 1 | /* tslint:disable */ 2 | /* eslint-disable */ 3 | /** 4 | * OpenAI API 5 | * APIs for sampling from and fine-tuning language models 6 | * 7 | * The version of the OpenAPI document: 1.2.0 8 | * 9 | * 10 | * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). 11 | * https://openapi-generator.tech 12 | * Do not edit the class manually. 13 | */ 14 | 15 | 16 | import type { Configuration } from "./configuration"; 17 | import type { RequestArgs } from "./base"; 18 | import type { AxiosInstance, AxiosResponse } from 'axios'; 19 | import { RequiredError } from "./base"; 20 | import { ChatCompletionRequestMessage } from "./api"; 21 | 22 | /** 23 | * 24 | * @export 25 | */ 26 | export const DUMMY_BASE_URL = 'https://example.com' 27 | 28 | /** 29 | * 30 | * @throws {RequiredError} 31 | * @export 32 | */ 33 | export const assertParamExists = function (functionName: string, paramName: string, paramValue: unknown) { 34 | if (paramValue === null || paramValue === undefined) { 35 | throw new RequiredError(paramName, `Required parameter ${paramName} was null or undefined when calling ${functionName}.`); 36 | } 37 | } 38 | 39 | /** 40 | * 41 | * @export 42 | */ 43 | export const setApiKeyToObject = async function (object: any, keyParamName: string, configuration?: Configuration) { 44 | if (configuration && configuration.apiKey) { 45 | const localVarApiKeyValue = typeof configuration.apiKey === 'function' 46 | ? await configuration.apiKey(keyParamName) 47 | : await configuration.apiKey; 48 | object[keyParamName] = localVarApiKeyValue; 49 | } 50 | } 51 | 52 | /** 53 | * 54 | * @export 55 | */ 56 | export const setBasicAuthToObject = function (object: any, configuration?: Configuration) { 57 | if (configuration && (configuration.username || configuration.password)) { 58 | object["auth"] = { username: configuration.username, password: configuration.password }; 59 | } 60 | } 61 | 62 | /** 63 | * 64 | * @export 65 | */ 66 | export const setBearerAuthToObject = async function (object: any, configuration?: Configuration) { 67 | if (configuration && configuration.accessToken) { 68 | const accessToken = typeof configuration.accessToken === 'function' 69 | ? await configuration.accessToken() 70 | : await configuration.accessToken; 71 | object["Authorization"] = "Bearer " + accessToken; 72 | } 73 | } 74 | 75 | /** 76 | * 77 | * @export 78 | */ 79 | export const setOAuthToObject = async function (object: any, name: string, scopes: string[], configuration?: Configuration) { 80 | if (configuration && configuration.accessToken) { 81 | const localVarAccessTokenValue = typeof configuration.accessToken === 'function' 82 | ? await configuration.accessToken(name, scopes) 83 | : await configuration.accessToken; 84 | object["Authorization"] = "Bearer " + localVarAccessTokenValue; 85 | } 86 | } 87 | 88 | function setFlattenedQueryParams(urlSearchParams: URLSearchParams, parameter: any, key: string = ""): void { 89 | if (parameter == null) return; 90 | if (typeof parameter === "object") { 91 | if (Array.isArray(parameter)) { 92 | (parameter as any[]).forEach(item => setFlattenedQueryParams(urlSearchParams, item, key)); 93 | } 94 | else { 95 | Object.keys(parameter).forEach(currentKey => 96 | setFlattenedQueryParams(urlSearchParams, parameter[currentKey], `${key}${key !== '' ? '.' : ''}${currentKey}`) 97 | ); 98 | } 99 | } 100 | else { 101 | if (urlSearchParams.has(key)) { 102 | urlSearchParams.append(key, parameter); 103 | } 104 | else { 105 | urlSearchParams.set(key, parameter); 106 | } 107 | } 108 | } 109 | 110 | /** 111 | * 112 | * @export 113 | */ 114 | export const setSearchParams = function (url: URL, ...objects: any[]) { 115 | const searchParams = new URLSearchParams(url.search); 116 | setFlattenedQueryParams(searchParams, objects); 117 | url.search = searchParams.toString(); 118 | } 119 | 120 | /** 121 | * 122 | * @export 123 | */ 124 | export const serializeDataIfNeeded = function (value: any, requestOptions: any, configuration?: Configuration) { 125 | const nonString = typeof value !== 'string'; 126 | const needsSerialization = nonString && configuration && configuration.isJsonMime 127 | ? configuration.isJsonMime(requestOptions.headers['Content-Type']) 128 | : nonString; 129 | return needsSerialization 130 | ? JSON.stringify(value !== undefined ? value : {}) 131 | : (value || ""); 132 | } 133 | 134 | /** 135 | * 136 | * @export 137 | */ 138 | export const toPathString = function (url: URL) { 139 | return url.pathname + url.search + url.hash 140 | } 141 | 142 | /** 143 | * 144 | * @export 145 | */ 146 | export const createRequestFunction = function (axiosArgs: RequestArgs, globalAxios: AxiosInstance, BASE_PATH: string, configuration?: Configuration) { 147 | return >(axios: AxiosInstance = globalAxios, basePath: string = BASE_PATH) => { 148 | const axiosRequestArgs = { ...axiosArgs.options, url: (configuration?.basePath || basePath) + axiosArgs.url }; 149 | return axios.request(axiosRequestArgs); 150 | }; 151 | } 152 | 153 | /** 154 | * 155 | * @export 156 | */ 157 | export const createPrompt = function (systemMessage: string, messages: { sender: string, text: string }[]): string { 158 | let prompt = systemMessage; 159 | for (const message of messages) { 160 | prompt += `\n<|im_start|>${message.sender}\n${message.text}\n<|im_end|>`; 161 | } 162 | prompt += "\n<|im_start|>assistant\n"; 163 | return prompt; 164 | } 165 | 166 | export const messageToAzurePrompt = function (messages: Array): string { 167 | let systemMessage = ''; 168 | let conversationMessage = []; 169 | for (const message of messages) { 170 | systemMessage = message.role === "system" ? `<|im_start|>system\n{'${message.content}'}\n<|im_end|>` : ''; 171 | conversationMessage.push({ 172 | sender: message.role, 173 | text: message.content, 174 | }) 175 | } 176 | return createPrompt(systemMessage, conversationMessage); 177 | } -------------------------------------------------------------------------------- /configuration.ts: -------------------------------------------------------------------------------- 1 | /* tslint:disable */ 2 | /* eslint-disable */ 3 | /** 4 | * OpenAI API 5 | * APIs for sampling from and fine-tuning language models 6 | * 7 | * The version of the OpenAPI document: 1.2.0 8 | * 9 | * 10 | * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). 11 | * https://openapi-generator.tech 12 | * Do not edit the class manually. 13 | */ 14 | 15 | 16 | const packageJson = require("../package.json"); 17 | 18 | export interface AzureConfigurationParameters { 19 | apiKey?: string | Promise | ((name: string) => string) | ((name: string) => Promise); 20 | endpoint?: string; 21 | deploymentName?: string; 22 | } 23 | 24 | export interface ConfigurationParameters { 25 | apiKey?: string | Promise | ((name: string) => string) | ((name: string) => Promise); 26 | organization?: string; 27 | username?: string; 28 | password?: string; 29 | accessToken?: string | Promise | ((name?: string, scopes?: string[]) => string) | ((name?: string, scopes?: string[]) => Promise); 30 | basePath?: string; 31 | baseOptions?: any; 32 | formDataCtor?: new () => any; 33 | azure?: AzureConfigurationParameters; 34 | } 35 | 36 | export class Configuration { 37 | /** 38 | * parameter for apiKey security 39 | * @param name security name 40 | * @memberof Configuration 41 | */ 42 | apiKey?: string | Promise | ((name: string) => string) | ((name: string) => Promise); 43 | /** 44 | * OpenAI organization id 45 | * 46 | * @type {string} 47 | * @memberof Configuration 48 | */ 49 | organization?: string; 50 | /** 51 | * parameter for basic security 52 | * 53 | * @type {string} 54 | * @memberof Configuration 55 | */ 56 | username?: string; 57 | /** 58 | * parameter for basic security 59 | * 60 | * @type {string} 61 | * @memberof Configuration 62 | */ 63 | password?: string; 64 | /** 65 | * parameter for oauth2 security 66 | * @param name security name 67 | * @param scopes oauth2 scope 68 | * @memberof Configuration 69 | */ 70 | accessToken?: string | Promise | ((name?: string, scopes?: string[]) => string) | ((name?: string, scopes?: string[]) => Promise); 71 | /** 72 | * override base path 73 | * 74 | * @type {string} 75 | * @memberof Configuration 76 | */ 77 | basePath?: string; 78 | /** 79 | * base options for axios calls 80 | * 81 | * @type {any} 82 | * @memberof Configuration 83 | */ 84 | baseOptions?: any; 85 | /** 86 | * The FormData constructor that will be used to create multipart form data 87 | * requests. You can inject this here so that execution environments that 88 | * do not support the FormData class can still run the generated client. 89 | * 90 | * @type {new () => FormData} 91 | */ 92 | formDataCtor?: new () => any; 93 | /** 94 | * @memberof Configuration 95 | */ 96 | azure?: AzureConfigurationParameters; 97 | 98 | constructor(param: ConfigurationParameters = {}) { 99 | this.apiKey = param.apiKey; 100 | this.organization = param.organization; 101 | this.username = param.username; 102 | this.password = param.password; 103 | this.accessToken = param.accessToken; 104 | this.basePath = param.basePath; 105 | this.baseOptions = param.baseOptions; 106 | this.formDataCtor = param.formDataCtor; 107 | this.azure = param.azure; 108 | 109 | if (!this.baseOptions) { 110 | this.baseOptions = {}; 111 | } 112 | this.baseOptions.headers = { 113 | 'User-Agent': `AzureOpenAI/NodeJS/${packageJson.version}`, 114 | 'Authorization': `Bearer ${this.apiKey}`, 115 | ...this.baseOptions.headers, 116 | } 117 | if (this.organization) { 118 | this.baseOptions.headers['OpenAI-Organization'] = this.organization; 119 | } 120 | if (!this.formDataCtor) { 121 | this.formDataCtor = require("form-data"); 122 | } 123 | if (this.azure) { 124 | if (!this.azure.apiKey || !this.azure.endpoint) { 125 | throw new Error("Azure Configuration requires apiKey, endpoint"); 126 | } 127 | this.apiKey = this.azure.apiKey; 128 | this.baseOptions.headers['api-key'] = this.azure.apiKey; 129 | this.baseOptions.headers['Authorization'] = ''; 130 | this.basePath = this.azure.endpoint; 131 | } 132 | } 133 | 134 | /** 135 | * Check if the given MIME is a JSON MIME. 136 | * JSON MIME examples: 137 | * application/json 138 | * application/json; charset=UTF8 139 | * APPLICATION/JSON 140 | * application/vnd.company+json 141 | * @param mime - MIME (Multipurpose Internet Mail Extensions) 142 | * @return True if the given MIME is JSON, false otherwise. 143 | */ 144 | public isJsonMime(mime: string): boolean { 145 | const jsonMime: RegExp = new RegExp('^(application\/json|[^;/ \t]+\/[^;/ \t]+[+]json)[ \t]*(;.*)?$', 'i'); 146 | return mime !== null && (jsonMime.test(mime) || mime.toLowerCase() === 'application/json-patch+json'); 147 | } 148 | } -------------------------------------------------------------------------------- /dist/api.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | /* tslint:disable */ 3 | /* eslint-disable */ 4 | /** 5 | * OpenAI API 6 | * APIs for sampling from and fine-tuning language models 7 | * 8 | * The version of the OpenAPI document: 1.2.0 9 | * 10 | * 11 | * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). 12 | * https://openapi-generator.tech 13 | * Do not edit the class manually. 14 | */ 15 | var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { 16 | function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } 17 | return new (P || (P = Promise))(function (resolve, reject) { 18 | function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } 19 | function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } 20 | function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } 21 | step((generator = generator.apply(thisArg, _arguments || [])).next()); 22 | }); 23 | }; 24 | Object.defineProperty(exports, "__esModule", { value: true }); 25 | exports.OpenAIApi = exports.OpenAIApiFactory = exports.OpenAIApiFp = exports.OpenAIApiAxiosParamCreator = exports.CreateImageRequestResponseFormatEnum = exports.CreateImageRequestSizeEnum = exports.ChatCompletionResponseMessageRoleEnum = exports.ChatCompletionRequestMessageRoleEnum = void 0; 26 | const axios_1 = require("axios"); 27 | // Some imports not used depending on template conditions 28 | // @ts-ignore 29 | const common_1 = require("./common"); 30 | // @ts-ignore 31 | const base_1 = require("./base"); 32 | exports.ChatCompletionRequestMessageRoleEnum = { 33 | System: 'system', 34 | User: 'user', 35 | Assistant: 'assistant' 36 | }; 37 | exports.ChatCompletionResponseMessageRoleEnum = { 38 | System: 'system', 39 | User: 'user', 40 | Assistant: 'assistant' 41 | }; 42 | exports.CreateImageRequestSizeEnum = { 43 | _256x256: '256x256', 44 | _512x512: '512x512', 45 | _1024x1024: '1024x1024' 46 | }; 47 | exports.CreateImageRequestResponseFormatEnum = { 48 | Url: 'url', 49 | B64Json: 'b64_json' 50 | }; 51 | /** 52 | * OpenAIApi - axios parameter creator 53 | * @export 54 | */ 55 | exports.OpenAIApiAxiosParamCreator = function (configuration) { 56 | return { 57 | /** 58 | * 59 | * @summary Immediately cancel a fine-tune job. 60 | * @param {string} fineTuneId The ID of the fine-tune job to cancel 61 | * @param {*} [options] Override http request option. 62 | * @throws {RequiredError} 63 | */ 64 | cancelFineTune: (fineTuneId, options = {}) => __awaiter(this, void 0, void 0, function* () { 65 | // verify required parameter 'fineTuneId' is not null or undefined 66 | common_1.assertParamExists('cancelFineTune', 'fineTuneId', fineTuneId); 67 | const localVarPath = `/fine-tunes/{fine_tune_id}/cancel` 68 | .replace(`{${"fine_tune_id"}}`, encodeURIComponent(String(fineTuneId))); 69 | // use dummy base URL string because the URL constructor only accepts absolute URLs. 70 | const localVarUrlObj = new URL(localVarPath, common_1.DUMMY_BASE_URL); 71 | let baseOptions; 72 | if (configuration) { 73 | baseOptions = configuration.baseOptions; 74 | } 75 | const localVarRequestOptions = Object.assign(Object.assign({ method: 'POST' }, baseOptions), options); 76 | const localVarHeaderParameter = {}; 77 | const localVarQueryParameter = {}; 78 | common_1.setSearchParams(localVarUrlObj, localVarQueryParameter); 79 | let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; 80 | localVarRequestOptions.headers = Object.assign(Object.assign(Object.assign({}, localVarHeaderParameter), headersFromBaseOptions), options.headers); 81 | return { 82 | url: common_1.toPathString(localVarUrlObj), 83 | options: localVarRequestOptions, 84 | }; 85 | }), 86 | /** 87 | * 88 | * @summary Answers the specified question using the provided documents and examples. The endpoint first [searches](/docs/api-reference/searches) over provided documents or files to find relevant context. The relevant context is combined with the provided examples and question to create the prompt for [completion](/docs/api-reference/completions). 89 | * @param {CreateAnswerRequest} createAnswerRequest 90 | * @param {*} [options] Override http request option. 91 | * @deprecated 92 | * @throws {RequiredError} 93 | */ 94 | createAnswer: (createAnswerRequest, options = {}) => __awaiter(this, void 0, void 0, function* () { 95 | // verify required parameter 'createAnswerRequest' is not null or undefined 96 | common_1.assertParamExists('createAnswer', 'createAnswerRequest', createAnswerRequest); 97 | const localVarPath = `/answers`; 98 | // use dummy base URL string because the URL constructor only accepts absolute URLs. 99 | const localVarUrlObj = new URL(localVarPath, common_1.DUMMY_BASE_URL); 100 | let baseOptions; 101 | if (configuration) { 102 | baseOptions = configuration.baseOptions; 103 | } 104 | const localVarRequestOptions = Object.assign(Object.assign({ method: 'POST' }, baseOptions), options); 105 | const localVarHeaderParameter = {}; 106 | const localVarQueryParameter = {}; 107 | localVarHeaderParameter['Content-Type'] = 'application/json'; 108 | common_1.setSearchParams(localVarUrlObj, localVarQueryParameter); 109 | let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; 110 | localVarRequestOptions.headers = Object.assign(Object.assign(Object.assign({}, localVarHeaderParameter), headersFromBaseOptions), options.headers); 111 | localVarRequestOptions.data = common_1.serializeDataIfNeeded(createAnswerRequest, localVarRequestOptions, configuration); 112 | return { 113 | url: common_1.toPathString(localVarUrlObj), 114 | options: localVarRequestOptions, 115 | }; 116 | }), 117 | /** 118 | * 119 | * @summary Creates a completion for the chat message 120 | * @param {CreateChatCompletionRequest} createChatCompletionRequest 121 | * @param {*} [options] Override http request option. 122 | * @throws {RequiredError} 123 | */ 124 | createChatCompletion: (createChatCompletionRequest, options = {}) => __awaiter(this, void 0, void 0, function* () { 125 | // verify required parameter 'createChatCompletionRequest' is not null or undefined 126 | common_1.assertParamExists('createChatCompletion', 'createChatCompletionRequest', createChatCompletionRequest); 127 | let localVarPath = `/chat/completions`; 128 | if (configuration.azure) { 129 | let deploymentName = configuration.azure.deploymentName ? configuration.azure.deploymentName : createChatCompletionRequest.model; 130 | localVarPath = `/openai/deployments/${deploymentName}/chat/completions?api-version=2023-03-15-preview`; 131 | } 132 | // use dummy base URL string because the URL constructor only accepts absolute URLs. 133 | const localVarUrlObj = new URL(localVarPath, common_1.DUMMY_BASE_URL); 134 | let baseOptions; 135 | if (configuration) { 136 | baseOptions = configuration.baseOptions; 137 | } 138 | const localVarRequestOptions = Object.assign(Object.assign({ method: 'POST' }, baseOptions), options); 139 | const localVarHeaderParameter = {}; 140 | const localVarQueryParameter = {}; 141 | localVarHeaderParameter['Content-Type'] = 'application/json'; 142 | common_1.setSearchParams(localVarUrlObj, localVarQueryParameter); 143 | let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; 144 | localVarRequestOptions.headers = Object.assign(Object.assign(Object.assign({}, localVarHeaderParameter), headersFromBaseOptions), options.headers); 145 | localVarRequestOptions.data = common_1.serializeDataIfNeeded(createChatCompletionRequest, localVarRequestOptions, configuration); 146 | return { 147 | url: common_1.toPathString(localVarUrlObj), 148 | options: localVarRequestOptions, 149 | }; 150 | }), 151 | /** 152 | * 153 | * @summary Classifies the specified `query` using provided examples. The endpoint first [searches](/docs/api-reference/searches) over the labeled examples to select the ones most relevant for the particular query. Then, the relevant examples are combined with the query to construct a prompt to produce the final label via the [completions](/docs/api-reference/completions) endpoint. Labeled examples can be provided via an uploaded `file`, or explicitly listed in the request using the `examples` parameter for quick tests and small scale use cases. 154 | * @param {CreateClassificationRequest} createClassificationRequest 155 | * @param {*} [options] Override http request option. 156 | * @deprecated 157 | * @throws {RequiredError} 158 | */ 159 | createClassification: (createClassificationRequest, options = {}) => __awaiter(this, void 0, void 0, function* () { 160 | // verify required parameter 'createClassificationRequest' is not null or undefined 161 | common_1.assertParamExists('createClassification', 'createClassificationRequest', createClassificationRequest); 162 | const localVarPath = `/classifications`; 163 | // use dummy base URL string because the URL constructor only accepts absolute URLs. 164 | const localVarUrlObj = new URL(localVarPath, common_1.DUMMY_BASE_URL); 165 | let baseOptions; 166 | if (configuration) { 167 | baseOptions = configuration.baseOptions; 168 | } 169 | const localVarRequestOptions = Object.assign(Object.assign({ method: 'POST' }, baseOptions), options); 170 | const localVarHeaderParameter = {}; 171 | const localVarQueryParameter = {}; 172 | localVarHeaderParameter['Content-Type'] = 'application/json'; 173 | common_1.setSearchParams(localVarUrlObj, localVarQueryParameter); 174 | let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; 175 | localVarRequestOptions.headers = Object.assign(Object.assign(Object.assign({}, localVarHeaderParameter), headersFromBaseOptions), options.headers); 176 | localVarRequestOptions.data = common_1.serializeDataIfNeeded(createClassificationRequest, localVarRequestOptions, configuration); 177 | return { 178 | url: common_1.toPathString(localVarUrlObj), 179 | options: localVarRequestOptions, 180 | }; 181 | }), 182 | /** 183 | * 184 | * @summary Creates a completion for the provided prompt and parameters 185 | * @param {CreateCompletionRequest} createCompletionRequest 186 | * @param {*} [options] Override http request option. 187 | * @throws {RequiredError} 188 | */ 189 | createCompletion: (createCompletionRequest, options = {}) => __awaiter(this, void 0, void 0, function* () { 190 | // verify required parameter 'createCompletionRequest' is not null or undefined 191 | common_1.assertParamExists('createCompletion', 'createCompletionRequest', createCompletionRequest); 192 | let localVarPath = `/completions`; 193 | if (configuration.azure) { 194 | let deploymentName = configuration.azure.deploymentName ? configuration.azure.deploymentName : createCompletionRequest.model; 195 | localVarPath = `/openai/deployments/${deploymentName}/completions?api-version=2023-03-15-preview`; 196 | } 197 | // use dummy base URL string because the URL constructor only accepts absolute URLs. 198 | const localVarUrlObj = new URL(localVarPath, common_1.DUMMY_BASE_URL); 199 | let baseOptions; 200 | if (configuration) { 201 | baseOptions = configuration.baseOptions; 202 | } 203 | const localVarRequestOptions = Object.assign(Object.assign({ method: 'POST' }, baseOptions), options); 204 | const localVarHeaderParameter = {}; 205 | const localVarQueryParameter = {}; 206 | localVarHeaderParameter['Content-Type'] = 'application/json'; 207 | common_1.setSearchParams(localVarUrlObj, localVarQueryParameter); 208 | let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; 209 | localVarRequestOptions.headers = Object.assign(Object.assign(Object.assign({}, localVarHeaderParameter), headersFromBaseOptions), options.headers); 210 | localVarRequestOptions.data = common_1.serializeDataIfNeeded(createCompletionRequest, localVarRequestOptions, configuration); 211 | return { 212 | url: common_1.toPathString(localVarUrlObj), 213 | options: localVarRequestOptions, 214 | }; 215 | }), 216 | /** 217 | * 218 | * @summary Creates a new edit for the provided input, instruction, and parameters. 219 | * @param {CreateEditRequest} createEditRequest 220 | * @param {*} [options] Override http request option. 221 | * @throws {RequiredError} 222 | */ 223 | createEdit: (createEditRequest, options = {}) => __awaiter(this, void 0, void 0, function* () { 224 | // verify required parameter 'createEditRequest' is not null or undefined 225 | common_1.assertParamExists('createEdit', 'createEditRequest', createEditRequest); 226 | const localVarPath = `/edits`; 227 | // use dummy base URL string because the URL constructor only accepts absolute URLs. 228 | const localVarUrlObj = new URL(localVarPath, common_1.DUMMY_BASE_URL); 229 | let baseOptions; 230 | if (configuration) { 231 | baseOptions = configuration.baseOptions; 232 | } 233 | const localVarRequestOptions = Object.assign(Object.assign({ method: 'POST' }, baseOptions), options); 234 | const localVarHeaderParameter = {}; 235 | const localVarQueryParameter = {}; 236 | localVarHeaderParameter['Content-Type'] = 'application/json'; 237 | common_1.setSearchParams(localVarUrlObj, localVarQueryParameter); 238 | let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; 239 | localVarRequestOptions.headers = Object.assign(Object.assign(Object.assign({}, localVarHeaderParameter), headersFromBaseOptions), options.headers); 240 | localVarRequestOptions.data = common_1.serializeDataIfNeeded(createEditRequest, localVarRequestOptions, configuration); 241 | return { 242 | url: common_1.toPathString(localVarUrlObj), 243 | options: localVarRequestOptions, 244 | }; 245 | }), 246 | /** 247 | * 248 | * @summary Creates an embedding vector representing the input text. 249 | * @param {CreateEmbeddingRequest} createEmbeddingRequest 250 | * @param {*} [options] Override http request option. 251 | * @throws {RequiredError} 252 | */ 253 | createEmbedding: (createEmbeddingRequest, options = {}) => __awaiter(this, void 0, void 0, function* () { 254 | // verify required parameter 'createEmbeddingRequest' is not null or undefined 255 | common_1.assertParamExists('createEmbedding', 'createEmbeddingRequest', createEmbeddingRequest); 256 | let localVarPath = `/embeddings`; 257 | if (configuration.azure) { 258 | let deploymentName = configuration.azure.deploymentName ? configuration.azure.deploymentName : createEmbeddingRequest.model; 259 | localVarPath = `/openai/deployments/${deploymentName}/embeddings?api-version=2023-03-15-preview`; 260 | } 261 | // use dummy base URL string because the URL constructor only accepts absolute URLs. 262 | const localVarUrlObj = new URL(localVarPath, common_1.DUMMY_BASE_URL); 263 | let baseOptions; 264 | if (configuration) { 265 | baseOptions = configuration.baseOptions; 266 | } 267 | const localVarRequestOptions = Object.assign(Object.assign({ method: 'POST' }, baseOptions), options); 268 | const localVarHeaderParameter = {}; 269 | const localVarQueryParameter = {}; 270 | localVarHeaderParameter['Content-Type'] = 'application/json'; 271 | common_1.setSearchParams(localVarUrlObj, localVarQueryParameter); 272 | let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; 273 | localVarRequestOptions.headers = Object.assign(Object.assign(Object.assign({}, localVarHeaderParameter), headersFromBaseOptions), options.headers); 274 | localVarRequestOptions.data = common_1.serializeDataIfNeeded(createEmbeddingRequest, localVarRequestOptions, configuration); 275 | return { 276 | url: common_1.toPathString(localVarUrlObj), 277 | options: localVarRequestOptions, 278 | }; 279 | }), 280 | /** 281 | * 282 | * @summary Upload a file that contains document(s) to be used across various endpoints/features. Currently, the size of all the files uploaded by one organization can be up to 1 GB. Please contact us if you need to increase the storage limit. 283 | * @param {File} file Name of the [JSON Lines](https://jsonlines.readthedocs.io/en/latest/) file to be uploaded. If the `purpose` is set to \\\"fine-tune\\\", each line is a JSON record with \\\"prompt\\\" and \\\"completion\\\" fields representing your [training examples](/docs/guides/fine-tuning/prepare-training-data). 284 | * @param {string} purpose The intended purpose of the uploaded documents. Use \\\"fine-tune\\\" for [Fine-tuning](/docs/api-reference/fine-tunes). This allows us to validate the format of the uploaded file. 285 | * @param {*} [options] Override http request option. 286 | * @throws {RequiredError} 287 | */ 288 | createFile: (file, purpose, options = {}) => __awaiter(this, void 0, void 0, function* () { 289 | // verify required parameter 'file' is not null or undefined 290 | common_1.assertParamExists('createFile', 'file', file); 291 | // verify required parameter 'purpose' is not null or undefined 292 | common_1.assertParamExists('createFile', 'purpose', purpose); 293 | const localVarPath = `/files`; 294 | // use dummy base URL string because the URL constructor only accepts absolute URLs. 295 | const localVarUrlObj = new URL(localVarPath, common_1.DUMMY_BASE_URL); 296 | let baseOptions; 297 | if (configuration) { 298 | baseOptions = configuration.baseOptions; 299 | } 300 | const localVarRequestOptions = Object.assign(Object.assign({ method: 'POST' }, baseOptions), options); 301 | const localVarHeaderParameter = {}; 302 | const localVarQueryParameter = {}; 303 | const localVarFormParams = new ((configuration && configuration.formDataCtor) || FormData)(); 304 | if (file !== undefined) { 305 | localVarFormParams.append('file', file); 306 | } 307 | if (purpose !== undefined) { 308 | localVarFormParams.append('purpose', purpose); 309 | } 310 | localVarHeaderParameter['Content-Type'] = 'multipart/form-data'; 311 | common_1.setSearchParams(localVarUrlObj, localVarQueryParameter); 312 | let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; 313 | localVarRequestOptions.headers = Object.assign(Object.assign(Object.assign(Object.assign({}, localVarHeaderParameter), localVarFormParams.getHeaders()), headersFromBaseOptions), options.headers); 314 | localVarRequestOptions.data = localVarFormParams; 315 | return { 316 | url: common_1.toPathString(localVarUrlObj), 317 | options: localVarRequestOptions, 318 | }; 319 | }), 320 | /** 321 | * 322 | * @summary Creates a job that fine-tunes a specified model from a given dataset. Response includes details of the enqueued job including job status and the name of the fine-tuned models once complete. [Learn more about Fine-tuning](/docs/guides/fine-tuning) 323 | * @param {CreateFineTuneRequest} createFineTuneRequest 324 | * @param {*} [options] Override http request option. 325 | * @throws {RequiredError} 326 | */ 327 | createFineTune: (createFineTuneRequest, options = {}) => __awaiter(this, void 0, void 0, function* () { 328 | // verify required parameter 'createFineTuneRequest' is not null or undefined 329 | common_1.assertParamExists('createFineTune', 'createFineTuneRequest', createFineTuneRequest); 330 | const localVarPath = `/fine-tunes`; 331 | // use dummy base URL string because the URL constructor only accepts absolute URLs. 332 | const localVarUrlObj = new URL(localVarPath, common_1.DUMMY_BASE_URL); 333 | let baseOptions; 334 | if (configuration) { 335 | baseOptions = configuration.baseOptions; 336 | } 337 | const localVarRequestOptions = Object.assign(Object.assign({ method: 'POST' }, baseOptions), options); 338 | const localVarHeaderParameter = {}; 339 | const localVarQueryParameter = {}; 340 | localVarHeaderParameter['Content-Type'] = 'application/json'; 341 | common_1.setSearchParams(localVarUrlObj, localVarQueryParameter); 342 | let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; 343 | localVarRequestOptions.headers = Object.assign(Object.assign(Object.assign({}, localVarHeaderParameter), headersFromBaseOptions), options.headers); 344 | localVarRequestOptions.data = common_1.serializeDataIfNeeded(createFineTuneRequest, localVarRequestOptions, configuration); 345 | return { 346 | url: common_1.toPathString(localVarUrlObj), 347 | options: localVarRequestOptions, 348 | }; 349 | }), 350 | /** 351 | * 352 | * @summary Creates an image given a prompt. 353 | * @param {CreateImageRequest} createImageRequest 354 | * @param {*} [options] Override http request option. 355 | * @throws {RequiredError} 356 | */ 357 | createImage: (createImageRequest, options = {}) => __awaiter(this, void 0, void 0, function* () { 358 | // verify required parameter 'createImageRequest' is not null or undefined 359 | common_1.assertParamExists('createImage', 'createImageRequest', createImageRequest); 360 | const localVarPath = `/images/generations`; 361 | // use dummy base URL string because the URL constructor only accepts absolute URLs. 362 | const localVarUrlObj = new URL(localVarPath, common_1.DUMMY_BASE_URL); 363 | let baseOptions; 364 | if (configuration) { 365 | baseOptions = configuration.baseOptions; 366 | } 367 | const localVarRequestOptions = Object.assign(Object.assign({ method: 'POST' }, baseOptions), options); 368 | const localVarHeaderParameter = {}; 369 | const localVarQueryParameter = {}; 370 | localVarHeaderParameter['Content-Type'] = 'application/json'; 371 | common_1.setSearchParams(localVarUrlObj, localVarQueryParameter); 372 | let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; 373 | localVarRequestOptions.headers = Object.assign(Object.assign(Object.assign({}, localVarHeaderParameter), headersFromBaseOptions), options.headers); 374 | localVarRequestOptions.data = common_1.serializeDataIfNeeded(createImageRequest, localVarRequestOptions, configuration); 375 | return { 376 | url: common_1.toPathString(localVarUrlObj), 377 | options: localVarRequestOptions, 378 | }; 379 | }), 380 | /** 381 | * 382 | * @summary Creates an edited or extended image given an original image and a prompt. 383 | * @param {File} image The image to edit. Must be a valid PNG file, less than 4MB, and square. If mask is not provided, image must have transparency, which will be used as the mask. 384 | * @param {string} prompt A text description of the desired image(s). The maximum length is 1000 characters. 385 | * @param {File} [mask] An additional image whose fully transparent areas (e.g. where alpha is zero) indicate where `image` should be edited. Must be a valid PNG file, less than 4MB, and have the same dimensions as `image`. 386 | * @param {number} [n] The number of images to generate. Must be between 1 and 10. 387 | * @param {string} [size] The size of the generated images. Must be one of `256x256`, `512x512`, or `1024x1024`. 388 | * @param {string} [responseFormat] The format in which the generated images are returned. Must be one of `url` or `b64_json`. 389 | * @param {string} [user] A unique identifier representing your end-user, which can help OpenAI to monitor and detect abuse. [Learn more](/docs/guides/safety-best-practices/end-user-ids). 390 | * @param {*} [options] Override http request option. 391 | * @throws {RequiredError} 392 | */ 393 | createImageEdit: (image, prompt, mask, n, size, responseFormat, user, options = {}) => __awaiter(this, void 0, void 0, function* () { 394 | // verify required parameter 'image' is not null or undefined 395 | common_1.assertParamExists('createImageEdit', 'image', image); 396 | // verify required parameter 'prompt' is not null or undefined 397 | common_1.assertParamExists('createImageEdit', 'prompt', prompt); 398 | const localVarPath = `/images/edits`; 399 | // use dummy base URL string because the URL constructor only accepts absolute URLs. 400 | const localVarUrlObj = new URL(localVarPath, common_1.DUMMY_BASE_URL); 401 | let baseOptions; 402 | if (configuration) { 403 | baseOptions = configuration.baseOptions; 404 | } 405 | const localVarRequestOptions = Object.assign(Object.assign({ method: 'POST' }, baseOptions), options); 406 | const localVarHeaderParameter = {}; 407 | const localVarQueryParameter = {}; 408 | const localVarFormParams = new ((configuration && configuration.formDataCtor) || FormData)(); 409 | if (image !== undefined) { 410 | localVarFormParams.append('image', image); 411 | } 412 | if (mask !== undefined) { 413 | localVarFormParams.append('mask', mask); 414 | } 415 | if (prompt !== undefined) { 416 | localVarFormParams.append('prompt', prompt); 417 | } 418 | if (n !== undefined) { 419 | localVarFormParams.append('n', n); 420 | } 421 | if (size !== undefined) { 422 | localVarFormParams.append('size', size); 423 | } 424 | if (responseFormat !== undefined) { 425 | localVarFormParams.append('response_format', responseFormat); 426 | } 427 | if (user !== undefined) { 428 | localVarFormParams.append('user', user); 429 | } 430 | localVarHeaderParameter['Content-Type'] = 'multipart/form-data'; 431 | common_1.setSearchParams(localVarUrlObj, localVarQueryParameter); 432 | let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; 433 | localVarRequestOptions.headers = Object.assign(Object.assign(Object.assign(Object.assign({}, localVarHeaderParameter), localVarFormParams.getHeaders()), headersFromBaseOptions), options.headers); 434 | localVarRequestOptions.data = localVarFormParams; 435 | return { 436 | url: common_1.toPathString(localVarUrlObj), 437 | options: localVarRequestOptions, 438 | }; 439 | }), 440 | /** 441 | * 442 | * @summary Creates a variation of a given image. 443 | * @param {File} image The image to use as the basis for the variation(s). Must be a valid PNG file, less than 4MB, and square. 444 | * @param {number} [n] The number of images to generate. Must be between 1 and 10. 445 | * @param {string} [size] The size of the generated images. Must be one of `256x256`, `512x512`, or `1024x1024`. 446 | * @param {string} [responseFormat] The format in which the generated images are returned. Must be one of `url` or `b64_json`. 447 | * @param {string} [user] A unique identifier representing your end-user, which can help OpenAI to monitor and detect abuse. [Learn more](/docs/guides/safety-best-practices/end-user-ids). 448 | * @param {*} [options] Override http request option. 449 | * @throws {RequiredError} 450 | */ 451 | createImageVariation: (image, n, size, responseFormat, user, options = {}) => __awaiter(this, void 0, void 0, function* () { 452 | // verify required parameter 'image' is not null or undefined 453 | common_1.assertParamExists('createImageVariation', 'image', image); 454 | const localVarPath = `/images/variations`; 455 | // use dummy base URL string because the URL constructor only accepts absolute URLs. 456 | const localVarUrlObj = new URL(localVarPath, common_1.DUMMY_BASE_URL); 457 | let baseOptions; 458 | if (configuration) { 459 | baseOptions = configuration.baseOptions; 460 | } 461 | const localVarRequestOptions = Object.assign(Object.assign({ method: 'POST' }, baseOptions), options); 462 | const localVarHeaderParameter = {}; 463 | const localVarQueryParameter = {}; 464 | const localVarFormParams = new ((configuration && configuration.formDataCtor) || FormData)(); 465 | if (image !== undefined) { 466 | localVarFormParams.append('image', image); 467 | } 468 | if (n !== undefined) { 469 | localVarFormParams.append('n', n); 470 | } 471 | if (size !== undefined) { 472 | localVarFormParams.append('size', size); 473 | } 474 | if (responseFormat !== undefined) { 475 | localVarFormParams.append('response_format', responseFormat); 476 | } 477 | if (user !== undefined) { 478 | localVarFormParams.append('user', user); 479 | } 480 | localVarHeaderParameter['Content-Type'] = 'multipart/form-data'; 481 | common_1.setSearchParams(localVarUrlObj, localVarQueryParameter); 482 | let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; 483 | localVarRequestOptions.headers = Object.assign(Object.assign(Object.assign(Object.assign({}, localVarHeaderParameter), localVarFormParams.getHeaders()), headersFromBaseOptions), options.headers); 484 | localVarRequestOptions.data = localVarFormParams; 485 | return { 486 | url: common_1.toPathString(localVarUrlObj), 487 | options: localVarRequestOptions, 488 | }; 489 | }), 490 | /** 491 | * 492 | * @summary Classifies if text violates OpenAI\'s Content Policy 493 | * @param {CreateModerationRequest} createModerationRequest 494 | * @param {*} [options] Override http request option. 495 | * @throws {RequiredError} 496 | */ 497 | createModeration: (createModerationRequest, options = {}) => __awaiter(this, void 0, void 0, function* () { 498 | // verify required parameter 'createModerationRequest' is not null or undefined 499 | common_1.assertParamExists('createModeration', 'createModerationRequest', createModerationRequest); 500 | const localVarPath = `/moderations`; 501 | // use dummy base URL string because the URL constructor only accepts absolute URLs. 502 | const localVarUrlObj = new URL(localVarPath, common_1.DUMMY_BASE_URL); 503 | let baseOptions; 504 | if (configuration) { 505 | baseOptions = configuration.baseOptions; 506 | } 507 | const localVarRequestOptions = Object.assign(Object.assign({ method: 'POST' }, baseOptions), options); 508 | const localVarHeaderParameter = {}; 509 | const localVarQueryParameter = {}; 510 | localVarHeaderParameter['Content-Type'] = 'application/json'; 511 | common_1.setSearchParams(localVarUrlObj, localVarQueryParameter); 512 | let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; 513 | localVarRequestOptions.headers = Object.assign(Object.assign(Object.assign({}, localVarHeaderParameter), headersFromBaseOptions), options.headers); 514 | localVarRequestOptions.data = common_1.serializeDataIfNeeded(createModerationRequest, localVarRequestOptions, configuration); 515 | return { 516 | url: common_1.toPathString(localVarUrlObj), 517 | options: localVarRequestOptions, 518 | }; 519 | }), 520 | /** 521 | * 522 | * @summary The search endpoint computes similarity scores between provided query and documents. Documents can be passed directly to the API if there are no more than 200 of them. To go beyond the 200 document limit, documents can be processed offline and then used for efficient retrieval at query time. When `file` is set, the search endpoint searches over all the documents in the given file and returns up to the `max_rerank` number of documents. These documents will be returned along with their search scores. The similarity score is a positive score that usually ranges from 0 to 300 (but can sometimes go higher), where a score above 200 usually means the document is semantically similar to the query. 523 | * @param {string} engineId The ID of the engine to use for this request. You can select one of `ada`, `babbage`, `curie`, or `davinci`. 524 | * @param {CreateSearchRequest} createSearchRequest 525 | * @param {*} [options] Override http request option. 526 | * @deprecated 527 | * @throws {RequiredError} 528 | */ 529 | createSearch: (engineId, createSearchRequest, options = {}) => __awaiter(this, void 0, void 0, function* () { 530 | // verify required parameter 'engineId' is not null or undefined 531 | common_1.assertParamExists('createSearch', 'engineId', engineId); 532 | // verify required parameter 'createSearchRequest' is not null or undefined 533 | common_1.assertParamExists('createSearch', 'createSearchRequest', createSearchRequest); 534 | const localVarPath = `/engines/{engine_id}/search` 535 | .replace(`{${"engine_id"}}`, encodeURIComponent(String(engineId))); 536 | // use dummy base URL string because the URL constructor only accepts absolute URLs. 537 | const localVarUrlObj = new URL(localVarPath, common_1.DUMMY_BASE_URL); 538 | let baseOptions; 539 | if (configuration) { 540 | baseOptions = configuration.baseOptions; 541 | } 542 | const localVarRequestOptions = Object.assign(Object.assign({ method: 'POST' }, baseOptions), options); 543 | const localVarHeaderParameter = {}; 544 | const localVarQueryParameter = {}; 545 | localVarHeaderParameter['Content-Type'] = 'application/json'; 546 | common_1.setSearchParams(localVarUrlObj, localVarQueryParameter); 547 | let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; 548 | localVarRequestOptions.headers = Object.assign(Object.assign(Object.assign({}, localVarHeaderParameter), headersFromBaseOptions), options.headers); 549 | localVarRequestOptions.data = common_1.serializeDataIfNeeded(createSearchRequest, localVarRequestOptions, configuration); 550 | return { 551 | url: common_1.toPathString(localVarUrlObj), 552 | options: localVarRequestOptions, 553 | }; 554 | }), 555 | /** 556 | * 557 | * @summary Transcribes audio into the input language. 558 | * @param {File} file The audio file to transcribe, in one of these formats: mp3, mp4, mpeg, mpga, m4a, wav, or webm. 559 | * @param {string} model ID of the model to use. Only `whisper-1` is currently available. 560 | * @param {string} [prompt] An optional text to guide the model\\\'s style or continue a previous audio segment. The [prompt](/docs/guides/speech-to-text/prompting) should match the audio language. 561 | * @param {string} [responseFormat] The format of the transcript output, in one of these options: json, text, srt, verbose_json, or vtt. 562 | * @param {number} [temperature] The sampling temperature, between 0 and 1. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic. If set to 0, the model will use [log probability](https://en.wikipedia.org/wiki/Log_probability) to automatically increase the temperature until certain thresholds are hit. 563 | * @param {string} [language] The language of the input audio. Supplying the input language in [ISO-639-1](https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes) format will improve accuracy and latency. 564 | * @param {*} [options] Override http request option. 565 | * @throws {RequiredError} 566 | */ 567 | createTranscription: (file, model, prompt, responseFormat, temperature, language, options = {}) => __awaiter(this, void 0, void 0, function* () { 568 | // verify required parameter 'file' is not null or undefined 569 | common_1.assertParamExists('createTranscription', 'file', file); 570 | // verify required parameter 'model' is not null or undefined 571 | common_1.assertParamExists('createTranscription', 'model', model); 572 | const localVarPath = `/audio/transcriptions`; 573 | // use dummy base URL string because the URL constructor only accepts absolute URLs. 574 | const localVarUrlObj = new URL(localVarPath, common_1.DUMMY_BASE_URL); 575 | let baseOptions; 576 | if (configuration) { 577 | baseOptions = configuration.baseOptions; 578 | } 579 | const localVarRequestOptions = Object.assign(Object.assign({ method: 'POST' }, baseOptions), options); 580 | const localVarHeaderParameter = {}; 581 | const localVarQueryParameter = {}; 582 | const localVarFormParams = new ((configuration && configuration.formDataCtor) || FormData)(); 583 | if (file !== undefined) { 584 | localVarFormParams.append('file', file); 585 | } 586 | if (model !== undefined) { 587 | localVarFormParams.append('model', model); 588 | } 589 | if (prompt !== undefined) { 590 | localVarFormParams.append('prompt', prompt); 591 | } 592 | if (responseFormat !== undefined) { 593 | localVarFormParams.append('response_format', responseFormat); 594 | } 595 | if (temperature !== undefined) { 596 | localVarFormParams.append('temperature', temperature); 597 | } 598 | if (language !== undefined) { 599 | localVarFormParams.append('language', language); 600 | } 601 | localVarHeaderParameter['Content-Type'] = 'multipart/form-data'; 602 | common_1.setSearchParams(localVarUrlObj, localVarQueryParameter); 603 | let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; 604 | localVarRequestOptions.headers = Object.assign(Object.assign(Object.assign(Object.assign({}, localVarHeaderParameter), localVarFormParams.getHeaders()), headersFromBaseOptions), options.headers); 605 | localVarRequestOptions.data = localVarFormParams; 606 | return { 607 | url: common_1.toPathString(localVarUrlObj), 608 | options: localVarRequestOptions, 609 | }; 610 | }), 611 | /** 612 | * 613 | * @summary Translates audio into into English. 614 | * @param {File} file The audio file to translate, in one of these formats: mp3, mp4, mpeg, mpga, m4a, wav, or webm. 615 | * @param {string} model ID of the model to use. Only `whisper-1` is currently available. 616 | * @param {string} [prompt] An optional text to guide the model\\\'s style or continue a previous audio segment. The [prompt](/docs/guides/speech-to-text/prompting) should be in English. 617 | * @param {string} [responseFormat] The format of the transcript output, in one of these options: json, text, srt, verbose_json, or vtt. 618 | * @param {number} [temperature] The sampling temperature, between 0 and 1. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic. If set to 0, the model will use [log probability](https://en.wikipedia.org/wiki/Log_probability) to automatically increase the temperature until certain thresholds are hit. 619 | * @param {*} [options] Override http request option. 620 | * @throws {RequiredError} 621 | */ 622 | createTranslation: (file, model, prompt, responseFormat, temperature, options = {}) => __awaiter(this, void 0, void 0, function* () { 623 | // verify required parameter 'file' is not null or undefined 624 | common_1.assertParamExists('createTranslation', 'file', file); 625 | // verify required parameter 'model' is not null or undefined 626 | common_1.assertParamExists('createTranslation', 'model', model); 627 | const localVarPath = `/audio/translations`; 628 | // use dummy base URL string because the URL constructor only accepts absolute URLs. 629 | const localVarUrlObj = new URL(localVarPath, common_1.DUMMY_BASE_URL); 630 | let baseOptions; 631 | if (configuration) { 632 | baseOptions = configuration.baseOptions; 633 | } 634 | const localVarRequestOptions = Object.assign(Object.assign({ method: 'POST' }, baseOptions), options); 635 | const localVarHeaderParameter = {}; 636 | const localVarQueryParameter = {}; 637 | const localVarFormParams = new ((configuration && configuration.formDataCtor) || FormData)(); 638 | if (file !== undefined) { 639 | localVarFormParams.append('file', file); 640 | } 641 | if (model !== undefined) { 642 | localVarFormParams.append('model', model); 643 | } 644 | if (prompt !== undefined) { 645 | localVarFormParams.append('prompt', prompt); 646 | } 647 | if (responseFormat !== undefined) { 648 | localVarFormParams.append('response_format', responseFormat); 649 | } 650 | if (temperature !== undefined) { 651 | localVarFormParams.append('temperature', temperature); 652 | } 653 | localVarHeaderParameter['Content-Type'] = 'multipart/form-data'; 654 | common_1.setSearchParams(localVarUrlObj, localVarQueryParameter); 655 | let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; 656 | localVarRequestOptions.headers = Object.assign(Object.assign(Object.assign(Object.assign({}, localVarHeaderParameter), localVarFormParams.getHeaders()), headersFromBaseOptions), options.headers); 657 | localVarRequestOptions.data = localVarFormParams; 658 | return { 659 | url: common_1.toPathString(localVarUrlObj), 660 | options: localVarRequestOptions, 661 | }; 662 | }), 663 | /** 664 | * 665 | * @summary Delete a file. 666 | * @param {string} fileId The ID of the file to use for this request 667 | * @param {*} [options] Override http request option. 668 | * @throws {RequiredError} 669 | */ 670 | deleteFile: (fileId, options = {}) => __awaiter(this, void 0, void 0, function* () { 671 | // verify required parameter 'fileId' is not null or undefined 672 | common_1.assertParamExists('deleteFile', 'fileId', fileId); 673 | const localVarPath = `/files/{file_id}` 674 | .replace(`{${"file_id"}}`, encodeURIComponent(String(fileId))); 675 | // use dummy base URL string because the URL constructor only accepts absolute URLs. 676 | const localVarUrlObj = new URL(localVarPath, common_1.DUMMY_BASE_URL); 677 | let baseOptions; 678 | if (configuration) { 679 | baseOptions = configuration.baseOptions; 680 | } 681 | const localVarRequestOptions = Object.assign(Object.assign({ method: 'DELETE' }, baseOptions), options); 682 | const localVarHeaderParameter = {}; 683 | const localVarQueryParameter = {}; 684 | common_1.setSearchParams(localVarUrlObj, localVarQueryParameter); 685 | let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; 686 | localVarRequestOptions.headers = Object.assign(Object.assign(Object.assign({}, localVarHeaderParameter), headersFromBaseOptions), options.headers); 687 | return { 688 | url: common_1.toPathString(localVarUrlObj), 689 | options: localVarRequestOptions, 690 | }; 691 | }), 692 | /** 693 | * 694 | * @summary Delete a fine-tuned model. You must have the Owner role in your organization. 695 | * @param {string} model The model to delete 696 | * @param {*} [options] Override http request option. 697 | * @throws {RequiredError} 698 | */ 699 | deleteModel: (model, options = {}) => __awaiter(this, void 0, void 0, function* () { 700 | // verify required parameter 'model' is not null or undefined 701 | common_1.assertParamExists('deleteModel', 'model', model); 702 | const localVarPath = `/models/{model}` 703 | .replace(`{${"model"}}`, encodeURIComponent(String(model))); 704 | // use dummy base URL string because the URL constructor only accepts absolute URLs. 705 | const localVarUrlObj = new URL(localVarPath, common_1.DUMMY_BASE_URL); 706 | let baseOptions; 707 | if (configuration) { 708 | baseOptions = configuration.baseOptions; 709 | } 710 | const localVarRequestOptions = Object.assign(Object.assign({ method: 'DELETE' }, baseOptions), options); 711 | const localVarHeaderParameter = {}; 712 | const localVarQueryParameter = {}; 713 | common_1.setSearchParams(localVarUrlObj, localVarQueryParameter); 714 | let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; 715 | localVarRequestOptions.headers = Object.assign(Object.assign(Object.assign({}, localVarHeaderParameter), headersFromBaseOptions), options.headers); 716 | return { 717 | url: common_1.toPathString(localVarUrlObj), 718 | options: localVarRequestOptions, 719 | }; 720 | }), 721 | /** 722 | * 723 | * @summary Returns the contents of the specified file 724 | * @param {string} fileId The ID of the file to use for this request 725 | * @param {*} [options] Override http request option. 726 | * @throws {RequiredError} 727 | */ 728 | downloadFile: (fileId, options = {}) => __awaiter(this, void 0, void 0, function* () { 729 | // verify required parameter 'fileId' is not null or undefined 730 | common_1.assertParamExists('downloadFile', 'fileId', fileId); 731 | const localVarPath = `/files/{file_id}/content` 732 | .replace(`{${"file_id"}}`, encodeURIComponent(String(fileId))); 733 | // use dummy base URL string because the URL constructor only accepts absolute URLs. 734 | const localVarUrlObj = new URL(localVarPath, common_1.DUMMY_BASE_URL); 735 | let baseOptions; 736 | if (configuration) { 737 | baseOptions = configuration.baseOptions; 738 | } 739 | const localVarRequestOptions = Object.assign(Object.assign({ method: 'GET' }, baseOptions), options); 740 | const localVarHeaderParameter = {}; 741 | const localVarQueryParameter = {}; 742 | common_1.setSearchParams(localVarUrlObj, localVarQueryParameter); 743 | let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; 744 | localVarRequestOptions.headers = Object.assign(Object.assign(Object.assign({}, localVarHeaderParameter), headersFromBaseOptions), options.headers); 745 | return { 746 | url: common_1.toPathString(localVarUrlObj), 747 | options: localVarRequestOptions, 748 | }; 749 | }), 750 | /** 751 | * 752 | * @summary Lists the currently available (non-finetuned) models, and provides basic information about each one such as the owner and availability. 753 | * @param {*} [options] Override http request option. 754 | * @deprecated 755 | * @throws {RequiredError} 756 | */ 757 | listEngines: (options = {}) => __awaiter(this, void 0, void 0, function* () { 758 | const localVarPath = `/engines`; 759 | // use dummy base URL string because the URL constructor only accepts absolute URLs. 760 | const localVarUrlObj = new URL(localVarPath, common_1.DUMMY_BASE_URL); 761 | let baseOptions; 762 | if (configuration) { 763 | baseOptions = configuration.baseOptions; 764 | } 765 | const localVarRequestOptions = Object.assign(Object.assign({ method: 'GET' }, baseOptions), options); 766 | const localVarHeaderParameter = {}; 767 | const localVarQueryParameter = {}; 768 | common_1.setSearchParams(localVarUrlObj, localVarQueryParameter); 769 | let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; 770 | localVarRequestOptions.headers = Object.assign(Object.assign(Object.assign({}, localVarHeaderParameter), headersFromBaseOptions), options.headers); 771 | return { 772 | url: common_1.toPathString(localVarUrlObj), 773 | options: localVarRequestOptions, 774 | }; 775 | }), 776 | /** 777 | * 778 | * @summary Returns a list of files that belong to the user\'s organization. 779 | * @param {*} [options] Override http request option. 780 | * @throws {RequiredError} 781 | */ 782 | listFiles: (options = {}) => __awaiter(this, void 0, void 0, function* () { 783 | const localVarPath = `/files`; 784 | // use dummy base URL string because the URL constructor only accepts absolute URLs. 785 | const localVarUrlObj = new URL(localVarPath, common_1.DUMMY_BASE_URL); 786 | let baseOptions; 787 | if (configuration) { 788 | baseOptions = configuration.baseOptions; 789 | } 790 | const localVarRequestOptions = Object.assign(Object.assign({ method: 'GET' }, baseOptions), options); 791 | const localVarHeaderParameter = {}; 792 | const localVarQueryParameter = {}; 793 | common_1.setSearchParams(localVarUrlObj, localVarQueryParameter); 794 | let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; 795 | localVarRequestOptions.headers = Object.assign(Object.assign(Object.assign({}, localVarHeaderParameter), headersFromBaseOptions), options.headers); 796 | return { 797 | url: common_1.toPathString(localVarUrlObj), 798 | options: localVarRequestOptions, 799 | }; 800 | }), 801 | /** 802 | * 803 | * @summary Get fine-grained status updates for a fine-tune job. 804 | * @param {string} fineTuneId The ID of the fine-tune job to get events for. 805 | * @param {boolean} [stream] Whether to stream events for the fine-tune job. If set to true, events will be sent as data-only [server-sent events](https://developer.mozilla.org/en-US/docs/Web/API/Server-sent_events/Using_server-sent_events#Event_stream_format) as they become available. The stream will terminate with a `data: [DONE]` message when the job is finished (succeeded, cancelled, or failed). If set to false, only events generated so far will be returned. 806 | * @param {*} [options] Override http request option. 807 | * @throws {RequiredError} 808 | */ 809 | listFineTuneEvents: (fineTuneId, stream, options = {}) => __awaiter(this, void 0, void 0, function* () { 810 | // verify required parameter 'fineTuneId' is not null or undefined 811 | common_1.assertParamExists('listFineTuneEvents', 'fineTuneId', fineTuneId); 812 | const localVarPath = `/fine-tunes/{fine_tune_id}/events` 813 | .replace(`{${"fine_tune_id"}}`, encodeURIComponent(String(fineTuneId))); 814 | // use dummy base URL string because the URL constructor only accepts absolute URLs. 815 | const localVarUrlObj = new URL(localVarPath, common_1.DUMMY_BASE_URL); 816 | let baseOptions; 817 | if (configuration) { 818 | baseOptions = configuration.baseOptions; 819 | } 820 | const localVarRequestOptions = Object.assign(Object.assign({ method: 'GET' }, baseOptions), options); 821 | const localVarHeaderParameter = {}; 822 | const localVarQueryParameter = {}; 823 | if (stream !== undefined) { 824 | localVarQueryParameter['stream'] = stream; 825 | } 826 | common_1.setSearchParams(localVarUrlObj, localVarQueryParameter); 827 | let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; 828 | localVarRequestOptions.headers = Object.assign(Object.assign(Object.assign({}, localVarHeaderParameter), headersFromBaseOptions), options.headers); 829 | return { 830 | url: common_1.toPathString(localVarUrlObj), 831 | options: localVarRequestOptions, 832 | }; 833 | }), 834 | /** 835 | * 836 | * @summary List your organization\'s fine-tuning jobs 837 | * @param {*} [options] Override http request option. 838 | * @throws {RequiredError} 839 | */ 840 | listFineTunes: (options = {}) => __awaiter(this, void 0, void 0, function* () { 841 | const localVarPath = `/fine-tunes`; 842 | // use dummy base URL string because the URL constructor only accepts absolute URLs. 843 | const localVarUrlObj = new URL(localVarPath, common_1.DUMMY_BASE_URL); 844 | let baseOptions; 845 | if (configuration) { 846 | baseOptions = configuration.baseOptions; 847 | } 848 | const localVarRequestOptions = Object.assign(Object.assign({ method: 'GET' }, baseOptions), options); 849 | const localVarHeaderParameter = {}; 850 | const localVarQueryParameter = {}; 851 | common_1.setSearchParams(localVarUrlObj, localVarQueryParameter); 852 | let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; 853 | localVarRequestOptions.headers = Object.assign(Object.assign(Object.assign({}, localVarHeaderParameter), headersFromBaseOptions), options.headers); 854 | return { 855 | url: common_1.toPathString(localVarUrlObj), 856 | options: localVarRequestOptions, 857 | }; 858 | }), 859 | /** 860 | * 861 | * @summary Lists the currently available models, and provides basic information about each one such as the owner and availability. 862 | * @param {*} [options] Override http request option. 863 | * @throws {RequiredError} 864 | */ 865 | listModels: (options = {}) => __awaiter(this, void 0, void 0, function* () { 866 | const localVarPath = `/models`; 867 | // use dummy base URL string because the URL constructor only accepts absolute URLs. 868 | const localVarUrlObj = new URL(localVarPath, common_1.DUMMY_BASE_URL); 869 | let baseOptions; 870 | if (configuration) { 871 | baseOptions = configuration.baseOptions; 872 | } 873 | const localVarRequestOptions = Object.assign(Object.assign({ method: 'GET' }, baseOptions), options); 874 | const localVarHeaderParameter = {}; 875 | const localVarQueryParameter = {}; 876 | common_1.setSearchParams(localVarUrlObj, localVarQueryParameter); 877 | let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; 878 | localVarRequestOptions.headers = Object.assign(Object.assign(Object.assign({}, localVarHeaderParameter), headersFromBaseOptions), options.headers); 879 | return { 880 | url: common_1.toPathString(localVarUrlObj), 881 | options: localVarRequestOptions, 882 | }; 883 | }), 884 | /** 885 | * 886 | * @summary Retrieves a model instance, providing basic information about it such as the owner and availability. 887 | * @param {string} engineId The ID of the engine to use for this request 888 | * @param {*} [options] Override http request option. 889 | * @deprecated 890 | * @throws {RequiredError} 891 | */ 892 | retrieveEngine: (engineId, options = {}) => __awaiter(this, void 0, void 0, function* () { 893 | // verify required parameter 'engineId' is not null or undefined 894 | common_1.assertParamExists('retrieveEngine', 'engineId', engineId); 895 | const localVarPath = `/engines/{engine_id}` 896 | .replace(`{${"engine_id"}}`, encodeURIComponent(String(engineId))); 897 | // use dummy base URL string because the URL constructor only accepts absolute URLs. 898 | const localVarUrlObj = new URL(localVarPath, common_1.DUMMY_BASE_URL); 899 | let baseOptions; 900 | if (configuration) { 901 | baseOptions = configuration.baseOptions; 902 | } 903 | const localVarRequestOptions = Object.assign(Object.assign({ method: 'GET' }, baseOptions), options); 904 | const localVarHeaderParameter = {}; 905 | const localVarQueryParameter = {}; 906 | common_1.setSearchParams(localVarUrlObj, localVarQueryParameter); 907 | let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; 908 | localVarRequestOptions.headers = Object.assign(Object.assign(Object.assign({}, localVarHeaderParameter), headersFromBaseOptions), options.headers); 909 | return { 910 | url: common_1.toPathString(localVarUrlObj), 911 | options: localVarRequestOptions, 912 | }; 913 | }), 914 | /** 915 | * 916 | * @summary Returns information about a specific file. 917 | * @param {string} fileId The ID of the file to use for this request 918 | * @param {*} [options] Override http request option. 919 | * @throws {RequiredError} 920 | */ 921 | retrieveFile: (fileId, options = {}) => __awaiter(this, void 0, void 0, function* () { 922 | // verify required parameter 'fileId' is not null or undefined 923 | common_1.assertParamExists('retrieveFile', 'fileId', fileId); 924 | const localVarPath = `/files/{file_id}` 925 | .replace(`{${"file_id"}}`, encodeURIComponent(String(fileId))); 926 | // use dummy base URL string because the URL constructor only accepts absolute URLs. 927 | const localVarUrlObj = new URL(localVarPath, common_1.DUMMY_BASE_URL); 928 | let baseOptions; 929 | if (configuration) { 930 | baseOptions = configuration.baseOptions; 931 | } 932 | const localVarRequestOptions = Object.assign(Object.assign({ method: 'GET' }, baseOptions), options); 933 | const localVarHeaderParameter = {}; 934 | const localVarQueryParameter = {}; 935 | common_1.setSearchParams(localVarUrlObj, localVarQueryParameter); 936 | let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; 937 | localVarRequestOptions.headers = Object.assign(Object.assign(Object.assign({}, localVarHeaderParameter), headersFromBaseOptions), options.headers); 938 | return { 939 | url: common_1.toPathString(localVarUrlObj), 940 | options: localVarRequestOptions, 941 | }; 942 | }), 943 | /** 944 | * 945 | * @summary Gets info about the fine-tune job. [Learn more about Fine-tuning](/docs/guides/fine-tuning) 946 | * @param {string} fineTuneId The ID of the fine-tune job 947 | * @param {*} [options] Override http request option. 948 | * @throws {RequiredError} 949 | */ 950 | retrieveFineTune: (fineTuneId, options = {}) => __awaiter(this, void 0, void 0, function* () { 951 | // verify required parameter 'fineTuneId' is not null or undefined 952 | common_1.assertParamExists('retrieveFineTune', 'fineTuneId', fineTuneId); 953 | const localVarPath = `/fine-tunes/{fine_tune_id}` 954 | .replace(`{${"fine_tune_id"}}`, encodeURIComponent(String(fineTuneId))); 955 | // use dummy base URL string because the URL constructor only accepts absolute URLs. 956 | const localVarUrlObj = new URL(localVarPath, common_1.DUMMY_BASE_URL); 957 | let baseOptions; 958 | if (configuration) { 959 | baseOptions = configuration.baseOptions; 960 | } 961 | const localVarRequestOptions = Object.assign(Object.assign({ method: 'GET' }, baseOptions), options); 962 | const localVarHeaderParameter = {}; 963 | const localVarQueryParameter = {}; 964 | common_1.setSearchParams(localVarUrlObj, localVarQueryParameter); 965 | let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; 966 | localVarRequestOptions.headers = Object.assign(Object.assign(Object.assign({}, localVarHeaderParameter), headersFromBaseOptions), options.headers); 967 | return { 968 | url: common_1.toPathString(localVarUrlObj), 969 | options: localVarRequestOptions, 970 | }; 971 | }), 972 | /** 973 | * 974 | * @summary Retrieves a model instance, providing basic information about the model such as the owner and permissioning. 975 | * @param {string} model The ID of the model to use for this request 976 | * @param {*} [options] Override http request option. 977 | * @throws {RequiredError} 978 | */ 979 | retrieveModel: (model, options = {}) => __awaiter(this, void 0, void 0, function* () { 980 | // verify required parameter 'model' is not null or undefined 981 | common_1.assertParamExists('retrieveModel', 'model', model); 982 | const localVarPath = `/models/{model}` 983 | .replace(`{${"model"}}`, encodeURIComponent(String(model))); 984 | // use dummy base URL string because the URL constructor only accepts absolute URLs. 985 | const localVarUrlObj = new URL(localVarPath, common_1.DUMMY_BASE_URL); 986 | let baseOptions; 987 | if (configuration) { 988 | baseOptions = configuration.baseOptions; 989 | } 990 | const localVarRequestOptions = Object.assign(Object.assign({ method: 'GET' }, baseOptions), options); 991 | const localVarHeaderParameter = {}; 992 | const localVarQueryParameter = {}; 993 | common_1.setSearchParams(localVarUrlObj, localVarQueryParameter); 994 | let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; 995 | localVarRequestOptions.headers = Object.assign(Object.assign(Object.assign({}, localVarHeaderParameter), headersFromBaseOptions), options.headers); 996 | return { 997 | url: common_1.toPathString(localVarUrlObj), 998 | options: localVarRequestOptions, 999 | }; 1000 | }), 1001 | }; 1002 | }; 1003 | /** 1004 | * OpenAIApi - functional programming interface 1005 | * @export 1006 | */ 1007 | exports.OpenAIApiFp = function (configuration) { 1008 | const localVarAxiosParamCreator = exports.OpenAIApiAxiosParamCreator(configuration); 1009 | return { 1010 | /** 1011 | * 1012 | * @summary Immediately cancel a fine-tune job. 1013 | * @param {string} fineTuneId The ID of the fine-tune job to cancel 1014 | * @param {*} [options] Override http request option. 1015 | * @throws {RequiredError} 1016 | */ 1017 | cancelFineTune(fineTuneId, options) { 1018 | return __awaiter(this, void 0, void 0, function* () { 1019 | const localVarAxiosArgs = yield localVarAxiosParamCreator.cancelFineTune(fineTuneId, options); 1020 | return common_1.createRequestFunction(localVarAxiosArgs, axios_1.default, base_1.BASE_PATH, configuration); 1021 | }); 1022 | }, 1023 | /** 1024 | * 1025 | * @summary Answers the specified question using the provided documents and examples. The endpoint first [searches](/docs/api-reference/searches) over provided documents or files to find relevant context. The relevant context is combined with the provided examples and question to create the prompt for [completion](/docs/api-reference/completions). 1026 | * @param {CreateAnswerRequest} createAnswerRequest 1027 | * @param {*} [options] Override http request option. 1028 | * @deprecated 1029 | * @throws {RequiredError} 1030 | */ 1031 | createAnswer(createAnswerRequest, options) { 1032 | return __awaiter(this, void 0, void 0, function* () { 1033 | const localVarAxiosArgs = yield localVarAxiosParamCreator.createAnswer(createAnswerRequest, options); 1034 | return common_1.createRequestFunction(localVarAxiosArgs, axios_1.default, base_1.BASE_PATH, configuration); 1035 | }); 1036 | }, 1037 | /** 1038 | * 1039 | * @summary Creates a completion for the chat message 1040 | * @param {CreateChatCompletionRequest} createChatCompletionRequest 1041 | * @param {*} [options] Override http request option. 1042 | * @throws {RequiredError} 1043 | */ 1044 | createChatCompletion(createChatCompletionRequest, options) { 1045 | return __awaiter(this, void 0, void 0, function* () { 1046 | const localVarAxiosArgs = yield localVarAxiosParamCreator.createChatCompletion(createChatCompletionRequest, options); 1047 | return common_1.createRequestFunction(localVarAxiosArgs, axios_1.default, base_1.BASE_PATH, configuration); 1048 | }); 1049 | }, 1050 | /** 1051 | * 1052 | * @summary Classifies the specified `query` using provided examples. The endpoint first [searches](/docs/api-reference/searches) over the labeled examples to select the ones most relevant for the particular query. Then, the relevant examples are combined with the query to construct a prompt to produce the final label via the [completions](/docs/api-reference/completions) endpoint. Labeled examples can be provided via an uploaded `file`, or explicitly listed in the request using the `examples` parameter for quick tests and small scale use cases. 1053 | * @param {CreateClassificationRequest} createClassificationRequest 1054 | * @param {*} [options] Override http request option. 1055 | * @deprecated 1056 | * @throws {RequiredError} 1057 | */ 1058 | createClassification(createClassificationRequest, options) { 1059 | return __awaiter(this, void 0, void 0, function* () { 1060 | const localVarAxiosArgs = yield localVarAxiosParamCreator.createClassification(createClassificationRequest, options); 1061 | return common_1.createRequestFunction(localVarAxiosArgs, axios_1.default, base_1.BASE_PATH, configuration); 1062 | }); 1063 | }, 1064 | /** 1065 | * 1066 | * @summary Creates a completion for the provided prompt and parameters 1067 | * @param {CreateCompletionRequest} createCompletionRequest 1068 | * @param {*} [options] Override http request option. 1069 | * @throws {RequiredError} 1070 | */ 1071 | createCompletion(createCompletionRequest, options) { 1072 | return __awaiter(this, void 0, void 0, function* () { 1073 | const localVarAxiosArgs = yield localVarAxiosParamCreator.createCompletion(createCompletionRequest, options); 1074 | return common_1.createRequestFunction(localVarAxiosArgs, axios_1.default, base_1.BASE_PATH, configuration); 1075 | }); 1076 | }, 1077 | /** 1078 | * 1079 | * @summary Creates a new edit for the provided input, instruction, and parameters. 1080 | * @param {CreateEditRequest} createEditRequest 1081 | * @param {*} [options] Override http request option. 1082 | * @throws {RequiredError} 1083 | */ 1084 | createEdit(createEditRequest, options) { 1085 | return __awaiter(this, void 0, void 0, function* () { 1086 | const localVarAxiosArgs = yield localVarAxiosParamCreator.createEdit(createEditRequest, options); 1087 | return common_1.createRequestFunction(localVarAxiosArgs, axios_1.default, base_1.BASE_PATH, configuration); 1088 | }); 1089 | }, 1090 | /** 1091 | * 1092 | * @summary Creates an embedding vector representing the input text. 1093 | * @param {CreateEmbeddingRequest} createEmbeddingRequest 1094 | * @param {*} [options] Override http request option. 1095 | * @throws {RequiredError} 1096 | */ 1097 | createEmbedding(createEmbeddingRequest, options) { 1098 | return __awaiter(this, void 0, void 0, function* () { 1099 | const localVarAxiosArgs = yield localVarAxiosParamCreator.createEmbedding(createEmbeddingRequest, options); 1100 | return common_1.createRequestFunction(localVarAxiosArgs, axios_1.default, base_1.BASE_PATH, configuration); 1101 | }); 1102 | }, 1103 | /** 1104 | * 1105 | * @summary Upload a file that contains document(s) to be used across various endpoints/features. Currently, the size of all the files uploaded by one organization can be up to 1 GB. Please contact us if you need to increase the storage limit. 1106 | * @param {File} file Name of the [JSON Lines](https://jsonlines.readthedocs.io/en/latest/) file to be uploaded. If the `purpose` is set to \\\"fine-tune\\\", each line is a JSON record with \\\"prompt\\\" and \\\"completion\\\" fields representing your [training examples](/docs/guides/fine-tuning/prepare-training-data). 1107 | * @param {string} purpose The intended purpose of the uploaded documents. Use \\\"fine-tune\\\" for [Fine-tuning](/docs/api-reference/fine-tunes). This allows us to validate the format of the uploaded file. 1108 | * @param {*} [options] Override http request option. 1109 | * @throws {RequiredError} 1110 | */ 1111 | createFile(file, purpose, options) { 1112 | return __awaiter(this, void 0, void 0, function* () { 1113 | const localVarAxiosArgs = yield localVarAxiosParamCreator.createFile(file, purpose, options); 1114 | return common_1.createRequestFunction(localVarAxiosArgs, axios_1.default, base_1.BASE_PATH, configuration); 1115 | }); 1116 | }, 1117 | /** 1118 | * 1119 | * @summary Creates a job that fine-tunes a specified model from a given dataset. Response includes details of the enqueued job including job status and the name of the fine-tuned models once complete. [Learn more about Fine-tuning](/docs/guides/fine-tuning) 1120 | * @param {CreateFineTuneRequest} createFineTuneRequest 1121 | * @param {*} [options] Override http request option. 1122 | * @throws {RequiredError} 1123 | */ 1124 | createFineTune(createFineTuneRequest, options) { 1125 | return __awaiter(this, void 0, void 0, function* () { 1126 | const localVarAxiosArgs = yield localVarAxiosParamCreator.createFineTune(createFineTuneRequest, options); 1127 | return common_1.createRequestFunction(localVarAxiosArgs, axios_1.default, base_1.BASE_PATH, configuration); 1128 | }); 1129 | }, 1130 | /** 1131 | * 1132 | * @summary Creates an image given a prompt. 1133 | * @param {CreateImageRequest} createImageRequest 1134 | * @param {*} [options] Override http request option. 1135 | * @throws {RequiredError} 1136 | */ 1137 | createImage(createImageRequest, options) { 1138 | return __awaiter(this, void 0, void 0, function* () { 1139 | const localVarAxiosArgs = yield localVarAxiosParamCreator.createImage(createImageRequest, options); 1140 | return common_1.createRequestFunction(localVarAxiosArgs, axios_1.default, base_1.BASE_PATH, configuration); 1141 | }); 1142 | }, 1143 | /** 1144 | * 1145 | * @summary Creates an edited or extended image given an original image and a prompt. 1146 | * @param {File} image The image to edit. Must be a valid PNG file, less than 4MB, and square. If mask is not provided, image must have transparency, which will be used as the mask. 1147 | * @param {string} prompt A text description of the desired image(s). The maximum length is 1000 characters. 1148 | * @param {File} [mask] An additional image whose fully transparent areas (e.g. where alpha is zero) indicate where `image` should be edited. Must be a valid PNG file, less than 4MB, and have the same dimensions as `image`. 1149 | * @param {number} [n] The number of images to generate. Must be between 1 and 10. 1150 | * @param {string} [size] The size of the generated images. Must be one of `256x256`, `512x512`, or `1024x1024`. 1151 | * @param {string} [responseFormat] The format in which the generated images are returned. Must be one of `url` or `b64_json`. 1152 | * @param {string} [user] A unique identifier representing your end-user, which can help OpenAI to monitor and detect abuse. [Learn more](/docs/guides/safety-best-practices/end-user-ids). 1153 | * @param {*} [options] Override http request option. 1154 | * @throws {RequiredError} 1155 | */ 1156 | createImageEdit(image, prompt, mask, n, size, responseFormat, user, options) { 1157 | return __awaiter(this, void 0, void 0, function* () { 1158 | const localVarAxiosArgs = yield localVarAxiosParamCreator.createImageEdit(image, prompt, mask, n, size, responseFormat, user, options); 1159 | return common_1.createRequestFunction(localVarAxiosArgs, axios_1.default, base_1.BASE_PATH, configuration); 1160 | }); 1161 | }, 1162 | /** 1163 | * 1164 | * @summary Creates a variation of a given image. 1165 | * @param {File} image The image to use as the basis for the variation(s). Must be a valid PNG file, less than 4MB, and square. 1166 | * @param {number} [n] The number of images to generate. Must be between 1 and 10. 1167 | * @param {string} [size] The size of the generated images. Must be one of `256x256`, `512x512`, or `1024x1024`. 1168 | * @param {string} [responseFormat] The format in which the generated images are returned. Must be one of `url` or `b64_json`. 1169 | * @param {string} [user] A unique identifier representing your end-user, which can help OpenAI to monitor and detect abuse. [Learn more](/docs/guides/safety-best-practices/end-user-ids). 1170 | * @param {*} [options] Override http request option. 1171 | * @throws {RequiredError} 1172 | */ 1173 | createImageVariation(image, n, size, responseFormat, user, options) { 1174 | return __awaiter(this, void 0, void 0, function* () { 1175 | const localVarAxiosArgs = yield localVarAxiosParamCreator.createImageVariation(image, n, size, responseFormat, user, options); 1176 | return common_1.createRequestFunction(localVarAxiosArgs, axios_1.default, base_1.BASE_PATH, configuration); 1177 | }); 1178 | }, 1179 | /** 1180 | * 1181 | * @summary Classifies if text violates OpenAI\'s Content Policy 1182 | * @param {CreateModerationRequest} createModerationRequest 1183 | * @param {*} [options] Override http request option. 1184 | * @throws {RequiredError} 1185 | */ 1186 | createModeration(createModerationRequest, options) { 1187 | return __awaiter(this, void 0, void 0, function* () { 1188 | const localVarAxiosArgs = yield localVarAxiosParamCreator.createModeration(createModerationRequest, options); 1189 | return common_1.createRequestFunction(localVarAxiosArgs, axios_1.default, base_1.BASE_PATH, configuration); 1190 | }); 1191 | }, 1192 | /** 1193 | * 1194 | * @summary The search endpoint computes similarity scores between provided query and documents. Documents can be passed directly to the API if there are no more than 200 of them. To go beyond the 200 document limit, documents can be processed offline and then used for efficient retrieval at query time. When `file` is set, the search endpoint searches over all the documents in the given file and returns up to the `max_rerank` number of documents. These documents will be returned along with their search scores. The similarity score is a positive score that usually ranges from 0 to 300 (but can sometimes go higher), where a score above 200 usually means the document is semantically similar to the query. 1195 | * @param {string} engineId The ID of the engine to use for this request. You can select one of `ada`, `babbage`, `curie`, or `davinci`. 1196 | * @param {CreateSearchRequest} createSearchRequest 1197 | * @param {*} [options] Override http request option. 1198 | * @deprecated 1199 | * @throws {RequiredError} 1200 | */ 1201 | createSearch(engineId, createSearchRequest, options) { 1202 | return __awaiter(this, void 0, void 0, function* () { 1203 | const localVarAxiosArgs = yield localVarAxiosParamCreator.createSearch(engineId, createSearchRequest, options); 1204 | return common_1.createRequestFunction(localVarAxiosArgs, axios_1.default, base_1.BASE_PATH, configuration); 1205 | }); 1206 | }, 1207 | /** 1208 | * 1209 | * @summary Transcribes audio into the input language. 1210 | * @param {File} file The audio file to transcribe, in one of these formats: mp3, mp4, mpeg, mpga, m4a, wav, or webm. 1211 | * @param {string} model ID of the model to use. Only `whisper-1` is currently available. 1212 | * @param {string} [prompt] An optional text to guide the model\\\'s style or continue a previous audio segment. The [prompt](/docs/guides/speech-to-text/prompting) should match the audio language. 1213 | * @param {string} [responseFormat] The format of the transcript output, in one of these options: json, text, srt, verbose_json, or vtt. 1214 | * @param {number} [temperature] The sampling temperature, between 0 and 1. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic. If set to 0, the model will use [log probability](https://en.wikipedia.org/wiki/Log_probability) to automatically increase the temperature until certain thresholds are hit. 1215 | * @param {string} [language] The language of the input audio. Supplying the input language in [ISO-639-1](https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes) format will improve accuracy and latency. 1216 | * @param {*} [options] Override http request option. 1217 | * @throws {RequiredError} 1218 | */ 1219 | createTranscription(file, model, prompt, responseFormat, temperature, language, options) { 1220 | return __awaiter(this, void 0, void 0, function* () { 1221 | const localVarAxiosArgs = yield localVarAxiosParamCreator.createTranscription(file, model, prompt, responseFormat, temperature, language, options); 1222 | return common_1.createRequestFunction(localVarAxiosArgs, axios_1.default, base_1.BASE_PATH, configuration); 1223 | }); 1224 | }, 1225 | /** 1226 | * 1227 | * @summary Translates audio into into English. 1228 | * @param {File} file The audio file to translate, in one of these formats: mp3, mp4, mpeg, mpga, m4a, wav, or webm. 1229 | * @param {string} model ID of the model to use. Only `whisper-1` is currently available. 1230 | * @param {string} [prompt] An optional text to guide the model\\\'s style or continue a previous audio segment. The [prompt](/docs/guides/speech-to-text/prompting) should be in English. 1231 | * @param {string} [responseFormat] The format of the transcript output, in one of these options: json, text, srt, verbose_json, or vtt. 1232 | * @param {number} [temperature] The sampling temperature, between 0 and 1. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic. If set to 0, the model will use [log probability](https://en.wikipedia.org/wiki/Log_probability) to automatically increase the temperature until certain thresholds are hit. 1233 | * @param {*} [options] Override http request option. 1234 | * @throws {RequiredError} 1235 | */ 1236 | createTranslation(file, model, prompt, responseFormat, temperature, options) { 1237 | return __awaiter(this, void 0, void 0, function* () { 1238 | const localVarAxiosArgs = yield localVarAxiosParamCreator.createTranslation(file, model, prompt, responseFormat, temperature, options); 1239 | return common_1.createRequestFunction(localVarAxiosArgs, axios_1.default, base_1.BASE_PATH, configuration); 1240 | }); 1241 | }, 1242 | /** 1243 | * 1244 | * @summary Delete a file. 1245 | * @param {string} fileId The ID of the file to use for this request 1246 | * @param {*} [options] Override http request option. 1247 | * @throws {RequiredError} 1248 | */ 1249 | deleteFile(fileId, options) { 1250 | return __awaiter(this, void 0, void 0, function* () { 1251 | const localVarAxiosArgs = yield localVarAxiosParamCreator.deleteFile(fileId, options); 1252 | return common_1.createRequestFunction(localVarAxiosArgs, axios_1.default, base_1.BASE_PATH, configuration); 1253 | }); 1254 | }, 1255 | /** 1256 | * 1257 | * @summary Delete a fine-tuned model. You must have the Owner role in your organization. 1258 | * @param {string} model The model to delete 1259 | * @param {*} [options] Override http request option. 1260 | * @throws {RequiredError} 1261 | */ 1262 | deleteModel(model, options) { 1263 | return __awaiter(this, void 0, void 0, function* () { 1264 | const localVarAxiosArgs = yield localVarAxiosParamCreator.deleteModel(model, options); 1265 | return common_1.createRequestFunction(localVarAxiosArgs, axios_1.default, base_1.BASE_PATH, configuration); 1266 | }); 1267 | }, 1268 | /** 1269 | * 1270 | * @summary Returns the contents of the specified file 1271 | * @param {string} fileId The ID of the file to use for this request 1272 | * @param {*} [options] Override http request option. 1273 | * @throws {RequiredError} 1274 | */ 1275 | downloadFile(fileId, options) { 1276 | return __awaiter(this, void 0, void 0, function* () { 1277 | const localVarAxiosArgs = yield localVarAxiosParamCreator.downloadFile(fileId, options); 1278 | return common_1.createRequestFunction(localVarAxiosArgs, axios_1.default, base_1.BASE_PATH, configuration); 1279 | }); 1280 | }, 1281 | /** 1282 | * 1283 | * @summary Lists the currently available (non-finetuned) models, and provides basic information about each one such as the owner and availability. 1284 | * @param {*} [options] Override http request option. 1285 | * @deprecated 1286 | * @throws {RequiredError} 1287 | */ 1288 | listEngines(options) { 1289 | return __awaiter(this, void 0, void 0, function* () { 1290 | const localVarAxiosArgs = yield localVarAxiosParamCreator.listEngines(options); 1291 | return common_1.createRequestFunction(localVarAxiosArgs, axios_1.default, base_1.BASE_PATH, configuration); 1292 | }); 1293 | }, 1294 | /** 1295 | * 1296 | * @summary Returns a list of files that belong to the user\'s organization. 1297 | * @param {*} [options] Override http request option. 1298 | * @throws {RequiredError} 1299 | */ 1300 | listFiles(options) { 1301 | return __awaiter(this, void 0, void 0, function* () { 1302 | const localVarAxiosArgs = yield localVarAxiosParamCreator.listFiles(options); 1303 | return common_1.createRequestFunction(localVarAxiosArgs, axios_1.default, base_1.BASE_PATH, configuration); 1304 | }); 1305 | }, 1306 | /** 1307 | * 1308 | * @summary Get fine-grained status updates for a fine-tune job. 1309 | * @param {string} fineTuneId The ID of the fine-tune job to get events for. 1310 | * @param {boolean} [stream] Whether to stream events for the fine-tune job. If set to true, events will be sent as data-only [server-sent events](https://developer.mozilla.org/en-US/docs/Web/API/Server-sent_events/Using_server-sent_events#Event_stream_format) as they become available. The stream will terminate with a `data: [DONE]` message when the job is finished (succeeded, cancelled, or failed). If set to false, only events generated so far will be returned. 1311 | * @param {*} [options] Override http request option. 1312 | * @throws {RequiredError} 1313 | */ 1314 | listFineTuneEvents(fineTuneId, stream, options) { 1315 | return __awaiter(this, void 0, void 0, function* () { 1316 | const localVarAxiosArgs = yield localVarAxiosParamCreator.listFineTuneEvents(fineTuneId, stream, options); 1317 | return common_1.createRequestFunction(localVarAxiosArgs, axios_1.default, base_1.BASE_PATH, configuration); 1318 | }); 1319 | }, 1320 | /** 1321 | * 1322 | * @summary List your organization\'s fine-tuning jobs 1323 | * @param {*} [options] Override http request option. 1324 | * @throws {RequiredError} 1325 | */ 1326 | listFineTunes(options) { 1327 | return __awaiter(this, void 0, void 0, function* () { 1328 | const localVarAxiosArgs = yield localVarAxiosParamCreator.listFineTunes(options); 1329 | return common_1.createRequestFunction(localVarAxiosArgs, axios_1.default, base_1.BASE_PATH, configuration); 1330 | }); 1331 | }, 1332 | /** 1333 | * 1334 | * @summary Lists the currently available models, and provides basic information about each one such as the owner and availability. 1335 | * @param {*} [options] Override http request option. 1336 | * @throws {RequiredError} 1337 | */ 1338 | listModels(options) { 1339 | return __awaiter(this, void 0, void 0, function* () { 1340 | const localVarAxiosArgs = yield localVarAxiosParamCreator.listModels(options); 1341 | return common_1.createRequestFunction(localVarAxiosArgs, axios_1.default, base_1.BASE_PATH, configuration); 1342 | }); 1343 | }, 1344 | /** 1345 | * 1346 | * @summary Retrieves a model instance, providing basic information about it such as the owner and availability. 1347 | * @param {string} engineId The ID of the engine to use for this request 1348 | * @param {*} [options] Override http request option. 1349 | * @deprecated 1350 | * @throws {RequiredError} 1351 | */ 1352 | retrieveEngine(engineId, options) { 1353 | return __awaiter(this, void 0, void 0, function* () { 1354 | const localVarAxiosArgs = yield localVarAxiosParamCreator.retrieveEngine(engineId, options); 1355 | return common_1.createRequestFunction(localVarAxiosArgs, axios_1.default, base_1.BASE_PATH, configuration); 1356 | }); 1357 | }, 1358 | /** 1359 | * 1360 | * @summary Returns information about a specific file. 1361 | * @param {string} fileId The ID of the file to use for this request 1362 | * @param {*} [options] Override http request option. 1363 | * @throws {RequiredError} 1364 | */ 1365 | retrieveFile(fileId, options) { 1366 | return __awaiter(this, void 0, void 0, function* () { 1367 | const localVarAxiosArgs = yield localVarAxiosParamCreator.retrieveFile(fileId, options); 1368 | return common_1.createRequestFunction(localVarAxiosArgs, axios_1.default, base_1.BASE_PATH, configuration); 1369 | }); 1370 | }, 1371 | /** 1372 | * 1373 | * @summary Gets info about the fine-tune job. [Learn more about Fine-tuning](/docs/guides/fine-tuning) 1374 | * @param {string} fineTuneId The ID of the fine-tune job 1375 | * @param {*} [options] Override http request option. 1376 | * @throws {RequiredError} 1377 | */ 1378 | retrieveFineTune(fineTuneId, options) { 1379 | return __awaiter(this, void 0, void 0, function* () { 1380 | const localVarAxiosArgs = yield localVarAxiosParamCreator.retrieveFineTune(fineTuneId, options); 1381 | return common_1.createRequestFunction(localVarAxiosArgs, axios_1.default, base_1.BASE_PATH, configuration); 1382 | }); 1383 | }, 1384 | /** 1385 | * 1386 | * @summary Retrieves a model instance, providing basic information about the model such as the owner and permissioning. 1387 | * @param {string} model The ID of the model to use for this request 1388 | * @param {*} [options] Override http request option. 1389 | * @throws {RequiredError} 1390 | */ 1391 | retrieveModel(model, options) { 1392 | return __awaiter(this, void 0, void 0, function* () { 1393 | const localVarAxiosArgs = yield localVarAxiosParamCreator.retrieveModel(model, options); 1394 | return common_1.createRequestFunction(localVarAxiosArgs, axios_1.default, base_1.BASE_PATH, configuration); 1395 | }); 1396 | }, 1397 | }; 1398 | }; 1399 | /** 1400 | * OpenAIApi - factory interface 1401 | * @export 1402 | */ 1403 | exports.OpenAIApiFactory = function (configuration, basePath, axios) { 1404 | const localVarFp = exports.OpenAIApiFp(configuration); 1405 | return { 1406 | /** 1407 | * 1408 | * @summary Immediately cancel a fine-tune job. 1409 | * @param {string} fineTuneId The ID of the fine-tune job to cancel 1410 | * @param {*} [options] Override http request option. 1411 | * @throws {RequiredError} 1412 | */ 1413 | cancelFineTune(fineTuneId, options) { 1414 | return localVarFp.cancelFineTune(fineTuneId, options).then((request) => request(axios, basePath)); 1415 | }, 1416 | /** 1417 | * 1418 | * @summary Answers the specified question using the provided documents and examples. The endpoint first [searches](/docs/api-reference/searches) over provided documents or files to find relevant context. The relevant context is combined with the provided examples and question to create the prompt for [completion](/docs/api-reference/completions). 1419 | * @param {CreateAnswerRequest} createAnswerRequest 1420 | * @param {*} [options] Override http request option. 1421 | * @deprecated 1422 | * @throws {RequiredError} 1423 | */ 1424 | createAnswer(createAnswerRequest, options) { 1425 | return localVarFp.createAnswer(createAnswerRequest, options).then((request) => request(axios, basePath)); 1426 | }, 1427 | /** 1428 | * 1429 | * @summary Creates a completion for the chat message 1430 | * @param {CreateChatCompletionRequest} createChatCompletionRequest 1431 | * @param {*} [options] Override http request option. 1432 | * @throws {RequiredError} 1433 | */ 1434 | createChatCompletion(createChatCompletionRequest, options) { 1435 | return localVarFp.createChatCompletion(createChatCompletionRequest, options).then((request) => request(axios, basePath)); 1436 | }, 1437 | /** 1438 | * 1439 | * @summary Classifies the specified `query` using provided examples. The endpoint first [searches](/docs/api-reference/searches) over the labeled examples to select the ones most relevant for the particular query. Then, the relevant examples are combined with the query to construct a prompt to produce the final label via the [completions](/docs/api-reference/completions) endpoint. Labeled examples can be provided via an uploaded `file`, or explicitly listed in the request using the `examples` parameter for quick tests and small scale use cases. 1440 | * @param {CreateClassificationRequest} createClassificationRequest 1441 | * @param {*} [options] Override http request option. 1442 | * @deprecated 1443 | * @throws {RequiredError} 1444 | */ 1445 | createClassification(createClassificationRequest, options) { 1446 | return localVarFp.createClassification(createClassificationRequest, options).then((request) => request(axios, basePath)); 1447 | }, 1448 | /** 1449 | * 1450 | * @summary Creates a completion for the provided prompt and parameters 1451 | * @param {CreateCompletionRequest} createCompletionRequest 1452 | * @param {*} [options] Override http request option. 1453 | * @throws {RequiredError} 1454 | */ 1455 | createCompletion(createCompletionRequest, options) { 1456 | return localVarFp.createCompletion(createCompletionRequest, options).then((request) => request(axios, basePath)); 1457 | }, 1458 | /** 1459 | * 1460 | * @summary Creates a new edit for the provided input, instruction, and parameters. 1461 | * @param {CreateEditRequest} createEditRequest 1462 | * @param {*} [options] Override http request option. 1463 | * @throws {RequiredError} 1464 | */ 1465 | createEdit(createEditRequest, options) { 1466 | return localVarFp.createEdit(createEditRequest, options).then((request) => request(axios, basePath)); 1467 | }, 1468 | /** 1469 | * 1470 | * @summary Creates an embedding vector representing the input text. 1471 | * @param {CreateEmbeddingRequest} createEmbeddingRequest 1472 | * @param {*} [options] Override http request option. 1473 | * @throws {RequiredError} 1474 | */ 1475 | createEmbedding(createEmbeddingRequest, options) { 1476 | return localVarFp.createEmbedding(createEmbeddingRequest, options).then((request) => request(axios, basePath)); 1477 | }, 1478 | /** 1479 | * 1480 | * @summary Upload a file that contains document(s) to be used across various endpoints/features. Currently, the size of all the files uploaded by one organization can be up to 1 GB. Please contact us if you need to increase the storage limit. 1481 | * @param {File} file Name of the [JSON Lines](https://jsonlines.readthedocs.io/en/latest/) file to be uploaded. If the `purpose` is set to \\\"fine-tune\\\", each line is a JSON record with \\\"prompt\\\" and \\\"completion\\\" fields representing your [training examples](/docs/guides/fine-tuning/prepare-training-data). 1482 | * @param {string} purpose The intended purpose of the uploaded documents. Use \\\"fine-tune\\\" for [Fine-tuning](/docs/api-reference/fine-tunes). This allows us to validate the format of the uploaded file. 1483 | * @param {*} [options] Override http request option. 1484 | * @throws {RequiredError} 1485 | */ 1486 | createFile(file, purpose, options) { 1487 | return localVarFp.createFile(file, purpose, options).then((request) => request(axios, basePath)); 1488 | }, 1489 | /** 1490 | * 1491 | * @summary Creates a job that fine-tunes a specified model from a given dataset. Response includes details of the enqueued job including job status and the name of the fine-tuned models once complete. [Learn more about Fine-tuning](/docs/guides/fine-tuning) 1492 | * @param {CreateFineTuneRequest} createFineTuneRequest 1493 | * @param {*} [options] Override http request option. 1494 | * @throws {RequiredError} 1495 | */ 1496 | createFineTune(createFineTuneRequest, options) { 1497 | return localVarFp.createFineTune(createFineTuneRequest, options).then((request) => request(axios, basePath)); 1498 | }, 1499 | /** 1500 | * 1501 | * @summary Creates an image given a prompt. 1502 | * @param {CreateImageRequest} createImageRequest 1503 | * @param {*} [options] Override http request option. 1504 | * @throws {RequiredError} 1505 | */ 1506 | createImage(createImageRequest, options) { 1507 | return localVarFp.createImage(createImageRequest, options).then((request) => request(axios, basePath)); 1508 | }, 1509 | /** 1510 | * 1511 | * @summary Creates an edited or extended image given an original image and a prompt. 1512 | * @param {File} image The image to edit. Must be a valid PNG file, less than 4MB, and square. If mask is not provided, image must have transparency, which will be used as the mask. 1513 | * @param {string} prompt A text description of the desired image(s). The maximum length is 1000 characters. 1514 | * @param {File} [mask] An additional image whose fully transparent areas (e.g. where alpha is zero) indicate where `image` should be edited. Must be a valid PNG file, less than 4MB, and have the same dimensions as `image`. 1515 | * @param {number} [n] The number of images to generate. Must be between 1 and 10. 1516 | * @param {string} [size] The size of the generated images. Must be one of `256x256`, `512x512`, or `1024x1024`. 1517 | * @param {string} [responseFormat] The format in which the generated images are returned. Must be one of `url` or `b64_json`. 1518 | * @param {string} [user] A unique identifier representing your end-user, which can help OpenAI to monitor and detect abuse. [Learn more](/docs/guides/safety-best-practices/end-user-ids). 1519 | * @param {*} [options] Override http request option. 1520 | * @throws {RequiredError} 1521 | */ 1522 | createImageEdit(image, prompt, mask, n, size, responseFormat, user, options) { 1523 | return localVarFp.createImageEdit(image, prompt, mask, n, size, responseFormat, user, options).then((request) => request(axios, basePath)); 1524 | }, 1525 | /** 1526 | * 1527 | * @summary Creates a variation of a given image. 1528 | * @param {File} image The image to use as the basis for the variation(s). Must be a valid PNG file, less than 4MB, and square. 1529 | * @param {number} [n] The number of images to generate. Must be between 1 and 10. 1530 | * @param {string} [size] The size of the generated images. Must be one of `256x256`, `512x512`, or `1024x1024`. 1531 | * @param {string} [responseFormat] The format in which the generated images are returned. Must be one of `url` or `b64_json`. 1532 | * @param {string} [user] A unique identifier representing your end-user, which can help OpenAI to monitor and detect abuse. [Learn more](/docs/guides/safety-best-practices/end-user-ids). 1533 | * @param {*} [options] Override http request option. 1534 | * @throws {RequiredError} 1535 | */ 1536 | createImageVariation(image, n, size, responseFormat, user, options) { 1537 | return localVarFp.createImageVariation(image, n, size, responseFormat, user, options).then((request) => request(axios, basePath)); 1538 | }, 1539 | /** 1540 | * 1541 | * @summary Classifies if text violates OpenAI\'s Content Policy 1542 | * @param {CreateModerationRequest} createModerationRequest 1543 | * @param {*} [options] Override http request option. 1544 | * @throws {RequiredError} 1545 | */ 1546 | createModeration(createModerationRequest, options) { 1547 | return localVarFp.createModeration(createModerationRequest, options).then((request) => request(axios, basePath)); 1548 | }, 1549 | /** 1550 | * 1551 | * @summary The search endpoint computes similarity scores between provided query and documents. Documents can be passed directly to the API if there are no more than 200 of them. To go beyond the 200 document limit, documents can be processed offline and then used for efficient retrieval at query time. When `file` is set, the search endpoint searches over all the documents in the given file and returns up to the `max_rerank` number of documents. These documents will be returned along with their search scores. The similarity score is a positive score that usually ranges from 0 to 300 (but can sometimes go higher), where a score above 200 usually means the document is semantically similar to the query. 1552 | * @param {string} engineId The ID of the engine to use for this request. You can select one of `ada`, `babbage`, `curie`, or `davinci`. 1553 | * @param {CreateSearchRequest} createSearchRequest 1554 | * @param {*} [options] Override http request option. 1555 | * @deprecated 1556 | * @throws {RequiredError} 1557 | */ 1558 | createSearch(engineId, createSearchRequest, options) { 1559 | return localVarFp.createSearch(engineId, createSearchRequest, options).then((request) => request(axios, basePath)); 1560 | }, 1561 | /** 1562 | * 1563 | * @summary Transcribes audio into the input language. 1564 | * @param {File} file The audio file to transcribe, in one of these formats: mp3, mp4, mpeg, mpga, m4a, wav, or webm. 1565 | * @param {string} model ID of the model to use. Only `whisper-1` is currently available. 1566 | * @param {string} [prompt] An optional text to guide the model\\\'s style or continue a previous audio segment. The [prompt](/docs/guides/speech-to-text/prompting) should match the audio language. 1567 | * @param {string} [responseFormat] The format of the transcript output, in one of these options: json, text, srt, verbose_json, or vtt. 1568 | * @param {number} [temperature] The sampling temperature, between 0 and 1. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic. If set to 0, the model will use [log probability](https://en.wikipedia.org/wiki/Log_probability) to automatically increase the temperature until certain thresholds are hit. 1569 | * @param {string} [language] The language of the input audio. Supplying the input language in [ISO-639-1](https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes) format will improve accuracy and latency. 1570 | * @param {*} [options] Override http request option. 1571 | * @throws {RequiredError} 1572 | */ 1573 | createTranscription(file, model, prompt, responseFormat, temperature, language, options) { 1574 | return localVarFp.createTranscription(file, model, prompt, responseFormat, temperature, language, options).then((request) => request(axios, basePath)); 1575 | }, 1576 | /** 1577 | * 1578 | * @summary Translates audio into into English. 1579 | * @param {File} file The audio file to translate, in one of these formats: mp3, mp4, mpeg, mpga, m4a, wav, or webm. 1580 | * @param {string} model ID of the model to use. Only `whisper-1` is currently available. 1581 | * @param {string} [prompt] An optional text to guide the model\\\'s style or continue a previous audio segment. The [prompt](/docs/guides/speech-to-text/prompting) should be in English. 1582 | * @param {string} [responseFormat] The format of the transcript output, in one of these options: json, text, srt, verbose_json, or vtt. 1583 | * @param {number} [temperature] The sampling temperature, between 0 and 1. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic. If set to 0, the model will use [log probability](https://en.wikipedia.org/wiki/Log_probability) to automatically increase the temperature until certain thresholds are hit. 1584 | * @param {*} [options] Override http request option. 1585 | * @throws {RequiredError} 1586 | */ 1587 | createTranslation(file, model, prompt, responseFormat, temperature, options) { 1588 | return localVarFp.createTranslation(file, model, prompt, responseFormat, temperature, options).then((request) => request(axios, basePath)); 1589 | }, 1590 | /** 1591 | * 1592 | * @summary Delete a file. 1593 | * @param {string} fileId The ID of the file to use for this request 1594 | * @param {*} [options] Override http request option. 1595 | * @throws {RequiredError} 1596 | */ 1597 | deleteFile(fileId, options) { 1598 | return localVarFp.deleteFile(fileId, options).then((request) => request(axios, basePath)); 1599 | }, 1600 | /** 1601 | * 1602 | * @summary Delete a fine-tuned model. You must have the Owner role in your organization. 1603 | * @param {string} model The model to delete 1604 | * @param {*} [options] Override http request option. 1605 | * @throws {RequiredError} 1606 | */ 1607 | deleteModel(model, options) { 1608 | return localVarFp.deleteModel(model, options).then((request) => request(axios, basePath)); 1609 | }, 1610 | /** 1611 | * 1612 | * @summary Returns the contents of the specified file 1613 | * @param {string} fileId The ID of the file to use for this request 1614 | * @param {*} [options] Override http request option. 1615 | * @throws {RequiredError} 1616 | */ 1617 | downloadFile(fileId, options) { 1618 | return localVarFp.downloadFile(fileId, options).then((request) => request(axios, basePath)); 1619 | }, 1620 | /** 1621 | * 1622 | * @summary Lists the currently available (non-finetuned) models, and provides basic information about each one such as the owner and availability. 1623 | * @param {*} [options] Override http request option. 1624 | * @deprecated 1625 | * @throws {RequiredError} 1626 | */ 1627 | listEngines(options) { 1628 | return localVarFp.listEngines(options).then((request) => request(axios, basePath)); 1629 | }, 1630 | /** 1631 | * 1632 | * @summary Returns a list of files that belong to the user\'s organization. 1633 | * @param {*} [options] Override http request option. 1634 | * @throws {RequiredError} 1635 | */ 1636 | listFiles(options) { 1637 | return localVarFp.listFiles(options).then((request) => request(axios, basePath)); 1638 | }, 1639 | /** 1640 | * 1641 | * @summary Get fine-grained status updates for a fine-tune job. 1642 | * @param {string} fineTuneId The ID of the fine-tune job to get events for. 1643 | * @param {boolean} [stream] Whether to stream events for the fine-tune job. If set to true, events will be sent as data-only [server-sent events](https://developer.mozilla.org/en-US/docs/Web/API/Server-sent_events/Using_server-sent_events#Event_stream_format) as they become available. The stream will terminate with a `data: [DONE]` message when the job is finished (succeeded, cancelled, or failed). If set to false, only events generated so far will be returned. 1644 | * @param {*} [options] Override http request option. 1645 | * @throws {RequiredError} 1646 | */ 1647 | listFineTuneEvents(fineTuneId, stream, options) { 1648 | return localVarFp.listFineTuneEvents(fineTuneId, stream, options).then((request) => request(axios, basePath)); 1649 | }, 1650 | /** 1651 | * 1652 | * @summary List your organization\'s fine-tuning jobs 1653 | * @param {*} [options] Override http request option. 1654 | * @throws {RequiredError} 1655 | */ 1656 | listFineTunes(options) { 1657 | return localVarFp.listFineTunes(options).then((request) => request(axios, basePath)); 1658 | }, 1659 | /** 1660 | * 1661 | * @summary Lists the currently available models, and provides basic information about each one such as the owner and availability. 1662 | * @param {*} [options] Override http request option. 1663 | * @throws {RequiredError} 1664 | */ 1665 | listModels(options) { 1666 | return localVarFp.listModels(options).then((request) => request(axios, basePath)); 1667 | }, 1668 | /** 1669 | * 1670 | * @summary Retrieves a model instance, providing basic information about it such as the owner and availability. 1671 | * @param {string} engineId The ID of the engine to use for this request 1672 | * @param {*} [options] Override http request option. 1673 | * @deprecated 1674 | * @throws {RequiredError} 1675 | */ 1676 | retrieveEngine(engineId, options) { 1677 | return localVarFp.retrieveEngine(engineId, options).then((request) => request(axios, basePath)); 1678 | }, 1679 | /** 1680 | * 1681 | * @summary Returns information about a specific file. 1682 | * @param {string} fileId The ID of the file to use for this request 1683 | * @param {*} [options] Override http request option. 1684 | * @throws {RequiredError} 1685 | */ 1686 | retrieveFile(fileId, options) { 1687 | return localVarFp.retrieveFile(fileId, options).then((request) => request(axios, basePath)); 1688 | }, 1689 | /** 1690 | * 1691 | * @summary Gets info about the fine-tune job. [Learn more about Fine-tuning](/docs/guides/fine-tuning) 1692 | * @param {string} fineTuneId The ID of the fine-tune job 1693 | * @param {*} [options] Override http request option. 1694 | * @throws {RequiredError} 1695 | */ 1696 | retrieveFineTune(fineTuneId, options) { 1697 | return localVarFp.retrieveFineTune(fineTuneId, options).then((request) => request(axios, basePath)); 1698 | }, 1699 | /** 1700 | * 1701 | * @summary Retrieves a model instance, providing basic information about the model such as the owner and permissioning. 1702 | * @param {string} model The ID of the model to use for this request 1703 | * @param {*} [options] Override http request option. 1704 | * @throws {RequiredError} 1705 | */ 1706 | retrieveModel(model, options) { 1707 | return localVarFp.retrieveModel(model, options).then((request) => request(axios, basePath)); 1708 | }, 1709 | }; 1710 | }; 1711 | /** 1712 | * OpenAIApi - object-oriented interface 1713 | * @export 1714 | * @class OpenAIApi 1715 | * @extends {BaseAPI} 1716 | */ 1717 | class OpenAIApi extends base_1.BaseAPI { 1718 | /** 1719 | * 1720 | * @summary Immediately cancel a fine-tune job. 1721 | * @param {string} fineTuneId The ID of the fine-tune job to cancel 1722 | * @param {*} [options] Override http request option. 1723 | * @throws {RequiredError} 1724 | * @memberof OpenAIApi 1725 | */ 1726 | cancelFineTune(fineTuneId, options) { 1727 | return exports.OpenAIApiFp(this.configuration).cancelFineTune(fineTuneId, options).then((request) => request(this.axios, this.basePath)); 1728 | } 1729 | /** 1730 | * 1731 | * @summary Answers the specified question using the provided documents and examples. The endpoint first [searches](/docs/api-reference/searches) over provided documents or files to find relevant context. The relevant context is combined with the provided examples and question to create the prompt for [completion](/docs/api-reference/completions). 1732 | * @param {CreateAnswerRequest} createAnswerRequest 1733 | * @param {*} [options] Override http request option. 1734 | * @deprecated 1735 | * @throws {RequiredError} 1736 | * @memberof OpenAIApi 1737 | */ 1738 | createAnswer(createAnswerRequest, options) { 1739 | return exports.OpenAIApiFp(this.configuration).createAnswer(createAnswerRequest, options).then((request) => request(this.axios, this.basePath)); 1740 | } 1741 | /** 1742 | * 1743 | * @summary Creates a completion for the chat message 1744 | * @param {CreateChatCompletionRequest} createChatCompletionRequest 1745 | * @param {*} [options] Override http request option. 1746 | * @throws {RequiredError} 1747 | * @memberof OpenAIApi 1748 | */ 1749 | createChatCompletion(createChatCompletionRequest, options) { 1750 | return exports.OpenAIApiFp(this.configuration).createChatCompletion(createChatCompletionRequest, options).then((request) => request(this.axios, this.basePath)); 1751 | } 1752 | /** 1753 | * 1754 | * @summary Classifies the specified `query` using provided examples. The endpoint first [searches](/docs/api-reference/searches) over the labeled examples to select the ones most relevant for the particular query. Then, the relevant examples are combined with the query to construct a prompt to produce the final label via the [completions](/docs/api-reference/completions) endpoint. Labeled examples can be provided via an uploaded `file`, or explicitly listed in the request using the `examples` parameter for quick tests and small scale use cases. 1755 | * @param {CreateClassificationRequest} createClassificationRequest 1756 | * @param {*} [options] Override http request option. 1757 | * @deprecated 1758 | * @throws {RequiredError} 1759 | * @memberof OpenAIApi 1760 | */ 1761 | createClassification(createClassificationRequest, options) { 1762 | return exports.OpenAIApiFp(this.configuration).createClassification(createClassificationRequest, options).then((request) => request(this.axios, this.basePath)); 1763 | } 1764 | /** 1765 | * 1766 | * @summary Creates a completion for the provided prompt and parameters 1767 | * @param {CreateCompletionRequest} createCompletionRequest 1768 | * @param {*} [options] Override http request option. 1769 | * @throws {RequiredError} 1770 | * @memberof OpenAIApi 1771 | */ 1772 | createCompletion(createCompletionRequest, options) { 1773 | return exports.OpenAIApiFp(this.configuration).createCompletion(createCompletionRequest, options).then((request) => request(this.axios, this.basePath)); 1774 | } 1775 | /** 1776 | * 1777 | * @summary Creates a new edit for the provided input, instruction, and parameters. 1778 | * @param {CreateEditRequest} createEditRequest 1779 | * @param {*} [options] Override http request option. 1780 | * @throws {RequiredError} 1781 | * @memberof OpenAIApi 1782 | */ 1783 | createEdit(createEditRequest, options) { 1784 | return exports.OpenAIApiFp(this.configuration).createEdit(createEditRequest, options).then((request) => request(this.axios, this.basePath)); 1785 | } 1786 | /** 1787 | * 1788 | * @summary Creates an embedding vector representing the input text. 1789 | * @param {CreateEmbeddingRequest} createEmbeddingRequest 1790 | * @param {*} [options] Override http request option. 1791 | * @throws {RequiredError} 1792 | * @memberof OpenAIApi 1793 | */ 1794 | createEmbedding(createEmbeddingRequest, options) { 1795 | return exports.OpenAIApiFp(this.configuration).createEmbedding(createEmbeddingRequest, options).then((request) => request(this.axios, this.basePath)); 1796 | } 1797 | /** 1798 | * 1799 | * @summary Upload a file that contains document(s) to be used across various endpoints/features. Currently, the size of all the files uploaded by one organization can be up to 1 GB. Please contact us if you need to increase the storage limit. 1800 | * @param {File} file Name of the [JSON Lines](https://jsonlines.readthedocs.io/en/latest/) file to be uploaded. If the `purpose` is set to \\\"fine-tune\\\", each line is a JSON record with \\\"prompt\\\" and \\\"completion\\\" fields representing your [training examples](/docs/guides/fine-tuning/prepare-training-data). 1801 | * @param {string} purpose The intended purpose of the uploaded documents. Use \\\"fine-tune\\\" for [Fine-tuning](/docs/api-reference/fine-tunes). This allows us to validate the format of the uploaded file. 1802 | * @param {*} [options] Override http request option. 1803 | * @throws {RequiredError} 1804 | * @memberof OpenAIApi 1805 | */ 1806 | createFile(file, purpose, options) { 1807 | return exports.OpenAIApiFp(this.configuration).createFile(file, purpose, options).then((request) => request(this.axios, this.basePath)); 1808 | } 1809 | /** 1810 | * 1811 | * @summary Creates a job that fine-tunes a specified model from a given dataset. Response includes details of the enqueued job including job status and the name of the fine-tuned models once complete. [Learn more about Fine-tuning](/docs/guides/fine-tuning) 1812 | * @param {CreateFineTuneRequest} createFineTuneRequest 1813 | * @param {*} [options] Override http request option. 1814 | * @throws {RequiredError} 1815 | * @memberof OpenAIApi 1816 | */ 1817 | createFineTune(createFineTuneRequest, options) { 1818 | return exports.OpenAIApiFp(this.configuration).createFineTune(createFineTuneRequest, options).then((request) => request(this.axios, this.basePath)); 1819 | } 1820 | /** 1821 | * 1822 | * @summary Creates an image given a prompt. 1823 | * @param {CreateImageRequest} createImageRequest 1824 | * @param {*} [options] Override http request option. 1825 | * @throws {RequiredError} 1826 | * @memberof OpenAIApi 1827 | */ 1828 | createImage(createImageRequest, options) { 1829 | return exports.OpenAIApiFp(this.configuration).createImage(createImageRequest, options).then((request) => request(this.axios, this.basePath)); 1830 | } 1831 | /** 1832 | * 1833 | * @summary Creates an edited or extended image given an original image and a prompt. 1834 | * @param {File} image The image to edit. Must be a valid PNG file, less than 4MB, and square. If mask is not provided, image must have transparency, which will be used as the mask. 1835 | * @param {string} prompt A text description of the desired image(s). The maximum length is 1000 characters. 1836 | * @param {File} [mask] An additional image whose fully transparent areas (e.g. where alpha is zero) indicate where `image` should be edited. Must be a valid PNG file, less than 4MB, and have the same dimensions as `image`. 1837 | * @param {number} [n] The number of images to generate. Must be between 1 and 10. 1838 | * @param {string} [size] The size of the generated images. Must be one of `256x256`, `512x512`, or `1024x1024`. 1839 | * @param {string} [responseFormat] The format in which the generated images are returned. Must be one of `url` or `b64_json`. 1840 | * @param {string} [user] A unique identifier representing your end-user, which can help OpenAI to monitor and detect abuse. [Learn more](/docs/guides/safety-best-practices/end-user-ids). 1841 | * @param {*} [options] Override http request option. 1842 | * @throws {RequiredError} 1843 | * @memberof OpenAIApi 1844 | */ 1845 | createImageEdit(image, prompt, mask, n, size, responseFormat, user, options) { 1846 | return exports.OpenAIApiFp(this.configuration).createImageEdit(image, prompt, mask, n, size, responseFormat, user, options).then((request) => request(this.axios, this.basePath)); 1847 | } 1848 | /** 1849 | * 1850 | * @summary Creates a variation of a given image. 1851 | * @param {File} image The image to use as the basis for the variation(s). Must be a valid PNG file, less than 4MB, and square. 1852 | * @param {number} [n] The number of images to generate. Must be between 1 and 10. 1853 | * @param {string} [size] The size of the generated images. Must be one of `256x256`, `512x512`, or `1024x1024`. 1854 | * @param {string} [responseFormat] The format in which the generated images are returned. Must be one of `url` or `b64_json`. 1855 | * @param {string} [user] A unique identifier representing your end-user, which can help OpenAI to monitor and detect abuse. [Learn more](/docs/guides/safety-best-practices/end-user-ids). 1856 | * @param {*} [options] Override http request option. 1857 | * @throws {RequiredError} 1858 | * @memberof OpenAIApi 1859 | */ 1860 | createImageVariation(image, n, size, responseFormat, user, options) { 1861 | return exports.OpenAIApiFp(this.configuration).createImageVariation(image, n, size, responseFormat, user, options).then((request) => request(this.axios, this.basePath)); 1862 | } 1863 | /** 1864 | * 1865 | * @summary Classifies if text violates OpenAI\'s Content Policy 1866 | * @param {CreateModerationRequest} createModerationRequest 1867 | * @param {*} [options] Override http request option. 1868 | * @throws {RequiredError} 1869 | * @memberof OpenAIApi 1870 | */ 1871 | createModeration(createModerationRequest, options) { 1872 | return exports.OpenAIApiFp(this.configuration).createModeration(createModerationRequest, options).then((request) => request(this.axios, this.basePath)); 1873 | } 1874 | /** 1875 | * 1876 | * @summary The search endpoint computes similarity scores between provided query and documents. Documents can be passed directly to the API if there are no more than 200 of them. To go beyond the 200 document limit, documents can be processed offline and then used for efficient retrieval at query time. When `file` is set, the search endpoint searches over all the documents in the given file and returns up to the `max_rerank` number of documents. These documents will be returned along with their search scores. The similarity score is a positive score that usually ranges from 0 to 300 (but can sometimes go higher), where a score above 200 usually means the document is semantically similar to the query. 1877 | * @param {string} engineId The ID of the engine to use for this request. You can select one of `ada`, `babbage`, `curie`, or `davinci`. 1878 | * @param {CreateSearchRequest} createSearchRequest 1879 | * @param {*} [options] Override http request option. 1880 | * @deprecated 1881 | * @throws {RequiredError} 1882 | * @memberof OpenAIApi 1883 | */ 1884 | createSearch(engineId, createSearchRequest, options) { 1885 | return exports.OpenAIApiFp(this.configuration).createSearch(engineId, createSearchRequest, options).then((request) => request(this.axios, this.basePath)); 1886 | } 1887 | /** 1888 | * 1889 | * @summary Transcribes audio into the input language. 1890 | * @param {File} file The audio file to transcribe, in one of these formats: mp3, mp4, mpeg, mpga, m4a, wav, or webm. 1891 | * @param {string} model ID of the model to use. Only `whisper-1` is currently available. 1892 | * @param {string} [prompt] An optional text to guide the model\\\'s style or continue a previous audio segment. The [prompt](/docs/guides/speech-to-text/prompting) should match the audio language. 1893 | * @param {string} [responseFormat] The format of the transcript output, in one of these options: json, text, srt, verbose_json, or vtt. 1894 | * @param {number} [temperature] The sampling temperature, between 0 and 1. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic. If set to 0, the model will use [log probability](https://en.wikipedia.org/wiki/Log_probability) to automatically increase the temperature until certain thresholds are hit. 1895 | * @param {string} [language] The language of the input audio. Supplying the input language in [ISO-639-1](https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes) format will improve accuracy and latency. 1896 | * @param {*} [options] Override http request option. 1897 | * @throws {RequiredError} 1898 | * @memberof OpenAIApi 1899 | */ 1900 | createTranscription(file, model, prompt, responseFormat, temperature, language, options) { 1901 | return exports.OpenAIApiFp(this.configuration).createTranscription(file, model, prompt, responseFormat, temperature, language, options).then((request) => request(this.axios, this.basePath)); 1902 | } 1903 | /** 1904 | * 1905 | * @summary Translates audio into into English. 1906 | * @param {File} file The audio file to translate, in one of these formats: mp3, mp4, mpeg, mpga, m4a, wav, or webm. 1907 | * @param {string} model ID of the model to use. Only `whisper-1` is currently available. 1908 | * @param {string} [prompt] An optional text to guide the model\\\'s style or continue a previous audio segment. The [prompt](/docs/guides/speech-to-text/prompting) should be in English. 1909 | * @param {string} [responseFormat] The format of the transcript output, in one of these options: json, text, srt, verbose_json, or vtt. 1910 | * @param {number} [temperature] The sampling temperature, between 0 and 1. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic. If set to 0, the model will use [log probability](https://en.wikipedia.org/wiki/Log_probability) to automatically increase the temperature until certain thresholds are hit. 1911 | * @param {*} [options] Override http request option. 1912 | * @throws {RequiredError} 1913 | * @memberof OpenAIApi 1914 | */ 1915 | createTranslation(file, model, prompt, responseFormat, temperature, options) { 1916 | return exports.OpenAIApiFp(this.configuration).createTranslation(file, model, prompt, responseFormat, temperature, options).then((request) => request(this.axios, this.basePath)); 1917 | } 1918 | /** 1919 | * 1920 | * @summary Delete a file. 1921 | * @param {string} fileId The ID of the file to use for this request 1922 | * @param {*} [options] Override http request option. 1923 | * @throws {RequiredError} 1924 | * @memberof OpenAIApi 1925 | */ 1926 | deleteFile(fileId, options) { 1927 | return exports.OpenAIApiFp(this.configuration).deleteFile(fileId, options).then((request) => request(this.axios, this.basePath)); 1928 | } 1929 | /** 1930 | * 1931 | * @summary Delete a fine-tuned model. You must have the Owner role in your organization. 1932 | * @param {string} model The model to delete 1933 | * @param {*} [options] Override http request option. 1934 | * @throws {RequiredError} 1935 | * @memberof OpenAIApi 1936 | */ 1937 | deleteModel(model, options) { 1938 | return exports.OpenAIApiFp(this.configuration).deleteModel(model, options).then((request) => request(this.axios, this.basePath)); 1939 | } 1940 | /** 1941 | * 1942 | * @summary Returns the contents of the specified file 1943 | * @param {string} fileId The ID of the file to use for this request 1944 | * @param {*} [options] Override http request option. 1945 | * @throws {RequiredError} 1946 | * @memberof OpenAIApi 1947 | */ 1948 | downloadFile(fileId, options) { 1949 | return exports.OpenAIApiFp(this.configuration).downloadFile(fileId, options).then((request) => request(this.axios, this.basePath)); 1950 | } 1951 | /** 1952 | * 1953 | * @summary Lists the currently available (non-finetuned) models, and provides basic information about each one such as the owner and availability. 1954 | * @param {*} [options] Override http request option. 1955 | * @deprecated 1956 | * @throws {RequiredError} 1957 | * @memberof OpenAIApi 1958 | */ 1959 | listEngines(options) { 1960 | return exports.OpenAIApiFp(this.configuration).listEngines(options).then((request) => request(this.axios, this.basePath)); 1961 | } 1962 | /** 1963 | * 1964 | * @summary Returns a list of files that belong to the user\'s organization. 1965 | * @param {*} [options] Override http request option. 1966 | * @throws {RequiredError} 1967 | * @memberof OpenAIApi 1968 | */ 1969 | listFiles(options) { 1970 | return exports.OpenAIApiFp(this.configuration).listFiles(options).then((request) => request(this.axios, this.basePath)); 1971 | } 1972 | /** 1973 | * 1974 | * @summary Get fine-grained status updates for a fine-tune job. 1975 | * @param {string} fineTuneId The ID of the fine-tune job to get events for. 1976 | * @param {boolean} [stream] Whether to stream events for the fine-tune job. If set to true, events will be sent as data-only [server-sent events](https://developer.mozilla.org/en-US/docs/Web/API/Server-sent_events/Using_server-sent_events#Event_stream_format) as they become available. The stream will terminate with a `data: [DONE]` message when the job is finished (succeeded, cancelled, or failed). If set to false, only events generated so far will be returned. 1977 | * @param {*} [options] Override http request option. 1978 | * @throws {RequiredError} 1979 | * @memberof OpenAIApi 1980 | */ 1981 | listFineTuneEvents(fineTuneId, stream, options) { 1982 | return exports.OpenAIApiFp(this.configuration).listFineTuneEvents(fineTuneId, stream, options).then((request) => request(this.axios, this.basePath)); 1983 | } 1984 | /** 1985 | * 1986 | * @summary List your organization\'s fine-tuning jobs 1987 | * @param {*} [options] Override http request option. 1988 | * @throws {RequiredError} 1989 | * @memberof OpenAIApi 1990 | */ 1991 | listFineTunes(options) { 1992 | return exports.OpenAIApiFp(this.configuration).listFineTunes(options).then((request) => request(this.axios, this.basePath)); 1993 | } 1994 | /** 1995 | * 1996 | * @summary Lists the currently available models, and provides basic information about each one such as the owner and availability. 1997 | * @param {*} [options] Override http request option. 1998 | * @throws {RequiredError} 1999 | * @memberof OpenAIApi 2000 | */ 2001 | listModels(options) { 2002 | return exports.OpenAIApiFp(this.configuration).listModels(options).then((request) => request(this.axios, this.basePath)); 2003 | } 2004 | /** 2005 | * 2006 | * @summary Retrieves a model instance, providing basic information about it such as the owner and availability. 2007 | * @param {string} engineId The ID of the engine to use for this request 2008 | * @param {*} [options] Override http request option. 2009 | * @deprecated 2010 | * @throws {RequiredError} 2011 | * @memberof OpenAIApi 2012 | */ 2013 | retrieveEngine(engineId, options) { 2014 | return exports.OpenAIApiFp(this.configuration).retrieveEngine(engineId, options).then((request) => request(this.axios, this.basePath)); 2015 | } 2016 | /** 2017 | * 2018 | * @summary Returns information about a specific file. 2019 | * @param {string} fileId The ID of the file to use for this request 2020 | * @param {*} [options] Override http request option. 2021 | * @throws {RequiredError} 2022 | * @memberof OpenAIApi 2023 | */ 2024 | retrieveFile(fileId, options) { 2025 | return exports.OpenAIApiFp(this.configuration).retrieveFile(fileId, options).then((request) => request(this.axios, this.basePath)); 2026 | } 2027 | /** 2028 | * 2029 | * @summary Gets info about the fine-tune job. [Learn more about Fine-tuning](/docs/guides/fine-tuning) 2030 | * @param {string} fineTuneId The ID of the fine-tune job 2031 | * @param {*} [options] Override http request option. 2032 | * @throws {RequiredError} 2033 | * @memberof OpenAIApi 2034 | */ 2035 | retrieveFineTune(fineTuneId, options) { 2036 | return exports.OpenAIApiFp(this.configuration).retrieveFineTune(fineTuneId, options).then((request) => request(this.axios, this.basePath)); 2037 | } 2038 | /** 2039 | * 2040 | * @summary Retrieves a model instance, providing basic information about the model such as the owner and permissioning. 2041 | * @param {string} model The ID of the model to use for this request 2042 | * @param {*} [options] Override http request option. 2043 | * @throws {RequiredError} 2044 | * @memberof OpenAIApi 2045 | */ 2046 | retrieveModel(model, options) { 2047 | return exports.OpenAIApiFp(this.configuration).retrieveModel(model, options).then((request) => request(this.axios, this.basePath)); 2048 | } 2049 | } 2050 | exports.OpenAIApi = OpenAIApi; 2051 | -------------------------------------------------------------------------------- /dist/base.d.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * OpenAI API 3 | * APIs for sampling from and fine-tuning language models 4 | * 5 | * The version of the OpenAPI document: 1.2.0 6 | * 7 | * 8 | * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). 9 | * https://openapi-generator.tech 10 | * Do not edit the class manually. 11 | */ 12 | import type { Configuration } from './configuration'; 13 | import type { AxiosInstance, AxiosRequestConfig } from 'axios'; 14 | export declare const BASE_PATH: string; 15 | /** 16 | * 17 | * @export 18 | */ 19 | export declare const COLLECTION_FORMATS: { 20 | csv: string; 21 | ssv: string; 22 | tsv: string; 23 | pipes: string; 24 | }; 25 | /** 26 | * 27 | * @export 28 | * @interface RequestArgs 29 | */ 30 | export interface RequestArgs { 31 | url: string; 32 | options: AxiosRequestConfig; 33 | } 34 | /** 35 | * 36 | * @export 37 | * @class BaseAPI 38 | */ 39 | export declare class BaseAPI { 40 | protected basePath: string; 41 | protected axios: AxiosInstance; 42 | protected configuration: Configuration | undefined; 43 | constructor(configuration?: Configuration, basePath?: string, axios?: AxiosInstance); 44 | } 45 | /** 46 | * 47 | * @export 48 | * @class RequiredError 49 | * @extends {Error} 50 | */ 51 | export declare class RequiredError extends Error { 52 | field: string; 53 | constructor(field: string, msg?: string); 54 | } 55 | -------------------------------------------------------------------------------- /dist/base.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | /* tslint:disable */ 3 | /* eslint-disable */ 4 | /** 5 | * OpenAI API 6 | * APIs for sampling from and fine-tuning language models 7 | * 8 | * The version of the OpenAPI document: 1.2.0 9 | * 10 | * 11 | * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). 12 | * https://openapi-generator.tech 13 | * Do not edit the class manually. 14 | */ 15 | Object.defineProperty(exports, "__esModule", { value: true }); 16 | exports.RequiredError = exports.BaseAPI = exports.COLLECTION_FORMATS = exports.BASE_PATH = void 0; 17 | const axios_1 = require("axios"); 18 | exports.BASE_PATH = "https://api.openai.com/v1".replace(/\/+$/, ""); 19 | /** 20 | * 21 | * @export 22 | */ 23 | exports.COLLECTION_FORMATS = { 24 | csv: ",", 25 | ssv: " ", 26 | tsv: "\t", 27 | pipes: "|", 28 | }; 29 | /** 30 | * 31 | * @export 32 | * @class BaseAPI 33 | */ 34 | class BaseAPI { 35 | constructor(configuration, basePath = exports.BASE_PATH, axios = axios_1.default) { 36 | this.basePath = basePath; 37 | this.axios = axios; 38 | if (configuration) { 39 | this.configuration = configuration; 40 | this.basePath = configuration.basePath || this.basePath; 41 | } 42 | } 43 | } 44 | exports.BaseAPI = BaseAPI; 45 | ; 46 | /** 47 | * 48 | * @export 49 | * @class RequiredError 50 | * @extends {Error} 51 | */ 52 | class RequiredError extends Error { 53 | constructor(field, msg) { 54 | super(msg); 55 | this.field = field; 56 | this.name = "RequiredError"; 57 | } 58 | } 59 | exports.RequiredError = RequiredError; 60 | -------------------------------------------------------------------------------- /dist/common.d.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * OpenAI API 3 | * APIs for sampling from and fine-tuning language models 4 | * 5 | * The version of the OpenAPI document: 1.2.0 6 | * 7 | * 8 | * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). 9 | * https://openapi-generator.tech 10 | * Do not edit the class manually. 11 | */ 12 | import type { Configuration } from "./configuration"; 13 | import type { RequestArgs } from "./base"; 14 | import type { AxiosInstance, AxiosResponse } from 'axios'; 15 | import { ChatCompletionRequestMessage } from "./api"; 16 | /** 17 | * 18 | * @export 19 | */ 20 | export declare const DUMMY_BASE_URL = "https://example.com"; 21 | /** 22 | * 23 | * @throws {RequiredError} 24 | * @export 25 | */ 26 | export declare const assertParamExists: (functionName: string, paramName: string, paramValue: unknown) => void; 27 | /** 28 | * 29 | * @export 30 | */ 31 | export declare const setApiKeyToObject: (object: any, keyParamName: string, configuration?: Configuration) => Promise; 32 | /** 33 | * 34 | * @export 35 | */ 36 | export declare const setBasicAuthToObject: (object: any, configuration?: Configuration) => void; 37 | /** 38 | * 39 | * @export 40 | */ 41 | export declare const setBearerAuthToObject: (object: any, configuration?: Configuration) => Promise; 42 | /** 43 | * 44 | * @export 45 | */ 46 | export declare const setOAuthToObject: (object: any, name: string, scopes: string[], configuration?: Configuration) => Promise; 47 | /** 48 | * 49 | * @export 50 | */ 51 | export declare const setSearchParams: (url: URL, ...objects: any[]) => void; 52 | /** 53 | * 54 | * @export 55 | */ 56 | export declare const serializeDataIfNeeded: (value: any, requestOptions: any, configuration?: Configuration) => any; 57 | /** 58 | * 59 | * @export 60 | */ 61 | export declare const toPathString: (url: URL) => string; 62 | /** 63 | * 64 | * @export 65 | */ 66 | export declare const createRequestFunction: (axiosArgs: RequestArgs, globalAxios: AxiosInstance, BASE_PATH: string, configuration?: Configuration) => >(axios?: AxiosInstance, basePath?: string) => Promise; 67 | /** 68 | * 69 | * @export 70 | */ 71 | export declare const createPrompt: (systemMessage: string, messages: { 72 | sender: string; 73 | text: string; 74 | }[]) => string; 75 | export declare const messageToAzurePrompt: (messages: Array) => string; 76 | -------------------------------------------------------------------------------- /dist/common.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | /* tslint:disable */ 3 | /* eslint-disable */ 4 | /** 5 | * OpenAI API 6 | * APIs for sampling from and fine-tuning language models 7 | * 8 | * The version of the OpenAPI document: 1.2.0 9 | * 10 | * 11 | * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). 12 | * https://openapi-generator.tech 13 | * Do not edit the class manually. 14 | */ 15 | var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { 16 | function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } 17 | return new (P || (P = Promise))(function (resolve, reject) { 18 | function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } 19 | function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } 20 | function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } 21 | step((generator = generator.apply(thisArg, _arguments || [])).next()); 22 | }); 23 | }; 24 | Object.defineProperty(exports, "__esModule", { value: true }); 25 | exports.messageToAzurePrompt = exports.createPrompt = exports.createRequestFunction = exports.toPathString = exports.serializeDataIfNeeded = exports.setSearchParams = exports.setOAuthToObject = exports.setBearerAuthToObject = exports.setBasicAuthToObject = exports.setApiKeyToObject = exports.assertParamExists = exports.DUMMY_BASE_URL = void 0; 26 | const base_1 = require("./base"); 27 | /** 28 | * 29 | * @export 30 | */ 31 | exports.DUMMY_BASE_URL = 'https://example.com'; 32 | /** 33 | * 34 | * @throws {RequiredError} 35 | * @export 36 | */ 37 | exports.assertParamExists = function (functionName, paramName, paramValue) { 38 | if (paramValue === null || paramValue === undefined) { 39 | throw new base_1.RequiredError(paramName, `Required parameter ${paramName} was null or undefined when calling ${functionName}.`); 40 | } 41 | }; 42 | /** 43 | * 44 | * @export 45 | */ 46 | exports.setApiKeyToObject = function (object, keyParamName, configuration) { 47 | return __awaiter(this, void 0, void 0, function* () { 48 | if (configuration && configuration.apiKey) { 49 | const localVarApiKeyValue = typeof configuration.apiKey === 'function' 50 | ? yield configuration.apiKey(keyParamName) 51 | : yield configuration.apiKey; 52 | object[keyParamName] = localVarApiKeyValue; 53 | } 54 | }); 55 | }; 56 | /** 57 | * 58 | * @export 59 | */ 60 | exports.setBasicAuthToObject = function (object, configuration) { 61 | if (configuration && (configuration.username || configuration.password)) { 62 | object["auth"] = { username: configuration.username, password: configuration.password }; 63 | } 64 | }; 65 | /** 66 | * 67 | * @export 68 | */ 69 | exports.setBearerAuthToObject = function (object, configuration) { 70 | return __awaiter(this, void 0, void 0, function* () { 71 | if (configuration && configuration.accessToken) { 72 | const accessToken = typeof configuration.accessToken === 'function' 73 | ? yield configuration.accessToken() 74 | : yield configuration.accessToken; 75 | object["Authorization"] = "Bearer " + accessToken; 76 | } 77 | }); 78 | }; 79 | /** 80 | * 81 | * @export 82 | */ 83 | exports.setOAuthToObject = function (object, name, scopes, configuration) { 84 | return __awaiter(this, void 0, void 0, function* () { 85 | if (configuration && configuration.accessToken) { 86 | const localVarAccessTokenValue = typeof configuration.accessToken === 'function' 87 | ? yield configuration.accessToken(name, scopes) 88 | : yield configuration.accessToken; 89 | object["Authorization"] = "Bearer " + localVarAccessTokenValue; 90 | } 91 | }); 92 | }; 93 | function setFlattenedQueryParams(urlSearchParams, parameter, key = "") { 94 | if (parameter == null) 95 | return; 96 | if (typeof parameter === "object") { 97 | if (Array.isArray(parameter)) { 98 | parameter.forEach(item => setFlattenedQueryParams(urlSearchParams, item, key)); 99 | } 100 | else { 101 | Object.keys(parameter).forEach(currentKey => setFlattenedQueryParams(urlSearchParams, parameter[currentKey], `${key}${key !== '' ? '.' : ''}${currentKey}`)); 102 | } 103 | } 104 | else { 105 | if (urlSearchParams.has(key)) { 106 | urlSearchParams.append(key, parameter); 107 | } 108 | else { 109 | urlSearchParams.set(key, parameter); 110 | } 111 | } 112 | } 113 | /** 114 | * 115 | * @export 116 | */ 117 | exports.setSearchParams = function (url, ...objects) { 118 | const searchParams = new URLSearchParams(url.search); 119 | setFlattenedQueryParams(searchParams, objects); 120 | url.search = searchParams.toString(); 121 | }; 122 | /** 123 | * 124 | * @export 125 | */ 126 | exports.serializeDataIfNeeded = function (value, requestOptions, configuration) { 127 | const nonString = typeof value !== 'string'; 128 | const needsSerialization = nonString && configuration && configuration.isJsonMime 129 | ? configuration.isJsonMime(requestOptions.headers['Content-Type']) 130 | : nonString; 131 | return needsSerialization 132 | ? JSON.stringify(value !== undefined ? value : {}) 133 | : (value || ""); 134 | }; 135 | /** 136 | * 137 | * @export 138 | */ 139 | exports.toPathString = function (url) { 140 | return url.pathname + url.search + url.hash; 141 | }; 142 | /** 143 | * 144 | * @export 145 | */ 146 | exports.createRequestFunction = function (axiosArgs, globalAxios, BASE_PATH, configuration) { 147 | return (axios = globalAxios, basePath = BASE_PATH) => { 148 | const axiosRequestArgs = Object.assign(Object.assign({}, axiosArgs.options), { url: ((configuration === null || configuration === void 0 ? void 0 : configuration.basePath) || basePath) + axiosArgs.url }); 149 | return axios.request(axiosRequestArgs); 150 | }; 151 | }; 152 | /** 153 | * 154 | * @export 155 | */ 156 | exports.createPrompt = function (systemMessage, messages) { 157 | let prompt = systemMessage; 158 | for (const message of messages) { 159 | prompt += `\n<|im_start|>${message.sender}\n${message.text}\n<|im_end|>`; 160 | } 161 | prompt += "\n<|im_start|>assistant\n"; 162 | return prompt; 163 | }; 164 | exports.messageToAzurePrompt = function (messages) { 165 | let systemMessage = ''; 166 | let conversationMessage = []; 167 | for (const message of messages) { 168 | systemMessage = message.role === "system" ? `<|im_start|>system\n{'${message.content}'}\n<|im_end|>` : ''; 169 | conversationMessage.push({ 170 | sender: message.role, 171 | text: message.content, 172 | }); 173 | } 174 | return exports.createPrompt(systemMessage, conversationMessage); 175 | }; 176 | -------------------------------------------------------------------------------- /dist/configuration.d.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * OpenAI API 3 | * APIs for sampling from and fine-tuning language models 4 | * 5 | * The version of the OpenAPI document: 1.2.0 6 | * 7 | * 8 | * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). 9 | * https://openapi-generator.tech 10 | * Do not edit the class manually. 11 | */ 12 | export interface AzureConfigurationParameters { 13 | apiKey?: string | Promise | ((name: string) => string) | ((name: string) => Promise); 14 | endpoint?: string; 15 | deploymentName?: string; 16 | } 17 | export interface ConfigurationParameters { 18 | apiKey?: string | Promise | ((name: string) => string) | ((name: string) => Promise); 19 | organization?: string; 20 | username?: string; 21 | password?: string; 22 | accessToken?: string | Promise | ((name?: string, scopes?: string[]) => string) | ((name?: string, scopes?: string[]) => Promise); 23 | basePath?: string; 24 | baseOptions?: any; 25 | formDataCtor?: new () => any; 26 | azure?: AzureConfigurationParameters; 27 | } 28 | export declare class Configuration { 29 | /** 30 | * parameter for apiKey security 31 | * @param name security name 32 | * @memberof Configuration 33 | */ 34 | apiKey?: string | Promise | ((name: string) => string) | ((name: string) => Promise); 35 | /** 36 | * OpenAI organization id 37 | * 38 | * @type {string} 39 | * @memberof Configuration 40 | */ 41 | organization?: string; 42 | /** 43 | * parameter for basic security 44 | * 45 | * @type {string} 46 | * @memberof Configuration 47 | */ 48 | username?: string; 49 | /** 50 | * parameter for basic security 51 | * 52 | * @type {string} 53 | * @memberof Configuration 54 | */ 55 | password?: string; 56 | /** 57 | * parameter for oauth2 security 58 | * @param name security name 59 | * @param scopes oauth2 scope 60 | * @memberof Configuration 61 | */ 62 | accessToken?: string | Promise | ((name?: string, scopes?: string[]) => string) | ((name?: string, scopes?: string[]) => Promise); 63 | /** 64 | * override base path 65 | * 66 | * @type {string} 67 | * @memberof Configuration 68 | */ 69 | basePath?: string; 70 | /** 71 | * base options for axios calls 72 | * 73 | * @type {any} 74 | * @memberof Configuration 75 | */ 76 | baseOptions?: any; 77 | /** 78 | * The FormData constructor that will be used to create multipart form data 79 | * requests. You can inject this here so that execution environments that 80 | * do not support the FormData class can still run the generated client. 81 | * 82 | * @type {new () => FormData} 83 | */ 84 | formDataCtor?: new () => any; 85 | /** 86 | * @memberof Configuration 87 | */ 88 | azure?: AzureConfigurationParameters; 89 | constructor(param?: ConfigurationParameters); 90 | /** 91 | * Check if the given MIME is a JSON MIME. 92 | * JSON MIME examples: 93 | * application/json 94 | * application/json; charset=UTF8 95 | * APPLICATION/JSON 96 | * application/vnd.company+json 97 | * @param mime - MIME (Multipurpose Internet Mail Extensions) 98 | * @return True if the given MIME is JSON, false otherwise. 99 | */ 100 | isJsonMime(mime: string): boolean; 101 | } 102 | -------------------------------------------------------------------------------- /dist/configuration.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | /* tslint:disable */ 3 | /* eslint-disable */ 4 | /** 5 | * OpenAI API 6 | * APIs for sampling from and fine-tuning language models 7 | * 8 | * The version of the OpenAPI document: 1.2.0 9 | * 10 | * 11 | * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). 12 | * https://openapi-generator.tech 13 | * Do not edit the class manually. 14 | */ 15 | Object.defineProperty(exports, "__esModule", { value: true }); 16 | exports.Configuration = void 0; 17 | const packageJson = require("../package.json"); 18 | class Configuration { 19 | constructor(param = {}) { 20 | this.apiKey = param.apiKey; 21 | this.organization = param.organization; 22 | this.username = param.username; 23 | this.password = param.password; 24 | this.accessToken = param.accessToken; 25 | this.basePath = param.basePath; 26 | this.baseOptions = param.baseOptions; 27 | this.formDataCtor = param.formDataCtor; 28 | this.azure = param.azure; 29 | if (!this.baseOptions) { 30 | this.baseOptions = {}; 31 | } 32 | this.baseOptions.headers = Object.assign({ 'User-Agent': `AzureOpenAI/NodeJS/${packageJson.version}`, 'Authorization': `Bearer ${this.apiKey}` }, this.baseOptions.headers); 33 | if (this.organization) { 34 | this.baseOptions.headers['OpenAI-Organization'] = this.organization; 35 | } 36 | if (!this.formDataCtor) { 37 | this.formDataCtor = require("form-data"); 38 | } 39 | if (this.azure) { 40 | if (!this.azure.apiKey || !this.azure.endpoint) { 41 | throw new Error("Azure Configuration requires apiKey, endpoint"); 42 | } 43 | this.apiKey = this.azure.apiKey; 44 | this.baseOptions.headers['api-key'] = this.azure.apiKey; 45 | this.baseOptions.headers['Authorization'] = ''; 46 | this.basePath = this.azure.endpoint; 47 | } 48 | } 49 | /** 50 | * Check if the given MIME is a JSON MIME. 51 | * JSON MIME examples: 52 | * application/json 53 | * application/json; charset=UTF8 54 | * APPLICATION/JSON 55 | * application/vnd.company+json 56 | * @param mime - MIME (Multipurpose Internet Mail Extensions) 57 | * @return True if the given MIME is JSON, false otherwise. 58 | */ 59 | isJsonMime(mime) { 60 | const jsonMime = new RegExp('^(application\/json|[^;/ \t]+\/[^;/ \t]+[+]json)[ \t]*(;.*)?$', 'i'); 61 | return mime !== null && (jsonMime.test(mime) || mime.toLowerCase() === 'application/json-patch+json'); 62 | } 63 | } 64 | exports.Configuration = Configuration; 65 | -------------------------------------------------------------------------------- /dist/index.d.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * OpenAI API 3 | * APIs for sampling from and fine-tuning language models 4 | * 5 | * The version of the OpenAPI document: 1.2.0 6 | * 7 | * 8 | * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). 9 | * https://openapi-generator.tech 10 | * Do not edit the class manually. 11 | */ 12 | export * from "./api"; 13 | export * from "./configuration"; 14 | -------------------------------------------------------------------------------- /dist/index.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | /* tslint:disable */ 3 | /* eslint-disable */ 4 | /** 5 | * OpenAI API 6 | * APIs for sampling from and fine-tuning language models 7 | * 8 | * The version of the OpenAPI document: 1.2.0 9 | * 10 | * 11 | * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). 12 | * https://openapi-generator.tech 13 | * Do not edit the class manually. 14 | */ 15 | var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { 16 | if (k2 === undefined) k2 = k; 17 | Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); 18 | }) : (function(o, m, k, k2) { 19 | if (k2 === undefined) k2 = k; 20 | o[k2] = m[k]; 21 | })); 22 | var __exportStar = (this && this.__exportStar) || function(m, exports) { 23 | for (var p in m) if (p !== "default" && !exports.hasOwnProperty(p)) __createBinding(exports, m, p); 24 | }; 25 | Object.defineProperty(exports, "__esModule", { value: true }); 26 | __exportStar(require("./api"), exports); 27 | __exportStar(require("./configuration"), exports); 28 | -------------------------------------------------------------------------------- /index.ts: -------------------------------------------------------------------------------- 1 | /* tslint:disable */ 2 | /* eslint-disable */ 3 | /** 4 | * OpenAI API 5 | * APIs for sampling from and fine-tuning language models 6 | * 7 | * The version of the OpenAPI document: 1.2.0 8 | * 9 | * 10 | * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). 11 | * https://openapi-generator.tech 12 | * Do not edit the class manually. 13 | */ 14 | 15 | 16 | export * from "./api"; 17 | export * from "./configuration"; 18 | 19 | -------------------------------------------------------------------------------- /package-lock.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "openai", 3 | "version": "3.2.1", 4 | "lockfileVersion": 2, 5 | "requires": true, 6 | "packages": { 7 | "": { 8 | "name": "openai", 9 | "version": "3.2.1", 10 | "license": "MIT", 11 | "dependencies": { 12 | "axios": "^0.26.0", 13 | "form-data": "^4.0.0" 14 | }, 15 | "devDependencies": { 16 | "@types/node": "^12.11.5", 17 | "typescript": "^3.6.4" 18 | } 19 | }, 20 | "node_modules/@types/node": { 21 | "version": "12.20.37", 22 | "resolved": "https://registry.npmjs.org/@types/node/-/node-12.20.37.tgz", 23 | "integrity": "sha512-i1KGxqcvJaLQali+WuypQnXwcplhtNtjs66eNsZpp2P2FL/trJJxx/VWsM0YCL2iMoIJrbXje48lvIQAQ4p2ZA==", 24 | "dev": true 25 | }, 26 | "node_modules/asynckit": { 27 | "version": "0.4.0", 28 | "resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz", 29 | "integrity": "sha1-x57Zf380y48robyXkLzDZkdLS3k=" 30 | }, 31 | "node_modules/axios": { 32 | "version": "0.26.0", 33 | "resolved": "https://registry.npmjs.org/axios/-/axios-0.26.0.tgz", 34 | "integrity": "sha512-lKoGLMYtHvFrPVt3r+RBMp9nh34N0M8zEfCWqdWZx6phynIEhQqAdydpyBAAG211zlhX9Rgu08cOamy6XjE5Og==", 35 | "dependencies": { 36 | "follow-redirects": "^1.14.8" 37 | } 38 | }, 39 | "node_modules/combined-stream": { 40 | "version": "1.0.8", 41 | "resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.8.tgz", 42 | "integrity": "sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg==", 43 | "dependencies": { 44 | "delayed-stream": "~1.0.0" 45 | }, 46 | "engines": { 47 | "node": ">= 0.8" 48 | } 49 | }, 50 | "node_modules/delayed-stream": { 51 | "version": "1.0.0", 52 | "resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz", 53 | "integrity": "sha1-3zrhmayt+31ECqrgsp4icrJOxhk=", 54 | "engines": { 55 | "node": ">=0.4.0" 56 | } 57 | }, 58 | "node_modules/follow-redirects": { 59 | "version": "1.14.8", 60 | "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.14.8.tgz", 61 | "integrity": "sha512-1x0S9UVJHsQprFcEC/qnNzBLcIxsjAV905f/UkQxbclCsoTWlacCNOpQa/anodLl2uaEKFhfWOvM2Qg77+15zA==", 62 | "funding": [ 63 | { 64 | "type": "individual", 65 | "url": "https://github.com/sponsors/RubenVerborgh" 66 | } 67 | ], 68 | "engines": { 69 | "node": ">=4.0" 70 | }, 71 | "peerDependenciesMeta": { 72 | "debug": { 73 | "optional": true 74 | } 75 | } 76 | }, 77 | "node_modules/form-data": { 78 | "version": "4.0.0", 79 | "resolved": "https://registry.npmjs.org/form-data/-/form-data-4.0.0.tgz", 80 | "integrity": "sha512-ETEklSGi5t0QMZuiXoA/Q6vcnxcLQP5vdugSpuAyi6SVGi2clPPp+xgEhuMaHC+zGgn31Kd235W35f7Hykkaww==", 81 | "dependencies": { 82 | "asynckit": "^0.4.0", 83 | "combined-stream": "^1.0.8", 84 | "mime-types": "^2.1.12" 85 | }, 86 | "engines": { 87 | "node": ">= 6" 88 | } 89 | }, 90 | "node_modules/mime-db": { 91 | "version": "1.51.0", 92 | "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.51.0.tgz", 93 | "integrity": "sha512-5y8A56jg7XVQx2mbv1lu49NR4dokRnhZYTtL+KGfaa27uq4pSTXkwQkFJl4pkRMyNFz/EtYDSkiiEHx3F7UN6g==", 94 | "engines": { 95 | "node": ">= 0.6" 96 | } 97 | }, 98 | "node_modules/mime-types": { 99 | "version": "2.1.34", 100 | "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.34.tgz", 101 | "integrity": "sha512-6cP692WwGIs9XXdOO4++N+7qjqv0rqxxVvJ3VHPh/Sc9mVZcQP+ZGhkKiTvWMQRr2tbHkJP/Yn7Y0npb3ZBs4A==", 102 | "dependencies": { 103 | "mime-db": "1.51.0" 104 | }, 105 | "engines": { 106 | "node": ">= 0.6" 107 | } 108 | }, 109 | "node_modules/typescript": { 110 | "version": "3.9.10", 111 | "resolved": "https://registry.npmjs.org/typescript/-/typescript-3.9.10.tgz", 112 | "integrity": "sha512-w6fIxVE/H1PkLKcCPsFqKE7Kv7QUwhU8qQY2MueZXWx5cPZdwFupLgKK3vntcK98BtNHZtAF4LA/yl2a7k8R6Q==", 113 | "dev": true, 114 | "bin": { 115 | "tsc": "bin/tsc", 116 | "tsserver": "bin/tsserver" 117 | }, 118 | "engines": { 119 | "node": ">=4.2.0" 120 | } 121 | } 122 | }, 123 | "dependencies": { 124 | "@types/node": { 125 | "version": "12.20.37", 126 | "resolved": "https://registry.npmjs.org/@types/node/-/node-12.20.37.tgz", 127 | "integrity": "sha512-i1KGxqcvJaLQali+WuypQnXwcplhtNtjs66eNsZpp2P2FL/trJJxx/VWsM0YCL2iMoIJrbXje48lvIQAQ4p2ZA==", 128 | "dev": true 129 | }, 130 | "asynckit": { 131 | "version": "0.4.0", 132 | "resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz", 133 | "integrity": "sha1-x57Zf380y48robyXkLzDZkdLS3k=" 134 | }, 135 | "axios": { 136 | "version": "0.26.0", 137 | "resolved": "https://registry.npmjs.org/axios/-/axios-0.26.0.tgz", 138 | "integrity": "sha512-lKoGLMYtHvFrPVt3r+RBMp9nh34N0M8zEfCWqdWZx6phynIEhQqAdydpyBAAG211zlhX9Rgu08cOamy6XjE5Og==", 139 | "requires": { 140 | "follow-redirects": "^1.14.8" 141 | } 142 | }, 143 | "combined-stream": { 144 | "version": "1.0.8", 145 | "resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.8.tgz", 146 | "integrity": "sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg==", 147 | "requires": { 148 | "delayed-stream": "~1.0.0" 149 | } 150 | }, 151 | "delayed-stream": { 152 | "version": "1.0.0", 153 | "resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz", 154 | "integrity": "sha1-3zrhmayt+31ECqrgsp4icrJOxhk=" 155 | }, 156 | "follow-redirects": { 157 | "version": "1.14.8", 158 | "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.14.8.tgz", 159 | "integrity": "sha512-1x0S9UVJHsQprFcEC/qnNzBLcIxsjAV905f/UkQxbclCsoTWlacCNOpQa/anodLl2uaEKFhfWOvM2Qg77+15zA==" 160 | }, 161 | "form-data": { 162 | "version": "4.0.0", 163 | "resolved": "https://registry.npmjs.org/form-data/-/form-data-4.0.0.tgz", 164 | "integrity": "sha512-ETEklSGi5t0QMZuiXoA/Q6vcnxcLQP5vdugSpuAyi6SVGi2clPPp+xgEhuMaHC+zGgn31Kd235W35f7Hykkaww==", 165 | "requires": { 166 | "asynckit": "^0.4.0", 167 | "combined-stream": "^1.0.8", 168 | "mime-types": "^2.1.12" 169 | } 170 | }, 171 | "mime-db": { 172 | "version": "1.51.0", 173 | "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.51.0.tgz", 174 | "integrity": "sha512-5y8A56jg7XVQx2mbv1lu49NR4dokRnhZYTtL+KGfaa27uq4pSTXkwQkFJl4pkRMyNFz/EtYDSkiiEHx3F7UN6g==" 175 | }, 176 | "mime-types": { 177 | "version": "2.1.34", 178 | "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.34.tgz", 179 | "integrity": "sha512-6cP692WwGIs9XXdOO4++N+7qjqv0rqxxVvJ3VHPh/Sc9mVZcQP+ZGhkKiTvWMQRr2tbHkJP/Yn7Y0npb3ZBs4A==", 180 | "requires": { 181 | "mime-db": "1.51.0" 182 | } 183 | }, 184 | "typescript": { 185 | "version": "3.9.10", 186 | "resolved": "https://registry.npmjs.org/typescript/-/typescript-3.9.10.tgz", 187 | "integrity": "sha512-w6fIxVE/H1PkLKcCPsFqKE7Kv7QUwhU8qQY2MueZXWx5cPZdwFupLgKK3vntcK98BtNHZtAF4LA/yl2a7k8R6Q==", 188 | "dev": true 189 | } 190 | } 191 | } 192 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "azure-openai", 3 | "version": "0.9.4", 4 | "description": "Node.js library for the Azure OpenAI API", 5 | "repository": { 6 | "type": "git", 7 | "url": "git@github.com:1openwindow/azure-openai-node" 8 | }, 9 | "keywords": [ 10 | "azure-openai", 11 | "openai", 12 | "open", 13 | "ai", 14 | "gpt-3", 15 | "gpt3" 16 | ], 17 | "author": "Zihong", 18 | "license": "MIT", 19 | "main": "./dist/index.js", 20 | "types": "./dist/index.d.ts", 21 | "scripts": { 22 | "build": "tsc --outDir dist/" 23 | }, 24 | "dependencies": { 25 | "axios": "^0.26.0", 26 | "form-data": "^4.0.0" 27 | }, 28 | "devDependencies": { 29 | "@types/node": "^12.11.5", 30 | "typescript": "^3.6.4" 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "declaration": true, 4 | "target": "es6", 5 | "module": "commonjs", 6 | "noImplicitAny": true, 7 | "outDir": "dist", 8 | "rootDir": ".", 9 | "typeRoots": [ 10 | "node_modules/@types" 11 | ] 12 | }, 13 | "exclude": [ 14 | "dist", 15 | "node_modules" 16 | ] 17 | } 18 | --------------------------------------------------------------------------------