{"id":24859673,"url":"https://github.com/crmne/ruby_llm","last_synced_at":"2026-04-02T23:46:25.550Z","repository":{"id":274944401,"uuid":"924568745","full_name":"crmne/ruby_llm","owner":"crmne","description":"Stop juggling AI SDKs! RubyLLM offers one delightful Ruby interface for OpenAI, Anthropic, Gemini, Bedrock, OpenRouter, DeepSeek, Ollama \u0026 compatible APIs. Chat, Vision, Audio, PDF, Images, Embeddings, Tools, Streaming \u0026 Rails integration.","archived":false,"fork":false,"pushed_at":"2025-05-07T14:21:48.000Z","size":37161,"stargazers_count":2164,"open_issues_count":51,"forks_count":106,"subscribers_count":19,"default_branch":"main","last_synced_at":"2025-05-07T14:51:12.087Z","etag":null,"topics":["ai","anthropic","chatgpt","claude","dall-e","deepseek","embeddings","gemini","image-generation","llm","openai","rails","ruby"],"latest_commit_sha":null,"homepage":"https://rubyllm.com/","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/crmne.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null},"funding":{"github":["crmne"],"patreon":null,"open_collective":null,"ko_fi":null,"tidelift":null,"community_bridge":null,"liberapay":null,"issuehunt":null,"lfx_crowdfunding":null,"polar":null,"buy_me_a_coffee":"crmne","thanks_dev":null,"custom":null}},"created_at":"2025-01-30T08:58:19.000Z","updated_at":"2025-05-07T14:40:56.000Z","dependencies_parsed_at":null,"dependency_job_id":"c9d0da8b-fee9-43df-9495-37ea5621d530","html_url":"https://github.com/crmne/ruby_llm","commit_stats":null,"previous_names":["crmne/ruby_llm"],"tags_count":9,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/crmne%2Fruby_llm","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/crmne%2Fruby_llm/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/crmne%2Fruby_llm/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/crmne%2Fruby_llm/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/crmne","download_url":"https://codeload.github.com/crmne/ruby_llm/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253767796,"owners_count":21961188,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ai","anthropic","chatgpt","claude","dall-e","deepseek","embeddings","gemini","image-generation","llm","openai","rails","ruby"],"created_at":"2025-01-31T20:59:30.311Z","updated_at":"2026-04-02T23:46:25.544Z","avatar_url":"https://github.com/crmne.png","language":"Ruby","funding_links":["https://github.com/sponsors/crmne","https://buymeacoffee.com/crmne"],"categories":["Ruby","NLP","Open Source","SDK, Libraries, Frameworks","Video \u0026 Animation","Media \u0026 Content Generation","5. Retrieval-Augmented Generation (RAG) \u0026 Knowledge"],"sub_categories":["API Libraries","Other sdk/libraries"],"readme":"\u003cdiv align=\"center\"\u003e\n\n\u003cpicture\u003e\n  \u003csource media=\"(prefers-color-scheme: dark)\" srcset=\"/docs/assets/images/logotype_dark.svg\"\u003e\n  \u003cimg src=\"/docs/assets/images/logotype.svg\" alt=\"RubyLLM\" height=\"120\" width=\"250\"\u003e\n\u003c/picture\u003e\n\n\u003cstrong\u003eOne *beautiful* Ruby API for GPT, Claude, Gemini, and more.\u003c/strong\u003e\n\nBattle tested at [\u003cpicture\u003e\u003csource media=\"(prefers-color-scheme: dark)\" srcset=\"https://chatwithwork.com/logotype-dark.svg\"\u003e\u003cimg src=\"https://chatwithwork.com/logotype.svg\" alt=\"Chat with Work\" height=\"30\" align=\"absmiddle\"\u003e\u003c/picture\u003e](https://chatwithwork.com) — *Your AI coworker*\n\n[![Gem Version](https://badge.fury.io/rb/ruby_llm.svg)](https://badge.fury.io/rb/ruby_llm)\n[![Ruby Style Guide](https://img.shields.io/badge/code_style-rubocop-brightgreen.svg)](https://github.com/rubocop/rubocop)\n[![Gem Downloads](https://img.shields.io/gem/dt/ruby_llm)](https://rubygems.org/gems/ruby_llm)\n[![codecov](https://codecov.io/gh/crmne/ruby_llm/branch/main/graph/badge.svg)](https://codecov.io/gh/crmne/ruby_llm)\n\n\u003ca href=\"https://trendshift.io/repositories/13640\" target=\"_blank\"\u003e\u003cimg src=\"https://trendshift.io/api/badge/repositories/13640\" alt=\"crmne%2Fruby_llm | Trendshift\" style=\"width: 250px; height: 55px;\" width=\"250\" height=\"55\"/\u003e\u003c/a\u003e\n\u003c/div\u003e\n\n\u003e [!NOTE]\n\u003e Using RubyLLM? [Share your story](https://tally.so/r/3Na02p)! Takes 5 minutes.\n\n---\n\nBuild chatbots, AI agents, RAG applications. Works with OpenAI, xAI, Anthropic, Google, AWS, local models, and any OpenAI-compatible API.\n\n## From zero to AI chat app in under two minutes\n\nhttps://github.com/user-attachments/assets/65422091-9338-47da-a303-92b918bd1345\n\n## Why RubyLLM?\n\nEvery AI provider ships their own bloated client. Different APIs. Different response formats. Different conventions. It's exhausting.\n\nRubyLLM gives you one beautiful API for all of them. Same interface whether you're using GPT, Claude, or your local Ollama. Just three dependencies: Faraday, Zeitwerk, and Marcel. That's it.\n\n## Show me the code\n\n```ruby\n# Just ask questions\nchat = RubyLLM.chat\nchat.ask \"What's the best way to learn Ruby?\"\n```\n\n```ruby\n# Analyze any file type\nchat.ask \"What's in this image?\", with: \"ruby_conf.jpg\"\nchat.ask \"What's happening in this video?\", with: \"video.mp4\"\nchat.ask \"Describe this meeting\", with: \"meeting.wav\"\nchat.ask \"Summarize this document\", with: \"contract.pdf\"\nchat.ask \"Explain this code\", with: \"app.rb\"\n```\n\n```ruby\n# Multiple files at once\nchat.ask \"Analyze these files\", with: [\"diagram.png\", \"report.pdf\", \"notes.txt\"]\n```\n\n```ruby\n# Stream responses\nchat.ask \"Tell me a story about Ruby\" do |chunk|\n  print chunk.content\nend\n```\n\n```ruby\n# Generate images\nRubyLLM.paint \"a sunset over mountains in watercolor style\"\n```\n\n```ruby\n# Create embeddings\nRubyLLM.embed \"Ruby is elegant and expressive\"\n```\n\n```ruby\n# Transcribe audio to text\nRubyLLM.transcribe \"meeting.wav\"\n```\n\n```ruby\n# Moderate content for safety\nRubyLLM.moderate \"Check if this text is safe\"\n```\n\n```ruby\n# Let AI use your code\nclass Weather \u003c RubyLLM::Tool\n  description \"Get current weather\"\n  param :latitude\n  param :longitude\n\n  def execute(latitude:, longitude:)\n    url = \"https://api.open-meteo.com/v1/forecast?latitude=#{latitude}\u0026longitude=#{longitude}\u0026current=temperature_2m,wind_speed_10m\"\n    JSON.parse(Faraday.get(url).body)\n  end\nend\n\nchat.with_tool(Weather).ask \"What's the weather in Berlin?\"\n```\n\n```ruby\n# Define an agent with instructions + tools\nclass WeatherAssistant \u003c RubyLLM::Agent\n  model \"gpt-5-nano\"\n  instructions \"Be concise and always use tools for weather.\"\n  tools Weather\nend\n\nWeatherAssistant.new.ask \"What's the weather in Berlin?\"\n```\n\n```ruby\n# Get structured output\nclass ProductSchema \u003c RubyLLM::Schema\n  string :name\n  number :price\n  array :features do\n    string\n  end\nend\n\nresponse = chat.with_schema(ProductSchema).ask \"Analyze this product\", with: \"product.txt\"\n```\n\n## Features\n\n* **Chat:** Conversational AI with `RubyLLM.chat`\n* **Vision:** Analyze images and videos\n* **Audio:** Transcribe and understand speech with `RubyLLM.transcribe`\n* **Documents:** Extract from PDFs, CSVs, JSON, any file type\n* **Image generation:** Create images with `RubyLLM.paint`\n* **Embeddings:** Generate embeddings with `RubyLLM.embed`\n* **Moderation:** Content safety with `RubyLLM.moderate`\n* **Tools:** Let AI call your Ruby methods\n* **Agents:** Reusable assistants with `RubyLLM::Agent`\n* **Structured output:** JSON schemas that just work\n* **Streaming:** Real-time responses with blocks\n* **Rails:** ActiveRecord integration with `acts_as_chat`\n* **Async:** Fiber-based concurrency\n* **Model registry:** 800+ models with capability detection and pricing\n* **Extended thinking:** Control, view, and persist model deliberation\n* **Providers:** OpenAI, xAI, Anthropic, Gemini, VertexAI, Bedrock, DeepSeek, Mistral, Ollama, OpenRouter, Perplexity, GPUStack, and any OpenAI-compatible API\n\n## Installation\n\nAdd to your Gemfile:\n```ruby\ngem 'ruby_llm'\n```\nThen `bundle install`.\n\nConfigure your API keys:\n```ruby\n# config/initializers/ruby_llm.rb\nRubyLLM.configure do |config|\n  config.openai_api_key = ENV['OPENAI_API_KEY']\nend\n```\n\n## Rails\n\n```bash\n# Install Rails Integration\nbin/rails generate ruby_llm:install\nbin/rails db:migrate\nbin/rails ruby_llm:load_models # v1.13+\n\n# Add Chat UI (optional)\nbin/rails generate ruby_llm:chat_ui\n```\n\n```ruby\nclass Chat \u003c ApplicationRecord\n  acts_as_chat\nend\n\nchat = Chat.create! model: \"claude-sonnet-4\"\nchat.ask \"What's in this file?\", with: \"report.pdf\"\n```\n\nVisit `http://localhost:3000/chats` for a ready-to-use chat interface!\n\n## Documentation\n\n[rubyllm.com](https://rubyllm.com)\n\n## Contributing\n\nSee [CONTRIBUTING.md](CONTRIBUTING.md).\n\n## License\n\nReleased under the MIT License.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcrmne%2Fruby_llm","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcrmne%2Fruby_llm","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcrmne%2Fruby_llm/lists"}