Skip to content
This repository has been archived by the owner on Nov 9, 2023. It is now read-only.

Latest commit

 

History

History
75 lines (52 loc) · 2.39 KB

ChatApi.md

File metadata and controls

75 lines (52 loc) · 2.39 KB

OpenapiClient::ChatApi

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(create_chat_completion_request)

Creates a model response for the given chat conversation.

Examples

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

Using the create_chat_completion_with_http_info variant

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

Parameters

Name Type Description Notes
create_chat_completion_request CreateChatCompletionRequest

Return type

CreateChatCompletionResponse

Authorization

ApiKeyAuth

HTTP request headers

  • Content-Type: application/json
  • Accept: application/json