Add this line to your application's Gemfile:

gem 'promptjoy-ruby'

And then execute:

bundle install

Or install it yourself as:

gem install promptjoy-ruby


require 'promptjoy-ruby'

client ='your_api_key')

You can find the API you want to interact with by using its URL. You can find the URL in the endpoint field of the API's page:

api = client.find_by_api_url('')

You can also just find the API by its id:

api = client.find('id')

To call the API, pass in the data as a Hash:

response ={
  key1: 'value1',
  key2: 'value2'


The following example uses PromptJoy to build an API that recommends an open-source software package based on a problem to be solved:

> require 'promptjoy-ruby'
> client ='***********************')
> api = client.find_by_api_url('')
> response ={problem: "queue processing in ruby"})
> puts response

{"software"=>"Sidekiq", "reason"=>"Efficient and reliable background processing 
for Ruby", "github_url"=>""}

Error Handling

If an error occurs during an API call, an instance of PromptjoyRuby::Error is raised with a message indicating the nature of the error.

rescue PromptjoyRuby::Error => e
  puts "An error occurred: #{e.message}"

Last updated