set_header_name( 'X-Goog-Api-Key' ); } parent::__construct( $default_base_url, $default_api_version, $api_name, $request_handler, $authentication ); } /** * Gets the request URL for the specified model and task. * * @since 0.1.0 * * @param string $path The path to the API endpoint, relative to the base URL and version. * @param array $request_options Optional. The request options. Default empty array. * @return string The request URL. */ protected function get_request_url( string $path, array $request_options = array() ): string { if ( isset( $request_options['stream'] ) && $request_options['stream'] && ! str_ends_with( $path, '?alt=sse' ) ) { $path .= '?alt=sse'; } return parent::get_request_url( $path, $request_options ); } /** * Adds additional default request options to the given request options. * * @since 0.7.0 * * @param array $request_options The request options. * @return array The updated request options. */ protected function add_default_options( array $request_options ): array { $request_options = parent::add_default_options( $request_options ); if ( ! isset( $request_options['headers'] ) ) { $request_options['headers'] = array(); } $request_options['headers']['X-Goog-Api-Client'] = 'ai-services/' . AI_SERVICES_VERSION; return $request_options; } }