Created
May 26, 2024 14:57
-
-
Save aik0aaac/53904669917718698461cbcc2eda236a to your computer and use it in GitHub Desktop.
OpenAI API - File APIのRequest/Response内容。(TypeScript-Interface)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* OpenAIへファイルをアップロードするAPIのPOSTリクエスト。 | |
* エンドポイント: | |
https://api.openai.com/v1/files | |
* Docs: https://platform.openai.com/docs/api-reference/files/create | |
*/ | |
export interface IFileUploadRequest { | |
/** | |
* アップロード対象のファイルオブジェクト。 | |
*/ | |
file: File; | |
/** | |
* アップロード対象ファイルの目的。 | |
* - `assistants`: AssistantsとMessage用ファイル | |
* - `vision`: Assistants等で使用する画像ファイル | |
* - `batch`: バッチの入力ファイル | |
* - `fine-tune`: Fine-tuning用データ | |
*/ | |
purpose: "assistants" | "vision" | "batch" | "fine-tune"; | |
} | |
/** | |
* OpenAIにアップロードされたファイル一覧を取得するAPIのGETリクエスト。 | |
* エンドポイント: https://api.openai.com/v1/files | |
* Docs: https://platform.openai.com/docs/api-reference/files/list | |
*/ | |
export interface IFileListRequest { | |
/** | |
* 絞り込み項目。 | |
*/ | |
purpose?: | |
| "assistants" | |
| "assistants_output" | |
| "batch" | |
| "batch_output" | |
| "fine-tune" | |
| "fine-tune-results" | |
| "vision"; | |
} | |
/** | |
* ID指定でOpenAIにアップロードされたファイルを取得するAPIのGETリクエスト。 | |
* エンドポイント: https://api.openai.com/v1/files/{file_id} | |
* Docs: https://platform.openai.com/docs/api-reference/files/retrieve | |
*/ | |
export interface IFileRetrieveRequest { | |
/** | |
* 対象ファイルID。 | |
* パスパラメータへ指定。 | |
*/ | |
file_id: string; | |
} | |
/** | |
* OpenAIへアップロードされたファイルを削除するAPIのDELETEリクエスト。 | |
* エンドポイント: https://api.openai.com/v1/files/{file_id} | |
* Docs: https://platform.openai.com/docs/api-reference/files/delete | |
*/ | |
// eslint-disable-next-line @typescript-eslint/no-empty-interface | |
export interface IFileDeleteRequest { | |
/** | |
* ファイルID。 | |
* パスパラメータへ指定。 | |
*/ | |
file_id: string; | |
} | |
/** | |
* ID指定でOpenAIにアップロードされたファイル内容を取得するAPIのGETリクエスト。 | |
* エンドポイント: https://api.openai.com/v1/files/{file_id}/content | |
* Docs: https://platform.openai.com/docs/api-reference/files/retrieve-contents | |
* 返却値はファイルの中身。 | |
*/ | |
export interface IFileRetrieveContentRequest { | |
/** | |
* 対象ファイルID。 | |
* パスパラメータへ指定。 | |
*/ | |
file_id: string; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* OpenAIへファイルをアップロードするAPIのPOSTレスポンス。 | |
* エンドポイント: https://api.openai.com/v1/files | |
* Docs: https://platform.openai.com/docs/api-reference/files/create | |
*/ | |
// eslint-disable-next-line @typescript-eslint/no-empty-interface | |
export interface IFileUploadResponse extends IApiFileResponse {} | |
/** | |
* OpenAIにアップロードされたファイル一覧を取得するAPIのGETレスポンス。 | |
* エンドポイント: https://api.openai.com/v1/files | |
* Docs: https://platform.openai.com/docs/api-reference/files/list | |
*/ | |
export interface IFileListResponse { | |
data: IApiFileResponse[]; | |
/** | |
* 対象が何のカテゴリかを示す。 | |
*/ | |
object: "list"; | |
} | |
/** | |
* ID指定でOpenAIにアップロードされたファイルを取得するAPIのGETレスポンス。 | |
* エンドポイント: https://api.openai.com/v1/files/{file_id} | |
* Docs: https://platform.openai.com/docs/api-reference/files/retrieve | |
*/ | |
// eslint-disable-next-line @typescript-eslint/no-empty-interface | |
export interface IFileRetrieveResponse extends IApiFileResponse {} | |
/** | |
* OpenAIへアップロードされたファイルを削除するAPIのDELETEレスポンス。 | |
* エンドポイント: https://api.openai.com/v1/files/{file_id} | |
* Docs: https://platform.openai.com/docs/api-reference/files/delete | |
*/ | |
// eslint-disable-next-line @typescript-eslint/no-empty-interface | |
export interface IFileDeleteResponse { | |
/** | |
* ファイルID。 | |
*/ | |
id: string; | |
/** | |
* 対象が何のカテゴリかを示す。 | |
*/ | |
object: "file"; | |
/** | |
* 削除ステータス。 | |
* `true`で削除成功を示す。 | |
*/ | |
deleted: boolean; | |
} | |
/** | |
* OpenAIへアップロードされたファイルデータ。 | |
* Docs: https://platform.openai.com/docs/api-reference/files/object | |
*/ | |
export interface IFileResponse { | |
/** | |
* ファイルID。 | |
*/ | |
id: string; | |
/** | |
* ファイルのバイト数。 | |
*/ | |
bytes: number; | |
/** | |
* ファイルアップロード(OpenAIへファイルが生成された)日時。 | |
* UNIXタイムスタンプ形式。 | |
*/ | |
created_at: number; | |
/** | |
* ファイル名。 | |
*/ | |
filename: string; | |
/** | |
* 対象が何のカテゴリかを示す。 | |
*/ | |
object: "file"; | |
/** | |
* アップロード対象ファイルの目的。 | |
*/ | |
purpose: | |
| "assistants" | |
| "assistants_output" | |
| "batch" | |
| "batch_output" | |
| "fine-tune" | |
| "fine-tune-results" | |
| "vision"; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment