Module: Llmshim
- Defined in:
- lib/llmshim.rb,
lib/llmshim/types.rb,
lib/llmshim/client.rb,
lib/llmshim/errors.rb,
lib/llmshim/version.rb
Overview
Ruby client for the llmshim multi-provider LLM proxy.
Point it at a running proxy (default http://localhost:3000) and send OpenAI-style chat requests; llmshim translates to the native provider API.
Object API:
client = Llmshim::Client.new(base_url: "http://localhost:3000")
resp = client.chat(model: "claude-sonnet-4-6", messages: "Hello!")
puts resp.content
Module convenience API (uses a shared default client):
Llmshim.chat(model: "gpt-5.5", messages: "Hello!")
Llmshim.stream(model: "gpt-5.5", messages: "Hi") { |ev| print ev.text if ev.content? }
Defined Under Namespace
Classes: APIError, ChatResponse, Client, Error, Health, Model, ResponseMessage, StreamEvent, ToolCall, Usage
Constant Summary collapse
- VERSION =
"0.1.24"
Class Attribute Summary collapse
- .base_url ⇒ Object
-
.default_client ⇒ Object
The shared default Client used by the convenience methods.
Class Method Summary collapse
- .chat(**kwargs, &block) ⇒ Object
- .health ⇒ Object
- .models ⇒ Object
- .stream(**kwargs, &block) ⇒ Object
Class Attribute Details
.base_url ⇒ Object
30 31 32 |
# File 'lib/llmshim.rb', line 30 def base_url @base_url ||= ENV.fetch("LLMSHIM_BASE_URL", Client::DEFAULT_BASE_URL) end |
Class Method Details
.chat(**kwargs, &block) ⇒ Object
43 44 45 |
# File 'lib/llmshim.rb', line 43 def chat(**kwargs, &block) default_client.chat(**kwargs, &block) end |
.health ⇒ Object
58 59 60 |
# File 'lib/llmshim.rb', line 58 def health default_client.health end |
.models ⇒ Object
53 54 55 |
# File 'lib/llmshim.rb', line 53 def models default_client.models end |
.stream(**kwargs, &block) ⇒ Object
48 49 50 |
# File 'lib/llmshim.rb', line 48 def stream(**kwargs, &block) default_client.stream(**kwargs, &block) end |