struct

OpenRouter::Model

Inherits JSON::Serializable < Struct < Value < Object

Represents a language model retrieved from the OpenRouter API via the /models endpoint

Constructors

new(json : JSON::Any)

Creates a new Model object from a JSON response from the OpenRouter API.

The JSON response from the OpenRouter API should be formatted as follows:

{
    "id": "string",
    "name": "string",
    "created": 0,
    "description": "string",
    "pricing": {
      "prompt": "string",
      "completion": "string",
      "request": "string",
      "image": "string"
    },
    "context_length": 0,
    "architecture": {
      "tokenizer": "Router",
      "instruct_type": "none",
      "modality": "text->text"
    },
    "top_provider": {
      "context_length": 0,
      "max_completion_tokens": 0,
      "is_moderated": true
    },
    "per_request_limits": {
      "prompt_tokens": null,
      "completion_tokens": null
    }
}
Source
new(*, __pull_for_json_serializable pull : JSON::PullParser)
Source

Instance methods

architecture_instruct_type
Source
architecture_modality
Source
architecture_tokenizer
Source
context_length
Source
created
Source
description
Source
name
Source
per_request_limits_completion_tokens
Source
per_request_limits_prompt_tokens
Source
pricing_completion
Source
pricing_image
Source
pricing_input_cache_read
Source
pricing_input_cache_write
Source
pricing_internal_reasoning
Source
pricing_prompt
Source
pricing_request
Source
pricing_web_search
Source
to_s

Returns a nicely readable and concise string representation of this object, typically intended for users.

This method should usually not be overridden. It delegates to #to_s(IO) which can be overridden for custom implementations.

Also see #inspect.

Source
top_provider_context_length
Source
top_provider_is_moderated
Source
top_provider_max_completion_tokens
Source