Skip to content

API call Usage example

Chamath K.B. Attanayaka edited this page Jul 31, 2023 · 2 revisions

OpenAI API call

apikey = ENV['OPENAI_API_KEY']
client = LlmLib::OpenAIClient.new(apikey)

prompt = "Once upon a time"
max_tokens = 100
response = client.chat_gpt_call(prompt, 
                        max_tokens)
puts response

HuggingFace API call

apikey = ENV['HUGGINGFACE_API_KEY']
client = LlmLib::HuggingfaceApiClient.new(apikey)

query = "Once upon a time"
response = client.hugging_bloom_call(query)

puts response

Replace 'API_KEY' with your actual OpenAI/Huggingface API key