RubyLLM क्या है?
RubyLLM 17 मॉडल providers के लिए एक Ruby API, जो Rails में घर जैसा चलता है. यह App Orchestration टूल्स की App Frameworks श्रेणी में आता है; ओपन सोर्स है, Ruby में लिखा गया है और MIT लाइसेंस के तहत है। शुरू करने के लिए: gem जोड़ें.
सारांश
RubyLLM उन लोगों के लिए AI framework है जिनका application पहले से Ruby में है। ज़्यादातर LLM tooling Python या TypeScript मानकर चलती है, इसलिए Rails टीमों को या तो HTTP client हाथ से लिखने पड़ते हैं या अलग sidecar service चलानी पड़ती है। RubyLLM chat, tools, agents, files, embeddings, reranking, moderation और media generation को एक ही Ruby API के पीछे रखता है — `RubyLLM.chat.ask`, `RubyLLM.embed`, `RubyLLM.paint`, `RubyLLM.transcribe` — ताकि providers के बीच का फ़र्क gem के अंदर ही रहे।
इस एक API के पीछे सत्रह providers सपोर्ट किए जाते हैं, जिनमें OpenAI, Azure, Anthropic, Gemini, VertexAI, Bedrock, xAI, Cohere, DeepSeek, Mistral, Perplexity, Ollama और Ollama Cloud, OpenRouter, GPUStack, ElevenLabs, Deepgram और कोई भी OpenAI-compatible endpoint शामिल हैं। hosted मॉडल से local मॉडल पर जाने के लिए बस एक model string बदलनी होती है, कोड दोबारा नहीं लिखना पड़ता। बिल्ट-इन model registry हर मॉडल की क्षमताएँ, सीमाएँ और कीमत दिखाती है, और `chat.tokens` व `chat.cost` के पीछे हर attempt का usage ledger रहता है, ताकि अलग से observability layer जोड़े बिना ही खर्च दिखता रहे।
Rails integration ही वह हिस्सा है जो इसे सिर्फ़ एक पतले API wrapper से अलग बनाता है। Generators चालू chat UI का scaffold बना देते हैं, बातचीत `acts_as_chat` के ज़रिए Active Record में सेव होती है, attachments Active Storage से जाते हैं, और जवाब Hotwire पर stream होते हैं। इन बुनियादी चीज़ों के अलावा यह agentic loop (`ask_later`, `step`, `complete?`), `requires_approval` से tool approval gates, web search और MCP connectors जैसे provider-side tools, Ruby schema classes से structured output, prompt caching, fallbacks और cancellation, batches, compaction और extended thinking को भी कवर करता है। MIT लाइसेंस; README के examples release 2.0.0 के लिए हैं।
यह क्या करता है
- 17 providers के लिए एक Ruby API — hosted, Ollama से local, या कोई भी OpenAI-compatible endpoint
- Chat, vision, audio transcription और speech, OCR, image व video generation, embeddings, reranking और moderation
- साधारण Ruby classes के रूप में tools, दोबारा इस्तेमाल होने वाली `RubyLLM::Agent` definitions, और `requires_approval` वाले human gates
- Rails-native: `acts_as_chat` से Active Record persistence, Active Storage attachments, Hotwire streaming, scaffold generators
- Ruby schema classes से structured output, जिसे `response.parsed` से पढ़ा जा सकता है
- `chat.tokens` / `chat.cost` के पीछे cost और token ledger, साथ में सीमाओं और कीमत वाला model registry
- Prompt caching, model fallbacks, cancellation, batches, compaction और extended thinking
शुरू करें
नीचे दिए कमांड README के 2.0.0 examples पर आधारित हैं। अगर आपका app 1.16 पर है, तो 2.0 deploy करने से पहले upgrade guide ज़रूर पढ़ें।
Gem जोड़ें
bundle add ruby_llm --version 2.0.0Provider configure करें
साधारण script में, या Rails में `config/initializers/ruby_llm.rb` में। बाकी providers तब जोड़ें जब आपके इस्तेमाल किए फ़ीचर्स को उनकी ज़रूरत हो।
require 'ruby_llm'
RubyLLM.configure do |config|
config.openai_api_key = ENV.fetch('OPENAI_API_KEY')
endकुछ पूछें
`with:` उन मॉडलों पर images, video, audio, PDF और source files स्वीकार करता है जो इन्हें सपोर्ट करते हैं।
RubyLLM.chat.ask "What's the best way to learn Ruby?"
chat = RubyLLM.chat(model: "gemini-3.7-flash")
chat.ask "What's in this image?", with: "ruby_conf.jpg"मॉडल को अपना कोड tool के रूप में दें
class Weather < RubyLLM::Tool
description "Get current weather"
def execute(latitude:, longitude:)
url = "https://api.open-meteo.com/v1/forecast?latitude=#{latitude}&longitude=#{longitude}¤t=temperature_2m,wind_speed_10m"
JSON.parse(Faraday.get(url).body)
end
end
chat.with_tools(Weather).ask "What's the weather in Berlin?"इसे Rails में जोड़ें
Generators migrations बनाते हैं और चाहें तो `/chats` पर चालू chat UI भी।
bin/rails generate ruby_llm:install
bin/rails db:migrate
bin/rails ruby_llm:load_models
# optional chat UI
bin/rails generate ruby_llm:chat_uiबातचीत को सेव करें
class Chat < ApplicationRecord
acts_as_chat
end
chat = Chat.create! model: "gpt-5.6-luna"
chat.ask "What's in this file?", with: "report.pdf"कमांड और कोड प्रोजेक्ट के अपने दस्तावेज़ों से लिए गए हैं — हमेशा जांचें आधिकारिक repo ताज़ा जानकारी के लिए।
कब इस्तेमाल करें
- मौजूदा Rails app में AI फ़ीचर जोड़ें, उसके बगल में Python service खड़ी किए बिना
- hosted और local मॉडलों के बीच जाएँ — या कीमत बदलने पर providers बदलें — call sites दोबारा लिखे बिना
- सेव होने वाला, streaming chat interface खुद बनाने के बजाय generators से तैयार पाएँ
- जिस app ने calls किए, उसी के अंदर हर बातचीत का token खर्च ट्रैक करें
How RubyLLM compares
RubyLLM alongside other open-source app frameworks tools AI/TLDR tracks, ranked by GitHub stars.
| टूल | स्टार | यह क्या करता है |
|---|---|---|
| LangChain | ★ 150k | आपस में जुड़ने वाले और बदले जा सकने वाले components से agents और LLM ऐप बनाएं |
| LlamaIndex | ★ 53.1k | रिट्रीवल और एजेंट्स के ज़रिए भाषा मॉडल को अपने डेटा से जोड़ें |
| Haystack | ★ 27.2k | प्रोडक्शन RAG पाइपलाइन और LLM एजेंट बनाने के लिए ओपन सोर्स Python फ़्रेमवर्क |
| Jina | ★ 21.9k | gRPC, HTTP और WebSockets पर संवाद करने वाली AI सर्विस बनाएं और चलाएं |
| RocketRide | ★ 19.9k | एक ओपन सोर्स, MIT लाइसेंस वाला AI मेटा-हार्नेस, जो C++ रनटाइम पर चलता है: VS Code, CLI, Python और TypeScript SDK, या इसके बिल्ट-इन MCP सर्वर से AI एजेंट और RAG पाइपलाइन बनाएं, टेस्ट करें और चलाएं |
| LLM | ★ 12.9k | कमांड लाइन से दर्जनों लैंग्वेज मॉडल इस्तेमाल करें, और हर एक को SQLite में लॉग करें |
| Prompt Flow | ★ 11.3k | लिंक्ड flows के साथ production-quality LLM ऐप्स बनाएँ, टेस्ट करें और शिप करें |
| RubyLLM | ★ 4.5k | 17 मॉडल providers के लिए एक Ruby API, जो Rails में घर जैसा चलता है |
