class RubyLLM::Provider

A Provider connects RubyLLM to one AI service. It knows where to talk (host, authentication headers, configuration) and which protocol to speak for a given model and request. The wire formats themselves live under RubyLLM::Protocols.

Subclass Provider to support a new service, then make it available with ::register:

class Acme < RubyLLM::Provider
  protocol :chat_completions, RubyLLM::Protocols::ChatCompletions

  def self.configuration_options
    %i[acme_api_key]
  end

  def api_base
    'https://api.acme.ai/v1'
  end

  def headers
    { 'Authorization' => "Bearer #{@config.acme_api_key}" }
  end
end

RubyLLM::Provider.register :acme, Acme

See the custom providers guide for the full walkthrough.