You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A delightful Ruby way to work with AI. No configuration madness, no complex callbacks, no handler hell – just beautiful, expressive Ruby code.
3
+
**A delightful Ruby way to work with AI.** RubyLLM provides **one** beautiful, Ruby-like interface to interact with modern AI models. Chat, generate images, create embeddings, and use tools – all with clean, expressive code that feels like Ruby, not like patching together multiple services.
@@ -39,17 +39,6 @@ Every AI provider comes with its own client library, its own response format, it
39
39
40
40
RubyLLM fixes all that. One beautiful API for everything. One consistent format. Minimal dependencies — just Faraday and Zeitwerk. Because working with AI should be a joy, not a chore.
41
41
42
-
## Features
43
-
44
-
- 💬 **Chat** with Anthropic, AWS Bedrock Anthropic, DeepSeek, Ollama, OpenAI, Gemini, and OpenRouter models
45
-
- 👁️ **Vision and Audio** understanding
46
-
- 📄 **PDF Analysis** for analyzing documents
47
-
- 🖼️ **Image generation** with DALL-E and other providers
48
-
- 📊 **Embeddings** for vector search and semantic analysis
49
-
- 🔧 **Tools** that let AI use your Ruby code
50
-
- 🚂 **Rails integration** to persist chats and messages with ActiveRecord
51
-
- 🌊 **Streaming** responses with proper Ruby patterns
52
-
53
42
## What makes it great
54
43
55
44
```ruby
@@ -96,142 +85,89 @@ end
96
85
chat.with_tool(Weather).ask "What's the weather in Berlin? (52.5200, 13.4050)"
97
86
```
98
87
88
+
## Core Capabilities
89
+
90
+
* 💬 **Unified Chat:** Converse with models from OpenAI, Anthropic, Gemini, Bedrock, OpenRouter, DeepSeek, Ollama, or any OpenAI-compatible API using `RubyLLM.chat`.
91
+
* 👁️ **Vision:** Analyze images within chats.
92
+
* 🔊 **Audio:** Transcribe and understand audio content.
93
+
* 📄 **PDF Analysis:** Extract information and summarize PDF documents.
94
+
* 🖼️ **Image Generation:** Create images with `RubyLLM.paint`.
95
+
* 📊 **Embeddings:** Generate text embeddings for vector search with `RubyLLM.embed`.
96
+
* 🔧 **Tools (Function Calling):** Let AI models call your Ruby code using `RubyLLM::Tool`.
97
+
* 🚂 **Rails Integration:** Easily persist chats, messages, and tool calls using `acts_as_chat` and `acts_as_message`.
98
+
* 🌊 **Streaming:** Process responses in real-time with idiomatic Ruby blocks.
99
+
99
100
## Installation
100
101
102
+
Add to your Gemfile:
101
103
```ruby
102
-
# In your Gemfile
103
104
gem 'ruby_llm'
104
-
105
-
# Then run
106
-
bundle install
107
-
108
-
# Or install it yourself
109
-
gem install ruby_llm
110
105
```
106
+
Then `bundle install`.
111
107
112
-
Configure with your API keys:
113
-
108
+
Configure your API keys (using environment variables is recommended):
Welcome to RubyLLM! This guide will get you up and running quickly. We'll cover installing the gem, configuring your first API key, and making basic chat, image, and embedding requests.
12
+
Welcome to RubyLLM! This guide will get you up and running quickly. We'll cover installing the gem, minimal configuration, and making your first chat, image, and embedding requests.
13
13
{: .fs-6 .fw-300 }
14
14
15
15
## Table of contents
@@ -23,10 +23,10 @@ Welcome to RubyLLM! This guide will get you up and running quickly. We'll cover
23
23
After reading this guide, you will know:
24
24
25
25
* How to install RubyLLM.
26
-
* How to configure API keys.
26
+
* How to perform minimal configuration.
27
27
* How to start a simple chat conversation.
28
28
* How to generate an image.
29
-
* How to create text embeddings.
29
+
* How to create a text embedding.
30
30
31
31
## Installation
32
32
@@ -38,34 +38,33 @@ gem 'ruby_llm'
38
38
39
39
Then run `bundle install`.
40
40
41
-
Alternatively, install it manually: `gem install ruby_llm`
42
-
43
41
(For full details, see the [Installation Guide]({% link installation.md %})).
44
42
45
-
## Configuration
43
+
## Minimal Configuration
46
44
47
-
RubyLLM needs API keys for the AI providers you want to use. Configure them, typically in an initializer (`config/initializers/ruby_llm.rb` in Rails) or at the start of your script.
45
+
RubyLLM needs API keys for the AI providers you want to use. Configure them once, typically when your application starts.
48
46
49
47
```ruby
48
+
# config/initializers/ruby_llm.rb (in Rails) or at the start of your script
50
49
require'ruby_llm'
51
50
52
51
RubyLLM.configure do |config|
53
-
# Add keys for the providers you plan to use.
54
-
# Using environment variables is recommended.
52
+
# Add keys ONLY for the providers you intend to use.
53
+
# Using environment variables is highly recommended.
You only need to configure keys for the providers you intend to use. See the [Installation Guide]({% link installation.md %}#configuration) for all configuration options.
59
+
{: .note }
60
+
You only need to configure keys for the providers you actually plan to use. See the [Configuration Guide]({% link configuration.md %}) for all options, including setting defaults and connecting to custom endpoints.
62
61
63
62
## Your First Chat
64
63
65
-
The primary way to interact with language models is through the `RubyLLM.chat` interface.
64
+
Interact with language models using `RubyLLM.chat`.
66
65
67
66
```ruby
68
-
# Create a chat instance (uses the default model, usually GPT)
67
+
# Create a chat instance (uses the configured default model)
69
68
chat =RubyLLM.chat
70
69
71
70
# Ask a question
@@ -74,62 +73,58 @@ response = chat.ask "What is Ruby on Rails?"
74
73
# The response is a RubyLLM::Message object
75
74
puts response.content
76
75
# => "Ruby on Rails, often shortened to Rails, is a server-side web application..."
77
-
78
-
# Continue the conversation naturally
79
-
response = chat.ask "What are its main advantages?"
80
-
puts response.content
81
-
# => "Some key advantages of Ruby on Rails include..."
82
76
```
83
77
84
-
RubyLLM automatically handles conversation history. Dive deeper in the [Chatting with AI Models Guide]({% link guides/chat.md %}).
78
+
RubyLLM handles the conversation history automatically. See the [Chatting with AI Models Guide]({% link guides/chat.md %}) for more details.
85
79
86
80
## Generating an Image
87
81
88
-
You can generate images using models like DALL-E 3 via the `RubyLLM.paint` method.
82
+
Generate images using models like DALL-E 3 via `RubyLLM.paint`.
89
83
90
84
```ruby
91
-
# Generate an image (uses the default image model, usually DALL-E 3)
92
-
image =RubyLLM.paint("A futuristic cityscape at sunset, watercolor style")
0 commit comments