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
- Updated the "Streaming Responses" guide to improve clarity and structure, including a new table of contents and detailed explanations of chunk handling and integration with web frameworks.
- Revised the "Using Tools" guide to clarify tool creation, usage, and error handling, along with new examples and best practices.
- Improved the "Installation" guide with clearer prerequisites, installation methods, and configuration options, including advanced settings for API keys and connection settings.
- Added a table of contents to the models documentation for better navigation and updated the last updated timestamp display.
This guide will help you get up and running with RubyLLM, showing you the basics of chatting with AI models, generating images, and creating embeddings.
12
+
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.
13
+
{: .fs-6 .fw-300 }
12
14
13
-
## Prerequisites
15
+
## Table of contents
16
+
{: .no_toc .text-delta }
14
17
15
-
Before starting, make sure you have:
18
+
1. TOC
19
+
{:toc}
16
20
17
-
1. Installed the RubyLLM gem (see the [Installation guide]({% link installation.md %}))
18
-
2. At least one API key from a supported provider (OpenAI, Anthropic, Google, AWS Bedrock, or DeepSeek)
21
+
---
22
+
23
+
After reading this guide, you will know:
24
+
25
+
* How to install RubyLLM.
26
+
* How to configure API keys.
27
+
* How to start a simple chat conversation.
28
+
* How to generate an image.
29
+
* How to create text embeddings.
19
30
20
-
## Basic Configuration
31
+
## Installation
21
32
22
-
Let's start by setting up RubyLLM with your API keys:
33
+
Add RubyLLM to your Gemfile:
34
+
35
+
```ruby
36
+
gem 'ruby_llm'
37
+
```
38
+
39
+
Then run `bundle install`.
40
+
41
+
Alternatively, install it manually: `gem install ruby_llm`
42
+
43
+
(For full details, see the [Installation Guide]({% link installation.md %})).
44
+
45
+
## Configuration
46
+
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.
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.
62
+
42
63
## Your First Chat
43
64
44
-
Let's start with a simple chat interaction:
65
+
The primary way to interact with language models is through the `RubyLLM.chat` interface.
45
66
46
67
```ruby
47
-
# Create a chat (uses the default model)
68
+
# Create a chat instance (uses the default model, usually GPT)
48
69
chat =RubyLLM.chat
49
70
50
71
# Ask a question
51
-
response = chat.ask "What's the capital of France?"
52
-
puts response.content
53
-
# => "The capital of France is Paris."
72
+
response = chat.ask "What is Ruby on Rails?"
54
73
55
-
# Continue the conversation
56
-
response = chat.ask "What's the population of that city?"
74
+
# The response is a RubyLLM::Message object
57
75
puts response.content
58
-
# => "Paris has a population of approximately 2.1 million people..."
59
-
```
60
-
61
-
### Using a Specific Model
76
+
# => "Ruby on Rails, often shortened to Rails, is a server-side web application..."
0 commit comments