/** * Create an embedding of a given input. * API Ref: https://platform.openai.com/docs/api-reference/embeddings * * @param string $model The ID of the model to use. * @param mixed $input The input text to get embeddings for, encoded as a string or array of tokens. * @param string|null $user A unique identifier representing your end-user (optional). * * @return object|null * @since 3.2.0 **/ public function create( string $model, $input, ?string $user = null ): ?object { // Build the request path. $path = "/embeddings"; // Set the request data. $data = new \stdClass(); $data->model = $model; $data->input = $input; if ($user !== null) { $data->user = $user; } // Send the post request. return $this->response->get( $this->http->post( $this->uri->get($path), json_encode($data) ) ); }