openai
Version, currently main branch1 version
- main branchlatestMay 6, 2021
github.com/wyhaines/openai-crystal
OpenAI API client library to access GPT-3 in Crystal
1 stars
1 dependent
License: MIT
Installation
# Add this to your shard.yml
dependencies:
openai:
github: wyhaines/openai-crystal
branch: mainmain is a branch, not a release, so this tracks it rather than pinning a version.
Then run:
shards installshard.yml
- Crystal
1.0.0- License
- MIT
- Author
- Erik Berlin
Dependencies
Development Dependencies
README
OpenAI API client library to access GPT-3 in Crystal
Installation
-
Add the dependency to your
shard.yml:dependencies: openai: github: wyhaines/openai-crystal -
Run
shards install
Usage
require "openai"
openai_client = OpenAI::Client.new(api_key: ENV.fetch("OPENAI_API_KEY"), default_engine: "ada")
# List Engines
openai_client.engines
# Retrieve Engine
openai_client.engine("babbage")
# Search
openai_client.search(documents: ["White House", "hospital", "school"], query: "the president")
# Create Completion
openai_client.completions(prompt: "Once upon a time", max_tokens: 5)
# Stream Completion
openai_client.completions(prompt: "Once upon a time", max_tokens: 100) do |completion|
puts completion.choices.first.text
end
Contributing
- Fork it (https://github.com/sferik/openai-crystal/fork)
- Create your feature branch (
git checkout -b my-new-feature) - Commit your changes (
git commit -am 'Add some feature') - Push to the branch (
git push origin my-new-feature) - Create a new Pull Request
Contributors
- Erik Berlin - creator and maintainer
Documentation
Built from the current release. The first visit to a release nobody has asked for starts its build.
Links
This branch
- Branch
main- Seen
- May 6, 2021
- Crystal
1.0.0- Indexed
- yes
Dependents
Repository
github.com/wyhaines/openai-crystal
Metadata
- Created
- Aug 19, 2026
- Updated
- Nov 22, 2026
- Synced
- Nov 22, 2026
- Versions
- 1