$parameters */ public function create(array $parameters): ThreadResponse { $payload = Payload::create('threads', $parameters); /** @var Response}> $response */ $response = $this->transporter->requestObject($payload); return ThreadResponse::from($response->data(), $response->meta()); } /** * Create a thread and run it in one request. * * @see https://platform.openai.com/docs/api-reference/runs/createThreadAndRun * * @param array $parameters */ public function createAndRun(array $parameters): ThreadRunResponse { $payload = Payload::create('threads/runs', $parameters); /** @var Response}}, last_error: ?array{code: string, message: string}, expires_at: ?int, started_at: ?int, cancelled_at: ?int, failed_at: ?int, completed_at: ?int, model: string, instructions: ?string, tools: array}}>, file_ids: array, metadata: array}> $response */ $response = $this->transporter->requestObject($payload); return ThreadRunResponse::from($response->data(), $response->meta()); } /** * Retrieves a thread. * * @see https://platform.openai.com/docs/api-reference/threads/getThread */ public function retrieve(string $id): ThreadResponse { $payload = Payload::retrieve('threads', $id); /** @var Response}> $response */ $response = $this->transporter->requestObject($payload); return ThreadResponse::from($response->data(), $response->meta()); } /** * Modifies a thread. * * @see https://platform.openai.com/docs/api-reference/threads/modifyThread * * @param array $parameters */ public function modify(string $id, array $parameters): ThreadResponse { $payload = Payload::modify('threads', $id, $parameters); /** @var Response}> $response */ $response = $this->transporter->requestObject($payload); return ThreadResponse::from($response->data(), $response->meta()); } /** * Delete an thread. * * @see https://platform.openai.com/docs/api-reference/threads/deleteThread */ public function delete(string $id): ThreadDeleteResponse { $payload = Payload::delete('threads', $id); /** @var Response $response */ $response = $this->transporter->requestObject($payload); return ThreadDeleteResponse::from($response->data(), $response->meta()); } /** * Manage messages attached to a thread. * * @see https://platform.openai.com/docs/api-reference/messages */ public function messages(): ThreadsMessagesContract { return new ThreadsMessages($this->transporter); } /** * Represents an execution run on a thread. * * @see https://platform.openai.com/docs/api-reference/runs */ public function runs(): ThreadsRunsContract { return new ThreadsRuns($this->transporter); } }