Class: Asimov::Client
- Inherits:
-
Object
- Object
- Asimov::Client
- Extended by:
- Forwardable
- Defined in:
- lib/asimov/client.rb
Overview
Asimov::Client is the main class which developers will use to interact with OpenAI.
Instance Attribute Summary collapse
-
#api_key ⇒ Object
readonly
Returns the value of attribute api_key.
-
#api_version ⇒ Object
readonly
Returns the value of attribute api_version.
-
#organization_id ⇒ Object
readonly
Returns the value of attribute organization_id.
-
#request_options ⇒ Object
readonly
Returns the value of attribute request_options.
Instance Method Summary collapse
-
#completions ⇒ Object
Use the completions method to access API calls in the /completions URI space.
-
#edits ⇒ Object
Use the edits method to access API calls in the /edits URI space.
-
#embeddings ⇒ Object
Use the embeddings method to access API calls in the /embeddings URI space.
-
#files ⇒ Object
Use the files method to access API calls in the /files URI space.
-
#finetunes ⇒ Object
Use the finetunes method to access API calls in the /fine-tunes URI space.
-
#images ⇒ Object
Use the images method to access API calls in the /images URI space.
-
#initialize(api_key: nil, organization_id: HeadersFactory::NULL_ORGANIZATION_ID, request_options: {}) ⇒ Client
constructor
Creates a new Asimov::Client.
-
#models ⇒ Object
Use the models method to access API calls in the /models URI space.
-
#moderations ⇒ Object
Use the moderations method to access API calls in the /moderations URI space.
Constructor Details
#initialize(api_key: nil, organization_id: HeadersFactory::NULL_ORGANIZATION_ID, request_options: {}) ⇒ Client
Creates a new Asimov::Client. Includes several optional named parameters:
api_key - The OpenAI API key that this Asimov::Client instance will use. If unspecified,
defaults to the application-wide configuration
organization_id - The OpenAI organization identifier that this Asimov::Client instance
will use. If unspecified, defaults to the application-wide configuration.
33 34 35 36 37 38 39 40 |
# File 'lib/asimov/client.rb', line 33 def initialize(api_key: nil, organization_id: HeadersFactory::NULL_ORGANIZATION_ID, request_options: {}) @headers_factory = HeadersFactory.new(api_key, organization_id) @request_options = Asimov.configuration. .merge(Utils::RequestOptionsValidator.validate()) .freeze end |
Instance Attribute Details
#api_key ⇒ Object (readonly)
Returns the value of attribute api_key.
23 24 25 |
# File 'lib/asimov/client.rb', line 23 def api_key @api_key end |
#api_version ⇒ Object (readonly)
Returns the value of attribute api_version.
23 24 25 |
# File 'lib/asimov/client.rb', line 23 def api_version @api_version end |
#organization_id ⇒ Object (readonly)
Returns the value of attribute organization_id.
23 24 25 |
# File 'lib/asimov/client.rb', line 23 def organization_id @organization_id end |
#request_options ⇒ Object (readonly)
Returns the value of attribute request_options.
23 24 25 |
# File 'lib/asimov/client.rb', line 23 def @request_options end |
Instance Method Details
#completions ⇒ Object
Use the completions method to access API calls in the /completions URI space.
46 47 48 |
# File 'lib/asimov/client.rb', line 46 def completions @completions ||= Asimov::ApiV1::Completions.new(client: self) end |
#edits ⇒ Object
Use the edits method to access API calls in the /edits URI space.
53 54 55 |
# File 'lib/asimov/client.rb', line 53 def edits @edits ||= Asimov::ApiV1::Edits.new(client: self) end |
#embeddings ⇒ Object
Use the embeddings method to access API calls in the /embeddings URI space.
60 61 62 |
# File 'lib/asimov/client.rb', line 60 def @embeddings ||= Asimov::ApiV1::Embeddings.new(client: self) end |
#files ⇒ Object
Use the files method to access API calls in the /files URI space.
67 68 69 |
# File 'lib/asimov/client.rb', line 67 def files @files ||= Asimov::ApiV1::Files.new(client: self) end |
#finetunes ⇒ Object
Use the finetunes method to access API calls in the /fine-tunes URI space.
74 75 76 |
# File 'lib/asimov/client.rb', line 74 def finetunes @finetunes ||= Asimov::ApiV1::Finetunes.new(client: self) end |
#images ⇒ Object
Use the images method to access API calls in the /images URI space.
81 82 83 |
# File 'lib/asimov/client.rb', line 81 def images @images ||= Asimov::ApiV1::Images.new(client: self) end |
#models ⇒ Object
Use the models method to access API calls in the /models URI space.
88 89 90 |
# File 'lib/asimov/client.rb', line 88 def models @models ||= Asimov::ApiV1::Models.new(client: self) end |
#moderations ⇒ Object
Use the moderations method to access API calls in the /moderations URI space.
95 96 97 |
# File 'lib/asimov/client.rb', line 95 def moderations @moderations ||= Asimov::ApiV1::Moderations.new(client: self) end |