Class: RubyLLM::Providers::OpenRouter

Inherits:
OpenAI show all
Includes:
Models
Defined in:
lib/ruby_llm/providers/openrouter.rb,
lib/ruby_llm/providers/openrouter/models.rb

Overview

OpenRouter API integration.

Defined Under Namespace

Modules: Models

Constant Summary

Constants included from RubyLLM::Providers::OpenAI::Tools

RubyLLM::Providers::OpenAI::Tools::EMPTY_PARAMETERS_SCHEMA

Instance Attribute Summary

Attributes inherited from RubyLLM::Provider

#config, #connection

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Models

models_url, parse_list_models_response, supported_parameters_to_capabilities

Methods inherited from OpenAI

capabilities, #maybe_normalize_temperature

Methods included from RubyLLM::Providers::OpenAI::Transcription

encode_speaker_references, parse_transcription_response, render_transcription_payload, response_format_for, supports_chunking_strategy?, transcription_url

Methods included from RubyLLM::Providers::OpenAI::Media

format_audio, format_content, format_image, format_pdf, format_text, format_text_file

Methods included from RubyLLM::Providers::OpenAI::Images

images_url, parse_image_response, render_image_payload

Methods included from RubyLLM::Providers::OpenAI::Tools

format_tool_calls, param_schema, parameters_schema_for, parse_tool_call_arguments, parse_tool_calls, schema_from_parameters, tool_for

Methods included from RubyLLM::Providers::OpenAI::Streaming

build_chunk, parse_streaming_error, stream_url

Methods included from RubyLLM::Providers::OpenAI::Moderation

moderation_url, parse_moderation_response, render_moderation_payload

Methods included from RubyLLM::Providers::OpenAI::Models

models_url, parse_list_models_response

Methods included from RubyLLM::Providers::OpenAI::Embeddings

embedding_url, parse_embedding_response, render_embedding_payload

Methods included from RubyLLM::Providers::OpenAI::Chat

#completion_url, format_messages, format_role, parse_completion_response, render_payload

Methods inherited from RubyLLM::Provider

capabilities, #capabilities, #complete, #configuration_requirements, configured?, #configured?, configured_providers, configured_remote_providers, #embed, for, #format_messages, #format_tool_calls, #initialize, #list_models, #local?, local?, local_providers, #moderate, #name, name, #paint, #parse_error, #parse_tool_calls, providers, register, remote?, #remote?, remote_providers, resolve, slug, #slug, #transcribe

Methods included from Streaming

handle_stream, stream_response

Constructor Details

This class inherits a constructor from RubyLLM::Provider

Class Method Details

.configuration_requirementsObject



20
21
22
# File 'lib/ruby_llm/providers/openrouter.rb', line 20

def configuration_requirements
  i[openrouter_api_key]
end

Instance Method Details

#api_baseObject



9
10
11
# File 'lib/ruby_llm/providers/openrouter.rb', line 9

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

#headersObject



13
14
15
16
17
# File 'lib/ruby_llm/providers/openrouter.rb', line 13

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