diff --git a/examples/openapi-ts-openai/.gitignore b/examples/openapi-ts-openai/.gitignore
new file mode 100644
index 000000000..a547bf36d
--- /dev/null
+++ b/examples/openapi-ts-openai/.gitignore
@@ -0,0 +1,24 @@
+# Logs
+logs
+*.log
+npm-debug.log*
+yarn-debug.log*
+yarn-error.log*
+pnpm-debug.log*
+lerna-debug.log*
+
+node_modules
+dist
+dist-ssr
+*.local
+
+# Editor directories and files
+.vscode/*
+!.vscode/extensions.json
+.idea
+.DS_Store
+*.suo
+*.ntvs*
+*.njsproj
+*.sln
+*.sw?
diff --git a/examples/openapi-ts-openai/index.html b/examples/openapi-ts-openai/index.html
new file mode 100644
index 000000000..86f7792b9
--- /dev/null
+++ b/examples/openapi-ts-openai/index.html
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+ Hey API + OpenAI Demo
+
+
+
+
+
+
diff --git a/examples/openapi-ts-openai/openapi-ts.config.ts b/examples/openapi-ts-openai/openapi-ts.config.ts
new file mode 100644
index 000000000..09508faee
--- /dev/null
+++ b/examples/openapi-ts-openai/openapi-ts.config.ts
@@ -0,0 +1,31 @@
+import path from 'node:path';
+
+import { defineConfig } from '@hey-api/openapi-ts';
+
+export default defineConfig({
+ input: path.resolve(
+ '..',
+ '..',
+ 'packages',
+ 'openapi-ts-tests',
+ 'specs',
+ '3.1.x',
+ 'openai.yaml',
+ ),
+ output: {
+ format: 'prettier',
+ lint: 'eslint',
+ path: './src/client',
+ },
+ plugins: [
+ '@hey-api/client-fetch',
+ {
+ enums: 'javascript',
+ name: '@hey-api/typescript',
+ },
+ {
+ instance: 'OpenAI',
+ name: '@hey-api/sdk',
+ },
+ ],
+});
diff --git a/examples/openapi-ts-openai/package.json b/examples/openapi-ts-openai/package.json
new file mode 100644
index 000000000..f50b95e8f
--- /dev/null
+++ b/examples/openapi-ts-openai/package.json
@@ -0,0 +1,40 @@
+{
+ "name": "@example/openapi-ts-openai",
+ "private": true,
+ "version": "0.0.0",
+ "type": "module",
+ "scripts": {
+ "build": "tsc && vite build",
+ "dev": "vite",
+ "lint": "eslint . --ext ts,tsx --report-unused-disable-directives --max-warnings 0",
+ "openapi-ts": "openapi-ts",
+ "preview": "vite preview",
+ "typecheck": "tsc --noEmit"
+ },
+ "dependencies": {
+ "@radix-ui/react-form": "0.1.1",
+ "@radix-ui/react-icons": "1.3.2",
+ "@radix-ui/themes": "3.1.6",
+ "openai": "5.13.1",
+ "react": "19.0.0",
+ "react-dom": "19.0.0"
+ },
+ "devDependencies": {
+ "@config/vite-base": "workspace:*",
+ "@hey-api/openapi-ts": "workspace:*",
+ "@types/react": "19.0.1",
+ "@types/react-dom": "19.0.1",
+ "@typescript-eslint/eslint-plugin": "8.29.1",
+ "@typescript-eslint/parser": "8.29.1",
+ "@vitejs/plugin-react": "4.4.0-beta.1",
+ "autoprefixer": "10.4.19",
+ "eslint": "9.17.0",
+ "eslint-plugin-react-hooks": "5.2.0",
+ "eslint-plugin-react-refresh": "0.4.7",
+ "postcss": "8.4.41",
+ "prettier": "3.4.2",
+ "tailwindcss": "3.4.9",
+ "typescript": "5.8.3",
+ "vite": "7.1.2"
+ }
+}
diff --git a/examples/openapi-ts-openai/postcss.config.js b/examples/openapi-ts-openai/postcss.config.js
new file mode 100644
index 000000000..9eef821c4
--- /dev/null
+++ b/examples/openapi-ts-openai/postcss.config.js
@@ -0,0 +1,6 @@
+export default {
+ plugins: {
+ autoprefixer: {},
+ tailwindcss: {},
+ },
+};
diff --git a/examples/openapi-ts-openai/src/App.css b/examples/openapi-ts-openai/src/App.css
new file mode 100644
index 000000000..b5c61c956
--- /dev/null
+++ b/examples/openapi-ts-openai/src/App.css
@@ -0,0 +1,3 @@
+@tailwind base;
+@tailwind components;
+@tailwind utilities;
diff --git a/examples/openapi-ts-openai/src/App.tsx b/examples/openapi-ts-openai/src/App.tsx
new file mode 100644
index 000000000..a24a7fb48
--- /dev/null
+++ b/examples/openapi-ts-openai/src/App.tsx
@@ -0,0 +1,127 @@
+import './App.css';
+
+import * as Form from '@radix-ui/react-form';
+import { PlusIcon } from '@radix-ui/react-icons';
+import {
+ Box,
+ Button,
+ Container,
+ Flex,
+ Heading,
+ Section,
+ TextField,
+} from '@radix-ui/themes';
+import OpenAI from 'openai';
+import { useState } from 'react';
+
+import { client as baseClient } from './client/client.gen';
+import { OpenAi } from './client/sdk.gen';
+
+const sdk = new OpenAI({
+ apiKey: import.meta.env.VITE_OPENAI_API_KEY,
+ dangerouslyAllowBrowser: true,
+});
+
+baseClient.setConfig({
+ auth() {
+ return import.meta.env.VITE_OPENAI_API_KEY;
+ },
+});
+
+const client = new OpenAi({
+ client: baseClient,
+});
+
+function App() {
+ const [isRequiredNameError] = useState(false);
+
+ const onCreateResponse = async (values: FormData) => {
+ const response = await sdk.responses.create({
+ input: values.get('input') as string,
+ model: 'gpt-5-nano',
+ });
+
+ console.log(response.output_text);
+ const { data, error } = await client.createResponse({
+ body: {
+ input: values.get('input') as string,
+ model: 'gpt-5-nano',
+ },
+ });
+ if (error) {
+ console.log(error);
+ return;
+ }
+ console.log(data?.output);
+ };
+
+ return (
+
+
+
+
+
+
+
+ @hey-api/openapi-ts 🤝 OpenAI
+
+
+
+ {
+ event.preventDefault();
+ onCreateResponse(new FormData(event.currentTarget));
+ }}
+ >
+
+
+
+ Input
+
+ {isRequiredNameError && (
+
+ Please enter a name
+
+ )}
+
+ Please enter an input
+
+
+
+
+
+
+
+
+
+
+ {/* */}
+
+
+
+
+
+
+ );
+}
+
+export default App;
diff --git a/examples/openapi-ts-openai/src/client/client.gen.ts b/examples/openapi-ts-openai/src/client/client.gen.ts
new file mode 100644
index 000000000..ed96ef557
--- /dev/null
+++ b/examples/openapi-ts-openai/src/client/client.gen.ts
@@ -0,0 +1,28 @@
+// This file is auto-generated by @hey-api/openapi-ts
+
+import {
+ type ClientOptions as DefaultClientOptions,
+ type Config,
+ createClient,
+ createConfig,
+} from './client';
+import type { ClientOptions } from './types.gen';
+
+/**
+ * The `createClientConfig()` function will be called on client initialization
+ * and the returned object will become the client's initial configuration.
+ *
+ * You may want to initialize your client this way instead of calling
+ * `setConfig()`. This is useful for example if you're using Next.js
+ * to ensure your client always has the correct values.
+ */
+export type CreateClientConfig =
+ (
+ override?: Config,
+ ) => Config & T>;
+
+export const client = createClient(
+ createConfig({
+ baseUrl: 'https://api.openai.com/v1',
+ }),
+);
diff --git a/examples/openapi-ts-openai/src/client/client/client.gen.ts b/examples/openapi-ts-openai/src/client/client/client.gen.ts
new file mode 100644
index 000000000..0c606b81c
--- /dev/null
+++ b/examples/openapi-ts-openai/src/client/client/client.gen.ts
@@ -0,0 +1,199 @@
+// This file is auto-generated by @hey-api/openapi-ts
+
+import type { Client, Config, ResolvedRequestOptions } from './types.gen';
+import {
+ buildUrl,
+ createConfig,
+ createInterceptors,
+ getParseAs,
+ mergeConfigs,
+ mergeHeaders,
+ setAuthParams,
+} from './utils.gen';
+
+type ReqInit = Omit & {
+ body?: any;
+ headers: ReturnType;
+};
+
+export const createClient = (config: Config = {}): Client => {
+ let _config = mergeConfigs(createConfig(), config);
+
+ const getConfig = (): Config => ({ ..._config });
+
+ const setConfig = (config: Config): Config => {
+ _config = mergeConfigs(_config, config);
+ return getConfig();
+ };
+
+ const interceptors = createInterceptors<
+ Request,
+ Response,
+ unknown,
+ ResolvedRequestOptions
+ >();
+
+ const request: Client['request'] = async (options) => {
+ const opts = {
+ ..._config,
+ ...options,
+ fetch: options.fetch ?? _config.fetch ?? globalThis.fetch,
+ headers: mergeHeaders(_config.headers, options.headers),
+ serializedBody: undefined,
+ };
+
+ if (opts.security) {
+ await setAuthParams({
+ ...opts,
+ security: opts.security,
+ });
+ }
+
+ if (opts.requestValidator) {
+ await opts.requestValidator(opts);
+ }
+
+ if (opts.body && opts.bodySerializer) {
+ opts.serializedBody = opts.bodySerializer(opts.body);
+ }
+
+ // remove Content-Type header if body is empty to avoid sending invalid requests
+ if (opts.serializedBody === undefined || opts.serializedBody === '') {
+ opts.headers.delete('Content-Type');
+ }
+
+ const url = buildUrl(opts);
+ const requestInit: ReqInit = {
+ redirect: 'follow',
+ ...opts,
+ body: opts.serializedBody,
+ };
+
+ let request = new Request(url, requestInit);
+
+ for (const fn of interceptors.request._fns) {
+ if (fn) {
+ request = await fn(request, opts);
+ }
+ }
+
+ // fetch must be assigned here, otherwise it would throw the error:
+ // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation
+ const _fetch = opts.fetch!;
+ let response = await _fetch(request);
+
+ for (const fn of interceptors.response._fns) {
+ if (fn) {
+ response = await fn(response, request, opts);
+ }
+ }
+
+ const result = {
+ request,
+ response,
+ };
+
+ if (response.ok) {
+ if (
+ response.status === 204 ||
+ response.headers.get('Content-Length') === '0'
+ ) {
+ return opts.responseStyle === 'data'
+ ? {}
+ : {
+ data: {},
+ ...result,
+ };
+ }
+
+ const parseAs =
+ (opts.parseAs === 'auto'
+ ? getParseAs(response.headers.get('Content-Type'))
+ : opts.parseAs) ?? 'json';
+
+ let data: any;
+ switch (parseAs) {
+ case 'arrayBuffer':
+ case 'blob':
+ case 'formData':
+ case 'json':
+ case 'text':
+ data = await response[parseAs]();
+ break;
+ case 'stream':
+ return opts.responseStyle === 'data'
+ ? response.body
+ : {
+ data: response.body,
+ ...result,
+ };
+ }
+
+ if (parseAs === 'json') {
+ if (opts.responseValidator) {
+ await opts.responseValidator(data);
+ }
+
+ if (opts.responseTransformer) {
+ data = await opts.responseTransformer(data);
+ }
+ }
+
+ return opts.responseStyle === 'data'
+ ? data
+ : {
+ data,
+ ...result,
+ };
+ }
+
+ const textError = await response.text();
+ let jsonError: unknown;
+
+ try {
+ jsonError = JSON.parse(textError);
+ } catch {
+ // noop
+ }
+
+ const error = jsonError ?? textError;
+ let finalError = error;
+
+ for (const fn of interceptors.error._fns) {
+ if (fn) {
+ finalError = (await fn(error, response, request, opts)) as string;
+ }
+ }
+
+ finalError = finalError || ({} as string);
+
+ if (opts.throwOnError) {
+ throw finalError;
+ }
+
+ // TODO: we probably want to return error and improve types
+ return opts.responseStyle === 'data'
+ ? undefined
+ : {
+ error: finalError,
+ ...result,
+ };
+ };
+
+ return {
+ buildUrl,
+ connect: (options) => request({ ...options, method: 'CONNECT' }),
+ delete: (options) => request({ ...options, method: 'DELETE' }),
+ get: (options) => request({ ...options, method: 'GET' }),
+ getConfig,
+ head: (options) => request({ ...options, method: 'HEAD' }),
+ interceptors,
+ options: (options) => request({ ...options, method: 'OPTIONS' }),
+ patch: (options) => request({ ...options, method: 'PATCH' }),
+ post: (options) => request({ ...options, method: 'POST' }),
+ put: (options) => request({ ...options, method: 'PUT' }),
+ request,
+ setConfig,
+ trace: (options) => request({ ...options, method: 'TRACE' }),
+ };
+};
diff --git a/examples/openapi-ts-openai/src/client/client/index.ts b/examples/openapi-ts-openai/src/client/client/index.ts
new file mode 100644
index 000000000..318a84b6a
--- /dev/null
+++ b/examples/openapi-ts-openai/src/client/client/index.ts
@@ -0,0 +1,25 @@
+// This file is auto-generated by @hey-api/openapi-ts
+
+export type { Auth } from '../core/auth.gen';
+export type { QuerySerializerOptions } from '../core/bodySerializer.gen';
+export {
+ formDataBodySerializer,
+ jsonBodySerializer,
+ urlSearchParamsBodySerializer,
+} from '../core/bodySerializer.gen';
+export { buildClientParams } from '../core/params.gen';
+export { createClient } from './client.gen';
+export type {
+ Client,
+ ClientOptions,
+ Config,
+ CreateClientConfig,
+ Options,
+ OptionsLegacyParser,
+ RequestOptions,
+ RequestResult,
+ ResolvedRequestOptions,
+ ResponseStyle,
+ TDataShape,
+} from './types.gen';
+export { createConfig, mergeHeaders } from './utils.gen';
diff --git a/examples/openapi-ts-openai/src/client/client/types.gen.ts b/examples/openapi-ts-openai/src/client/client/types.gen.ts
new file mode 100644
index 000000000..2a123be9a
--- /dev/null
+++ b/examples/openapi-ts-openai/src/client/client/types.gen.ts
@@ -0,0 +1,232 @@
+// This file is auto-generated by @hey-api/openapi-ts
+
+import type { Auth } from '../core/auth.gen';
+import type {
+ Client as CoreClient,
+ Config as CoreConfig,
+} from '../core/types.gen';
+import type { Middleware } from './utils.gen';
+
+export type ResponseStyle = 'data' | 'fields';
+
+export interface Config
+ extends Omit,
+ CoreConfig {
+ /**
+ * Base URL for all requests made by this client.
+ */
+ baseUrl?: T['baseUrl'];
+ /**
+ * Fetch API implementation. You can use this option to provide a custom
+ * fetch instance.
+ *
+ * @default globalThis.fetch
+ */
+ fetch?: (request: Request) => ReturnType;
+ /**
+ * Please don't use the Fetch client for Next.js applications. The `next`
+ * options won't have any effect.
+ *
+ * Install {@link https://www.npmjs.com/package/@hey-api/client-next `@hey-api/client-next`} instead.
+ */
+ next?: never;
+ /**
+ * Return the response data parsed in a specified format. By default, `auto`
+ * will infer the appropriate method from the `Content-Type` response header.
+ * You can override this behavior with any of the {@link Body} methods.
+ * Select `stream` if you don't want to parse response data at all.
+ *
+ * @default 'auto'
+ */
+ parseAs?:
+ | 'arrayBuffer'
+ | 'auto'
+ | 'blob'
+ | 'formData'
+ | 'json'
+ | 'stream'
+ | 'text';
+ /**
+ * Should we return only data or multiple fields (data, error, response, etc.)?
+ *
+ * @default 'fields'
+ */
+ responseStyle?: ResponseStyle;
+ /**
+ * Throw an error instead of returning it in the response?
+ *
+ * @default false
+ */
+ throwOnError?: T['throwOnError'];
+}
+
+export interface RequestOptions<
+ TResponseStyle extends ResponseStyle = 'fields',
+ ThrowOnError extends boolean = boolean,
+ Url extends string = string,
+> extends Config<{
+ responseStyle: TResponseStyle;
+ throwOnError: ThrowOnError;
+ }> {
+ /**
+ * Any body that you want to add to your request.
+ *
+ * {@link https://developer.mozilla.org/docs/Web/API/fetch#body}
+ */
+ body?: unknown;
+ path?: Record;
+ query?: Record;
+ /**
+ * Security mechanism(s) to use for the request.
+ */
+ security?: ReadonlyArray;
+ url: Url;
+}
+
+export interface ResolvedRequestOptions<
+ TResponseStyle extends ResponseStyle = 'fields',
+ ThrowOnError extends boolean = boolean,
+ Url extends string = string,
+> extends RequestOptions {
+ serializedBody?: string;
+}
+
+export type RequestResult<
+ TData = unknown,
+ TError = unknown,
+ ThrowOnError extends boolean = boolean,
+ TResponseStyle extends ResponseStyle = 'fields',
+> = ThrowOnError extends true
+ ? Promise<
+ TResponseStyle extends 'data'
+ ? TData extends Record
+ ? TData[keyof TData]
+ : TData
+ : {
+ data: TData extends Record
+ ? TData[keyof TData]
+ : TData;
+ request: Request;
+ response: Response;
+ }
+ >
+ : Promise<
+ TResponseStyle extends 'data'
+ ?
+ | (TData extends Record
+ ? TData[keyof TData]
+ : TData)
+ | undefined
+ : (
+ | {
+ data: TData extends Record
+ ? TData[keyof TData]
+ : TData;
+ error: undefined;
+ }
+ | {
+ data: undefined;
+ error: TError extends Record
+ ? TError[keyof TError]
+ : TError;
+ }
+ ) & {
+ request: Request;
+ response: Response;
+ }
+ >;
+
+export interface ClientOptions {
+ baseUrl?: string;
+ responseStyle?: ResponseStyle;
+ throwOnError?: boolean;
+}
+
+type MethodFn = <
+ TData = unknown,
+ TError = unknown,
+ ThrowOnError extends boolean = false,
+ TResponseStyle extends ResponseStyle = 'fields',
+>(
+ options: Omit, 'method'>,
+) => RequestResult;
+
+type RequestFn = <
+ TData = unknown,
+ TError = unknown,
+ ThrowOnError extends boolean = false,
+ TResponseStyle extends ResponseStyle = 'fields',
+>(
+ options: Omit, 'method'> &
+ Pick>, 'method'>,
+) => RequestResult;
+
+type BuildUrlFn = <
+ TData extends {
+ body?: unknown;
+ path?: Record;
+ query?: Record;
+ url: string;
+ },
+>(
+ options: Pick & Options,
+) => string;
+
+export type Client = CoreClient & {
+ interceptors: Middleware;
+};
+
+/**
+ * The `createClientConfig()` function will be called on client initialization
+ * and the returned object will become the client's initial configuration.
+ *
+ * You may want to initialize your client this way instead of calling
+ * `setConfig()`. This is useful for example if you're using Next.js
+ * to ensure your client always has the correct values.
+ */
+export type CreateClientConfig = (
+ override?: Config,
+) => Config & T>;
+
+export interface TDataShape {
+ body?: unknown;
+ headers?: unknown;
+ path?: unknown;
+ query?: unknown;
+ url: string;
+}
+
+type OmitKeys = Pick>;
+
+export type Options<
+ TData extends TDataShape = TDataShape,
+ ThrowOnError extends boolean = boolean,
+ TResponseStyle extends ResponseStyle = 'fields',
+> = OmitKeys<
+ RequestOptions,
+ 'body' | 'path' | 'query' | 'url'
+> &
+ Omit;
+
+export type OptionsLegacyParser<
+ TData = unknown,
+ ThrowOnError extends boolean = boolean,
+ TResponseStyle extends ResponseStyle = 'fields',
+> = TData extends { body?: any }
+ ? TData extends { headers?: any }
+ ? OmitKeys<
+ RequestOptions,
+ 'body' | 'headers' | 'url'
+ > &
+ TData
+ : OmitKeys, 'body' | 'url'> &
+ TData &
+ Pick, 'headers'>
+ : TData extends { headers?: any }
+ ? OmitKeys<
+ RequestOptions,
+ 'headers' | 'url'
+ > &
+ TData &
+ Pick, 'body'>
+ : OmitKeys, 'url'> & TData;
diff --git a/examples/openapi-ts-openai/src/client/client/utils.gen.ts b/examples/openapi-ts-openai/src/client/client/utils.gen.ts
new file mode 100644
index 000000000..6f955d080
--- /dev/null
+++ b/examples/openapi-ts-openai/src/client/client/utils.gen.ts
@@ -0,0 +1,445 @@
+// This file is auto-generated by @hey-api/openapi-ts
+
+import { getAuthToken } from '../core/auth.gen';
+import type {
+ QuerySerializer,
+ QuerySerializerOptions,
+} from '../core/bodySerializer.gen';
+import { jsonBodySerializer } from '../core/bodySerializer.gen';
+import {
+ serializeArrayParam,
+ serializeObjectParam,
+ serializePrimitiveParam,
+} from '../core/pathSerializer.gen';
+import type {
+ Client,
+ ClientOptions,
+ Config,
+ RequestOptions,
+} from './types.gen';
+
+interface PathSerializer {
+ path: Record;
+ url: string;
+}
+
+const PATH_PARAM_RE = /\{[^{}]+\}/g;
+
+type ArrayStyle = 'form' | 'spaceDelimited' | 'pipeDelimited';
+type MatrixStyle = 'label' | 'matrix' | 'simple';
+type ArraySeparatorStyle = ArrayStyle | MatrixStyle;
+
+const defaultPathSerializer = ({ path, url: _url }: PathSerializer) => {
+ let url = _url;
+ const matches = _url.match(PATH_PARAM_RE);
+ if (matches) {
+ for (const match of matches) {
+ let explode = false;
+ let name = match.substring(1, match.length - 1);
+ let style: ArraySeparatorStyle = 'simple';
+
+ if (name.endsWith('*')) {
+ explode = true;
+ name = name.substring(0, name.length - 1);
+ }
+
+ if (name.startsWith('.')) {
+ name = name.substring(1);
+ style = 'label';
+ } else if (name.startsWith(';')) {
+ name = name.substring(1);
+ style = 'matrix';
+ }
+
+ const value = path[name];
+
+ if (value === undefined || value === null) {
+ continue;
+ }
+
+ if (Array.isArray(value)) {
+ url = url.replace(
+ match,
+ serializeArrayParam({ explode, name, style, value }),
+ );
+ continue;
+ }
+
+ if (typeof value === 'object') {
+ url = url.replace(
+ match,
+ serializeObjectParam({
+ explode,
+ name,
+ style,
+ value: value as Record,
+ valueOnly: true,
+ }),
+ );
+ continue;
+ }
+
+ if (style === 'matrix') {
+ url = url.replace(
+ match,
+ `;${serializePrimitiveParam({
+ name,
+ value: value as string,
+ })}`,
+ );
+ continue;
+ }
+
+ const replaceValue = encodeURIComponent(
+ style === 'label' ? `.${value as string}` : (value as string),
+ );
+ url = url.replace(match, replaceValue);
+ }
+ }
+ return url;
+};
+
+export const createQuerySerializer = ({
+ allowReserved,
+ array,
+ object,
+}: QuerySerializerOptions = {}) => {
+ const querySerializer = (queryParams: T) => {
+ const search: string[] = [];
+ if (queryParams && typeof queryParams === 'object') {
+ for (const name in queryParams) {
+ const value = queryParams[name];
+
+ if (value === undefined || value === null) {
+ continue;
+ }
+
+ if (Array.isArray(value)) {
+ const serializedArray = serializeArrayParam({
+ allowReserved,
+ explode: true,
+ name,
+ style: 'form',
+ value,
+ ...array,
+ });
+ if (serializedArray) search.push(serializedArray);
+ } else if (typeof value === 'object') {
+ const serializedObject = serializeObjectParam({
+ allowReserved,
+ explode: true,
+ name,
+ style: 'deepObject',
+ value: value as Record,
+ ...object,
+ });
+ if (serializedObject) search.push(serializedObject);
+ } else {
+ const serializedPrimitive = serializePrimitiveParam({
+ allowReserved,
+ name,
+ value: value as string,
+ });
+ if (serializedPrimitive) search.push(serializedPrimitive);
+ }
+ }
+ }
+ return search.join('&');
+ };
+ return querySerializer;
+};
+
+/**
+ * Infers parseAs value from provided Content-Type header.
+ */
+export const getParseAs = (
+ contentType: string | null,
+): Exclude => {
+ if (!contentType) {
+ // If no Content-Type header is provided, the best we can do is return the raw response body,
+ // which is effectively the same as the 'stream' option.
+ return 'stream';
+ }
+
+ const cleanContent = contentType.split(';')[0]?.trim();
+
+ if (!cleanContent) {
+ return;
+ }
+
+ if (
+ cleanContent.startsWith('application/json') ||
+ cleanContent.endsWith('+json')
+ ) {
+ return 'json';
+ }
+
+ if (cleanContent === 'multipart/form-data') {
+ return 'formData';
+ }
+
+ if (
+ ['application/', 'audio/', 'image/', 'video/'].some((type) =>
+ cleanContent.startsWith(type),
+ )
+ ) {
+ return 'blob';
+ }
+
+ if (cleanContent.startsWith('text/')) {
+ return 'text';
+ }
+
+ return;
+};
+
+const checkForExistence = (
+ options: Pick & {
+ headers: Headers;
+ },
+ name?: string,
+): boolean => {
+ if (!name) {
+ return false;
+ }
+ if (
+ options.headers.has(name) ||
+ options.query?.[name] ||
+ options.headers.get('Cookie')?.includes(`${name}=`)
+ ) {
+ return true;
+ }
+ return false;
+};
+
+export const setAuthParams = async ({
+ security,
+ ...options
+}: Pick, 'security'> &
+ Pick & {
+ headers: Headers;
+ }) => {
+ for (const auth of security) {
+ if (checkForExistence(options, auth.name)) {
+ continue;
+ }
+
+ const token = await getAuthToken(auth, options.auth);
+
+ if (!token) {
+ continue;
+ }
+
+ const name = auth.name ?? 'Authorization';
+
+ switch (auth.in) {
+ case 'query':
+ if (!options.query) {
+ options.query = {};
+ }
+ options.query[name] = token;
+ break;
+ case 'cookie':
+ options.headers.append('Cookie', `${name}=${token}`);
+ break;
+ case 'header':
+ default:
+ options.headers.set(name, token);
+ break;
+ }
+ }
+};
+
+export const buildUrl: Client['buildUrl'] = (options) => {
+ const url = getUrl({
+ baseUrl: options.baseUrl as string,
+ path: options.path,
+ query: options.query,
+ querySerializer:
+ typeof options.querySerializer === 'function'
+ ? options.querySerializer
+ : createQuerySerializer(options.querySerializer),
+ url: options.url,
+ });
+ return url;
+};
+
+export const getUrl = ({
+ baseUrl,
+ path,
+ query,
+ querySerializer,
+ url: _url,
+}: {
+ baseUrl?: string;
+ path?: Record;
+ query?: Record;
+ querySerializer: QuerySerializer;
+ url: string;
+}) => {
+ const pathUrl = _url.startsWith('/') ? _url : `/${_url}`;
+ let url = (baseUrl ?? '') + pathUrl;
+ if (path) {
+ url = defaultPathSerializer({ path, url });
+ }
+ let search = query ? querySerializer(query) : '';
+ if (search.startsWith('?')) {
+ search = search.substring(1);
+ }
+ if (search) {
+ url += `?${search}`;
+ }
+ return url;
+};
+
+export const mergeConfigs = (a: Config, b: Config): Config => {
+ const config = { ...a, ...b };
+ if (config.baseUrl?.endsWith('/')) {
+ config.baseUrl = config.baseUrl.substring(0, config.baseUrl.length - 1);
+ }
+ config.headers = mergeHeaders(a.headers, b.headers);
+ return config;
+};
+
+export const mergeHeaders = (
+ ...headers: Array['headers'] | undefined>
+): Headers => {
+ const mergedHeaders = new Headers();
+ for (const header of headers) {
+ if (!header || typeof header !== 'object') {
+ continue;
+ }
+
+ const iterator =
+ header instanceof Headers ? header.entries() : Object.entries(header);
+
+ for (const [key, value] of iterator) {
+ if (value === null) {
+ mergedHeaders.delete(key);
+ } else if (Array.isArray(value)) {
+ for (const v of value) {
+ mergedHeaders.append(key, v as string);
+ }
+ } else if (value !== undefined) {
+ // assume object headers are meant to be JSON stringified, i.e. their
+ // content value in OpenAPI specification is 'application/json'
+ mergedHeaders.set(
+ key,
+ typeof value === 'object' ? JSON.stringify(value) : (value as string),
+ );
+ }
+ }
+ }
+ return mergedHeaders;
+};
+
+type ErrInterceptor = (
+ error: Err,
+ response: Res,
+ request: Req,
+ options: Options,
+) => Err | Promise;
+
+type ReqInterceptor = (
+ request: Req,
+ options: Options,
+) => Req | Promise;
+
+type ResInterceptor = (
+ response: Res,
+ request: Req,
+ options: Options,
+) => Res | Promise;
+
+class Interceptors {
+ _fns: (Interceptor | null)[];
+
+ constructor() {
+ this._fns = [];
+ }
+
+ clear() {
+ this._fns = [];
+ }
+
+ getInterceptorIndex(id: number | Interceptor): number {
+ if (typeof id === 'number') {
+ return this._fns[id] ? id : -1;
+ } else {
+ return this._fns.indexOf(id);
+ }
+ }
+ exists(id: number | Interceptor) {
+ const index = this.getInterceptorIndex(id);
+ return !!this._fns[index];
+ }
+
+ eject(id: number | Interceptor) {
+ const index = this.getInterceptorIndex(id);
+ if (this._fns[index]) {
+ this._fns[index] = null;
+ }
+ }
+
+ update(id: number | Interceptor, fn: Interceptor) {
+ const index = this.getInterceptorIndex(id);
+ if (this._fns[index]) {
+ this._fns[index] = fn;
+ return id;
+ } else {
+ return false;
+ }
+ }
+
+ use(fn: Interceptor) {
+ this._fns = [...this._fns, fn];
+ return this._fns.length - 1;
+ }
+}
+
+// `createInterceptors()` response, meant for external use as it does not
+// expose internals
+export interface Middleware {
+ error: Pick<
+ Interceptors>,
+ 'eject' | 'use'
+ >;
+ request: Pick>, 'eject' | 'use'>;
+ response: Pick<
+ Interceptors>,
+ 'eject' | 'use'
+ >;
+}
+
+// do not add `Middleware` as return type so we can use _fns internally
+export const createInterceptors = () => ({
+ error: new Interceptors>(),
+ request: new Interceptors>(),
+ response: new Interceptors>(),
+});
+
+const defaultQuerySerializer = createQuerySerializer({
+ allowReserved: false,
+ array: {
+ explode: true,
+ style: 'form',
+ },
+ object: {
+ explode: true,
+ style: 'deepObject',
+ },
+});
+
+const defaultHeaders = {
+ 'Content-Type': 'application/json',
+};
+
+export const createConfig = (
+ override: Config & T> = {},
+): Config & T> => ({
+ ...jsonBodySerializer,
+ headers: defaultHeaders,
+ parseAs: 'auto',
+ querySerializer: defaultQuerySerializer,
+ ...override,
+});
diff --git a/examples/openapi-ts-openai/src/client/core/auth.gen.ts b/examples/openapi-ts-openai/src/client/core/auth.gen.ts
new file mode 100644
index 000000000..f8a73266f
--- /dev/null
+++ b/examples/openapi-ts-openai/src/client/core/auth.gen.ts
@@ -0,0 +1,42 @@
+// This file is auto-generated by @hey-api/openapi-ts
+
+export type AuthToken = string | undefined;
+
+export interface Auth {
+ /**
+ * Which part of the request do we use to send the auth?
+ *
+ * @default 'header'
+ */
+ in?: 'header' | 'query' | 'cookie';
+ /**
+ * Header or query parameter name.
+ *
+ * @default 'Authorization'
+ */
+ name?: string;
+ scheme?: 'basic' | 'bearer';
+ type: 'apiKey' | 'http';
+}
+
+export const getAuthToken = async (
+ auth: Auth,
+ callback: ((auth: Auth) => Promise | AuthToken) | AuthToken,
+): Promise => {
+ const token =
+ typeof callback === 'function' ? await callback(auth) : callback;
+
+ if (!token) {
+ return;
+ }
+
+ if (auth.scheme === 'bearer') {
+ return `Bearer ${token}`;
+ }
+
+ if (auth.scheme === 'basic') {
+ return `Basic ${btoa(token)}`;
+ }
+
+ return token;
+};
diff --git a/examples/openapi-ts-openai/src/client/core/bodySerializer.gen.ts b/examples/openapi-ts-openai/src/client/core/bodySerializer.gen.ts
new file mode 100644
index 000000000..49cd8925e
--- /dev/null
+++ b/examples/openapi-ts-openai/src/client/core/bodySerializer.gen.ts
@@ -0,0 +1,92 @@
+// This file is auto-generated by @hey-api/openapi-ts
+
+import type {
+ ArrayStyle,
+ ObjectStyle,
+ SerializerOptions,
+} from './pathSerializer.gen';
+
+export type QuerySerializer = (query: Record) => string;
+
+export type BodySerializer = (body: any) => any;
+
+export interface QuerySerializerOptions {
+ allowReserved?: boolean;
+ array?: SerializerOptions;
+ object?: SerializerOptions;
+}
+
+const serializeFormDataPair = (
+ data: FormData,
+ key: string,
+ value: unknown,
+): void => {
+ if (typeof value === 'string' || value instanceof Blob) {
+ data.append(key, value);
+ } else if (value instanceof Date) {
+ data.append(key, value.toISOString());
+ } else {
+ data.append(key, JSON.stringify(value));
+ }
+};
+
+const serializeUrlSearchParamsPair = (
+ data: URLSearchParams,
+ key: string,
+ value: unknown,
+): void => {
+ if (typeof value === 'string') {
+ data.append(key, value);
+ } else {
+ data.append(key, JSON.stringify(value));
+ }
+};
+
+export const formDataBodySerializer = {
+ bodySerializer: | Array>>(
+ body: T,
+ ): FormData => {
+ const data = new FormData();
+
+ Object.entries(body).forEach(([key, value]) => {
+ if (value === undefined || value === null) {
+ return;
+ }
+ if (Array.isArray(value)) {
+ value.forEach((v) => serializeFormDataPair(data, key, v));
+ } else {
+ serializeFormDataPair(data, key, value);
+ }
+ });
+
+ return data;
+ },
+};
+
+export const jsonBodySerializer = {
+ bodySerializer: (body: T): string =>
+ JSON.stringify(body, (_key, value) =>
+ typeof value === 'bigint' ? value.toString() : value,
+ ),
+};
+
+export const urlSearchParamsBodySerializer = {
+ bodySerializer: | Array>>(
+ body: T,
+ ): string => {
+ const data = new URLSearchParams();
+
+ Object.entries(body).forEach(([key, value]) => {
+ if (value === undefined || value === null) {
+ return;
+ }
+ if (Array.isArray(value)) {
+ value.forEach((v) => serializeUrlSearchParamsPair(data, key, v));
+ } else {
+ serializeUrlSearchParamsPair(data, key, value);
+ }
+ });
+
+ return data.toString();
+ },
+};
diff --git a/examples/openapi-ts-openai/src/client/core/params.gen.ts b/examples/openapi-ts-openai/src/client/core/params.gen.ts
new file mode 100644
index 000000000..71c88e852
--- /dev/null
+++ b/examples/openapi-ts-openai/src/client/core/params.gen.ts
@@ -0,0 +1,153 @@
+// This file is auto-generated by @hey-api/openapi-ts
+
+type Slot = 'body' | 'headers' | 'path' | 'query';
+
+export type Field =
+ | {
+ in: Exclude;
+ /**
+ * Field name. This is the name we want the user to see and use.
+ */
+ key: string;
+ /**
+ * Field mapped name. This is the name we want to use in the request.
+ * If omitted, we use the same value as `key`.
+ */
+ map?: string;
+ }
+ | {
+ in: Extract;
+ /**
+ * Key isn't required for bodies.
+ */
+ key?: string;
+ map?: string;
+ };
+
+export interface Fields {
+ allowExtra?: Partial>;
+ args?: ReadonlyArray;
+}
+
+export type FieldsConfig = ReadonlyArray;
+
+const extraPrefixesMap: Record = {
+ $body_: 'body',
+ $headers_: 'headers',
+ $path_: 'path',
+ $query_: 'query',
+};
+const extraPrefixes = Object.entries(extraPrefixesMap);
+
+type KeyMap = Map<
+ string,
+ {
+ in: Slot;
+ map?: string;
+ }
+>;
+
+const buildKeyMap = (fields: FieldsConfig, map?: KeyMap): KeyMap => {
+ if (!map) {
+ map = new Map();
+ }
+
+ for (const config of fields) {
+ if ('in' in config) {
+ if (config.key) {
+ map.set(config.key, {
+ in: config.in,
+ map: config.map,
+ });
+ }
+ } else if (config.args) {
+ buildKeyMap(config.args, map);
+ }
+ }
+
+ return map;
+};
+
+interface Params {
+ body: unknown;
+ headers: Record;
+ path: Record;
+ query: Record;
+}
+
+const stripEmptySlots = (params: Params) => {
+ for (const [slot, value] of Object.entries(params)) {
+ if (value && typeof value === 'object' && !Object.keys(value).length) {
+ delete params[slot as Slot];
+ }
+ }
+};
+
+export const buildClientParams = (
+ args: ReadonlyArray,
+ fields: FieldsConfig,
+) => {
+ const params: Params = {
+ body: {},
+ headers: {},
+ path: {},
+ query: {},
+ };
+
+ const map = buildKeyMap(fields);
+
+ let config: FieldsConfig[number] | undefined;
+
+ for (const [index, arg] of args.entries()) {
+ if (fields[index]) {
+ config = fields[index];
+ }
+
+ if (!config) {
+ continue;
+ }
+
+ if ('in' in config) {
+ if (config.key) {
+ const field = map.get(config.key)!;
+ const name = field.map || config.key;
+ (params[field.in] as Record)[name] = arg;
+ } else {
+ params.body = arg;
+ }
+ } else {
+ for (const [key, value] of Object.entries(arg ?? {})) {
+ const field = map.get(key);
+
+ if (field) {
+ const name = field.map || key;
+ (params[field.in] as Record)[name] = value;
+ } else {
+ const extra = extraPrefixes.find(([prefix]) =>
+ key.startsWith(prefix),
+ );
+
+ if (extra) {
+ const [prefix, slot] = extra;
+ (params[slot] as Record)[
+ key.slice(prefix.length)
+ ] = value;
+ } else {
+ for (const [slot, allowed] of Object.entries(
+ config.allowExtra ?? {},
+ )) {
+ if (allowed) {
+ (params[slot as Slot] as Record)[key] = value;
+ break;
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+
+ stripEmptySlots(params);
+
+ return params;
+};
diff --git a/examples/openapi-ts-openai/src/client/core/pathSerializer.gen.ts b/examples/openapi-ts-openai/src/client/core/pathSerializer.gen.ts
new file mode 100644
index 000000000..8d9993104
--- /dev/null
+++ b/examples/openapi-ts-openai/src/client/core/pathSerializer.gen.ts
@@ -0,0 +1,181 @@
+// This file is auto-generated by @hey-api/openapi-ts
+
+interface SerializeOptions
+ extends SerializePrimitiveOptions,
+ SerializerOptions {}
+
+interface SerializePrimitiveOptions {
+ allowReserved?: boolean;
+ name: string;
+}
+
+export interface SerializerOptions {
+ /**
+ * @default true
+ */
+ explode: boolean;
+ style: T;
+}
+
+export type ArrayStyle = 'form' | 'spaceDelimited' | 'pipeDelimited';
+export type ArraySeparatorStyle = ArrayStyle | MatrixStyle;
+type MatrixStyle = 'label' | 'matrix' | 'simple';
+export type ObjectStyle = 'form' | 'deepObject';
+type ObjectSeparatorStyle = ObjectStyle | MatrixStyle;
+
+interface SerializePrimitiveParam extends SerializePrimitiveOptions {
+ value: string;
+}
+
+export const separatorArrayExplode = (style: ArraySeparatorStyle) => {
+ switch (style) {
+ case 'label':
+ return '.';
+ case 'matrix':
+ return ';';
+ case 'simple':
+ return ',';
+ default:
+ return '&';
+ }
+};
+
+export const separatorArrayNoExplode = (style: ArraySeparatorStyle) => {
+ switch (style) {
+ case 'form':
+ return ',';
+ case 'pipeDelimited':
+ return '|';
+ case 'spaceDelimited':
+ return '%20';
+ default:
+ return ',';
+ }
+};
+
+export const separatorObjectExplode = (style: ObjectSeparatorStyle) => {
+ switch (style) {
+ case 'label':
+ return '.';
+ case 'matrix':
+ return ';';
+ case 'simple':
+ return ',';
+ default:
+ return '&';
+ }
+};
+
+export const serializeArrayParam = ({
+ allowReserved,
+ explode,
+ name,
+ style,
+ value,
+}: SerializeOptions & {
+ value: unknown[];
+}) => {
+ if (!explode) {
+ const joinedValues = (
+ allowReserved ? value : value.map((v) => encodeURIComponent(v as string))
+ ).join(separatorArrayNoExplode(style));
+ switch (style) {
+ case 'label':
+ return `.${joinedValues}`;
+ case 'matrix':
+ return `;${name}=${joinedValues}`;
+ case 'simple':
+ return joinedValues;
+ default:
+ return `${name}=${joinedValues}`;
+ }
+ }
+
+ const separator = separatorArrayExplode(style);
+ const joinedValues = value
+ .map((v) => {
+ if (style === 'label' || style === 'simple') {
+ return allowReserved ? v : encodeURIComponent(v as string);
+ }
+
+ return serializePrimitiveParam({
+ allowReserved,
+ name,
+ value: v as string,
+ });
+ })
+ .join(separator);
+ return style === 'label' || style === 'matrix'
+ ? separator + joinedValues
+ : joinedValues;
+};
+
+export const serializePrimitiveParam = ({
+ allowReserved,
+ name,
+ value,
+}: SerializePrimitiveParam) => {
+ if (value === undefined || value === null) {
+ return '';
+ }
+
+ if (typeof value === 'object') {
+ throw new Error(
+ 'Deeply-nested arrays/objects aren’t supported. Provide your own `querySerializer()` to handle these.',
+ );
+ }
+
+ return `${name}=${allowReserved ? value : encodeURIComponent(value)}`;
+};
+
+export const serializeObjectParam = ({
+ allowReserved,
+ explode,
+ name,
+ style,
+ value,
+ valueOnly,
+}: SerializeOptions & {
+ value: Record | Date;
+ valueOnly?: boolean;
+}) => {
+ if (value instanceof Date) {
+ return valueOnly ? value.toISOString() : `${name}=${value.toISOString()}`;
+ }
+
+ if (style !== 'deepObject' && !explode) {
+ let values: string[] = [];
+ Object.entries(value).forEach(([key, v]) => {
+ values = [
+ ...values,
+ key,
+ allowReserved ? (v as string) : encodeURIComponent(v as string),
+ ];
+ });
+ const joinedValues = values.join(',');
+ switch (style) {
+ case 'form':
+ return `${name}=${joinedValues}`;
+ case 'label':
+ return `.${joinedValues}`;
+ case 'matrix':
+ return `;${name}=${joinedValues}`;
+ default:
+ return joinedValues;
+ }
+ }
+
+ const separator = separatorObjectExplode(style);
+ const joinedValues = Object.entries(value)
+ .map(([key, v]) =>
+ serializePrimitiveParam({
+ allowReserved,
+ name: style === 'deepObject' ? `${name}[${key}]` : key,
+ value: v as string,
+ }),
+ )
+ .join(separator);
+ return style === 'label' || style === 'matrix'
+ ? separator + joinedValues
+ : joinedValues;
+};
diff --git a/examples/openapi-ts-openai/src/client/core/types.gen.ts b/examples/openapi-ts-openai/src/client/core/types.gen.ts
new file mode 100644
index 000000000..5bfae35c0
--- /dev/null
+++ b/examples/openapi-ts-openai/src/client/core/types.gen.ts
@@ -0,0 +1,120 @@
+// This file is auto-generated by @hey-api/openapi-ts
+
+import type { Auth, AuthToken } from './auth.gen';
+import type {
+ BodySerializer,
+ QuerySerializer,
+ QuerySerializerOptions,
+} from './bodySerializer.gen';
+
+export interface Client<
+ RequestFn = never,
+ Config = unknown,
+ MethodFn = never,
+ BuildUrlFn = never,
+> {
+ /**
+ * Returns the final request URL.
+ */
+ buildUrl: BuildUrlFn;
+ connect: MethodFn;
+ delete: MethodFn;
+ get: MethodFn;
+ getConfig: () => Config;
+ head: MethodFn;
+ options: MethodFn;
+ patch: MethodFn;
+ post: MethodFn;
+ put: MethodFn;
+ request: RequestFn;
+ setConfig: (config: Config) => Config;
+ trace: MethodFn;
+}
+
+export interface Config {
+ /**
+ * Auth token or a function returning auth token. The resolved value will be
+ * added to the request payload as defined by its `security` array.
+ */
+ auth?: ((auth: Auth) => Promise | AuthToken) | AuthToken;
+ /**
+ * A function for serializing request body parameter. By default,
+ * {@link JSON.stringify()} will be used.
+ */
+ bodySerializer?: BodySerializer | null;
+ /**
+ * An object containing any HTTP headers that you want to pre-populate your
+ * `Headers` object with.
+ *
+ * {@link https://developer.mozilla.org/docs/Web/API/Headers/Headers#init See more}
+ */
+ headers?:
+ | RequestInit['headers']
+ | Record<
+ string,
+ | string
+ | number
+ | boolean
+ | (string | number | boolean)[]
+ | null
+ | undefined
+ | unknown
+ >;
+ /**
+ * The request method.
+ *
+ * {@link https://developer.mozilla.org/docs/Web/API/fetch#method See more}
+ */
+ method?:
+ | 'CONNECT'
+ | 'DELETE'
+ | 'GET'
+ | 'HEAD'
+ | 'OPTIONS'
+ | 'PATCH'
+ | 'POST'
+ | 'PUT'
+ | 'TRACE';
+ /**
+ * A function for serializing request query parameters. By default, arrays
+ * will be exploded in form style, objects will be exploded in deepObject
+ * style, and reserved characters are percent-encoded.
+ *
+ * This method will have no effect if the native `paramsSerializer()` Axios
+ * API function is used.
+ *
+ * {@link https://swagger.io/docs/specification/serialization/#query View examples}
+ */
+ querySerializer?: QuerySerializer | QuerySerializerOptions;
+ /**
+ * A function validating request data. This is useful if you want to ensure
+ * the request conforms to the desired shape, so it can be safely sent to
+ * the server.
+ */
+ requestValidator?: (data: unknown) => Promise;
+ /**
+ * A function transforming response data before it's returned. This is useful
+ * for post-processing data, e.g. converting ISO strings into Date objects.
+ */
+ responseTransformer?: (data: unknown) => Promise;
+ /**
+ * A function validating response data. This is useful if you want to ensure
+ * the response conforms to the desired shape, so it can be safely passed to
+ * the transformers and returned to the user.
+ */
+ responseValidator?: (data: unknown) => Promise;
+}
+
+type IsExactlyNeverOrNeverUndefined = [T] extends [never]
+ ? true
+ : [T] extends [never | undefined]
+ ? [undefined] extends [T]
+ ? false
+ : true
+ : false;
+
+export type OmitNever> = {
+ [K in keyof T as IsExactlyNeverOrNeverUndefined extends true
+ ? never
+ : K]: T[K];
+};
diff --git a/examples/openapi-ts-openai/src/client/index.ts b/examples/openapi-ts-openai/src/client/index.ts
new file mode 100644
index 000000000..688e3c912
--- /dev/null
+++ b/examples/openapi-ts-openai/src/client/index.ts
@@ -0,0 +1,3 @@
+// This file is auto-generated by @hey-api/openapi-ts
+export * from './sdk.gen';
+export * from './types.gen';
diff --git a/examples/openapi-ts-openai/src/client/sdk.gen.ts b/examples/openapi-ts-openai/src/client/sdk.gen.ts
new file mode 100644
index 000000000..6bcc5384d
--- /dev/null
+++ b/examples/openapi-ts-openai/src/client/sdk.gen.ts
@@ -0,0 +1,4506 @@
+// This file is auto-generated by @hey-api/openapi-ts
+
+import {
+ type Client,
+ formDataBodySerializer,
+ type Options as ClientOptions,
+ type TDataShape,
+} from './client';
+import { client as _heyApiClient } from './client.gen';
+import type {
+ ActivateOrganizationCertificatesData,
+ ActivateOrganizationCertificatesResponses,
+ ActivateProjectCertificatesData,
+ ActivateProjectCertificatesResponses,
+ AddUploadPartData,
+ AddUploadPartResponses,
+ AdminApiKeysCreateData,
+ AdminApiKeysCreateResponses,
+ AdminApiKeysDeleteData,
+ AdminApiKeysDeleteResponses,
+ AdminApiKeysGetData,
+ AdminApiKeysGetResponses,
+ AdminApiKeysListData,
+ AdminApiKeysListResponses,
+ ArchiveProjectData,
+ ArchiveProjectResponses,
+ CancelBatchData,
+ CancelBatchResponses,
+ CancelEvalRunData,
+ CancelEvalRunResponses,
+ CancelFineTuningJobData,
+ CancelFineTuningJobResponses,
+ CancelResponseData,
+ CancelResponseErrors,
+ CancelResponseResponses,
+ CancelRunData,
+ CancelRunResponses,
+ CancelUploadData,
+ CancelUploadResponses,
+ CancelVectorStoreFileBatchData,
+ CancelVectorStoreFileBatchResponses,
+ CompleteUploadData,
+ CompleteUploadResponses,
+ CreateAssistantData,
+ CreateAssistantResponses,
+ CreateBatchData,
+ CreateBatchResponses,
+ CreateChatCompletionData,
+ CreateChatCompletionResponses,
+ CreateCompletionData,
+ CreateCompletionResponses,
+ CreateContainerData,
+ CreateContainerFileData,
+ CreateContainerFileResponses,
+ CreateContainerResponses,
+ CreateEmbeddingData,
+ CreateEmbeddingResponses,
+ CreateEvalData,
+ CreateEvalResponses,
+ CreateEvalRunData,
+ CreateEvalRunErrors,
+ CreateEvalRunResponses,
+ CreateFileData,
+ CreateFileResponses,
+ CreateFineTuningCheckpointPermissionData,
+ CreateFineTuningCheckpointPermissionResponses,
+ CreateFineTuningJobData,
+ CreateFineTuningJobResponses,
+ CreateImageData,
+ CreateImageEditData,
+ CreateImageEditResponses,
+ CreateImageResponses,
+ CreateImageVariationData,
+ CreateImageVariationResponses,
+ CreateMessageData,
+ CreateMessageResponses,
+ CreateModerationData,
+ CreateModerationResponses,
+ CreateProjectData,
+ CreateProjectResponses,
+ CreateProjectServiceAccountData,
+ CreateProjectServiceAccountErrors,
+ CreateProjectServiceAccountResponses,
+ CreateProjectUserData,
+ CreateProjectUserErrors,
+ CreateProjectUserResponses,
+ CreateRealtimeSessionData,
+ CreateRealtimeSessionResponses,
+ CreateRealtimeTranscriptionSessionData,
+ CreateRealtimeTranscriptionSessionResponses,
+ CreateResponseData,
+ CreateResponseResponses,
+ CreateRunData,
+ CreateRunResponses,
+ CreateSpeechData,
+ CreateSpeechResponses,
+ CreateThreadAndRunData,
+ CreateThreadAndRunResponses,
+ CreateThreadData,
+ CreateThreadResponses,
+ CreateTranscriptionData,
+ CreateTranscriptionResponses,
+ CreateTranslationData,
+ CreateTranslationResponses,
+ CreateUploadData,
+ CreateUploadResponses,
+ CreateVectorStoreData,
+ CreateVectorStoreFileBatchData,
+ CreateVectorStoreFileBatchResponses,
+ CreateVectorStoreFileData,
+ CreateVectorStoreFileResponses,
+ CreateVectorStoreResponses,
+ DeactivateOrganizationCertificatesData,
+ DeactivateOrganizationCertificatesResponses,
+ DeactivateProjectCertificatesData,
+ DeactivateProjectCertificatesResponses,
+ DeleteAssistantData,
+ DeleteAssistantResponses,
+ DeleteCertificateData,
+ DeleteCertificateResponses,
+ DeleteChatCompletionData,
+ DeleteChatCompletionResponses,
+ DeleteContainerData,
+ DeleteContainerFileData,
+ DeleteContainerFileResponses,
+ DeleteContainerResponses,
+ DeleteEvalData,
+ DeleteEvalErrors,
+ DeleteEvalResponses,
+ DeleteEvalRunData,
+ DeleteEvalRunErrors,
+ DeleteEvalRunResponses,
+ DeleteFileData,
+ DeleteFileResponses,
+ DeleteFineTuningCheckpointPermissionData,
+ DeleteFineTuningCheckpointPermissionResponses,
+ DeleteInviteData,
+ DeleteInviteResponses,
+ DeleteMessageData,
+ DeleteMessageResponses,
+ DeleteModelData,
+ DeleteModelResponses,
+ DeleteProjectApiKeyData,
+ DeleteProjectApiKeyErrors,
+ DeleteProjectApiKeyResponses,
+ DeleteProjectServiceAccountData,
+ DeleteProjectServiceAccountResponses,
+ DeleteProjectUserData,
+ DeleteProjectUserErrors,
+ DeleteProjectUserResponses,
+ DeleteResponseData,
+ DeleteResponseErrors,
+ DeleteResponseResponses,
+ DeleteThreadData,
+ DeleteThreadResponses,
+ DeleteUserData,
+ DeleteUserResponses,
+ DeleteVectorStoreData,
+ DeleteVectorStoreFileData,
+ DeleteVectorStoreFileResponses,
+ DeleteVectorStoreResponses,
+ DownloadFileData,
+ DownloadFileResponses,
+ GetAssistantData,
+ GetAssistantResponses,
+ GetCertificateData,
+ GetCertificateResponses,
+ GetChatCompletionData,
+ GetChatCompletionMessagesData,
+ GetChatCompletionMessagesResponses,
+ GetChatCompletionResponses,
+ GetEvalData,
+ GetEvalResponses,
+ GetEvalRunData,
+ GetEvalRunOutputItemData,
+ GetEvalRunOutputItemResponses,
+ GetEvalRunOutputItemsData,
+ GetEvalRunOutputItemsResponses,
+ GetEvalRunResponses,
+ GetEvalRunsData,
+ GetEvalRunsResponses,
+ GetMessageData,
+ GetMessageResponses,
+ GetResponseData,
+ GetResponseResponses,
+ GetRunData,
+ GetRunResponses,
+ GetRunStepData,
+ GetRunStepResponses,
+ GetThreadData,
+ GetThreadResponses,
+ GetVectorStoreData,
+ GetVectorStoreFileBatchData,
+ GetVectorStoreFileBatchResponses,
+ GetVectorStoreFileData,
+ GetVectorStoreFileResponses,
+ GetVectorStoreResponses,
+ InviteUserData,
+ InviteUserResponses,
+ ListAssistantsData,
+ ListAssistantsResponses,
+ ListAuditLogsData,
+ ListAuditLogsResponses,
+ ListBatchesData,
+ ListBatchesResponses,
+ ListChatCompletionsData,
+ ListChatCompletionsResponses,
+ ListContainerFilesData,
+ ListContainerFilesResponses,
+ ListContainersData,
+ ListContainersResponses,
+ ListEvalsData,
+ ListEvalsResponses,
+ ListFilesData,
+ ListFilesInVectorStoreBatchData,
+ ListFilesInVectorStoreBatchResponses,
+ ListFilesResponses,
+ ListFineTuningCheckpointPermissionsData,
+ ListFineTuningCheckpointPermissionsResponses,
+ ListFineTuningEventsData,
+ ListFineTuningEventsResponses,
+ ListFineTuningJobCheckpointsData,
+ ListFineTuningJobCheckpointsResponses,
+ ListInputItemsData,
+ ListInputItemsResponses,
+ ListInvitesData,
+ ListInvitesResponses,
+ ListMessagesData,
+ ListMessagesResponses,
+ ListModelsData,
+ ListModelsResponses,
+ ListOrganizationCertificatesData,
+ ListOrganizationCertificatesResponses,
+ ListPaginatedFineTuningJobsData,
+ ListPaginatedFineTuningJobsResponses,
+ ListProjectApiKeysData,
+ ListProjectApiKeysResponses,
+ ListProjectCertificatesData,
+ ListProjectCertificatesResponses,
+ ListProjectRateLimitsData,
+ ListProjectRateLimitsResponses,
+ ListProjectsData,
+ ListProjectServiceAccountsData,
+ ListProjectServiceAccountsErrors,
+ ListProjectServiceAccountsResponses,
+ ListProjectsResponses,
+ ListProjectUsersData,
+ ListProjectUsersErrors,
+ ListProjectUsersResponses,
+ ListRunsData,
+ ListRunsResponses,
+ ListRunStepsData,
+ ListRunStepsResponses,
+ ListUsersData,
+ ListUsersResponses,
+ ListVectorStoreFilesData,
+ ListVectorStoreFilesResponses,
+ ListVectorStoresData,
+ ListVectorStoresResponses,
+ ModifyAssistantData,
+ ModifyAssistantResponses,
+ ModifyCertificateData,
+ ModifyCertificateResponses,
+ ModifyMessageData,
+ ModifyMessageResponses,
+ ModifyProjectData,
+ ModifyProjectErrors,
+ ModifyProjectResponses,
+ ModifyProjectUserData,
+ ModifyProjectUserErrors,
+ ModifyProjectUserResponses,
+ ModifyRunData,
+ ModifyRunResponses,
+ ModifyThreadData,
+ ModifyThreadResponses,
+ ModifyUserData,
+ ModifyUserResponses,
+ ModifyVectorStoreData,
+ ModifyVectorStoreResponses,
+ PauseFineTuningJobData,
+ PauseFineTuningJobResponses,
+ ResumeFineTuningJobData,
+ ResumeFineTuningJobResponses,
+ RetrieveBatchData,
+ RetrieveBatchResponses,
+ RetrieveContainerData,
+ RetrieveContainerFileContentData,
+ RetrieveContainerFileContentResponses,
+ RetrieveContainerFileData,
+ RetrieveContainerFileResponses,
+ RetrieveContainerResponses,
+ RetrieveFileData,
+ RetrieveFileResponses,
+ RetrieveFineTuningJobData,
+ RetrieveFineTuningJobResponses,
+ RetrieveInviteData,
+ RetrieveInviteResponses,
+ RetrieveModelData,
+ RetrieveModelResponses,
+ RetrieveProjectApiKeyData,
+ RetrieveProjectApiKeyResponses,
+ RetrieveProjectData,
+ RetrieveProjectResponses,
+ RetrieveProjectServiceAccountData,
+ RetrieveProjectServiceAccountResponses,
+ RetrieveProjectUserData,
+ RetrieveProjectUserResponses,
+ RetrieveUserData,
+ RetrieveUserResponses,
+ RetrieveVectorStoreFileContentData,
+ RetrieveVectorStoreFileContentResponses,
+ RunGraderData,
+ RunGraderResponses,
+ SearchVectorStoreData,
+ SearchVectorStoreResponses,
+ SubmitToolOuputsToRunData,
+ SubmitToolOuputsToRunResponses,
+ UpdateChatCompletionData,
+ UpdateChatCompletionResponses,
+ UpdateEvalData,
+ UpdateEvalResponses,
+ UpdateProjectRateLimitsData,
+ UpdateProjectRateLimitsErrors,
+ UpdateProjectRateLimitsResponses,
+ UpdateVectorStoreFileAttributesData,
+ UpdateVectorStoreFileAttributesResponses,
+ UploadCertificateData,
+ UploadCertificateResponses,
+ UsageAudioSpeechesData,
+ UsageAudioSpeechesResponses,
+ UsageAudioTranscriptionsData,
+ UsageAudioTranscriptionsResponses,
+ UsageCodeInterpreterSessionsData,
+ UsageCodeInterpreterSessionsResponses,
+ UsageCompletionsData,
+ UsageCompletionsResponses,
+ UsageCostsData,
+ UsageCostsResponses,
+ UsageEmbeddingsData,
+ UsageEmbeddingsResponses,
+ UsageImagesData,
+ UsageImagesResponses,
+ UsageModerationsData,
+ UsageModerationsResponses,
+ UsageVectorStoresData,
+ UsageVectorStoresResponses,
+ ValidateGraderData,
+ ValidateGraderResponses,
+} from './types.gen';
+
+export type Options<
+ TData extends TDataShape = TDataShape,
+ ThrowOnError extends boolean = boolean,
+> = ClientOptions & {
+ /**
+ * You can provide a client instance returned by `createClient()` instead of
+ * individual options. This might be also useful if you want to implement a
+ * custom client.
+ */
+ client?: Client;
+ /**
+ * You can pass arbitrary values through the `meta` object. This can be
+ * used to access values that aren't defined as part of the SDK function.
+ */
+ meta?: Record;
+};
+
+class _HeyApiClient {
+ protected _client: Client = _heyApiClient;
+
+ constructor(args?: { client?: Client }) {
+ if (args?.client) {
+ this._client = args.client;
+ }
+ }
+}
+
+export class OpenAi extends _HeyApiClient {
+ /**
+ * List assistants
+ * Returns a list of assistants.
+ */
+ public listAssistants(
+ options?: Options,
+ ) {
+ return (options?.client ?? this._client).get<
+ ListAssistantsResponses,
+ unknown,
+ ThrowOnError
+ >({
+ security: [
+ {
+ scheme: 'bearer',
+ type: 'http',
+ },
+ ],
+ url: '/assistants',
+ ...options,
+ });
+ }
+
+ /**
+ * Create assistant
+ * Create an assistant with a model and instructions.
+ */
+ public createAssistant(
+ options: Options,
+ ) {
+ return (options.client ?? this._client).post<
+ CreateAssistantResponses,
+ unknown,
+ ThrowOnError
+ >({
+ security: [
+ {
+ scheme: 'bearer',
+ type: 'http',
+ },
+ ],
+ url: '/assistants',
+ ...options,
+ headers: {
+ 'Content-Type': 'application/json',
+ ...options.headers,
+ },
+ });
+ }
+
+ /**
+ * Delete assistant
+ * Delete an assistant.
+ */
+ public deleteAssistant(
+ options: Options,
+ ) {
+ return (options.client ?? this._client).delete<
+ DeleteAssistantResponses,
+ unknown,
+ ThrowOnError
+ >({
+ security: [
+ {
+ scheme: 'bearer',
+ type: 'http',
+ },
+ ],
+ url: '/assistants/{assistant_id}',
+ ...options,
+ });
+ }
+
+ /**
+ * Retrieve assistant
+ * Retrieves an assistant.
+ */
+ public getAssistant(
+ options: Options,
+ ) {
+ return (options.client ?? this._client).get<
+ GetAssistantResponses,
+ unknown,
+ ThrowOnError
+ >({
+ security: [
+ {
+ scheme: 'bearer',
+ type: 'http',
+ },
+ ],
+ url: '/assistants/{assistant_id}',
+ ...options,
+ });
+ }
+
+ /**
+ * Modify assistant
+ * Modifies an assistant.
+ */
+ public modifyAssistant(
+ options: Options,
+ ) {
+ return (options.client ?? this._client).post<
+ ModifyAssistantResponses,
+ unknown,
+ ThrowOnError
+ >({
+ security: [
+ {
+ scheme: 'bearer',
+ type: 'http',
+ },
+ ],
+ url: '/assistants/{assistant_id}',
+ ...options,
+ headers: {
+ 'Content-Type': 'application/json',
+ ...options.headers,
+ },
+ });
+ }
+
+ /**
+ * Create speech
+ * Generates audio from the input text.
+ */
+ public createSpeech(
+ options: Options,
+ ) {
+ return (options.client ?? this._client).post<
+ CreateSpeechResponses,
+ unknown,
+ ThrowOnError
+ >({
+ security: [
+ {
+ scheme: 'bearer',
+ type: 'http',
+ },
+ ],
+ url: '/audio/speech',
+ ...options,
+ headers: {
+ 'Content-Type': 'application/json',
+ ...options.headers,
+ },
+ });
+ }
+
+ /**
+ * Create transcription
+ * Transcribes audio into the input language.
+ */
+ public createTranscription(
+ options: Options,
+ ) {
+ return (options.client ?? this._client).post<
+ CreateTranscriptionResponses,
+ unknown,
+ ThrowOnError
+ >({
+ ...formDataBodySerializer,
+ security: [
+ {
+ scheme: 'bearer',
+ type: 'http',
+ },
+ ],
+ url: '/audio/transcriptions',
+ ...options,
+ headers: {
+ 'Content-Type': null,
+ ...options.headers,
+ },
+ });
+ }
+
+ /**
+ * Create translation
+ * Translates audio into English.
+ */
+ public createTranslation(
+ options: Options,
+ ) {
+ return (options.client ?? this._client).post<
+ CreateTranslationResponses,
+ unknown,
+ ThrowOnError
+ >({
+ ...formDataBodySerializer,
+ security: [
+ {
+ scheme: 'bearer',
+ type: 'http',
+ },
+ ],
+ url: '/audio/translations',
+ ...options,
+ headers: {
+ 'Content-Type': null,
+ ...options.headers,
+ },
+ });
+ }
+
+ /**
+ * List batch
+ * List your organization's batches.
+ */
+ public listBatches(
+ options?: Options,
+ ) {
+ return (options?.client ?? this._client).get<
+ ListBatchesResponses,
+ unknown,
+ ThrowOnError
+ >({
+ security: [
+ {
+ scheme: 'bearer',
+ type: 'http',
+ },
+ ],
+ url: '/batches',
+ ...options,
+ });
+ }
+
+ /**
+ * Create batch
+ * Creates and executes a batch from an uploaded file of requests
+ */
+ public createBatch(
+ options: Options,
+ ) {
+ return (options.client ?? this._client).post<
+ CreateBatchResponses,
+ unknown,
+ ThrowOnError
+ >({
+ security: [
+ {
+ scheme: 'bearer',
+ type: 'http',
+ },
+ ],
+ url: '/batches',
+ ...options,
+ headers: {
+ 'Content-Type': 'application/json',
+ ...options.headers,
+ },
+ });
+ }
+
+ /**
+ * Retrieve batch
+ * Retrieves a batch.
+ */
+ public retrieveBatch(
+ options: Options,
+ ) {
+ return (options.client ?? this._client).get<
+ RetrieveBatchResponses,
+ unknown,
+ ThrowOnError
+ >({
+ security: [
+ {
+ scheme: 'bearer',
+ type: 'http',
+ },
+ ],
+ url: '/batches/{batch_id}',
+ ...options,
+ });
+ }
+
+ /**
+ * Cancel batch
+ * Cancels an in-progress batch. The batch will be in status `cancelling` for up to 10 minutes, before changing to `cancelled`, where it will have partial results (if any) available in the output file.
+ */
+ public cancelBatch(
+ options: Options,
+ ) {
+ return (options.client ?? this._client).post<
+ CancelBatchResponses,
+ unknown,
+ ThrowOnError
+ >({
+ security: [
+ {
+ scheme: 'bearer',
+ type: 'http',
+ },
+ ],
+ url: '/batches/{batch_id}/cancel',
+ ...options,
+ });
+ }
+
+ /**
+ * List Chat Completions
+ * List stored Chat Completions. Only Chat Completions that have been stored
+ * with the `store` parameter set to `true` will be returned.
+ *
+ */
+ public listChatCompletions(
+ options?: Options,
+ ) {
+ return (options?.client ?? this._client).get<
+ ListChatCompletionsResponses,
+ unknown,
+ ThrowOnError
+ >({
+ security: [
+ {
+ scheme: 'bearer',
+ type: 'http',
+ },
+ ],
+ url: '/chat/completions',
+ ...options,
+ });
+ }
+
+ /**
+ * Create chat completion
+ * **Starting a new project?** We recommend trying [Responses](https://platform.openai.com/docs/api-reference/responses)
+ * to take advantage of the latest OpenAI platform features. Compare
+ * [Chat Completions with Responses](https://platform.openai.com/docs/guides/responses-vs-chat-completions?api-mode=responses).
+ *
+ * ---
+ *
+ * Creates a model response for the given chat conversation. Learn more in the
+ * [text generation](https://platform.openai.com/docs/guides/text-generation), [vision](https://platform.openai.com/docs/guides/vision),
+ * and [audio](https://platform.openai.com/docs/guides/audio) guides.
+ *
+ * Parameter support can differ depending on the model used to generate the
+ * response, particularly for newer reasoning models. Parameters that are only
+ * supported for reasoning models are noted below. For the current state of
+ * unsupported parameters in reasoning models,
+ * [refer to the reasoning guide](https://platform.openai.com/docs/guides/reasoning).
+ *
+ */
+ public createChatCompletion(
+ options: Options,
+ ) {
+ return (options.client ?? this._client).post<
+ CreateChatCompletionResponses,
+ unknown,
+ ThrowOnError
+ >({
+ security: [
+ {
+ scheme: 'bearer',
+ type: 'http',
+ },
+ ],
+ url: '/chat/completions',
+ ...options,
+ headers: {
+ 'Content-Type': 'application/json',
+ ...options.headers,
+ },
+ });
+ }
+
+ /**
+ * Delete chat completion
+ * Delete a stored chat completion. Only Chat Completions that have been
+ * created with the `store` parameter set to `true` can be deleted.
+ *
+ */
+ public deleteChatCompletion(
+ options: Options,
+ ) {
+ return (options.client ?? this._client).delete<
+ DeleteChatCompletionResponses,
+ unknown,
+ ThrowOnError
+ >({
+ security: [
+ {
+ scheme: 'bearer',
+ type: 'http',
+ },
+ ],
+ url: '/chat/completions/{completion_id}',
+ ...options,
+ });
+ }
+
+ /**
+ * Get chat completion
+ * Get a stored chat completion. Only Chat Completions that have been created
+ * with the `store` parameter set to `true` will be returned.
+ *
+ */
+ public getChatCompletion(
+ options: Options,
+ ) {
+ return (options.client ?? this._client).get<
+ GetChatCompletionResponses,
+ unknown,
+ ThrowOnError
+ >({
+ security: [
+ {
+ scheme: 'bearer',
+ type: 'http',
+ },
+ ],
+ url: '/chat/completions/{completion_id}',
+ ...options,
+ });
+ }
+
+ /**
+ * Update chat completion
+ * Modify a stored chat completion. Only Chat Completions that have been
+ * created with the `store` parameter set to `true` can be modified. Currently,
+ * the only supported modification is to update the `metadata` field.
+ *
+ */
+ public updateChatCompletion(
+ options: Options,
+ ) {
+ return (options.client ?? this._client).post<
+ UpdateChatCompletionResponses,
+ unknown,
+ ThrowOnError
+ >({
+ security: [
+ {
+ scheme: 'bearer',
+ type: 'http',
+ },
+ ],
+ url: '/chat/completions/{completion_id}',
+ ...options,
+ headers: {
+ 'Content-Type': 'application/json',
+ ...options.headers,
+ },
+ });
+ }
+
+ /**
+ * Get chat messages
+ * Get the messages in a stored chat completion. Only Chat Completions that
+ * have been created with the `store` parameter set to `true` will be
+ * returned.
+ *
+ */
+ public getChatCompletionMessages(
+ options: Options,
+ ) {
+ return (options.client ?? this._client).get<
+ GetChatCompletionMessagesResponses,
+ unknown,
+ ThrowOnError
+ >({
+ security: [
+ {
+ scheme: 'bearer',
+ type: 'http',
+ },
+ ],
+ url: '/chat/completions/{completion_id}/messages',
+ ...options,
+ });
+ }
+
+ /**
+ * Create completion
+ * Creates a completion for the provided prompt and parameters.
+ */
+ public createCompletion(
+ options: Options,
+ ) {
+ return (options.client ?? this._client).post<
+ CreateCompletionResponses,
+ unknown,
+ ThrowOnError
+ >({
+ security: [
+ {
+ scheme: 'bearer',
+ type: 'http',
+ },
+ ],
+ url: '/completions',
+ ...options,
+ headers: {
+ 'Content-Type': 'application/json',
+ ...options.headers,
+ },
+ });
+ }
+
+ /**
+ * List containers
+ * List Containers
+ */
+ public listContainers(
+ options?: Options,
+ ) {
+ return (options?.client ?? this._client).get<
+ ListContainersResponses,
+ unknown,
+ ThrowOnError
+ >({
+ security: [
+ {
+ scheme: 'bearer',
+ type: 'http',
+ },
+ ],
+ url: '/containers',
+ ...options,
+ });
+ }
+
+ /**
+ * Create container
+ * Create Container
+ */
+ public createContainer(
+ options?: Options,
+ ) {
+ return (options?.client ?? this._client).post<
+ CreateContainerResponses,
+ unknown,
+ ThrowOnError
+ >({
+ security: [
+ {
+ scheme: 'bearer',
+ type: 'http',
+ },
+ ],
+ url: '/containers',
+ ...options,
+ headers: {
+ 'Content-Type': 'application/json',
+ ...options?.headers,
+ },
+ });
+ }
+
+ /**
+ * Delete a container
+ * Delete Container
+ */
+ public deleteContainer(
+ options: Options,
+ ) {
+ return (options.client ?? this._client).delete<
+ DeleteContainerResponses,
+ unknown,
+ ThrowOnError
+ >({
+ security: [
+ {
+ scheme: 'bearer',
+ type: 'http',
+ },
+ ],
+ url: '/containers/{container_id}',
+ ...options,
+ });
+ }
+
+ /**
+ * Retrieve container
+ * Retrieve Container
+ */
+ public retrieveContainer(
+ options: Options,
+ ) {
+ return (options.client ?? this._client).get<
+ RetrieveContainerResponses,
+ unknown,
+ ThrowOnError
+ >({
+ security: [
+ {
+ scheme: 'bearer',
+ type: 'http',
+ },
+ ],
+ url: '/containers/{container_id}',
+ ...options,
+ });
+ }
+
+ /**
+ * List container files
+ * List Container files
+ */
+ public listContainerFiles(
+ options: Options,
+ ) {
+ return (options.client ?? this._client).get<
+ ListContainerFilesResponses,
+ unknown,
+ ThrowOnError
+ >({
+ security: [
+ {
+ scheme: 'bearer',
+ type: 'http',
+ },
+ ],
+ url: '/containers/{container_id}/files',
+ ...options,
+ });
+ }
+
+ /**
+ * Create container file
+ * Create a Container File
+ *
+ * You can send either a multipart/form-data request with the raw file content, or a JSON request with a file ID.
+ *
+ */
+ public createContainerFile(
+ options: Options,
+ ) {
+ return (options.client ?? this._client).post<
+ CreateContainerFileResponses,
+ unknown,
+ ThrowOnError
+ >({
+ ...formDataBodySerializer,
+ security: [
+ {
+ scheme: 'bearer',
+ type: 'http',
+ },
+ ],
+ url: '/containers/{container_id}/files',
+ ...options,
+ headers: {
+ 'Content-Type': null,
+ ...options.headers,
+ },
+ });
+ }
+
+ /**
+ * Delete a container file
+ * Delete Container File
+ */
+ public deleteContainerFile(
+ options: Options,
+ ) {
+ return (options.client ?? this._client).delete<
+ DeleteContainerFileResponses,
+ unknown,
+ ThrowOnError
+ >({
+ security: [
+ {
+ scheme: 'bearer',
+ type: 'http',
+ },
+ ],
+ url: '/containers/{container_id}/files/{file_id}',
+ ...options,
+ });
+ }
+
+ /**
+ * Retrieve container file
+ * Retrieve Container File
+ */
+ public retrieveContainerFile(
+ options: Options,
+ ) {
+ return (options.client ?? this._client).get<
+ RetrieveContainerFileResponses,
+ unknown,
+ ThrowOnError
+ >({
+ security: [
+ {
+ scheme: 'bearer',
+ type: 'http',
+ },
+ ],
+ url: '/containers/{container_id}/files/{file_id}',
+ ...options,
+ });
+ }
+
+ /**
+ * Retrieve container file content
+ * Retrieve Container File Content
+ */
+ public retrieveContainerFileContent(
+ options: Options,
+ ) {
+ return (options.client ?? this._client).get<
+ RetrieveContainerFileContentResponses,
+ unknown,
+ ThrowOnError
+ >({
+ security: [
+ {
+ scheme: 'bearer',
+ type: 'http',
+ },
+ ],
+ url: '/containers/{container_id}/files/{file_id}/content',
+ ...options,
+ });
+ }
+
+ /**
+ * Create embeddings
+ * Creates an embedding vector representing the input text.
+ */
+ public createEmbedding(
+ options: Options,
+ ) {
+ return (options.client ?? this._client).post<
+ CreateEmbeddingResponses,
+ unknown,
+ ThrowOnError
+ >({
+ security: [
+ {
+ scheme: 'bearer',
+ type: 'http',
+ },
+ ],
+ url: '/embeddings',
+ ...options,
+ headers: {
+ 'Content-Type': 'application/json',
+ ...options.headers,
+ },
+ });
+ }
+
+ /**
+ * List evals
+ * List evaluations for a project.
+ *
+ */
+ public listEvals(
+ options?: Options,
+ ) {
+ return (options?.client ?? this._client).get<
+ ListEvalsResponses,
+ unknown,
+ ThrowOnError
+ >({
+ security: [
+ {
+ scheme: 'bearer',
+ type: 'http',
+ },
+ ],
+ url: '/evals',
+ ...options,
+ });
+ }
+
+ /**
+ * Create eval
+ * Create the structure of an evaluation that can be used to test a model's performance.
+ * An evaluation is a set of testing criteria and the config for a data source, which dictates the schema of the data used in the evaluation. After creating an evaluation, you can run it on different models and model parameters. We support several types of graders and datasources.
+ * For more information, see the [Evals guide](https://platform.openai.com/docs/guides/evals).
+ *
+ */
+ public createEval(
+ options: Options,
+ ) {
+ return (options.client ?? this._client).post<
+ CreateEvalResponses,
+ unknown,
+ ThrowOnError
+ >({
+ security: [
+ {
+ scheme: 'bearer',
+ type: 'http',
+ },
+ ],
+ url: '/evals',
+ ...options,
+ headers: {
+ 'Content-Type': 'application/json',
+ ...options.headers,
+ },
+ });
+ }
+
+ /**
+ * Delete an eval
+ * Delete an evaluation.
+ *
+ */
+ public deleteEval(
+ options: Options,
+ ) {
+ return (options.client ?? this._client).delete<
+ DeleteEvalResponses,
+ DeleteEvalErrors,
+ ThrowOnError
+ >({
+ security: [
+ {
+ scheme: 'bearer',
+ type: 'http',
+ },
+ ],
+ url: '/evals/{eval_id}',
+ ...options,
+ });
+ }
+
+ /**
+ * Get an eval
+ * Get an evaluation by ID.
+ *
+ */
+ public getEval(
+ options: Options,
+ ) {
+ return (options.client ?? this._client).get<
+ GetEvalResponses,
+ unknown,
+ ThrowOnError
+ >({
+ security: [
+ {
+ scheme: 'bearer',
+ type: 'http',
+ },
+ ],
+ url: '/evals/{eval_id}',
+ ...options,
+ });
+ }
+
+ /**
+ * Update an eval
+ * Update certain properties of an evaluation.
+ *
+ */
+ public updateEval(
+ options: Options,
+ ) {
+ return (options.client ?? this._client).post<
+ UpdateEvalResponses,
+ unknown,
+ ThrowOnError
+ >({
+ security: [
+ {
+ scheme: 'bearer',
+ type: 'http',
+ },
+ ],
+ url: '/evals/{eval_id}',
+ ...options,
+ headers: {
+ 'Content-Type': 'application/json',
+ ...options.headers,
+ },
+ });
+ }
+
+ /**
+ * Get eval runs
+ * Get a list of runs for an evaluation.
+ *
+ */
+ public getEvalRuns(
+ options: Options,
+ ) {
+ return (options.client ?? this._client).get<
+ GetEvalRunsResponses,
+ unknown,
+ ThrowOnError
+ >({
+ security: [
+ {
+ scheme: 'bearer',
+ type: 'http',
+ },
+ ],
+ url: '/evals/{eval_id}/runs',
+ ...options,
+ });
+ }
+
+ /**
+ * Create eval run
+ * Kicks off a new run for a given evaluation, specifying the data source, and what model configuration to use to test. The datasource will be validated against the schema specified in the config of the evaluation.
+ *
+ */
+ public createEvalRun(
+ options: Options,
+ ) {
+ return (options.client ?? this._client).post<
+ CreateEvalRunResponses,
+ CreateEvalRunErrors,
+ ThrowOnError
+ >({
+ security: [
+ {
+ scheme: 'bearer',
+ type: 'http',
+ },
+ ],
+ url: '/evals/{eval_id}/runs',
+ ...options,
+ headers: {
+ 'Content-Type': 'application/json',
+ ...options.headers,
+ },
+ });
+ }
+
+ /**
+ * Delete eval run
+ * Delete an eval run.
+ *
+ */
+ public deleteEvalRun(
+ options: Options,
+ ) {
+ return (options.client ?? this._client).delete<
+ DeleteEvalRunResponses,
+ DeleteEvalRunErrors,
+ ThrowOnError
+ >({
+ security: [
+ {
+ scheme: 'bearer',
+ type: 'http',
+ },
+ ],
+ url: '/evals/{eval_id}/runs/{run_id}',
+ ...options,
+ });
+ }
+
+ /**
+ * Get an eval run
+ * Get an evaluation run by ID.
+ *
+ */
+ public getEvalRun(
+ options: Options,
+ ) {
+ return (options.client ?? this._client).get<
+ GetEvalRunResponses,
+ unknown,
+ ThrowOnError
+ >({
+ security: [
+ {
+ scheme: 'bearer',
+ type: 'http',
+ },
+ ],
+ url: '/evals/{eval_id}/runs/{run_id}',
+ ...options,
+ });
+ }
+
+ /**
+ * Cancel eval run
+ * Cancel an ongoing evaluation run.
+ *
+ */
+ public cancelEvalRun(
+ options: Options,
+ ) {
+ return (options.client ?? this._client).post<
+ CancelEvalRunResponses,
+ unknown,
+ ThrowOnError
+ >({
+ security: [
+ {
+ scheme: 'bearer',
+ type: 'http',
+ },
+ ],
+ url: '/evals/{eval_id}/runs/{run_id}',
+ ...options,
+ });
+ }
+
+ /**
+ * Get eval run output items
+ * Get a list of output items for an evaluation run.
+ *
+ */
+ public getEvalRunOutputItems(
+ options: Options,
+ ) {
+ return (options.client ?? this._client).get<
+ GetEvalRunOutputItemsResponses,
+ unknown,
+ ThrowOnError
+ >({
+ security: [
+ {
+ scheme: 'bearer',
+ type: 'http',
+ },
+ ],
+ url: '/evals/{eval_id}/runs/{run_id}/output_items',
+ ...options,
+ });
+ }
+
+ /**
+ * Get an output item of an eval run
+ * Get an evaluation run output item by ID.
+ *
+ */
+ public getEvalRunOutputItem(
+ options: Options,
+ ) {
+ return (options.client ?? this._client).get<
+ GetEvalRunOutputItemResponses,
+ unknown,
+ ThrowOnError
+ >({
+ security: [
+ {
+ scheme: 'bearer',
+ type: 'http',
+ },
+ ],
+ url: '/evals/{eval_id}/runs/{run_id}/output_items/{output_item_id}',
+ ...options,
+ });
+ }
+
+ /**
+ * List files
+ * Returns a list of files.
+ */
+ public listFiles(
+ options?: Options,
+ ) {
+ return (options?.client ?? this._client).get<
+ ListFilesResponses,
+ unknown,
+ ThrowOnError
+ >({
+ security: [
+ {
+ scheme: 'bearer',
+ type: 'http',
+ },
+ ],
+ url: '/files',
+ ...options,
+ });
+ }
+
+ /**
+ * Upload file
+ * Upload a file that can be used across various endpoints. Individual files can be up to 512 MB, and the size of all files uploaded by one organization can be up to 1 TB.
+ *
+ * The Assistants API supports files up to 2 million tokens and of specific file types. See the [Assistants Tools guide](https://platform.openai.com/docs/assistants/tools) for details.
+ *
+ * The Fine-tuning API only supports `.jsonl` files. The input also has certain required formats for fine-tuning [chat](https://platform.openai.com/docs/api-reference/fine-tuning/chat-input) or [completions](https://platform.openai.com/docs/api-reference/fine-tuning/completions-input) models.
+ *
+ * The Batch API only supports `.jsonl` files up to 200 MB in size. The input also has a specific required [format](https://platform.openai.com/docs/api-reference/batch/request-input).
+ *
+ * Please [contact us](https://help.openai.com/) if you need to increase these storage limits.
+ *
+ */
+ public createFile(
+ options: Options,
+ ) {
+ return (options.client ?? this._client).post<
+ CreateFileResponses,
+ unknown,
+ ThrowOnError
+ >({
+ ...formDataBodySerializer,
+ security: [
+ {
+ scheme: 'bearer',
+ type: 'http',
+ },
+ ],
+ url: '/files',
+ ...options,
+ headers: {
+ 'Content-Type': null,
+ ...options.headers,
+ },
+ });
+ }
+
+ /**
+ * Delete file
+ * Delete a file.
+ */
+ public deleteFile(
+ options: Options,
+ ) {
+ return (options.client ?? this._client).delete<
+ DeleteFileResponses,
+ unknown,
+ ThrowOnError
+ >({
+ security: [
+ {
+ scheme: 'bearer',
+ type: 'http',
+ },
+ ],
+ url: '/files/{file_id}',
+ ...options,
+ });
+ }
+
+ /**
+ * Retrieve file
+ * Returns information about a specific file.
+ */
+ public retrieveFile(
+ options: Options,
+ ) {
+ return (options.client ?? this._client).get<
+ RetrieveFileResponses,
+ unknown,
+ ThrowOnError
+ >({
+ security: [
+ {
+ scheme: 'bearer',
+ type: 'http',
+ },
+ ],
+ url: '/files/{file_id}',
+ ...options,
+ });
+ }
+
+ /**
+ * Retrieve file content
+ * Returns the contents of the specified file.
+ */
+ public downloadFile(
+ options: Options,
+ ) {
+ return (options.client ?? this._client).get<
+ DownloadFileResponses,
+ unknown,
+ ThrowOnError
+ >({
+ security: [
+ {
+ scheme: 'bearer',
+ type: 'http',
+ },
+ ],
+ url: '/files/{file_id}/content',
+ ...options,
+ });
+ }
+
+ /**
+ * Run grader
+ * Run a grader.
+ *
+ */
+ public runGrader(
+ options: Options,
+ ) {
+ return (options.client ?? this._client).post<
+ RunGraderResponses,
+ unknown,
+ ThrowOnError
+ >({
+ security: [
+ {
+ scheme: 'bearer',
+ type: 'http',
+ },
+ ],
+ url: '/fine_tuning/alpha/graders/run',
+ ...options,
+ headers: {
+ 'Content-Type': 'application/json',
+ ...options.headers,
+ },
+ });
+ }
+
+ /**
+ * Validate grader
+ * Validate a grader.
+ *
+ */
+ public validateGrader(
+ options: Options,
+ ) {
+ return (options.client ?? this._client).post<
+ ValidateGraderResponses,
+ unknown,
+ ThrowOnError
+ >({
+ security: [
+ {
+ scheme: 'bearer',
+ type: 'http',
+ },
+ ],
+ url: '/fine_tuning/alpha/graders/validate',
+ ...options,
+ headers: {
+ 'Content-Type': 'application/json',
+ ...options.headers,
+ },
+ });
+ }
+
+ /**
+ * List checkpoint permissions
+ * **NOTE:** This endpoint requires an [admin API key](../admin-api-keys).
+ *
+ * Organization owners can use this endpoint to view all permissions for a fine-tuned model checkpoint.
+ *
+ */
+ public listFineTuningCheckpointPermissions<
+ ThrowOnError extends boolean = false,
+ >(options: Options) {
+ return (options.client ?? this._client).get<
+ ListFineTuningCheckpointPermissionsResponses,
+ unknown,
+ ThrowOnError
+ >({
+ security: [
+ {
+ scheme: 'bearer',
+ type: 'http',
+ },
+ ],
+ url: '/fine_tuning/checkpoints/{fine_tuned_model_checkpoint}/permissions',
+ ...options,
+ });
+ }
+
+ /**
+ * Create checkpoint permissions
+ * **NOTE:** Calling this endpoint requires an [admin API key](../admin-api-keys).
+ *
+ * This enables organization owners to share fine-tuned models with other projects in their organization.
+ *
+ */
+ public createFineTuningCheckpointPermission<
+ ThrowOnError extends boolean = false,
+ >(options: Options) {
+ return (options.client ?? this._client).post<
+ CreateFineTuningCheckpointPermissionResponses,
+ unknown,
+ ThrowOnError
+ >({
+ security: [
+ {
+ scheme: 'bearer',
+ type: 'http',
+ },
+ ],
+ url: '/fine_tuning/checkpoints/{fine_tuned_model_checkpoint}/permissions',
+ ...options,
+ headers: {
+ 'Content-Type': 'application/json',
+ ...options.headers,
+ },
+ });
+ }
+
+ /**
+ * Delete checkpoint permission
+ * **NOTE:** This endpoint requires an [admin API key](../admin-api-keys).
+ *
+ * Organization owners can use this endpoint to delete a permission for a fine-tuned model checkpoint.
+ *
+ */
+ public deleteFineTuningCheckpointPermission<
+ ThrowOnError extends boolean = false,
+ >(options: Options) {
+ return (options.client ?? this._client).delete<
+ DeleteFineTuningCheckpointPermissionResponses,
+ unknown,
+ ThrowOnError
+ >({
+ security: [
+ {
+ scheme: 'bearer',
+ type: 'http',
+ },
+ ],
+ url: '/fine_tuning/checkpoints/{fine_tuned_model_checkpoint}/permissions/{permission_id}',
+ ...options,
+ });
+ }
+
+ /**
+ * List fine-tuning jobs
+ * List your organization's fine-tuning jobs
+ *
+ */
+ public listPaginatedFineTuningJobs(
+ options?: Options,
+ ) {
+ return (options?.client ?? this._client).get<
+ ListPaginatedFineTuningJobsResponses,
+ unknown,
+ ThrowOnError
+ >({
+ security: [
+ {
+ scheme: 'bearer',
+ type: 'http',
+ },
+ ],
+ url: '/fine_tuning/jobs',
+ ...options,
+ });
+ }
+
+ /**
+ * Create fine-tuning job
+ * Creates a fine-tuning job which begins the process of creating a new 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](https://platform.openai.com/docs/guides/model-optimization)
+ *
+ */
+ public createFineTuningJob(
+ options: Options,
+ ) {
+ return (options.client ?? this._client).post<
+ CreateFineTuningJobResponses,
+ unknown,
+ ThrowOnError
+ >({
+ security: [
+ {
+ scheme: 'bearer',
+ type: 'http',
+ },
+ ],
+ url: '/fine_tuning/jobs',
+ ...options,
+ headers: {
+ 'Content-Type': 'application/json',
+ ...options.headers,
+ },
+ });
+ }
+
+ /**
+ * Retrieve fine-tuning job
+ * Get info about a fine-tuning job.
+ *
+ * [Learn more about fine-tuning](https://platform.openai.com/docs/guides/model-optimization)
+ *
+ */
+ public retrieveFineTuningJob(
+ options: Options,
+ ) {
+ return (options.client ?? this._client).get<
+ RetrieveFineTuningJobResponses,
+ unknown,
+ ThrowOnError
+ >({
+ security: [
+ {
+ scheme: 'bearer',
+ type: 'http',
+ },
+ ],
+ url: '/fine_tuning/jobs/{fine_tuning_job_id}',
+ ...options,
+ });
+ }
+
+ /**
+ * Cancel fine-tuning
+ * Immediately cancel a fine-tune job.
+ *
+ */
+ public cancelFineTuningJob(
+ options: Options,
+ ) {
+ return (options.client ?? this._client).post<
+ CancelFineTuningJobResponses,
+ unknown,
+ ThrowOnError
+ >({
+ security: [
+ {
+ scheme: 'bearer',
+ type: 'http',
+ },
+ ],
+ url: '/fine_tuning/jobs/{fine_tuning_job_id}/cancel',
+ ...options,
+ });
+ }
+
+ /**
+ * List fine-tuning checkpoints
+ * List checkpoints for a fine-tuning job.
+ *
+ */
+ public listFineTuningJobCheckpoints(
+ options: Options,
+ ) {
+ return (options.client ?? this._client).get<
+ ListFineTuningJobCheckpointsResponses,
+ unknown,
+ ThrowOnError
+ >({
+ security: [
+ {
+ scheme: 'bearer',
+ type: 'http',
+ },
+ ],
+ url: '/fine_tuning/jobs/{fine_tuning_job_id}/checkpoints',
+ ...options,
+ });
+ }
+
+ /**
+ * List fine-tuning events
+ * Get status updates for a fine-tuning job.
+ *
+ */
+ public listFineTuningEvents(
+ options: Options,
+ ) {
+ return (options.client ?? this._client).get<
+ ListFineTuningEventsResponses,
+ unknown,
+ ThrowOnError
+ >({
+ security: [
+ {
+ scheme: 'bearer',
+ type: 'http',
+ },
+ ],
+ url: '/fine_tuning/jobs/{fine_tuning_job_id}/events',
+ ...options,
+ });
+ }
+
+ /**
+ * Pause fine-tuning
+ * Pause a fine-tune job.
+ *
+ */
+ public pauseFineTuningJob(
+ options: Options,
+ ) {
+ return (options.client ?? this._client).post<
+ PauseFineTuningJobResponses,
+ unknown,
+ ThrowOnError
+ >({
+ security: [
+ {
+ scheme: 'bearer',
+ type: 'http',
+ },
+ ],
+ url: '/fine_tuning/jobs/{fine_tuning_job_id}/pause',
+ ...options,
+ });
+ }
+
+ /**
+ * Resume fine-tuning
+ * Resume a fine-tune job.
+ *
+ */
+ public resumeFineTuningJob(
+ options: Options,
+ ) {
+ return (options.client ?? this._client).post<
+ ResumeFineTuningJobResponses,
+ unknown,
+ ThrowOnError
+ >({
+ security: [
+ {
+ scheme: 'bearer',
+ type: 'http',
+ },
+ ],
+ url: '/fine_tuning/jobs/{fine_tuning_job_id}/resume',
+ ...options,
+ });
+ }
+
+ /**
+ * Create image edit
+ * Creates an edited or extended image given one or more source images and a prompt. This endpoint only supports `gpt-image-1` and `dall-e-2`.
+ */
+ public createImageEdit(
+ options: Options,
+ ) {
+ return (options.client ?? this._client).post<
+ CreateImageEditResponses,
+ unknown,
+ ThrowOnError
+ >({
+ ...formDataBodySerializer,
+ security: [
+ {
+ scheme: 'bearer',
+ type: 'http',
+ },
+ ],
+ url: '/images/edits',
+ ...options,
+ headers: {
+ 'Content-Type': null,
+ ...options.headers,
+ },
+ });
+ }
+
+ /**
+ * Create image
+ * Creates an image given a prompt. [Learn more](https://platform.openai.com/docs/guides/images).
+ *
+ */
+ public createImage(
+ options: Options,
+ ) {
+ return (options.client ?? this._client).post<
+ CreateImageResponses,
+ unknown,
+ ThrowOnError
+ >({
+ security: [
+ {
+ scheme: 'bearer',
+ type: 'http',
+ },
+ ],
+ url: '/images/generations',
+ ...options,
+ headers: {
+ 'Content-Type': 'application/json',
+ ...options.headers,
+ },
+ });
+ }
+
+ /**
+ * Create image variation
+ * Creates a variation of a given image. This endpoint only supports `dall-e-2`.
+ */
+ public createImageVariation(
+ options: Options,
+ ) {
+ return (options.client ?? this._client).post<
+ CreateImageVariationResponses,
+ unknown,
+ ThrowOnError
+ >({
+ ...formDataBodySerializer,
+ security: [
+ {
+ scheme: 'bearer',
+ type: 'http',
+ },
+ ],
+ url: '/images/variations',
+ ...options,
+ headers: {
+ 'Content-Type': null,
+ ...options.headers,
+ },
+ });
+ }
+
+ /**
+ * List models
+ * Lists the currently available models, and provides basic information about each one such as the owner and availability.
+ */
+ public listModels(
+ options?: Options,
+ ) {
+ return (options?.client ?? this._client).get<
+ ListModelsResponses,
+ unknown,
+ ThrowOnError
+ >({
+ security: [
+ {
+ scheme: 'bearer',
+ type: 'http',
+ },
+ ],
+ url: '/models',
+ ...options,
+ });
+ }
+
+ /**
+ * Delete a fine-tuned model
+ * Delete a fine-tuned model. You must have the Owner role in your organization to delete a model.
+ */
+ public deleteModel(
+ options: Options,
+ ) {
+ return (options.client ?? this._client).delete<
+ DeleteModelResponses,
+ unknown,
+ ThrowOnError
+ >({
+ security: [
+ {
+ scheme: 'bearer',
+ type: 'http',
+ },
+ ],
+ url: '/models/{model}',
+ ...options,
+ });
+ }
+
+ /**
+ * Retrieve model
+ * Retrieves a model instance, providing basic information about the model such as the owner and permissioning.
+ */
+ public retrieveModel(
+ options: Options,
+ ) {
+ return (options.client ?? this._client).get<
+ RetrieveModelResponses,
+ unknown,
+ ThrowOnError
+ >({
+ security: [
+ {
+ scheme: 'bearer',
+ type: 'http',
+ },
+ ],
+ url: '/models/{model}',
+ ...options,
+ });
+ }
+
+ /**
+ * Create moderation
+ * Classifies if text and/or image inputs are potentially harmful. Learn
+ * more in the [moderation guide](https://platform.openai.com/docs/guides/moderation).
+ *
+ */
+ public createModeration(
+ options: Options,
+ ) {
+ return (options.client ?? this._client).post<
+ CreateModerationResponses,
+ unknown,
+ ThrowOnError
+ >({
+ security: [
+ {
+ scheme: 'bearer',
+ type: 'http',
+ },
+ ],
+ url: '/moderations',
+ ...options,
+ headers: {
+ 'Content-Type': 'application/json',
+ ...options.headers,
+ },
+ });
+ }
+
+ /**
+ * List all organization and project API keys.
+ * List organization API keys
+ */
+ public adminApiKeysList(
+ options?: Options,
+ ) {
+ return (options?.client ?? this._client).get<
+ AdminApiKeysListResponses,
+ unknown,
+ ThrowOnError
+ >({
+ security: [
+ {
+ scheme: 'bearer',
+ type: 'http',
+ },
+ ],
+ url: '/organization/admin_api_keys',
+ ...options,
+ });
+ }
+
+ /**
+ * Create admin API key
+ * Create an organization admin API key
+ */
+ public adminApiKeysCreate(
+ options: Options,
+ ) {
+ return (options.client ?? this._client).post<
+ AdminApiKeysCreateResponses,
+ unknown,
+ ThrowOnError
+ >({
+ security: [
+ {
+ scheme: 'bearer',
+ type: 'http',
+ },
+ ],
+ url: '/organization/admin_api_keys',
+ ...options,
+ headers: {
+ 'Content-Type': 'application/json',
+ ...options.headers,
+ },
+ });
+ }
+
+ /**
+ * Delete admin API key
+ * Delete an organization admin API key
+ */
+ public adminApiKeysDelete(
+ options: Options,
+ ) {
+ return (options.client ?? this._client).delete<
+ AdminApiKeysDeleteResponses,
+ unknown,
+ ThrowOnError
+ >({
+ security: [
+ {
+ scheme: 'bearer',
+ type: 'http',
+ },
+ ],
+ url: '/organization/admin_api_keys/{key_id}',
+ ...options,
+ });
+ }
+
+ /**
+ * Retrieve admin API key
+ * Retrieve a single organization API key
+ */
+ public adminApiKeysGet(
+ options: Options,
+ ) {
+ return (options.client ?? this._client).get<
+ AdminApiKeysGetResponses,
+ unknown,
+ ThrowOnError
+ >({
+ security: [
+ {
+ scheme: 'bearer',
+ type: 'http',
+ },
+ ],
+ url: '/organization/admin_api_keys/{key_id}',
+ ...options,
+ });
+ }
+
+ /**
+ * List audit logs
+ * List user actions and configuration changes within this organization.
+ */
+ public listAuditLogs(
+ options?: Options,
+ ) {
+ return (options?.client ?? this._client).get<
+ ListAuditLogsResponses,
+ unknown,
+ ThrowOnError
+ >({
+ security: [
+ {
+ scheme: 'bearer',
+ type: 'http',
+ },
+ ],
+ url: '/organization/audit_logs',
+ ...options,
+ });
+ }
+
+ /**
+ * List organization certificates
+ * List uploaded certificates for this organization.
+ */
+ public listOrganizationCertificates(
+ options?: Options,
+ ) {
+ return (options?.client ?? this._client).get<
+ ListOrganizationCertificatesResponses,
+ unknown,
+ ThrowOnError
+ >({
+ security: [
+ {
+ scheme: 'bearer',
+ type: 'http',
+ },
+ ],
+ url: '/organization/certificates',
+ ...options,
+ });
+ }
+
+ /**
+ * Upload certificate
+ * Upload a certificate to the organization. This does **not** automatically activate the certificate.
+ *
+ * Organizations can upload up to 50 certificates.
+ *
+ */
+ public uploadCertificate(
+ options: Options,
+ ) {
+ return (options.client ?? this._client).post<
+ UploadCertificateResponses,
+ unknown,
+ ThrowOnError
+ >({
+ security: [
+ {
+ scheme: 'bearer',
+ type: 'http',
+ },
+ ],
+ url: '/organization/certificates',
+ ...options,
+ headers: {
+ 'Content-Type': 'application/json',
+ ...options.headers,
+ },
+ });
+ }
+
+ /**
+ * Activate certificates for organization
+ * Activate certificates at the organization level.
+ *
+ * You can atomically and idempotently activate up to 10 certificates at a time.
+ *
+ */
+ public activateOrganizationCertificates