openapi_openai 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (206) hide show
  1. checksums.yaml +7 -0
  2. data/Gemfile +9 -0
  3. data/Gemfile.lock +72 -0
  4. data/README.md +171 -0
  5. data/Rakefile +10 -0
  6. data/bin/bundle +109 -0
  7. data/bin/byebug +27 -0
  8. data/bin/coderay +27 -0
  9. data/bin/htmldiff +27 -0
  10. data/bin/ldiff +27 -0
  11. data/bin/pry +27 -0
  12. data/bin/racc +27 -0
  13. data/bin/rake +27 -0
  14. data/bin/rspec +27 -0
  15. data/bin/rubocop +27 -0
  16. data/bin/ruby-parse +27 -0
  17. data/bin/ruby-rewrite +27 -0
  18. data/docs/ChatCompletionFunctions.md +22 -0
  19. data/docs/ChatCompletionRequestMessage.md +24 -0
  20. data/docs/ChatCompletionRequestMessageFunctionCall.md +20 -0
  21. data/docs/ChatCompletionResponseMessage.md +22 -0
  22. data/docs/ChatCompletionStreamResponseDelta.md +22 -0
  23. data/docs/CreateChatCompletionRequest.md +44 -0
  24. data/docs/CreateChatCompletionRequestFunctionCall.md +49 -0
  25. data/docs/CreateChatCompletionRequestFunctionCallOneOf.md +18 -0
  26. data/docs/CreateChatCompletionRequestModel.md +47 -0
  27. data/docs/CreateChatCompletionRequestStop.md +49 -0
  28. data/docs/CreateChatCompletionResponse.md +28 -0
  29. data/docs/CreateChatCompletionResponseChoicesInner.md +22 -0
  30. data/docs/CreateChatCompletionStreamResponse.md +26 -0
  31. data/docs/CreateChatCompletionStreamResponseChoicesInner.md +22 -0
  32. data/docs/CreateCompletionRequest.md +48 -0
  33. data/docs/CreateCompletionRequestModel.md +47 -0
  34. data/docs/CreateCompletionRequestPrompt.md +53 -0
  35. data/docs/CreateCompletionRequestStop.md +49 -0
  36. data/docs/CreateCompletionResponse.md +28 -0
  37. data/docs/CreateCompletionResponseChoicesInner.md +24 -0
  38. data/docs/CreateCompletionResponseChoicesInnerLogprobs.md +24 -0
  39. data/docs/CreateCompletionResponseUsage.md +22 -0
  40. data/docs/CreateEditRequest.md +28 -0
  41. data/docs/CreateEditRequestModel.md +47 -0
  42. data/docs/CreateEditResponse.md +24 -0
  43. data/docs/CreateEditResponseChoicesInner.md +24 -0
  44. data/docs/CreateEmbeddingRequest.md +22 -0
  45. data/docs/CreateEmbeddingRequestInput.md +53 -0
  46. data/docs/CreateEmbeddingRequestModel.md +47 -0
  47. data/docs/CreateEmbeddingResponse.md +24 -0
  48. data/docs/CreateEmbeddingResponseDataInner.md +22 -0
  49. data/docs/CreateEmbeddingResponseUsage.md +20 -0
  50. data/docs/CreateFineTuneRequest.md +40 -0
  51. data/docs/CreateFineTuneRequestModel.md +47 -0
  52. data/docs/CreateImageRequest.md +26 -0
  53. data/docs/CreateModerationRequest.md +20 -0
  54. data/docs/CreateModerationRequestInput.md +49 -0
  55. data/docs/CreateModerationRequestModel.md +47 -0
  56. data/docs/CreateModerationResponse.md +22 -0
  57. data/docs/CreateModerationResponseResultsInner.md +22 -0
  58. data/docs/CreateModerationResponseResultsInnerCategories.md +30 -0
  59. data/docs/CreateModerationResponseResultsInnerCategoryScores.md +30 -0
  60. data/docs/CreateTranscriptionRequestModel.md +47 -0
  61. data/docs/CreateTranscriptionResponse.md +18 -0
  62. data/docs/CreateTranslationResponse.md +18 -0
  63. data/docs/DeleteFileResponse.md +22 -0
  64. data/docs/DeleteModelResponse.md +22 -0
  65. data/docs/Error.md +24 -0
  66. data/docs/ErrorResponse.md +18 -0
  67. data/docs/FineTune.md +42 -0
  68. data/docs/FineTuneEvent.md +24 -0
  69. data/docs/ImagesResponse.md +20 -0
  70. data/docs/ImagesResponseDataInner.md +20 -0
  71. data/docs/ListFilesResponse.md +20 -0
  72. data/docs/ListFineTuneEventsResponse.md +20 -0
  73. data/docs/ListFineTunesResponse.md +20 -0
  74. data/docs/ListModelsResponse.md +20 -0
  75. data/docs/Model.md +24 -0
  76. data/docs/OpenAIApi.md +1499 -0
  77. data/docs/OpenAIFile.md +32 -0
  78. data/git_push.sh +57 -0
  79. data/lib/openapi_openai/api/open_ai_api.rb +1583 -0
  80. data/lib/openapi_openai/api_client.rb +393 -0
  81. data/lib/openapi_openai/api_error.rb +58 -0
  82. data/lib/openapi_openai/configuration.rb +291 -0
  83. data/lib/openapi_openai/models/chat_completion_functions.rb +244 -0
  84. data/lib/openapi_openai/models/chat_completion_request_message.rb +285 -0
  85. data/lib/openapi_openai/models/chat_completion_request_message_function_call.rb +226 -0
  86. data/lib/openapi_openai/models/chat_completion_response_message.rb +276 -0
  87. data/lib/openapi_openai/models/chat_completion_stream_response_delta.rb +269 -0
  88. data/lib/openapi_openai/models/create_chat_completion_request.rb +537 -0
  89. data/lib/openapi_openai/models/create_chat_completion_request_function_call.rb +106 -0
  90. data/lib/openapi_openai/models/create_chat_completion_request_function_call_one_of.rb +222 -0
  91. data/lib/openapi_openai/models/create_chat_completion_request_model.rb +105 -0
  92. data/lib/openapi_openai/models/create_chat_completion_request_stop.rb +106 -0
  93. data/lib/openapi_openai/models/create_chat_completion_response.rb +296 -0
  94. data/lib/openapi_openai/models/create_chat_completion_response_choices_inner.rb +266 -0
  95. data/lib/openapi_openai/models/create_chat_completion_stream_response.rb +287 -0
  96. data/lib/openapi_openai/models/create_chat_completion_stream_response_choices_inner.rb +266 -0
  97. data/lib/openapi_openai/models/create_completion_request.rb +586 -0
  98. data/lib/openapi_openai/models/create_completion_request_model.rb +105 -0
  99. data/lib/openapi_openai/models/create_completion_request_prompt.rb +108 -0
  100. data/lib/openapi_openai/models/create_completion_request_stop.rb +106 -0
  101. data/lib/openapi_openai/models/create_completion_response.rb +296 -0
  102. data/lib/openapi_openai/models/create_completion_response_choices_inner.rb +299 -0
  103. data/lib/openapi_openai/models/create_completion_response_choices_inner_logprobs.rb +249 -0
  104. data/lib/openapi_openai/models/create_completion_response_usage.rb +253 -0
  105. data/lib/openapi_openai/models/create_edit_request.rb +362 -0
  106. data/lib/openapi_openai/models/create_edit_request_model.rb +105 -0
  107. data/lib/openapi_openai/models/create_edit_response.rb +271 -0
  108. data/lib/openapi_openai/models/create_edit_response_choices_inner.rb +276 -0
  109. data/lib/openapi_openai/models/create_embedding_request.rb +247 -0
  110. data/lib/openapi_openai/models/create_embedding_request_input.rb +108 -0
  111. data/lib/openapi_openai/models/create_embedding_request_model.rb +105 -0
  112. data/lib/openapi_openai/models/create_embedding_response.rb +271 -0
  113. data/lib/openapi_openai/models/create_embedding_response_data_inner.rb +255 -0
  114. data/lib/openapi_openai/models/create_embedding_response_usage.rb +237 -0
  115. data/lib/openapi_openai/models/create_fine_tune_request.rb +374 -0
  116. data/lib/openapi_openai/models/create_fine_tune_request_model.rb +105 -0
  117. data/lib/openapi_openai/models/create_image_request.rb +341 -0
  118. data/lib/openapi_openai/models/create_moderation_request.rb +230 -0
  119. data/lib/openapi_openai/models/create_moderation_request_input.rb +106 -0
  120. data/lib/openapi_openai/models/create_moderation_request_model.rb +105 -0
  121. data/lib/openapi_openai/models/create_moderation_response.rb +255 -0
  122. data/lib/openapi_openai/models/create_moderation_response_results_inner.rb +253 -0
  123. data/lib/openapi_openai/models/create_moderation_response_results_inner_categories.rb +317 -0
  124. data/lib/openapi_openai/models/create_moderation_response_results_inner_category_scores.rb +317 -0
  125. data/lib/openapi_openai/models/create_transcription_request_model.rb +105 -0
  126. data/lib/openapi_openai/models/create_transcription_response.rb +221 -0
  127. data/lib/openapi_openai/models/create_translation_response.rb +221 -0
  128. data/lib/openapi_openai/models/delete_file_response.rb +253 -0
  129. data/lib/openapi_openai/models/delete_model_response.rb +253 -0
  130. data/lib/openapi_openai/models/error.rb +261 -0
  131. data/lib/openapi_openai/models/error_response.rb +221 -0
  132. data/lib/openapi_openai/models/fine_tune.rb +410 -0
  133. data/lib/openapi_openai/models/fine_tune_event.rb +269 -0
  134. data/lib/openapi_openai/models/images_response.rb +239 -0
  135. data/lib/openapi_openai/models/images_response_data_inner.rb +223 -0
  136. data/lib/openapi_openai/models/list_files_response.rb +239 -0
  137. data/lib/openapi_openai/models/list_fine_tune_events_response.rb +239 -0
  138. data/lib/openapi_openai/models/list_fine_tunes_response.rb +239 -0
  139. data/lib/openapi_openai/models/list_models_response.rb +239 -0
  140. data/lib/openapi_openai/models/model.rb +269 -0
  141. data/lib/openapi_openai/models/open_ai_file.rb +320 -0
  142. data/lib/openapi_openai/version.rb +15 -0
  143. data/lib/openapi_openai.rb +99 -0
  144. data/openapi_openai.gemspec +39 -0
  145. data/spec/api/open_ai_api_spec.rb +306 -0
  146. data/spec/models/chat_completion_functions_spec.rb +48 -0
  147. data/spec/models/chat_completion_request_message_function_call_spec.rb +42 -0
  148. data/spec/models/chat_completion_request_message_spec.rb +58 -0
  149. data/spec/models/chat_completion_response_message_spec.rb +52 -0
  150. data/spec/models/chat_completion_stream_response_delta_spec.rb +52 -0
  151. data/spec/models/create_chat_completion_request_function_call_one_of_spec.rb +36 -0
  152. data/spec/models/create_chat_completion_request_function_call_spec.rb +32 -0
  153. data/spec/models/create_chat_completion_request_model_spec.rb +32 -0
  154. data/spec/models/create_chat_completion_request_spec.rb +114 -0
  155. data/spec/models/create_chat_completion_request_stop_spec.rb +32 -0
  156. data/spec/models/create_chat_completion_response_choices_inner_spec.rb +52 -0
  157. data/spec/models/create_chat_completion_response_spec.rb +66 -0
  158. data/spec/models/create_chat_completion_stream_response_choices_inner_spec.rb +52 -0
  159. data/spec/models/create_chat_completion_stream_response_spec.rb +60 -0
  160. data/spec/models/create_completion_request_model_spec.rb +32 -0
  161. data/spec/models/create_completion_request_prompt_spec.rb +32 -0
  162. data/spec/models/create_completion_request_spec.rb +126 -0
  163. data/spec/models/create_completion_request_stop_spec.rb +32 -0
  164. data/spec/models/create_completion_response_choices_inner_logprobs_spec.rb +54 -0
  165. data/spec/models/create_completion_response_choices_inner_spec.rb +58 -0
  166. data/spec/models/create_completion_response_spec.rb +66 -0
  167. data/spec/models/create_completion_response_usage_spec.rb +48 -0
  168. data/spec/models/create_edit_request_model_spec.rb +32 -0
  169. data/spec/models/create_edit_request_spec.rb +66 -0
  170. data/spec/models/create_edit_response_choices_inner_spec.rb +58 -0
  171. data/spec/models/create_edit_response_spec.rb +54 -0
  172. data/spec/models/create_embedding_request_input_spec.rb +32 -0
  173. data/spec/models/create_embedding_request_model_spec.rb +32 -0
  174. data/spec/models/create_embedding_request_spec.rb +48 -0
  175. data/spec/models/create_embedding_response_data_inner_spec.rb +48 -0
  176. data/spec/models/create_embedding_response_spec.rb +54 -0
  177. data/spec/models/create_embedding_response_usage_spec.rb +42 -0
  178. data/spec/models/create_fine_tune_request_model_spec.rb +32 -0
  179. data/spec/models/create_fine_tune_request_spec.rb +102 -0
  180. data/spec/models/create_image_request_spec.rb +68 -0
  181. data/spec/models/create_moderation_request_input_spec.rb +32 -0
  182. data/spec/models/create_moderation_request_model_spec.rb +32 -0
  183. data/spec/models/create_moderation_request_spec.rb +42 -0
  184. data/spec/models/create_moderation_response_results_inner_categories_spec.rb +72 -0
  185. data/spec/models/create_moderation_response_results_inner_category_scores_spec.rb +72 -0
  186. data/spec/models/create_moderation_response_results_inner_spec.rb +48 -0
  187. data/spec/models/create_moderation_response_spec.rb +48 -0
  188. data/spec/models/create_transcription_request_model_spec.rb +32 -0
  189. data/spec/models/create_transcription_response_spec.rb +36 -0
  190. data/spec/models/create_translation_response_spec.rb +36 -0
  191. data/spec/models/delete_file_response_spec.rb +48 -0
  192. data/spec/models/delete_model_response_spec.rb +48 -0
  193. data/spec/models/error_response_spec.rb +36 -0
  194. data/spec/models/error_spec.rb +54 -0
  195. data/spec/models/fine_tune_event_spec.rb +54 -0
  196. data/spec/models/fine_tune_spec.rb +108 -0
  197. data/spec/models/images_response_data_inner_spec.rb +42 -0
  198. data/spec/models/images_response_spec.rb +42 -0
  199. data/spec/models/list_files_response_spec.rb +42 -0
  200. data/spec/models/list_fine_tune_events_response_spec.rb +42 -0
  201. data/spec/models/list_fine_tunes_response_spec.rb +42 -0
  202. data/spec/models/list_models_response_spec.rb +42 -0
  203. data/spec/models/model_spec.rb +54 -0
  204. data/spec/models/open_ai_file_spec.rb +78 -0
  205. data/spec/spec_helper.rb +111 -0
  206. metadata +348 -0
@@ -0,0 +1,1583 @@
1
+ =begin
2
+ #OpenAI API
3
+
4
+ #APIs for sampling from and fine-tuning language models
5
+
6
+ The version of the OpenAPI document: 2.0.0
7
+ Contact: blah+oapicf@cliffano.com
8
+ Generated by: https://openapi-generator.tech
9
+ Generator version: 7.4.0
10
+
11
+ =end
12
+
13
+ require 'cgi'
14
+
15
+ module OpenApiOpenAIClient
16
+ class OpenAIApi
17
+ attr_accessor :api_client
18
+
19
+ def initialize(api_client = ApiClient.default)
20
+ @api_client = api_client
21
+ end
22
+ # Immediately cancel a fine-tune job.
23
+ # @param fine_tune_id [String] The ID of the fine-tune job to cancel
24
+ # @param [Hash] opts the optional parameters
25
+ # @return [FineTune]
26
+ def cancel_fine_tune(fine_tune_id, opts = {})
27
+ data, _status_code, _headers = cancel_fine_tune_with_http_info(fine_tune_id, opts)
28
+ data
29
+ end
30
+
31
+ # Immediately cancel a fine-tune job.
32
+ # @param fine_tune_id [String] The ID of the fine-tune job to cancel
33
+ # @param [Hash] opts the optional parameters
34
+ # @return [Array<(FineTune, Integer, Hash)>] FineTune data, response status code and response headers
35
+ def cancel_fine_tune_with_http_info(fine_tune_id, opts = {})
36
+ if @api_client.config.debugging
37
+ @api_client.config.logger.debug 'Calling API: OpenAIApi.cancel_fine_tune ...'
38
+ end
39
+ # verify the required parameter 'fine_tune_id' is set
40
+ if @api_client.config.client_side_validation && fine_tune_id.nil?
41
+ fail ArgumentError, "Missing the required parameter 'fine_tune_id' when calling OpenAIApi.cancel_fine_tune"
42
+ end
43
+ # resource path
44
+ local_var_path = '/fine-tunes/{fine_tune_id}/cancel'.sub('{' + 'fine_tune_id' + '}', CGI.escape(fine_tune_id.to_s))
45
+
46
+ # query parameters
47
+ query_params = opts[:query_params] || {}
48
+
49
+ # header parameters
50
+ header_params = opts[:header_params] || {}
51
+ # HTTP header 'Accept' (if needed)
52
+ header_params['Accept'] = @api_client.select_header_accept(['application/json'])
53
+
54
+ # form parameters
55
+ form_params = opts[:form_params] || {}
56
+
57
+ # http body (model)
58
+ post_body = opts[:debug_body]
59
+
60
+ # return_type
61
+ return_type = opts[:debug_return_type] || 'FineTune'
62
+
63
+ # auth_names
64
+ auth_names = opts[:debug_auth_names] || []
65
+
66
+ new_options = opts.merge(
67
+ :operation => :"OpenAIApi.cancel_fine_tune",
68
+ :header_params => header_params,
69
+ :query_params => query_params,
70
+ :form_params => form_params,
71
+ :body => post_body,
72
+ :auth_names => auth_names,
73
+ :return_type => return_type
74
+ )
75
+
76
+ data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)
77
+ if @api_client.config.debugging
78
+ @api_client.config.logger.debug "API called: OpenAIApi#cancel_fine_tune\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
79
+ end
80
+ return data, status_code, headers
81
+ end
82
+
83
+ # Creates a model response for the given chat conversation.
84
+ # @param create_chat_completion_request [CreateChatCompletionRequest]
85
+ # @param [Hash] opts the optional parameters
86
+ # @return [CreateChatCompletionResponse]
87
+ def create_chat_completion(create_chat_completion_request, opts = {})
88
+ data, _status_code, _headers = create_chat_completion_with_http_info(create_chat_completion_request, opts)
89
+ data
90
+ end
91
+
92
+ # Creates a model response for the given chat conversation.
93
+ # @param create_chat_completion_request [CreateChatCompletionRequest]
94
+ # @param [Hash] opts the optional parameters
95
+ # @return [Array<(CreateChatCompletionResponse, Integer, Hash)>] CreateChatCompletionResponse data, response status code and response headers
96
+ def create_chat_completion_with_http_info(create_chat_completion_request, opts = {})
97
+ if @api_client.config.debugging
98
+ @api_client.config.logger.debug 'Calling API: OpenAIApi.create_chat_completion ...'
99
+ end
100
+ # verify the required parameter 'create_chat_completion_request' is set
101
+ if @api_client.config.client_side_validation && create_chat_completion_request.nil?
102
+ fail ArgumentError, "Missing the required parameter 'create_chat_completion_request' when calling OpenAIApi.create_chat_completion"
103
+ end
104
+ # resource path
105
+ local_var_path = '/chat/completions'
106
+
107
+ # query parameters
108
+ query_params = opts[:query_params] || {}
109
+
110
+ # header parameters
111
+ header_params = opts[:header_params] || {}
112
+ # HTTP header 'Accept' (if needed)
113
+ header_params['Accept'] = @api_client.select_header_accept(['application/json'])
114
+ # HTTP header 'Content-Type'
115
+ content_type = @api_client.select_header_content_type(['application/json'])
116
+ if !content_type.nil?
117
+ header_params['Content-Type'] = content_type
118
+ end
119
+
120
+ # form parameters
121
+ form_params = opts[:form_params] || {}
122
+
123
+ # http body (model)
124
+ post_body = opts[:debug_body] || @api_client.object_to_http_body(create_chat_completion_request)
125
+
126
+ # return_type
127
+ return_type = opts[:debug_return_type] || 'CreateChatCompletionResponse'
128
+
129
+ # auth_names
130
+ auth_names = opts[:debug_auth_names] || []
131
+
132
+ new_options = opts.merge(
133
+ :operation => :"OpenAIApi.create_chat_completion",
134
+ :header_params => header_params,
135
+ :query_params => query_params,
136
+ :form_params => form_params,
137
+ :body => post_body,
138
+ :auth_names => auth_names,
139
+ :return_type => return_type
140
+ )
141
+
142
+ data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)
143
+ if @api_client.config.debugging
144
+ @api_client.config.logger.debug "API called: OpenAIApi#create_chat_completion\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
145
+ end
146
+ return data, status_code, headers
147
+ end
148
+
149
+ # Creates a completion for the provided prompt and parameters.
150
+ # @param create_completion_request [CreateCompletionRequest]
151
+ # @param [Hash] opts the optional parameters
152
+ # @return [CreateCompletionResponse]
153
+ def create_completion(create_completion_request, opts = {})
154
+ data, _status_code, _headers = create_completion_with_http_info(create_completion_request, opts)
155
+ data
156
+ end
157
+
158
+ # Creates a completion for the provided prompt and parameters.
159
+ # @param create_completion_request [CreateCompletionRequest]
160
+ # @param [Hash] opts the optional parameters
161
+ # @return [Array<(CreateCompletionResponse, Integer, Hash)>] CreateCompletionResponse data, response status code and response headers
162
+ def create_completion_with_http_info(create_completion_request, opts = {})
163
+ if @api_client.config.debugging
164
+ @api_client.config.logger.debug 'Calling API: OpenAIApi.create_completion ...'
165
+ end
166
+ # verify the required parameter 'create_completion_request' is set
167
+ if @api_client.config.client_side_validation && create_completion_request.nil?
168
+ fail ArgumentError, "Missing the required parameter 'create_completion_request' when calling OpenAIApi.create_completion"
169
+ end
170
+ # resource path
171
+ local_var_path = '/completions'
172
+
173
+ # query parameters
174
+ query_params = opts[:query_params] || {}
175
+
176
+ # header parameters
177
+ header_params = opts[:header_params] || {}
178
+ # HTTP header 'Accept' (if needed)
179
+ header_params['Accept'] = @api_client.select_header_accept(['application/json'])
180
+ # HTTP header 'Content-Type'
181
+ content_type = @api_client.select_header_content_type(['application/json'])
182
+ if !content_type.nil?
183
+ header_params['Content-Type'] = content_type
184
+ end
185
+
186
+ # form parameters
187
+ form_params = opts[:form_params] || {}
188
+
189
+ # http body (model)
190
+ post_body = opts[:debug_body] || @api_client.object_to_http_body(create_completion_request)
191
+
192
+ # return_type
193
+ return_type = opts[:debug_return_type] || 'CreateCompletionResponse'
194
+
195
+ # auth_names
196
+ auth_names = opts[:debug_auth_names] || []
197
+
198
+ new_options = opts.merge(
199
+ :operation => :"OpenAIApi.create_completion",
200
+ :header_params => header_params,
201
+ :query_params => query_params,
202
+ :form_params => form_params,
203
+ :body => post_body,
204
+ :auth_names => auth_names,
205
+ :return_type => return_type
206
+ )
207
+
208
+ data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)
209
+ if @api_client.config.debugging
210
+ @api_client.config.logger.debug "API called: OpenAIApi#create_completion\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
211
+ end
212
+ return data, status_code, headers
213
+ end
214
+
215
+ # Creates a new edit for the provided input, instruction, and parameters.
216
+ # @param create_edit_request [CreateEditRequest]
217
+ # @param [Hash] opts the optional parameters
218
+ # @return [CreateEditResponse]
219
+ def create_edit(create_edit_request, opts = {})
220
+ data, _status_code, _headers = create_edit_with_http_info(create_edit_request, opts)
221
+ data
222
+ end
223
+
224
+ # Creates a new edit for the provided input, instruction, and parameters.
225
+ # @param create_edit_request [CreateEditRequest]
226
+ # @param [Hash] opts the optional parameters
227
+ # @return [Array<(CreateEditResponse, Integer, Hash)>] CreateEditResponse data, response status code and response headers
228
+ def create_edit_with_http_info(create_edit_request, opts = {})
229
+ if @api_client.config.debugging
230
+ @api_client.config.logger.debug 'Calling API: OpenAIApi.create_edit ...'
231
+ end
232
+ # verify the required parameter 'create_edit_request' is set
233
+ if @api_client.config.client_side_validation && create_edit_request.nil?
234
+ fail ArgumentError, "Missing the required parameter 'create_edit_request' when calling OpenAIApi.create_edit"
235
+ end
236
+ # resource path
237
+ local_var_path = '/edits'
238
+
239
+ # query parameters
240
+ query_params = opts[:query_params] || {}
241
+
242
+ # header parameters
243
+ header_params = opts[:header_params] || {}
244
+ # HTTP header 'Accept' (if needed)
245
+ header_params['Accept'] = @api_client.select_header_accept(['application/json'])
246
+ # HTTP header 'Content-Type'
247
+ content_type = @api_client.select_header_content_type(['application/json'])
248
+ if !content_type.nil?
249
+ header_params['Content-Type'] = content_type
250
+ end
251
+
252
+ # form parameters
253
+ form_params = opts[:form_params] || {}
254
+
255
+ # http body (model)
256
+ post_body = opts[:debug_body] || @api_client.object_to_http_body(create_edit_request)
257
+
258
+ # return_type
259
+ return_type = opts[:debug_return_type] || 'CreateEditResponse'
260
+
261
+ # auth_names
262
+ auth_names = opts[:debug_auth_names] || []
263
+
264
+ new_options = opts.merge(
265
+ :operation => :"OpenAIApi.create_edit",
266
+ :header_params => header_params,
267
+ :query_params => query_params,
268
+ :form_params => form_params,
269
+ :body => post_body,
270
+ :auth_names => auth_names,
271
+ :return_type => return_type
272
+ )
273
+
274
+ data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)
275
+ if @api_client.config.debugging
276
+ @api_client.config.logger.debug "API called: OpenAIApi#create_edit\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
277
+ end
278
+ return data, status_code, headers
279
+ end
280
+
281
+ # Creates an embedding vector representing the input text.
282
+ # @param create_embedding_request [CreateEmbeddingRequest]
283
+ # @param [Hash] opts the optional parameters
284
+ # @return [CreateEmbeddingResponse]
285
+ def create_embedding(create_embedding_request, opts = {})
286
+ data, _status_code, _headers = create_embedding_with_http_info(create_embedding_request, opts)
287
+ data
288
+ end
289
+
290
+ # Creates an embedding vector representing the input text.
291
+ # @param create_embedding_request [CreateEmbeddingRequest]
292
+ # @param [Hash] opts the optional parameters
293
+ # @return [Array<(CreateEmbeddingResponse, Integer, Hash)>] CreateEmbeddingResponse data, response status code and response headers
294
+ def create_embedding_with_http_info(create_embedding_request, opts = {})
295
+ if @api_client.config.debugging
296
+ @api_client.config.logger.debug 'Calling API: OpenAIApi.create_embedding ...'
297
+ end
298
+ # verify the required parameter 'create_embedding_request' is set
299
+ if @api_client.config.client_side_validation && create_embedding_request.nil?
300
+ fail ArgumentError, "Missing the required parameter 'create_embedding_request' when calling OpenAIApi.create_embedding"
301
+ end
302
+ # resource path
303
+ local_var_path = '/embeddings'
304
+
305
+ # query parameters
306
+ query_params = opts[:query_params] || {}
307
+
308
+ # header parameters
309
+ header_params = opts[:header_params] || {}
310
+ # HTTP header 'Accept' (if needed)
311
+ header_params['Accept'] = @api_client.select_header_accept(['application/json'])
312
+ # HTTP header 'Content-Type'
313
+ content_type = @api_client.select_header_content_type(['application/json'])
314
+ if !content_type.nil?
315
+ header_params['Content-Type'] = content_type
316
+ end
317
+
318
+ # form parameters
319
+ form_params = opts[:form_params] || {}
320
+
321
+ # http body (model)
322
+ post_body = opts[:debug_body] || @api_client.object_to_http_body(create_embedding_request)
323
+
324
+ # return_type
325
+ return_type = opts[:debug_return_type] || 'CreateEmbeddingResponse'
326
+
327
+ # auth_names
328
+ auth_names = opts[:debug_auth_names] || []
329
+
330
+ new_options = opts.merge(
331
+ :operation => :"OpenAIApi.create_embedding",
332
+ :header_params => header_params,
333
+ :query_params => query_params,
334
+ :form_params => form_params,
335
+ :body => post_body,
336
+ :auth_names => auth_names,
337
+ :return_type => return_type
338
+ )
339
+
340
+ data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)
341
+ if @api_client.config.debugging
342
+ @api_client.config.logger.debug "API called: OpenAIApi#create_embedding\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
343
+ end
344
+ return data, status_code, headers
345
+ end
346
+
347
+ # Upload a file that contains document(s) to be used across various endpoints/features. Currently, the size of all the files uploaded by one organization can be up to 1 GB. Please contact us if you need to increase the storage limit.
348
+ # @param file [File] Name of the [JSON Lines](https://jsonlines.readthedocs.io/en/latest/) file to be uploaded. If the &#x60;purpose&#x60; is set to \\\&quot;fine-tune\\\&quot;, each line is a JSON record with \\\&quot;prompt\\\&quot; and \\\&quot;completion\\\&quot; fields representing your [training examples](/docs/guides/fine-tuning/prepare-training-data).
349
+ # @param purpose [String] The intended purpose of the uploaded documents. Use \\\&quot;fine-tune\\\&quot; for [Fine-tuning](/docs/api-reference/fine-tunes). This allows us to validate the format of the uploaded file.
350
+ # @param [Hash] opts the optional parameters
351
+ # @return [OpenAIFile]
352
+ def create_file(file, purpose, opts = {})
353
+ data, _status_code, _headers = create_file_with_http_info(file, purpose, opts)
354
+ data
355
+ end
356
+
357
+ # Upload a file that contains document(s) to be used across various endpoints/features. Currently, the size of all the files uploaded by one organization can be up to 1 GB. Please contact us if you need to increase the storage limit.
358
+ # @param file [File] Name of the [JSON Lines](https://jsonlines.readthedocs.io/en/latest/) file to be uploaded. If the &#x60;purpose&#x60; is set to \\\&quot;fine-tune\\\&quot;, each line is a JSON record with \\\&quot;prompt\\\&quot; and \\\&quot;completion\\\&quot; fields representing your [training examples](/docs/guides/fine-tuning/prepare-training-data).
359
+ # @param purpose [String] The intended purpose of the uploaded documents. Use \\\&quot;fine-tune\\\&quot; for [Fine-tuning](/docs/api-reference/fine-tunes). This allows us to validate the format of the uploaded file.
360
+ # @param [Hash] opts the optional parameters
361
+ # @return [Array<(OpenAIFile, Integer, Hash)>] OpenAIFile data, response status code and response headers
362
+ def create_file_with_http_info(file, purpose, opts = {})
363
+ if @api_client.config.debugging
364
+ @api_client.config.logger.debug 'Calling API: OpenAIApi.create_file ...'
365
+ end
366
+ # verify the required parameter 'file' is set
367
+ if @api_client.config.client_side_validation && file.nil?
368
+ fail ArgumentError, "Missing the required parameter 'file' when calling OpenAIApi.create_file"
369
+ end
370
+ # verify the required parameter 'purpose' is set
371
+ if @api_client.config.client_side_validation && purpose.nil?
372
+ fail ArgumentError, "Missing the required parameter 'purpose' when calling OpenAIApi.create_file"
373
+ end
374
+ # resource path
375
+ local_var_path = '/files'
376
+
377
+ # query parameters
378
+ query_params = opts[:query_params] || {}
379
+
380
+ # header parameters
381
+ header_params = opts[:header_params] || {}
382
+ # HTTP header 'Accept' (if needed)
383
+ header_params['Accept'] = @api_client.select_header_accept(['application/json'])
384
+ # HTTP header 'Content-Type'
385
+ content_type = @api_client.select_header_content_type(['multipart/form-data'])
386
+ if !content_type.nil?
387
+ header_params['Content-Type'] = content_type
388
+ end
389
+
390
+ # form parameters
391
+ form_params = opts[:form_params] || {}
392
+ form_params['file'] = file
393
+ form_params['purpose'] = purpose
394
+
395
+ # http body (model)
396
+ post_body = opts[:debug_body]
397
+
398
+ # return_type
399
+ return_type = opts[:debug_return_type] || 'OpenAIFile'
400
+
401
+ # auth_names
402
+ auth_names = opts[:debug_auth_names] || []
403
+
404
+ new_options = opts.merge(
405
+ :operation => :"OpenAIApi.create_file",
406
+ :header_params => header_params,
407
+ :query_params => query_params,
408
+ :form_params => form_params,
409
+ :body => post_body,
410
+ :auth_names => auth_names,
411
+ :return_type => return_type
412
+ )
413
+
414
+ data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)
415
+ if @api_client.config.debugging
416
+ @api_client.config.logger.debug "API called: OpenAIApi#create_file\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
417
+ end
418
+ return data, status_code, headers
419
+ end
420
+
421
+ # Creates a job that fine-tunes a specified model from a given dataset. Response includes details of the enqueued job including job status and the name of the fine-tuned models once complete. [Learn more about Fine-tuning](/docs/guides/fine-tuning)
422
+ # @param create_fine_tune_request [CreateFineTuneRequest]
423
+ # @param [Hash] opts the optional parameters
424
+ # @return [FineTune]
425
+ def create_fine_tune(create_fine_tune_request, opts = {})
426
+ data, _status_code, _headers = create_fine_tune_with_http_info(create_fine_tune_request, opts)
427
+ data
428
+ end
429
+
430
+ # Creates a job that fine-tunes a specified model from a given dataset. Response includes details of the enqueued job including job status and the name of the fine-tuned models once complete. [Learn more about Fine-tuning](/docs/guides/fine-tuning)
431
+ # @param create_fine_tune_request [CreateFineTuneRequest]
432
+ # @param [Hash] opts the optional parameters
433
+ # @return [Array<(FineTune, Integer, Hash)>] FineTune data, response status code and response headers
434
+ def create_fine_tune_with_http_info(create_fine_tune_request, opts = {})
435
+ if @api_client.config.debugging
436
+ @api_client.config.logger.debug 'Calling API: OpenAIApi.create_fine_tune ...'
437
+ end
438
+ # verify the required parameter 'create_fine_tune_request' is set
439
+ if @api_client.config.client_side_validation && create_fine_tune_request.nil?
440
+ fail ArgumentError, "Missing the required parameter 'create_fine_tune_request' when calling OpenAIApi.create_fine_tune"
441
+ end
442
+ # resource path
443
+ local_var_path = '/fine-tunes'
444
+
445
+ # query parameters
446
+ query_params = opts[:query_params] || {}
447
+
448
+ # header parameters
449
+ header_params = opts[:header_params] || {}
450
+ # HTTP header 'Accept' (if needed)
451
+ header_params['Accept'] = @api_client.select_header_accept(['application/json'])
452
+ # HTTP header 'Content-Type'
453
+ content_type = @api_client.select_header_content_type(['application/json'])
454
+ if !content_type.nil?
455
+ header_params['Content-Type'] = content_type
456
+ end
457
+
458
+ # form parameters
459
+ form_params = opts[:form_params] || {}
460
+
461
+ # http body (model)
462
+ post_body = opts[:debug_body] || @api_client.object_to_http_body(create_fine_tune_request)
463
+
464
+ # return_type
465
+ return_type = opts[:debug_return_type] || 'FineTune'
466
+
467
+ # auth_names
468
+ auth_names = opts[:debug_auth_names] || []
469
+
470
+ new_options = opts.merge(
471
+ :operation => :"OpenAIApi.create_fine_tune",
472
+ :header_params => header_params,
473
+ :query_params => query_params,
474
+ :form_params => form_params,
475
+ :body => post_body,
476
+ :auth_names => auth_names,
477
+ :return_type => return_type
478
+ )
479
+
480
+ data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)
481
+ if @api_client.config.debugging
482
+ @api_client.config.logger.debug "API called: OpenAIApi#create_fine_tune\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
483
+ end
484
+ return data, status_code, headers
485
+ end
486
+
487
+ # Creates an image given a prompt.
488
+ # @param create_image_request [CreateImageRequest]
489
+ # @param [Hash] opts the optional parameters
490
+ # @return [ImagesResponse]
491
+ def create_image(create_image_request, opts = {})
492
+ data, _status_code, _headers = create_image_with_http_info(create_image_request, opts)
493
+ data
494
+ end
495
+
496
+ # Creates an image given a prompt.
497
+ # @param create_image_request [CreateImageRequest]
498
+ # @param [Hash] opts the optional parameters
499
+ # @return [Array<(ImagesResponse, Integer, Hash)>] ImagesResponse data, response status code and response headers
500
+ def create_image_with_http_info(create_image_request, opts = {})
501
+ if @api_client.config.debugging
502
+ @api_client.config.logger.debug 'Calling API: OpenAIApi.create_image ...'
503
+ end
504
+ # verify the required parameter 'create_image_request' is set
505
+ if @api_client.config.client_side_validation && create_image_request.nil?
506
+ fail ArgumentError, "Missing the required parameter 'create_image_request' when calling OpenAIApi.create_image"
507
+ end
508
+ # resource path
509
+ local_var_path = '/images/generations'
510
+
511
+ # query parameters
512
+ query_params = opts[:query_params] || {}
513
+
514
+ # header parameters
515
+ header_params = opts[:header_params] || {}
516
+ # HTTP header 'Accept' (if needed)
517
+ header_params['Accept'] = @api_client.select_header_accept(['application/json'])
518
+ # HTTP header 'Content-Type'
519
+ content_type = @api_client.select_header_content_type(['application/json'])
520
+ if !content_type.nil?
521
+ header_params['Content-Type'] = content_type
522
+ end
523
+
524
+ # form parameters
525
+ form_params = opts[:form_params] || {}
526
+
527
+ # http body (model)
528
+ post_body = opts[:debug_body] || @api_client.object_to_http_body(create_image_request)
529
+
530
+ # return_type
531
+ return_type = opts[:debug_return_type] || 'ImagesResponse'
532
+
533
+ # auth_names
534
+ auth_names = opts[:debug_auth_names] || []
535
+
536
+ new_options = opts.merge(
537
+ :operation => :"OpenAIApi.create_image",
538
+ :header_params => header_params,
539
+ :query_params => query_params,
540
+ :form_params => form_params,
541
+ :body => post_body,
542
+ :auth_names => auth_names,
543
+ :return_type => return_type
544
+ )
545
+
546
+ data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)
547
+ if @api_client.config.debugging
548
+ @api_client.config.logger.debug "API called: OpenAIApi#create_image\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
549
+ end
550
+ return data, status_code, headers
551
+ end
552
+
553
+ # Creates an edited or extended image given an original image and a prompt.
554
+ # @param image [File] The image to edit. Must be a valid PNG file, less than 4MB, and square. If mask is not provided, image must have transparency, which will be used as the mask.
555
+ # @param prompt [String] A text description of the desired image(s). The maximum length is 1000 characters.
556
+ # @param [Hash] opts the optional parameters
557
+ # @option opts [File] :mask An additional image whose fully transparent areas (e.g. where alpha is zero) indicate where &#x60;image&#x60; should be edited. Must be a valid PNG file, less than 4MB, and have the same dimensions as &#x60;image&#x60;.
558
+ # @option opts [Integer] :n The number of images to generate. Must be between 1 and 10. (default to 1)
559
+ # @option opts [String] :size The size of the generated images. Must be one of &#x60;256x256&#x60;, &#x60;512x512&#x60;, or &#x60;1024x1024&#x60;. (default to '1024x1024')
560
+ # @option opts [String] :response_format The format in which the generated images are returned. Must be one of &#x60;url&#x60; or &#x60;b64_json&#x60;. (default to 'url')
561
+ # @option opts [String] :user A unique identifier representing your end-user, which can help OpenAI to monitor and detect abuse. [Learn more](/docs/guides/safety-best-practices/end-user-ids).
562
+ # @return [ImagesResponse]
563
+ def create_image_edit(image, prompt, opts = {})
564
+ data, _status_code, _headers = create_image_edit_with_http_info(image, prompt, opts)
565
+ data
566
+ end
567
+
568
+ # Creates an edited or extended image given an original image and a prompt.
569
+ # @param image [File] The image to edit. Must be a valid PNG file, less than 4MB, and square. If mask is not provided, image must have transparency, which will be used as the mask.
570
+ # @param prompt [String] A text description of the desired image(s). The maximum length is 1000 characters.
571
+ # @param [Hash] opts the optional parameters
572
+ # @option opts [File] :mask An additional image whose fully transparent areas (e.g. where alpha is zero) indicate where &#x60;image&#x60; should be edited. Must be a valid PNG file, less than 4MB, and have the same dimensions as &#x60;image&#x60;.
573
+ # @option opts [Integer] :n The number of images to generate. Must be between 1 and 10. (default to 1)
574
+ # @option opts [String] :size The size of the generated images. Must be one of &#x60;256x256&#x60;, &#x60;512x512&#x60;, or &#x60;1024x1024&#x60;. (default to '1024x1024')
575
+ # @option opts [String] :response_format The format in which the generated images are returned. Must be one of &#x60;url&#x60; or &#x60;b64_json&#x60;. (default to 'url')
576
+ # @option opts [String] :user A unique identifier representing your end-user, which can help OpenAI to monitor and detect abuse. [Learn more](/docs/guides/safety-best-practices/end-user-ids).
577
+ # @return [Array<(ImagesResponse, Integer, Hash)>] ImagesResponse data, response status code and response headers
578
+ def create_image_edit_with_http_info(image, prompt, opts = {})
579
+ if @api_client.config.debugging
580
+ @api_client.config.logger.debug 'Calling API: OpenAIApi.create_image_edit ...'
581
+ end
582
+ # verify the required parameter 'image' is set
583
+ if @api_client.config.client_side_validation && image.nil?
584
+ fail ArgumentError, "Missing the required parameter 'image' when calling OpenAIApi.create_image_edit"
585
+ end
586
+ # verify the required parameter 'prompt' is set
587
+ if @api_client.config.client_side_validation && prompt.nil?
588
+ fail ArgumentError, "Missing the required parameter 'prompt' when calling OpenAIApi.create_image_edit"
589
+ end
590
+ if @api_client.config.client_side_validation && !opts[:'n'].nil? && opts[:'n'] > 10
591
+ fail ArgumentError, 'invalid value for "opts[:"n"]" when calling OpenAIApi.create_image_edit, must be smaller than or equal to 10.'
592
+ end
593
+
594
+ if @api_client.config.client_side_validation && !opts[:'n'].nil? && opts[:'n'] < 1
595
+ fail ArgumentError, 'invalid value for "opts[:"n"]" when calling OpenAIApi.create_image_edit, must be greater than or equal to 1.'
596
+ end
597
+
598
+ allowable_values = ["256x256", "512x512", "1024x1024"]
599
+ if @api_client.config.client_side_validation && opts[:'size'] && !allowable_values.include?(opts[:'size'])
600
+ fail ArgumentError, "invalid value for \"size\", must be one of #{allowable_values}"
601
+ end
602
+ allowable_values = ["url", "b64_json"]
603
+ if @api_client.config.client_side_validation && opts[:'response_format'] && !allowable_values.include?(opts[:'response_format'])
604
+ fail ArgumentError, "invalid value for \"response_format\", must be one of #{allowable_values}"
605
+ end
606
+ # resource path
607
+ local_var_path = '/images/edits'
608
+
609
+ # query parameters
610
+ query_params = opts[:query_params] || {}
611
+
612
+ # header parameters
613
+ header_params = opts[:header_params] || {}
614
+ # HTTP header 'Accept' (if needed)
615
+ header_params['Accept'] = @api_client.select_header_accept(['application/json'])
616
+ # HTTP header 'Content-Type'
617
+ content_type = @api_client.select_header_content_type(['multipart/form-data'])
618
+ if !content_type.nil?
619
+ header_params['Content-Type'] = content_type
620
+ end
621
+
622
+ # form parameters
623
+ form_params = opts[:form_params] || {}
624
+ form_params['image'] = image
625
+ form_params['prompt'] = prompt
626
+ form_params['mask'] = opts[:'mask'] if !opts[:'mask'].nil?
627
+ form_params['n'] = opts[:'n'] if !opts[:'n'].nil?
628
+ form_params['size'] = opts[:'size'] if !opts[:'size'].nil?
629
+ form_params['response_format'] = opts[:'response_format'] if !opts[:'response_format'].nil?
630
+ form_params['user'] = opts[:'user'] if !opts[:'user'].nil?
631
+
632
+ # http body (model)
633
+ post_body = opts[:debug_body]
634
+
635
+ # return_type
636
+ return_type = opts[:debug_return_type] || 'ImagesResponse'
637
+
638
+ # auth_names
639
+ auth_names = opts[:debug_auth_names] || []
640
+
641
+ new_options = opts.merge(
642
+ :operation => :"OpenAIApi.create_image_edit",
643
+ :header_params => header_params,
644
+ :query_params => query_params,
645
+ :form_params => form_params,
646
+ :body => post_body,
647
+ :auth_names => auth_names,
648
+ :return_type => return_type
649
+ )
650
+
651
+ data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)
652
+ if @api_client.config.debugging
653
+ @api_client.config.logger.debug "API called: OpenAIApi#create_image_edit\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
654
+ end
655
+ return data, status_code, headers
656
+ end
657
+
658
+ # Creates a variation of a given image.
659
+ # @param image [File] The image to use as the basis for the variation(s). Must be a valid PNG file, less than 4MB, and square.
660
+ # @param [Hash] opts the optional parameters
661
+ # @option opts [Integer] :n The number of images to generate. Must be between 1 and 10. (default to 1)
662
+ # @option opts [String] :size The size of the generated images. Must be one of &#x60;256x256&#x60;, &#x60;512x512&#x60;, or &#x60;1024x1024&#x60;. (default to '1024x1024')
663
+ # @option opts [String] :response_format The format in which the generated images are returned. Must be one of &#x60;url&#x60; or &#x60;b64_json&#x60;. (default to 'url')
664
+ # @option opts [String] :user A unique identifier representing your end-user, which can help OpenAI to monitor and detect abuse. [Learn more](/docs/guides/safety-best-practices/end-user-ids).
665
+ # @return [ImagesResponse]
666
+ def create_image_variation(image, opts = {})
667
+ data, _status_code, _headers = create_image_variation_with_http_info(image, opts)
668
+ data
669
+ end
670
+
671
+ # Creates a variation of a given image.
672
+ # @param image [File] The image to use as the basis for the variation(s). Must be a valid PNG file, less than 4MB, and square.
673
+ # @param [Hash] opts the optional parameters
674
+ # @option opts [Integer] :n The number of images to generate. Must be between 1 and 10. (default to 1)
675
+ # @option opts [String] :size The size of the generated images. Must be one of &#x60;256x256&#x60;, &#x60;512x512&#x60;, or &#x60;1024x1024&#x60;. (default to '1024x1024')
676
+ # @option opts [String] :response_format The format in which the generated images are returned. Must be one of &#x60;url&#x60; or &#x60;b64_json&#x60;. (default to 'url')
677
+ # @option opts [String] :user A unique identifier representing your end-user, which can help OpenAI to monitor and detect abuse. [Learn more](/docs/guides/safety-best-practices/end-user-ids).
678
+ # @return [Array<(ImagesResponse, Integer, Hash)>] ImagesResponse data, response status code and response headers
679
+ def create_image_variation_with_http_info(image, opts = {})
680
+ if @api_client.config.debugging
681
+ @api_client.config.logger.debug 'Calling API: OpenAIApi.create_image_variation ...'
682
+ end
683
+ # verify the required parameter 'image' is set
684
+ if @api_client.config.client_side_validation && image.nil?
685
+ fail ArgumentError, "Missing the required parameter 'image' when calling OpenAIApi.create_image_variation"
686
+ end
687
+ if @api_client.config.client_side_validation && !opts[:'n'].nil? && opts[:'n'] > 10
688
+ fail ArgumentError, 'invalid value for "opts[:"n"]" when calling OpenAIApi.create_image_variation, must be smaller than or equal to 10.'
689
+ end
690
+
691
+ if @api_client.config.client_side_validation && !opts[:'n'].nil? && opts[:'n'] < 1
692
+ fail ArgumentError, 'invalid value for "opts[:"n"]" when calling OpenAIApi.create_image_variation, must be greater than or equal to 1.'
693
+ end
694
+
695
+ allowable_values = ["256x256", "512x512", "1024x1024"]
696
+ if @api_client.config.client_side_validation && opts[:'size'] && !allowable_values.include?(opts[:'size'])
697
+ fail ArgumentError, "invalid value for \"size\", must be one of #{allowable_values}"
698
+ end
699
+ allowable_values = ["url", "b64_json"]
700
+ if @api_client.config.client_side_validation && opts[:'response_format'] && !allowable_values.include?(opts[:'response_format'])
701
+ fail ArgumentError, "invalid value for \"response_format\", must be one of #{allowable_values}"
702
+ end
703
+ # resource path
704
+ local_var_path = '/images/variations'
705
+
706
+ # query parameters
707
+ query_params = opts[:query_params] || {}
708
+
709
+ # header parameters
710
+ header_params = opts[:header_params] || {}
711
+ # HTTP header 'Accept' (if needed)
712
+ header_params['Accept'] = @api_client.select_header_accept(['application/json'])
713
+ # HTTP header 'Content-Type'
714
+ content_type = @api_client.select_header_content_type(['multipart/form-data'])
715
+ if !content_type.nil?
716
+ header_params['Content-Type'] = content_type
717
+ end
718
+
719
+ # form parameters
720
+ form_params = opts[:form_params] || {}
721
+ form_params['image'] = image
722
+ form_params['n'] = opts[:'n'] if !opts[:'n'].nil?
723
+ form_params['size'] = opts[:'size'] if !opts[:'size'].nil?
724
+ form_params['response_format'] = opts[:'response_format'] if !opts[:'response_format'].nil?
725
+ form_params['user'] = opts[:'user'] if !opts[:'user'].nil?
726
+
727
+ # http body (model)
728
+ post_body = opts[:debug_body]
729
+
730
+ # return_type
731
+ return_type = opts[:debug_return_type] || 'ImagesResponse'
732
+
733
+ # auth_names
734
+ auth_names = opts[:debug_auth_names] || []
735
+
736
+ new_options = opts.merge(
737
+ :operation => :"OpenAIApi.create_image_variation",
738
+ :header_params => header_params,
739
+ :query_params => query_params,
740
+ :form_params => form_params,
741
+ :body => post_body,
742
+ :auth_names => auth_names,
743
+ :return_type => return_type
744
+ )
745
+
746
+ data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)
747
+ if @api_client.config.debugging
748
+ @api_client.config.logger.debug "API called: OpenAIApi#create_image_variation\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
749
+ end
750
+ return data, status_code, headers
751
+ end
752
+
753
+ # Classifies if text violates OpenAI's Content Policy
754
+ # @param create_moderation_request [CreateModerationRequest]
755
+ # @param [Hash] opts the optional parameters
756
+ # @return [CreateModerationResponse]
757
+ def create_moderation(create_moderation_request, opts = {})
758
+ data, _status_code, _headers = create_moderation_with_http_info(create_moderation_request, opts)
759
+ data
760
+ end
761
+
762
+ # Classifies if text violates OpenAI&#39;s Content Policy
763
+ # @param create_moderation_request [CreateModerationRequest]
764
+ # @param [Hash] opts the optional parameters
765
+ # @return [Array<(CreateModerationResponse, Integer, Hash)>] CreateModerationResponse data, response status code and response headers
766
+ def create_moderation_with_http_info(create_moderation_request, opts = {})
767
+ if @api_client.config.debugging
768
+ @api_client.config.logger.debug 'Calling API: OpenAIApi.create_moderation ...'
769
+ end
770
+ # verify the required parameter 'create_moderation_request' is set
771
+ if @api_client.config.client_side_validation && create_moderation_request.nil?
772
+ fail ArgumentError, "Missing the required parameter 'create_moderation_request' when calling OpenAIApi.create_moderation"
773
+ end
774
+ # resource path
775
+ local_var_path = '/moderations'
776
+
777
+ # query parameters
778
+ query_params = opts[:query_params] || {}
779
+
780
+ # header parameters
781
+ header_params = opts[:header_params] || {}
782
+ # HTTP header 'Accept' (if needed)
783
+ header_params['Accept'] = @api_client.select_header_accept(['application/json'])
784
+ # HTTP header 'Content-Type'
785
+ content_type = @api_client.select_header_content_type(['application/json'])
786
+ if !content_type.nil?
787
+ header_params['Content-Type'] = content_type
788
+ end
789
+
790
+ # form parameters
791
+ form_params = opts[:form_params] || {}
792
+
793
+ # http body (model)
794
+ post_body = opts[:debug_body] || @api_client.object_to_http_body(create_moderation_request)
795
+
796
+ # return_type
797
+ return_type = opts[:debug_return_type] || 'CreateModerationResponse'
798
+
799
+ # auth_names
800
+ auth_names = opts[:debug_auth_names] || []
801
+
802
+ new_options = opts.merge(
803
+ :operation => :"OpenAIApi.create_moderation",
804
+ :header_params => header_params,
805
+ :query_params => query_params,
806
+ :form_params => form_params,
807
+ :body => post_body,
808
+ :auth_names => auth_names,
809
+ :return_type => return_type
810
+ )
811
+
812
+ data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)
813
+ if @api_client.config.debugging
814
+ @api_client.config.logger.debug "API called: OpenAIApi#create_moderation\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
815
+ end
816
+ return data, status_code, headers
817
+ end
818
+
819
+ # Transcribes audio into the input language.
820
+ # @param file [File] The audio file object (not file name) to transcribe, in one of these formats: mp3, mp4, mpeg, mpga, m4a, wav, or webm.
821
+ # @param model [CreateTranscriptionRequestModel]
822
+ # @param [Hash] opts the optional parameters
823
+ # @option opts [String] :prompt An optional text to guide the model&#39;s style or continue a previous audio segment. The [prompt](/docs/guides/speech-to-text/prompting) should match the audio language.
824
+ # @option opts [String] :response_format The format of the transcript output, in one of these options: json, text, srt, verbose_json, or vtt. (default to 'json')
825
+ # @option opts [Float] :temperature The sampling temperature, between 0 and 1. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic. If set to 0, the model will use [log probability](https://en.wikipedia.org/wiki/Log_probability) to automatically increase the temperature until certain thresholds are hit. (default to 0)
826
+ # @option opts [String] :language The language of the input audio. Supplying the input language in [ISO-639-1](https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes) format will improve accuracy and latency.
827
+ # @return [CreateTranscriptionResponse]
828
+ def create_transcription(file, model, opts = {})
829
+ data, _status_code, _headers = create_transcription_with_http_info(file, model, opts)
830
+ data
831
+ end
832
+
833
+ # Transcribes audio into the input language.
834
+ # @param file [File] The audio file object (not file name) to transcribe, in one of these formats: mp3, mp4, mpeg, mpga, m4a, wav, or webm.
835
+ # @param model [CreateTranscriptionRequestModel]
836
+ # @param [Hash] opts the optional parameters
837
+ # @option opts [String] :prompt An optional text to guide the model&#39;s style or continue a previous audio segment. The [prompt](/docs/guides/speech-to-text/prompting) should match the audio language.
838
+ # @option opts [String] :response_format The format of the transcript output, in one of these options: json, text, srt, verbose_json, or vtt. (default to 'json')
839
+ # @option opts [Float] :temperature The sampling temperature, between 0 and 1. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic. If set to 0, the model will use [log probability](https://en.wikipedia.org/wiki/Log_probability) to automatically increase the temperature until certain thresholds are hit. (default to 0)
840
+ # @option opts [String] :language The language of the input audio. Supplying the input language in [ISO-639-1](https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes) format will improve accuracy and latency.
841
+ # @return [Array<(CreateTranscriptionResponse, Integer, Hash)>] CreateTranscriptionResponse data, response status code and response headers
842
+ def create_transcription_with_http_info(file, model, opts = {})
843
+ if @api_client.config.debugging
844
+ @api_client.config.logger.debug 'Calling API: OpenAIApi.create_transcription ...'
845
+ end
846
+ # verify the required parameter 'file' is set
847
+ if @api_client.config.client_side_validation && file.nil?
848
+ fail ArgumentError, "Missing the required parameter 'file' when calling OpenAIApi.create_transcription"
849
+ end
850
+ # verify the required parameter 'model' is set
851
+ if @api_client.config.client_side_validation && model.nil?
852
+ fail ArgumentError, "Missing the required parameter 'model' when calling OpenAIApi.create_transcription"
853
+ end
854
+ # resource path
855
+ local_var_path = '/audio/transcriptions'
856
+
857
+ # query parameters
858
+ query_params = opts[:query_params] || {}
859
+
860
+ # header parameters
861
+ header_params = opts[:header_params] || {}
862
+ # HTTP header 'Accept' (if needed)
863
+ header_params['Accept'] = @api_client.select_header_accept(['application/json'])
864
+ # HTTP header 'Content-Type'
865
+ content_type = @api_client.select_header_content_type(['multipart/form-data'])
866
+ if !content_type.nil?
867
+ header_params['Content-Type'] = content_type
868
+ end
869
+
870
+ # form parameters
871
+ form_params = opts[:form_params] || {}
872
+ form_params['file'] = file
873
+ form_params['model'] = model
874
+ form_params['prompt'] = opts[:'prompt'] if !opts[:'prompt'].nil?
875
+ form_params['response_format'] = opts[:'response_format'] if !opts[:'response_format'].nil?
876
+ form_params['temperature'] = opts[:'temperature'] if !opts[:'temperature'].nil?
877
+ form_params['language'] = opts[:'language'] if !opts[:'language'].nil?
878
+
879
+ # http body (model)
880
+ post_body = opts[:debug_body]
881
+
882
+ # return_type
883
+ return_type = opts[:debug_return_type] || 'CreateTranscriptionResponse'
884
+
885
+ # auth_names
886
+ auth_names = opts[:debug_auth_names] || []
887
+
888
+ new_options = opts.merge(
889
+ :operation => :"OpenAIApi.create_transcription",
890
+ :header_params => header_params,
891
+ :query_params => query_params,
892
+ :form_params => form_params,
893
+ :body => post_body,
894
+ :auth_names => auth_names,
895
+ :return_type => return_type
896
+ )
897
+
898
+ data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)
899
+ if @api_client.config.debugging
900
+ @api_client.config.logger.debug "API called: OpenAIApi#create_transcription\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
901
+ end
902
+ return data, status_code, headers
903
+ end
904
+
905
+ # Translates audio into English.
906
+ # @param file [File] The audio file object (not file name) translate, in one of these formats: mp3, mp4, mpeg, mpga, m4a, wav, or webm.
907
+ # @param model [CreateTranscriptionRequestModel]
908
+ # @param [Hash] opts the optional parameters
909
+ # @option opts [String] :prompt An optional text to guide the model&#39;s style or continue a previous audio segment. The [prompt](/docs/guides/speech-to-text/prompting) should be in English.
910
+ # @option opts [String] :response_format The format of the transcript output, in one of these options: json, text, srt, verbose_json, or vtt. (default to 'json')
911
+ # @option opts [Float] :temperature The sampling temperature, between 0 and 1. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic. If set to 0, the model will use [log probability](https://en.wikipedia.org/wiki/Log_probability) to automatically increase the temperature until certain thresholds are hit. (default to 0)
912
+ # @return [CreateTranslationResponse]
913
+ def create_translation(file, model, opts = {})
914
+ data, _status_code, _headers = create_translation_with_http_info(file, model, opts)
915
+ data
916
+ end
917
+
918
+ # Translates audio into English.
919
+ # @param file [File] The audio file object (not file name) translate, in one of these formats: mp3, mp4, mpeg, mpga, m4a, wav, or webm.
920
+ # @param model [CreateTranscriptionRequestModel]
921
+ # @param [Hash] opts the optional parameters
922
+ # @option opts [String] :prompt An optional text to guide the model&#39;s style or continue a previous audio segment. The [prompt](/docs/guides/speech-to-text/prompting) should be in English.
923
+ # @option opts [String] :response_format The format of the transcript output, in one of these options: json, text, srt, verbose_json, or vtt. (default to 'json')
924
+ # @option opts [Float] :temperature The sampling temperature, between 0 and 1. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic. If set to 0, the model will use [log probability](https://en.wikipedia.org/wiki/Log_probability) to automatically increase the temperature until certain thresholds are hit. (default to 0)
925
+ # @return [Array<(CreateTranslationResponse, Integer, Hash)>] CreateTranslationResponse data, response status code and response headers
926
+ def create_translation_with_http_info(file, model, opts = {})
927
+ if @api_client.config.debugging
928
+ @api_client.config.logger.debug 'Calling API: OpenAIApi.create_translation ...'
929
+ end
930
+ # verify the required parameter 'file' is set
931
+ if @api_client.config.client_side_validation && file.nil?
932
+ fail ArgumentError, "Missing the required parameter 'file' when calling OpenAIApi.create_translation"
933
+ end
934
+ # verify the required parameter 'model' is set
935
+ if @api_client.config.client_side_validation && model.nil?
936
+ fail ArgumentError, "Missing the required parameter 'model' when calling OpenAIApi.create_translation"
937
+ end
938
+ # resource path
939
+ local_var_path = '/audio/translations'
940
+
941
+ # query parameters
942
+ query_params = opts[:query_params] || {}
943
+
944
+ # header parameters
945
+ header_params = opts[:header_params] || {}
946
+ # HTTP header 'Accept' (if needed)
947
+ header_params['Accept'] = @api_client.select_header_accept(['application/json'])
948
+ # HTTP header 'Content-Type'
949
+ content_type = @api_client.select_header_content_type(['multipart/form-data'])
950
+ if !content_type.nil?
951
+ header_params['Content-Type'] = content_type
952
+ end
953
+
954
+ # form parameters
955
+ form_params = opts[:form_params] || {}
956
+ form_params['file'] = file
957
+ form_params['model'] = model
958
+ form_params['prompt'] = opts[:'prompt'] if !opts[:'prompt'].nil?
959
+ form_params['response_format'] = opts[:'response_format'] if !opts[:'response_format'].nil?
960
+ form_params['temperature'] = opts[:'temperature'] if !opts[:'temperature'].nil?
961
+
962
+ # http body (model)
963
+ post_body = opts[:debug_body]
964
+
965
+ # return_type
966
+ return_type = opts[:debug_return_type] || 'CreateTranslationResponse'
967
+
968
+ # auth_names
969
+ auth_names = opts[:debug_auth_names] || []
970
+
971
+ new_options = opts.merge(
972
+ :operation => :"OpenAIApi.create_translation",
973
+ :header_params => header_params,
974
+ :query_params => query_params,
975
+ :form_params => form_params,
976
+ :body => post_body,
977
+ :auth_names => auth_names,
978
+ :return_type => return_type
979
+ )
980
+
981
+ data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)
982
+ if @api_client.config.debugging
983
+ @api_client.config.logger.debug "API called: OpenAIApi#create_translation\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
984
+ end
985
+ return data, status_code, headers
986
+ end
987
+
988
+ # Delete a file.
989
+ # @param file_id [String] The ID of the file to use for this request
990
+ # @param [Hash] opts the optional parameters
991
+ # @return [DeleteFileResponse]
992
+ def delete_file(file_id, opts = {})
993
+ data, _status_code, _headers = delete_file_with_http_info(file_id, opts)
994
+ data
995
+ end
996
+
997
+ # Delete a file.
998
+ # @param file_id [String] The ID of the file to use for this request
999
+ # @param [Hash] opts the optional parameters
1000
+ # @return [Array<(DeleteFileResponse, Integer, Hash)>] DeleteFileResponse data, response status code and response headers
1001
+ def delete_file_with_http_info(file_id, opts = {})
1002
+ if @api_client.config.debugging
1003
+ @api_client.config.logger.debug 'Calling API: OpenAIApi.delete_file ...'
1004
+ end
1005
+ # verify the required parameter 'file_id' is set
1006
+ if @api_client.config.client_side_validation && file_id.nil?
1007
+ fail ArgumentError, "Missing the required parameter 'file_id' when calling OpenAIApi.delete_file"
1008
+ end
1009
+ # resource path
1010
+ local_var_path = '/files/{file_id}'.sub('{' + 'file_id' + '}', CGI.escape(file_id.to_s))
1011
+
1012
+ # query parameters
1013
+ query_params = opts[:query_params] || {}
1014
+
1015
+ # header parameters
1016
+ header_params = opts[:header_params] || {}
1017
+ # HTTP header 'Accept' (if needed)
1018
+ header_params['Accept'] = @api_client.select_header_accept(['application/json'])
1019
+
1020
+ # form parameters
1021
+ form_params = opts[:form_params] || {}
1022
+
1023
+ # http body (model)
1024
+ post_body = opts[:debug_body]
1025
+
1026
+ # return_type
1027
+ return_type = opts[:debug_return_type] || 'DeleteFileResponse'
1028
+
1029
+ # auth_names
1030
+ auth_names = opts[:debug_auth_names] || []
1031
+
1032
+ new_options = opts.merge(
1033
+ :operation => :"OpenAIApi.delete_file",
1034
+ :header_params => header_params,
1035
+ :query_params => query_params,
1036
+ :form_params => form_params,
1037
+ :body => post_body,
1038
+ :auth_names => auth_names,
1039
+ :return_type => return_type
1040
+ )
1041
+
1042
+ data, status_code, headers = @api_client.call_api(:DELETE, local_var_path, new_options)
1043
+ if @api_client.config.debugging
1044
+ @api_client.config.logger.debug "API called: OpenAIApi#delete_file\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
1045
+ end
1046
+ return data, status_code, headers
1047
+ end
1048
+
1049
+ # Delete a fine-tuned model. You must have the Owner role in your organization.
1050
+ # @param model [String] The model to delete
1051
+ # @param [Hash] opts the optional parameters
1052
+ # @return [DeleteModelResponse]
1053
+ def delete_model(model, opts = {})
1054
+ data, _status_code, _headers = delete_model_with_http_info(model, opts)
1055
+ data
1056
+ end
1057
+
1058
+ # Delete a fine-tuned model. You must have the Owner role in your organization.
1059
+ # @param model [String] The model to delete
1060
+ # @param [Hash] opts the optional parameters
1061
+ # @return [Array<(DeleteModelResponse, Integer, Hash)>] DeleteModelResponse data, response status code and response headers
1062
+ def delete_model_with_http_info(model, opts = {})
1063
+ if @api_client.config.debugging
1064
+ @api_client.config.logger.debug 'Calling API: OpenAIApi.delete_model ...'
1065
+ end
1066
+ # verify the required parameter 'model' is set
1067
+ if @api_client.config.client_side_validation && model.nil?
1068
+ fail ArgumentError, "Missing the required parameter 'model' when calling OpenAIApi.delete_model"
1069
+ end
1070
+ # resource path
1071
+ local_var_path = '/models/{model}'.sub('{' + 'model' + '}', CGI.escape(model.to_s))
1072
+
1073
+ # query parameters
1074
+ query_params = opts[:query_params] || {}
1075
+
1076
+ # header parameters
1077
+ header_params = opts[:header_params] || {}
1078
+ # HTTP header 'Accept' (if needed)
1079
+ header_params['Accept'] = @api_client.select_header_accept(['application/json'])
1080
+
1081
+ # form parameters
1082
+ form_params = opts[:form_params] || {}
1083
+
1084
+ # http body (model)
1085
+ post_body = opts[:debug_body]
1086
+
1087
+ # return_type
1088
+ return_type = opts[:debug_return_type] || 'DeleteModelResponse'
1089
+
1090
+ # auth_names
1091
+ auth_names = opts[:debug_auth_names] || []
1092
+
1093
+ new_options = opts.merge(
1094
+ :operation => :"OpenAIApi.delete_model",
1095
+ :header_params => header_params,
1096
+ :query_params => query_params,
1097
+ :form_params => form_params,
1098
+ :body => post_body,
1099
+ :auth_names => auth_names,
1100
+ :return_type => return_type
1101
+ )
1102
+
1103
+ data, status_code, headers = @api_client.call_api(:DELETE, local_var_path, new_options)
1104
+ if @api_client.config.debugging
1105
+ @api_client.config.logger.debug "API called: OpenAIApi#delete_model\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
1106
+ end
1107
+ return data, status_code, headers
1108
+ end
1109
+
1110
+ # Returns the contents of the specified file
1111
+ # @param file_id [String] The ID of the file to use for this request
1112
+ # @param [Hash] opts the optional parameters
1113
+ # @return [String]
1114
+ def download_file(file_id, opts = {})
1115
+ data, _status_code, _headers = download_file_with_http_info(file_id, opts)
1116
+ data
1117
+ end
1118
+
1119
+ # Returns the contents of the specified file
1120
+ # @param file_id [String] The ID of the file to use for this request
1121
+ # @param [Hash] opts the optional parameters
1122
+ # @return [Array<(String, Integer, Hash)>] String data, response status code and response headers
1123
+ def download_file_with_http_info(file_id, opts = {})
1124
+ if @api_client.config.debugging
1125
+ @api_client.config.logger.debug 'Calling API: OpenAIApi.download_file ...'
1126
+ end
1127
+ # verify the required parameter 'file_id' is set
1128
+ if @api_client.config.client_side_validation && file_id.nil?
1129
+ fail ArgumentError, "Missing the required parameter 'file_id' when calling OpenAIApi.download_file"
1130
+ end
1131
+ # resource path
1132
+ local_var_path = '/files/{file_id}/content'.sub('{' + 'file_id' + '}', CGI.escape(file_id.to_s))
1133
+
1134
+ # query parameters
1135
+ query_params = opts[:query_params] || {}
1136
+
1137
+ # header parameters
1138
+ header_params = opts[:header_params] || {}
1139
+ # HTTP header 'Accept' (if needed)
1140
+ header_params['Accept'] = @api_client.select_header_accept(['application/json'])
1141
+
1142
+ # form parameters
1143
+ form_params = opts[:form_params] || {}
1144
+
1145
+ # http body (model)
1146
+ post_body = opts[:debug_body]
1147
+
1148
+ # return_type
1149
+ return_type = opts[:debug_return_type] || 'String'
1150
+
1151
+ # auth_names
1152
+ auth_names = opts[:debug_auth_names] || []
1153
+
1154
+ new_options = opts.merge(
1155
+ :operation => :"OpenAIApi.download_file",
1156
+ :header_params => header_params,
1157
+ :query_params => query_params,
1158
+ :form_params => form_params,
1159
+ :body => post_body,
1160
+ :auth_names => auth_names,
1161
+ :return_type => return_type
1162
+ )
1163
+
1164
+ data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
1165
+ if @api_client.config.debugging
1166
+ @api_client.config.logger.debug "API called: OpenAIApi#download_file\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
1167
+ end
1168
+ return data, status_code, headers
1169
+ end
1170
+
1171
+ # Returns a list of files that belong to the user's organization.
1172
+ # @param [Hash] opts the optional parameters
1173
+ # @return [ListFilesResponse]
1174
+ def list_files(opts = {})
1175
+ data, _status_code, _headers = list_files_with_http_info(opts)
1176
+ data
1177
+ end
1178
+
1179
+ # Returns a list of files that belong to the user&#39;s organization.
1180
+ # @param [Hash] opts the optional parameters
1181
+ # @return [Array<(ListFilesResponse, Integer, Hash)>] ListFilesResponse data, response status code and response headers
1182
+ def list_files_with_http_info(opts = {})
1183
+ if @api_client.config.debugging
1184
+ @api_client.config.logger.debug 'Calling API: OpenAIApi.list_files ...'
1185
+ end
1186
+ # resource path
1187
+ local_var_path = '/files'
1188
+
1189
+ # query parameters
1190
+ query_params = opts[:query_params] || {}
1191
+
1192
+ # header parameters
1193
+ header_params = opts[:header_params] || {}
1194
+ # HTTP header 'Accept' (if needed)
1195
+ header_params['Accept'] = @api_client.select_header_accept(['application/json'])
1196
+
1197
+ # form parameters
1198
+ form_params = opts[:form_params] || {}
1199
+
1200
+ # http body (model)
1201
+ post_body = opts[:debug_body]
1202
+
1203
+ # return_type
1204
+ return_type = opts[:debug_return_type] || 'ListFilesResponse'
1205
+
1206
+ # auth_names
1207
+ auth_names = opts[:debug_auth_names] || []
1208
+
1209
+ new_options = opts.merge(
1210
+ :operation => :"OpenAIApi.list_files",
1211
+ :header_params => header_params,
1212
+ :query_params => query_params,
1213
+ :form_params => form_params,
1214
+ :body => post_body,
1215
+ :auth_names => auth_names,
1216
+ :return_type => return_type
1217
+ )
1218
+
1219
+ data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
1220
+ if @api_client.config.debugging
1221
+ @api_client.config.logger.debug "API called: OpenAIApi#list_files\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
1222
+ end
1223
+ return data, status_code, headers
1224
+ end
1225
+
1226
+ # Get fine-grained status updates for a fine-tune job.
1227
+ # @param fine_tune_id [String] The ID of the fine-tune job to get events for.
1228
+ # @param [Hash] opts the optional parameters
1229
+ # @option opts [Boolean] :stream Whether to stream events for the fine-tune job. If set to true, events will be sent as data-only [server-sent events](https://developer.mozilla.org/en-US/docs/Web/API/Server-sent_events/Using_server-sent_events#Event_stream_format) as they become available. The stream will terminate with a &#x60;data: [DONE]&#x60; message when the job is finished (succeeded, cancelled, or failed). If set to false, only events generated so far will be returned. (default to false)
1230
+ # @return [ListFineTuneEventsResponse]
1231
+ def list_fine_tune_events(fine_tune_id, opts = {})
1232
+ data, _status_code, _headers = list_fine_tune_events_with_http_info(fine_tune_id, opts)
1233
+ data
1234
+ end
1235
+
1236
+ # Get fine-grained status updates for a fine-tune job.
1237
+ # @param fine_tune_id [String] The ID of the fine-tune job to get events for.
1238
+ # @param [Hash] opts the optional parameters
1239
+ # @option opts [Boolean] :stream Whether to stream events for the fine-tune job. If set to true, events will be sent as data-only [server-sent events](https://developer.mozilla.org/en-US/docs/Web/API/Server-sent_events/Using_server-sent_events#Event_stream_format) as they become available. The stream will terminate with a &#x60;data: [DONE]&#x60; message when the job is finished (succeeded, cancelled, or failed). If set to false, only events generated so far will be returned. (default to false)
1240
+ # @return [Array<(ListFineTuneEventsResponse, Integer, Hash)>] ListFineTuneEventsResponse data, response status code and response headers
1241
+ def list_fine_tune_events_with_http_info(fine_tune_id, opts = {})
1242
+ if @api_client.config.debugging
1243
+ @api_client.config.logger.debug 'Calling API: OpenAIApi.list_fine_tune_events ...'
1244
+ end
1245
+ # verify the required parameter 'fine_tune_id' is set
1246
+ if @api_client.config.client_side_validation && fine_tune_id.nil?
1247
+ fail ArgumentError, "Missing the required parameter 'fine_tune_id' when calling OpenAIApi.list_fine_tune_events"
1248
+ end
1249
+ # resource path
1250
+ local_var_path = '/fine-tunes/{fine_tune_id}/events'.sub('{' + 'fine_tune_id' + '}', CGI.escape(fine_tune_id.to_s))
1251
+
1252
+ # query parameters
1253
+ query_params = opts[:query_params] || {}
1254
+ query_params[:'stream'] = opts[:'stream'] if !opts[:'stream'].nil?
1255
+
1256
+ # header parameters
1257
+ header_params = opts[:header_params] || {}
1258
+ # HTTP header 'Accept' (if needed)
1259
+ header_params['Accept'] = @api_client.select_header_accept(['application/json'])
1260
+
1261
+ # form parameters
1262
+ form_params = opts[:form_params] || {}
1263
+
1264
+ # http body (model)
1265
+ post_body = opts[:debug_body]
1266
+
1267
+ # return_type
1268
+ return_type = opts[:debug_return_type] || 'ListFineTuneEventsResponse'
1269
+
1270
+ # auth_names
1271
+ auth_names = opts[:debug_auth_names] || []
1272
+
1273
+ new_options = opts.merge(
1274
+ :operation => :"OpenAIApi.list_fine_tune_events",
1275
+ :header_params => header_params,
1276
+ :query_params => query_params,
1277
+ :form_params => form_params,
1278
+ :body => post_body,
1279
+ :auth_names => auth_names,
1280
+ :return_type => return_type
1281
+ )
1282
+
1283
+ data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
1284
+ if @api_client.config.debugging
1285
+ @api_client.config.logger.debug "API called: OpenAIApi#list_fine_tune_events\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
1286
+ end
1287
+ return data, status_code, headers
1288
+ end
1289
+
1290
+ # List your organization's fine-tuning jobs
1291
+ # @param [Hash] opts the optional parameters
1292
+ # @return [ListFineTunesResponse]
1293
+ def list_fine_tunes(opts = {})
1294
+ data, _status_code, _headers = list_fine_tunes_with_http_info(opts)
1295
+ data
1296
+ end
1297
+
1298
+ # List your organization&#39;s fine-tuning jobs
1299
+ # @param [Hash] opts the optional parameters
1300
+ # @return [Array<(ListFineTunesResponse, Integer, Hash)>] ListFineTunesResponse data, response status code and response headers
1301
+ def list_fine_tunes_with_http_info(opts = {})
1302
+ if @api_client.config.debugging
1303
+ @api_client.config.logger.debug 'Calling API: OpenAIApi.list_fine_tunes ...'
1304
+ end
1305
+ # resource path
1306
+ local_var_path = '/fine-tunes'
1307
+
1308
+ # query parameters
1309
+ query_params = opts[:query_params] || {}
1310
+
1311
+ # header parameters
1312
+ header_params = opts[:header_params] || {}
1313
+ # HTTP header 'Accept' (if needed)
1314
+ header_params['Accept'] = @api_client.select_header_accept(['application/json'])
1315
+
1316
+ # form parameters
1317
+ form_params = opts[:form_params] || {}
1318
+
1319
+ # http body (model)
1320
+ post_body = opts[:debug_body]
1321
+
1322
+ # return_type
1323
+ return_type = opts[:debug_return_type] || 'ListFineTunesResponse'
1324
+
1325
+ # auth_names
1326
+ auth_names = opts[:debug_auth_names] || []
1327
+
1328
+ new_options = opts.merge(
1329
+ :operation => :"OpenAIApi.list_fine_tunes",
1330
+ :header_params => header_params,
1331
+ :query_params => query_params,
1332
+ :form_params => form_params,
1333
+ :body => post_body,
1334
+ :auth_names => auth_names,
1335
+ :return_type => return_type
1336
+ )
1337
+
1338
+ data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
1339
+ if @api_client.config.debugging
1340
+ @api_client.config.logger.debug "API called: OpenAIApi#list_fine_tunes\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
1341
+ end
1342
+ return data, status_code, headers
1343
+ end
1344
+
1345
+ # Lists the currently available models, and provides basic information about each one such as the owner and availability.
1346
+ # @param [Hash] opts the optional parameters
1347
+ # @return [ListModelsResponse]
1348
+ def list_models(opts = {})
1349
+ data, _status_code, _headers = list_models_with_http_info(opts)
1350
+ data
1351
+ end
1352
+
1353
+ # Lists the currently available models, and provides basic information about each one such as the owner and availability.
1354
+ # @param [Hash] opts the optional parameters
1355
+ # @return [Array<(ListModelsResponse, Integer, Hash)>] ListModelsResponse data, response status code and response headers
1356
+ def list_models_with_http_info(opts = {})
1357
+ if @api_client.config.debugging
1358
+ @api_client.config.logger.debug 'Calling API: OpenAIApi.list_models ...'
1359
+ end
1360
+ # resource path
1361
+ local_var_path = '/models'
1362
+
1363
+ # query parameters
1364
+ query_params = opts[:query_params] || {}
1365
+
1366
+ # header parameters
1367
+ header_params = opts[:header_params] || {}
1368
+ # HTTP header 'Accept' (if needed)
1369
+ header_params['Accept'] = @api_client.select_header_accept(['application/json'])
1370
+
1371
+ # form parameters
1372
+ form_params = opts[:form_params] || {}
1373
+
1374
+ # http body (model)
1375
+ post_body = opts[:debug_body]
1376
+
1377
+ # return_type
1378
+ return_type = opts[:debug_return_type] || 'ListModelsResponse'
1379
+
1380
+ # auth_names
1381
+ auth_names = opts[:debug_auth_names] || []
1382
+
1383
+ new_options = opts.merge(
1384
+ :operation => :"OpenAIApi.list_models",
1385
+ :header_params => header_params,
1386
+ :query_params => query_params,
1387
+ :form_params => form_params,
1388
+ :body => post_body,
1389
+ :auth_names => auth_names,
1390
+ :return_type => return_type
1391
+ )
1392
+
1393
+ data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
1394
+ if @api_client.config.debugging
1395
+ @api_client.config.logger.debug "API called: OpenAIApi#list_models\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
1396
+ end
1397
+ return data, status_code, headers
1398
+ end
1399
+
1400
+ # Returns information about a specific file.
1401
+ # @param file_id [String] The ID of the file to use for this request
1402
+ # @param [Hash] opts the optional parameters
1403
+ # @return [OpenAIFile]
1404
+ def retrieve_file(file_id, opts = {})
1405
+ data, _status_code, _headers = retrieve_file_with_http_info(file_id, opts)
1406
+ data
1407
+ end
1408
+
1409
+ # Returns information about a specific file.
1410
+ # @param file_id [String] The ID of the file to use for this request
1411
+ # @param [Hash] opts the optional parameters
1412
+ # @return [Array<(OpenAIFile, Integer, Hash)>] OpenAIFile data, response status code and response headers
1413
+ def retrieve_file_with_http_info(file_id, opts = {})
1414
+ if @api_client.config.debugging
1415
+ @api_client.config.logger.debug 'Calling API: OpenAIApi.retrieve_file ...'
1416
+ end
1417
+ # verify the required parameter 'file_id' is set
1418
+ if @api_client.config.client_side_validation && file_id.nil?
1419
+ fail ArgumentError, "Missing the required parameter 'file_id' when calling OpenAIApi.retrieve_file"
1420
+ end
1421
+ # resource path
1422
+ local_var_path = '/files/{file_id}'.sub('{' + 'file_id' + '}', CGI.escape(file_id.to_s))
1423
+
1424
+ # query parameters
1425
+ query_params = opts[:query_params] || {}
1426
+
1427
+ # header parameters
1428
+ header_params = opts[:header_params] || {}
1429
+ # HTTP header 'Accept' (if needed)
1430
+ header_params['Accept'] = @api_client.select_header_accept(['application/json'])
1431
+
1432
+ # form parameters
1433
+ form_params = opts[:form_params] || {}
1434
+
1435
+ # http body (model)
1436
+ post_body = opts[:debug_body]
1437
+
1438
+ # return_type
1439
+ return_type = opts[:debug_return_type] || 'OpenAIFile'
1440
+
1441
+ # auth_names
1442
+ auth_names = opts[:debug_auth_names] || []
1443
+
1444
+ new_options = opts.merge(
1445
+ :operation => :"OpenAIApi.retrieve_file",
1446
+ :header_params => header_params,
1447
+ :query_params => query_params,
1448
+ :form_params => form_params,
1449
+ :body => post_body,
1450
+ :auth_names => auth_names,
1451
+ :return_type => return_type
1452
+ )
1453
+
1454
+ data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
1455
+ if @api_client.config.debugging
1456
+ @api_client.config.logger.debug "API called: OpenAIApi#retrieve_file\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
1457
+ end
1458
+ return data, status_code, headers
1459
+ end
1460
+
1461
+ # Gets info about the fine-tune job. [Learn more about Fine-tuning](/docs/guides/fine-tuning)
1462
+ # @param fine_tune_id [String] The ID of the fine-tune job
1463
+ # @param [Hash] opts the optional parameters
1464
+ # @return [FineTune]
1465
+ def retrieve_fine_tune(fine_tune_id, opts = {})
1466
+ data, _status_code, _headers = retrieve_fine_tune_with_http_info(fine_tune_id, opts)
1467
+ data
1468
+ end
1469
+
1470
+ # Gets info about the fine-tune job. [Learn more about Fine-tuning](/docs/guides/fine-tuning)
1471
+ # @param fine_tune_id [String] The ID of the fine-tune job
1472
+ # @param [Hash] opts the optional parameters
1473
+ # @return [Array<(FineTune, Integer, Hash)>] FineTune data, response status code and response headers
1474
+ def retrieve_fine_tune_with_http_info(fine_tune_id, opts = {})
1475
+ if @api_client.config.debugging
1476
+ @api_client.config.logger.debug 'Calling API: OpenAIApi.retrieve_fine_tune ...'
1477
+ end
1478
+ # verify the required parameter 'fine_tune_id' is set
1479
+ if @api_client.config.client_side_validation && fine_tune_id.nil?
1480
+ fail ArgumentError, "Missing the required parameter 'fine_tune_id' when calling OpenAIApi.retrieve_fine_tune"
1481
+ end
1482
+ # resource path
1483
+ local_var_path = '/fine-tunes/{fine_tune_id}'.sub('{' + 'fine_tune_id' + '}', CGI.escape(fine_tune_id.to_s))
1484
+
1485
+ # query parameters
1486
+ query_params = opts[:query_params] || {}
1487
+
1488
+ # header parameters
1489
+ header_params = opts[:header_params] || {}
1490
+ # HTTP header 'Accept' (if needed)
1491
+ header_params['Accept'] = @api_client.select_header_accept(['application/json'])
1492
+
1493
+ # form parameters
1494
+ form_params = opts[:form_params] || {}
1495
+
1496
+ # http body (model)
1497
+ post_body = opts[:debug_body]
1498
+
1499
+ # return_type
1500
+ return_type = opts[:debug_return_type] || 'FineTune'
1501
+
1502
+ # auth_names
1503
+ auth_names = opts[:debug_auth_names] || []
1504
+
1505
+ new_options = opts.merge(
1506
+ :operation => :"OpenAIApi.retrieve_fine_tune",
1507
+ :header_params => header_params,
1508
+ :query_params => query_params,
1509
+ :form_params => form_params,
1510
+ :body => post_body,
1511
+ :auth_names => auth_names,
1512
+ :return_type => return_type
1513
+ )
1514
+
1515
+ data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
1516
+ if @api_client.config.debugging
1517
+ @api_client.config.logger.debug "API called: OpenAIApi#retrieve_fine_tune\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
1518
+ end
1519
+ return data, status_code, headers
1520
+ end
1521
+
1522
+ # Retrieves a model instance, providing basic information about the model such as the owner and permissioning.
1523
+ # @param model [String] The ID of the model to use for this request
1524
+ # @param [Hash] opts the optional parameters
1525
+ # @return [Model]
1526
+ def retrieve_model(model, opts = {})
1527
+ data, _status_code, _headers = retrieve_model_with_http_info(model, opts)
1528
+ data
1529
+ end
1530
+
1531
+ # Retrieves a model instance, providing basic information about the model such as the owner and permissioning.
1532
+ # @param model [String] The ID of the model to use for this request
1533
+ # @param [Hash] opts the optional parameters
1534
+ # @return [Array<(Model, Integer, Hash)>] Model data, response status code and response headers
1535
+ def retrieve_model_with_http_info(model, opts = {})
1536
+ if @api_client.config.debugging
1537
+ @api_client.config.logger.debug 'Calling API: OpenAIApi.retrieve_model ...'
1538
+ end
1539
+ # verify the required parameter 'model' is set
1540
+ if @api_client.config.client_side_validation && model.nil?
1541
+ fail ArgumentError, "Missing the required parameter 'model' when calling OpenAIApi.retrieve_model"
1542
+ end
1543
+ # resource path
1544
+ local_var_path = '/models/{model}'.sub('{' + 'model' + '}', CGI.escape(model.to_s))
1545
+
1546
+ # query parameters
1547
+ query_params = opts[:query_params] || {}
1548
+
1549
+ # header parameters
1550
+ header_params = opts[:header_params] || {}
1551
+ # HTTP header 'Accept' (if needed)
1552
+ header_params['Accept'] = @api_client.select_header_accept(['application/json'])
1553
+
1554
+ # form parameters
1555
+ form_params = opts[:form_params] || {}
1556
+
1557
+ # http body (model)
1558
+ post_body = opts[:debug_body]
1559
+
1560
+ # return_type
1561
+ return_type = opts[:debug_return_type] || 'Model'
1562
+
1563
+ # auth_names
1564
+ auth_names = opts[:debug_auth_names] || []
1565
+
1566
+ new_options = opts.merge(
1567
+ :operation => :"OpenAIApi.retrieve_model",
1568
+ :header_params => header_params,
1569
+ :query_params => query_params,
1570
+ :form_params => form_params,
1571
+ :body => post_body,
1572
+ :auth_names => auth_names,
1573
+ :return_type => return_type
1574
+ )
1575
+
1576
+ data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
1577
+ if @api_client.config.debugging
1578
+ @api_client.config.logger.debug "API called: OpenAIApi#retrieve_model\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
1579
+ end
1580
+ return data, status_code, headers
1581
+ end
1582
+ end
1583
+ end