class ChatGPT::Client
- ChatGPT::Client
- Reference
- Object
Overview
Define the Client class that handles communication with the ChatGPT API
Defined in:
chatgpt/client.crConstant Summary
-
API_ENDPOINT =
"https://api.openai.com"
-
Set the API endpoint URL
-
WEB_APP_URL =
"https://chat.openai.com"
-
ChatGPT Web App URL
Constructors
-
.new
Initialize the Client object by building the required HTTP headers
Instance Method Summary
-
#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)
Send a POST request with the provided request data to the ChatGPT API
-
#send_chat_request(request_data)
Send a chat request to the ChatGPT API and log the request and response data if in debug mode
Constructor Detail
Instance Method Detail
Build the required HTTP headers using the API key from environment variables
Fetch the API key from the environment variables or display an error if not present
Send a POST request with the provided request data to the ChatGPT API
Send a chat request to the ChatGPT API and log the request and response data if in debug mode