all AI news
How to use openAI API
Aug. 7, 2023, 6:54 p.m. | Samuel Lubliner
DEV Community dev.to
require "http"
require "json"
request_headers_hash = {
"Authorization" => "Bearer #{ENV.fetch("OPENAI_API_KEY")}",
"content-type" => "application/json"
}
request_body_hash = {
"model" => "gpt-3.5-turbo",
"messages" => [
{
"role" => "system",
"content" => "You are Ruby programing expert"
},
{
"role" => "user",
"content" => "What are the steps for creating a dynamic web application"
}
]
}
request_body_json = JSON.generate(request_body_hash)
raw_response = HTTP.headers …
api application authorization dynamic expert fetch gpt gpt-3 gpt-3.5 gpt-3.5-turbo http json messages openai openai api programing role ruby turbo type web
More from dev.to / DEV Community
Jobs in AI, ML, Big Data
Data Architect
@ University of Texas at Austin | Austin, TX
Data ETL Engineer
@ University of Texas at Austin | Austin, TX
Lead GNSS Data Scientist
@ Lurra Systems | Melbourne
Senior Machine Learning Engineer (MLOps)
@ Promaton | Remote, Europe
Field Sample Specialist (Air Sampling) - Eurofins Environment Testing – Pueblo, CO
@ Eurofins | Pueblo, CO, United States
Camera Perception Engineer
@ Meta | Sunnyvale, CA