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
Instance methods
build_http_headers
Build the required HTTP headers using the API key from environment variables
fetch_api_key
Fetch the API key from the environment variables or display an error if not present
post_request(request_data : PostData)
Send a POST request with the provided request data to the Responses API
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.