diff --git a/docs/guides/getting-started.md b/docs/guides/getting-started.md index ff6cb1c..96dd61a 100644 --- a/docs/guides/getting-started.md +++ b/docs/guides/getting-started.md @@ -33,6 +33,12 @@ RubyLLM.configure do |config| end ``` +You can optionally provide the base URL for the OpenAI API, through which you can point to OpenAI API compatible engines like [Ollama](https://github.com/ollama/ollama), [KoboldCPP](https://github.com/LostRuins/koboldcpp), [TabbyAPI](https://github.com/theroyallab/tabbyAPI), etc: + +```ruby + config.openai_base_url = "http://localhost:11434/v1" +``` + ## Your First Chat Let's start with a simple chat interaction: @@ -161,4 +167,4 @@ Now that you've got the basics down, you're ready to explore more advanced featu - [Chatting with AI]({% link guides/chat.md %}) - Learn more about chat capabilities - [Using Tools]({% link guides/tools.md %}) - Let AI use your Ruby code -- [Rails Integration]({% link guides/rails.md %}) - Persist chats in your Rails apps \ No newline at end of file +- [Rails Integration]({% link guides/rails.md %}) - Persist chats in your Rails apps diff --git a/lib/ruby_llm/configuration.rb b/lib/ruby_llm/configuration.rb index 72a878a..adda72b 100644 --- a/lib/ruby_llm/configuration.rb +++ b/lib/ruby_llm/configuration.rb @@ -11,6 +11,7 @@ module RubyLLM # end class Configuration attr_accessor :openai_api_key, + :openai_base_url, :anthropic_api_key, :gemini_api_key, :deepseek_api_key, diff --git a/lib/ruby_llm/providers/openai.rb b/lib/ruby_llm/providers/openai.rb index f78062e..e7c4c32 100644 --- a/lib/ruby_llm/providers/openai.rb +++ b/lib/ruby_llm/providers/openai.rb @@ -29,7 +29,7 @@ def self.extended(base) module_function def api_base - 'https://api.openai.com/v1' + RubyLLM.config.openai_base_url || 'https://api.openai.com/v1' end def headers