Class: OpenAI::Client
- Inherits:
-
Object
- Object
- OpenAI::Client
- Defined in:
- lib/openai_ruby/client.rb
Constant Summary collapse
- BASE_URL =
"https://api.openai.com"
Instance Attribute Summary collapse
-
#api_key ⇒ Object
readonly
Returns the value of attribute api_key.
Instance Method Summary collapse
- #create_completion(params = {}) ⇒ Object
- #create_edit(params = {}) ⇒ Object
-
#initialize(api_key) ⇒ Client
constructor
A new instance of Client.
Constructor Details
#initialize(api_key) ⇒ Client
Returns a new instance of Client.
9 10 11 |
# File 'lib/openai_ruby/client.rb', line 9 def initialize(api_key) @api_key = api_key end |
Instance Attribute Details
#api_key ⇒ Object (readonly)
Returns the value of attribute api_key.
7 8 9 |
# File 'lib/openai_ruby/client.rb', line 7 def api_key @api_key end |
Instance Method Details
#create_completion(params = {}) ⇒ Object
13 14 15 16 17 18 19 |
# File 'lib/openai_ruby/client.rb', line 13 def create_completion(params = {}) Faraday.post( "#{BASE_URL}/v1/completions", params.to_json, headers ) end |
#create_edit(params = {}) ⇒ Object
21 22 23 24 25 26 27 |
# File 'lib/openai_ruby/client.rb', line 21 def create_edit(params = {}) Faraday.post( "#{BASE_URL}/v1/edits", params.to_json, headers ) end |