DEV Community

Cover image for Empowering Your Ruby Projects with the “openai_chatgpt” gem
Sulman Baig
Sulman Baig

Posted on • Originally published at

Empowering Your Ruby Projects with the “openai_chatgpt” gem

As developers, we constantly seek ways to improve and enhance our projects. That's why I'm thrilled to introduce you to openai_chatgpt, a new Ruby gem enabling you to leverage GPT-3.5 Turbo and GPT-3.5 Turbo-0301 in your Ruby projects.

GPT-3.5 Turbo and GPT-3.5 Turbo-0301 are OpenAI's latest language models, capable of producing human-like text with remarkable accuracy. Integrating these models into your Ruby projects can elevate your applications, delivering an unparalleled user experience.

Designed with simplicity, openai_chatgpt is easy to use and integrate into your Ruby projects. It provides a straightforward interface for generating text, allowing you to concentrate on building your application without the complexities of GPT-3.5 Turbo and GPT-3.5 Turbo-0301.

To start with openai_chatgpt, install the gem and authenticate your OpenAI API key. Once you've completed these steps, you can generate text by invoking the ‘completions’ method and providing the prompt you want the model to complete.

The complete documentation of the gem can be found at:

For instance, here's a simple example of using openai_chatgpt in Ruby:

require 'openai_chatgpt'
client = "your-api-key")
resp = client.completions(messages: [{role: "user", content: "Hello World"}])
p resp.results[0].content
Enter fullscreen mode Exit fullscreen mode

This gem enables all options available in OpenAI's official chatgpt documentation. The gem returns excellent OpenStruct results that can be accessed using simple dot notation.

Furthermore, the gem includes a usage object that details your API token usage after each call.

Please don't hesitate to submit PRs and issues to the open-source gem.

Happy Coding!
You can contact me at

Top comments (0)