class

ChatGPT::Client

Inherits Reference / Object

Define the Client class that handles communication with the ChatGPT API

Constants

API_ENDPOINT = "https://api.openai.com"

Set the API endpoint URL (host only; path is given per-request)

WEB_APP_URL = "https://chat.openai.com"

ChatGPT Web App URL

Constructors

new

Initialize the Client object by building the required HTTP headers

Source

Instance methods

build_http_headers

Build the required HTTP headers using the API key from environment variables

Source
fetch_api_key

Fetch the API key from the environment variables or display an error if not present

Source
post_request(request_data : PostData)

Send a POST request with the provided request data to the Responses API

Source
send_chat_request(request_data : PostData)

Send a model request to the OpenAI API (Responses API) and log the request and response data if in debug mode.

Source