Skip to content

Latest commit

 

History

History
45 lines (36 loc) · 958 Bytes

APP.md

File metadata and controls

45 lines (36 loc) · 958 Bytes

Ruby SDK to call 100+ LLM APIs in OpenAI format - [Bedrock, Azure, OpenAI, VertexAI, Cohere, Anthropic, Sagemaker, HuggingFace, Replicate, Groq]

Usage Examples

Configuration

Onellm.configure do |config|
  config.openai_api_key = "your-openai-key"
  config.anthropic_api_key = "your-cohere-key"
end

Module-based Style

response = Onellm.complete(
  model: "openai/gpt-4o",
  messages: [{ content: "Hello, how are you?", role: "user" }]
)

puts response.choices.first.message.content

Class-based Style

client = Onellm::Client.new

response = client.complete(
  model: "openai/gpt-4o",
  messages: [{ content: "Hello, how are you?", role: "user" }]
)

puts response.choices.first.message.content

Streaming

Onellm.complete(
  model: "openai/gpt-4o",
  messages: [{ content: "Hello, how are you?", role: "user" }],
  stream: true
) do |part|
  puts part.choices.first.delta.content
end