|string|null}>} $result */ $result = $this->transporter->requestObject($payload); return ListResponse::from($result); } /** * Returns information about a specific file. * * @see https://beta.openai.com/docs/api-reference/files/retrieve */ public function retrieve(string $file): RetrieveResponse { $payload = Payload::retrieve('files', $file); /** @var array{id: string, object: string, created_at: int, bytes: int, filename: string, purpose: string, status: string, status_details: array|string|null} $result */ $result = $this->transporter->requestObject($payload); return RetrieveResponse::from($result); } /** * Returns the contents of the specified file. * * @see https://beta.openai.com/docs/api-reference/files/retrieve-content */ public function download(string $file): string { $payload = Payload::retrieveContent('files', $file); return $this->transporter->requestContent($payload); } /** * Upload a file that contains document(s) to be used across various endpoints/features. * * @see https://beta.openai.com/docs/api-reference/files/upload * * @param array $parameters */ public function upload(array $parameters): CreateResponse { $payload = Payload::upload('files', $parameters); /** @var array{id: string, object: string, created_at: int, bytes: int, filename: string, purpose: string, status: string, status_details: array|string|null} $result */ $result = $this->transporter->requestObject($payload); return CreateResponse::from($result); } /** * Delete a file. * * @see https://beta.openai.com/docs/api-reference/files/delete */ public function delete(string $file): DeleteResponse { $payload = Payload::delete('files', $file); /** @var array{id: string, object: string, deleted: bool} $result */ $result = $this->transporter->requestObject($payload); return DeleteResponse::from($result); } }