get_body(), true ); $entity = Models_Virtual_Images_Openai::instance()->create( $data ); if ( empty( $entity->get( 'model' ) ) ) { throw new \Exception( esc_html__( 'The model field is empty.', 'ai-copilot' ), 400 ); } $response = ( new API_Fetch_Image_OpenAi() )->get_data( $entity->getProperties() ); return $this->handle_response( $response ); } catch ( \Throwable $error ) { return $this->handle_response( array( 'code' => $error->getCode(), 'message' => $error->getMessage(), ) ); } } public static function get_rest_method() { return \WP_REST_Server::CREATABLE; } public static function get_rest_args() { return array(); } }