Skip to main content

create_http_client

Function create_http_client 

Source
pub fn create_http_client(timeout: Option<Duration>) -> Result<Client>
Expand description

Creates an HTTP client with optional timeout configuration.

This function creates a reqwest::Client instance with an optional request timeout. If no timeout is specified, the client will have no timeout limit (the default reqwest behavior).

§Arguments

  • timeout - Optional request timeout duration. If None, no timeout is set.

§Returns

  • Ok(request::Client) - A configured HTTP client
  • Err(OpenAIToolError) - If client creation fails

§Example

use std::time::Duration;
use openai_tools::common::client::create_http_client;

// With timeout (30 seconds)
let client = create_http_client(Some(Duration::from_secs(30))).unwrap();

// Without timeout (default behavior)
let client = create_http_client(None).unwrap();