- 
                Notifications
    
You must be signed in to change notification settings  - Fork 6
 
Installation
        Nagendra Dhanakeerthi edited this page Oct 30, 2024 
        ·
        2 revisions
      
    - Ruby 3.0 or higher
 - An OpenAI API key
 - Bundler installed (
gem install bundler) 
Add this line to your application's Gemfile:
gem 'chatgpt-ruby'Then execute:
bundle installInstall the gem directly:
gem install chatgpt-ruby# config/initializers/chatgpt.rb
ChatGPT.configure do |config|
  config.api_key = ENV['OPENAI_API_KEY']
  config.request_timeout = 30
  config.max_retries = 3
  config.default_engine = 'text-davinci-002'
endrequire 'chatgpt'
ChatGPT.configure do |config|
  config.api_key = ENV['OPENAI_API_KEY']
endCreate a .env file:
OPENAI_API_KEY=your-api-key-hereAdd to your .gitignore:
echo ".env" >> .gitignoreTest your installation:
require 'chatgpt'
begin
  client = ChatGPT::Client.new(ENV['OPENAI_API_KEY'])
  response = client.completions("Hello, World!")
  puts "Installation successful!"
rescue => e
  puts "Installation failed: #{e.message}"
end- Linux
 - macOS (Intel and Apple Silicon)
 - Windows
 
- Check the Quick Start Guide
 - Review Configuration Options
 - Explore Usage Examples