module

LLM::Adapter

A normalized adapter interface for LLM clients.

Implementations should return a String response (JSON text after any provider-specific cleanup).

Instance methods

close

Optional cleanup hook for adapters that manage external resources.

Source
request(prompt : String, format : String = "json") : String

Send a single prompt and get a response as a String.

Source
request_messages(messages : Messages, format : String = "json") : String

Send chat-style messages (system/user) and get a response as a String.

Source
request_messages_with_tools(messages : Messages, _tools : String) : String

Request next step using provider-native tool definitions. Implementations that do not support this can fallback to regular JSON-mode requests.

Source
request_with_context(system : String | Nil, user : String, format : String = "json", cache_key : String | Nil = nil) : String

Context-aware request. Adapters that support provider-side context can reuse it using a cache_key. Default implementation falls back to request_messages without context reuse.

Source
supports_context?

Whether this adapter supports server-side KV context reuse across calls.

Source
supports_native_tool_calling?

Whether this adapter can leverage provider-native tool-calling.

Source

Nested types