$parameters */ public function create(array $parameters): ThreadResponse { $payload = Payload::create('threads', $parameters); /** @var Response}, file_search?: array{vector_store_ids: array}}, metadata: array}> $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}}>, metadata: array, usage?: array{prompt_tokens: int, completion_tokens: int|null, total_tokens: int}, incomplete_details: ?array{reason: string}, temperature: float|int|null, top_p: null|float|int, max_prompt_tokens: ?int, max_completion_tokens: ?int, truncation_strategy: array{type: string, last_messages: ?int}, tool_choice: string|array{type: string, function?: array{name: string}}, response_format: string|array{type: 'text'|'json_object'}}> $response */ $response = $this->transporter->requestObject($payload); return ThreadRunResponse::from($response->data(), $response->meta()); } /** * Create a thread and run it in one request, returning a stream. * * @see https://platform.openai.com/docs/api-reference/runs/createThreadAndRun * * @param array $parameters * @return StreamResponse */ public function createAndRunStreamed(array $parameters): StreamResponse { $parameters = $this->setStreamParameter($parameters); $payload = Payload::create('threads/runs', $parameters); $response = $this->transporter->requestStream($payload); return new StreamResponse(ThreadRunStreamResponse::class, $response); } /** * 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}, file_search?: array{vector_store_ids: array}}, metadata: array}> $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}, file_search?: array{vector_store_ids: array}}, metadata: array}> $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); } }