Class: RubyLLM::Providers::OpenRouter::ChatCompletions

Overview

OpenRouter's dialect of the Chat Completions API.

Constant Summary collapse

SERVER_TOOL_ALIASES =

OpenRouter runs its server tools transparently: results surface as citations and usage counters rather than discrete content blocks.

%i[
  web_search web_fetch datetime image_generation apply_patch shell
].to_h { |name| [name, { tool: { type: "openrouter:#{name}" } }] }.merge(
  url_context: { tool: { type: 'openrouter:web_fetch' } },
  code_execution: { tool: { type: 'openrouter:shell' } }
).freeze

Constants included from Videos

Videos::FRAME_TYPES

Constants included from Streaming

Streaming::ACCUMULATED_REASONING_KEYS

Constants included from Models

Models::CAPABILITY_BY_OUTPUT_MODALITY, Models::CAPABILITY_PARAMETERS, Models::CATALOG_URLS, Models::OUTPUT_MODALITY_MAP

Constants included from Embeddings

Embeddings::EMBEDDING_MEDIA_TYPES

Constants included from Chat

RubyLLM::Providers::OpenRouter::Chat::CACHE_CONTROL_TYPE, RubyLLM::Providers::OpenRouter::Chat::COMPACTION_PLUGIN_ID, RubyLLM::Providers::OpenRouter::Chat::OPENROUTER_FILE_UPLOAD_LIMIT, RubyLLM::Providers::OpenRouter::Chat::OPENROUTER_INLINE_FILE_THRESHOLD, RubyLLM::Providers::OpenRouter::Chat::PROMPT_CACHE_OPTIONS

Instance Attribute Summary

Attributes inherited from RubyLLM::Protocol

#config, #connection, #model, #provider

Instance Method Summary collapse

Methods included from RubyLLM::Protocols::OpenRouter::Transcription

#transcribe

Methods included from Videos

#download_video, #parse_video_job, #parse_video_job_status, #render_video_payload, #video_job_url, #video_url

Methods included from RubyLLM::Protocols::ChatCompletions::Rerank

parse_rerank_response, parse_rerank_results, render_rerank_payload, rerank_document, rerank_url, valid_rerank_index?

Methods included from Streaming

accumulate_raw_reasoning, build_chunk, merge_reasoning_detail, reasoning_detail_target

Methods included from Speech

parse_speech_response, render_speech_payload

Methods included from Models

#list_models, models_url, parse_list_models_response, supported_parameters_to_capabilities

Methods included from Images

build_input_references, image_usage, images_url, parse_image_response, parse_image_responses, render_image_payload, validate_paint_inputs!

Methods included from Embeddings

format_embedding_attachment, format_embedding_content, render_embedding_payload, supports_embedding_media?

Methods included from Chat

add_reasoning_toggle, apply_compaction, apply_end_user, build_reasoning, default_large_file_upload_threshold, extract_raw_reasoning, extract_thinking_signature, extract_thinking_text, format_cache_option_keys, format_content, format_message_content, format_thinking, inject_cache_control, log_ignored_compaction_options, openai_prompt_caching?, prompt_cache_control, prompt_cache_options, provider_file_attachable?, provider_file_upload_limit, render_payload, reported_cost, strip_schema_strict, supports_provider_file_references?

Methods inherited from RubyLLM::Protocol

abstract, #animate_later, #apply_compaction, #apply_compaction_headers, #apply_end_user, #cache_content, #compact, #complete, #count_tokens, #delete_cache, #embed, #extend_cache, #find_cache, #initialize, #list_models, #moderate, #ocr, #paint, #parse_error, #parse_image_responses, #post_image, #post_video, #preprocess_message, #raise_transcription_streaming_unsupported, #refresh_video_job, #render, #render_embedding, #render_transcription_options, #render_video_extension_payload, #rerank, #speak, #stream_speech, #stream_speech_response, #stream_transcription, #supports_embedding_media?, #tokenize, #tool_approval_response, #transcribe, #video_extension_attachment, #video_extension_url, #video_request_url

Methods included from RubyLLM::Protocol::BinaryStreaming

#stream_binary

Methods included from RubyLLM::Protocol::Streaming

build_on_data_handler, build_stream_error_response, error_chunk?, failed_http_status, faraday_1?, handle_data, handle_error_chunk, handle_error_event, handle_failed_response, handle_json_error_chunk, handle_sse, handle_stream, json_error_payload?, parse_error_from_json, parse_streaming_error, process_stream_chunk, raise_stream_error, stream_events, stream_response, stream_state

Constructor Details

This class inherits a constructor from RubyLLM::Protocol

Instance Method Details

#server_tool_aliasesObject



28
29
30
# File 'lib/ruby_llm/providers/openrouter.rb', line 28

def server_tool_aliases
  SERVER_TOOL_ALIASES
end