All URIs are relative to https://api.openai.com/v1
Method | HTTP request | Description |
---|---|---|
create_chat_completion | POST /chat/completions | Creates a model response for the given chat conversation. |
create_chat_completion(create_chat_completion_request)
Creates a model response for the given chat conversation.
require 'time'
require 'openapi_client'
# setup authorization
OpenapiClient.configure do |config|
# Configure Bearer authorization: ApiKeyAuth
config.access_token = 'YOUR_BEARER_TOKEN'
end
api_instance = OpenapiClient::ChatApi.new
create_chat_completion_request = OpenapiClient::CreateChatCompletionRequest.new({messages: [OpenapiClient::ChatCompletionRequestAssistantMessage.new({content: 'content_example', role: 'assistant'})], model: OpenapiClient::CreateChatCompletionRequestModel.new}) # CreateChatCompletionRequest |
begin
# Creates a model response for the given chat conversation.
result = api_instance.create_chat_completion(create_chat_completion_request)
p result
rescue OpenapiClient::ApiError => e
puts "Error when calling ChatApi->create_chat_completion: #{e}"
end
This returns an Array which contains the response data, status code and headers.
<Array(, Integer, Hash)> create_chat_completion_with_http_info(create_chat_completion_request)
begin
# Creates a model response for the given chat conversation.
data, status_code, headers = api_instance.create_chat_completion_with_http_info(create_chat_completion_request)
p status_code # => 2xx
p headers # => { ... }
p data # => <CreateChatCompletionResponse>
rescue OpenapiClient::ApiError => e
puts "Error when calling ChatApi->create_chat_completion_with_http_info: #{e}"
end
Name | Type | Description | Notes |
---|---|---|---|
create_chat_completion_request | CreateChatCompletionRequest |
- Content-Type: application/json
- Accept: application/json