openai
Version, currently main branch1 version
- main branchlatestMar 27, 2023
github.com/sferik/openai-crystal
OpenAI API client library to access GPT-3 in Crystal
54 stars
0 dependents
License: MIT
Installation
# Add this to your shard.yml
dependencies:
openai:
github: sferik/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
0.35.1- License
- MIT
- Author
- Erik Berlin <sferik@gmail.com>
Dependencies
Development Dependencies
README
# OpenAI API client library to access GPT-3 in Crystal
[](https://travis-ci.org/sferik/openai-crystal)
## Installation
1. Add the dependency to your `shard.yml`:
```yaml
dependencies:
openai:
github: sferik/openai-crystal
```
2. Run `shards install`
## Usage
```crystal
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
1. Fork it (<https://github.com/sferik/openai-crystal/fork>)
2. Create your feature branch (`git checkout -b my-new-feature`)
3. Commit your changes (`git commit -am 'Add some feature'`)
4. Push to the branch (`git push origin my-new-feature`)
5. Create a new Pull Request
## Contributors
- [Erik Berlin](https://github.com/sferik) - 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
- Mar 27, 2023
- Crystal
0.35.1- Indexed
- yes
Dependents
No indexed shard depends on this one yet.
Repository
github.com/sferik/openai-crystal
Metadata
- Created
- Aug 12, 2026
- Updated
- Aug 12, 2026
- Synced
- Aug 12, 2026
- Versions
- 1