struct OpenRouter::Model

Overview

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

Defined in:

openrouter/types/model.cr

Constructors

Instance Method Summary

Constructor Detail

def self.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
    }
}

[View source]

Instance Method Detail

def architecture_instruct_type : String | Nil #

[View source]
def architecture_modality : String #

[View source]
def architecture_tokenizer : String #

[View source]
def context_length : Int32 #

[View source]
def created : Int32 #

[View source]
def description : String #

[View source]
def id : String #

[View source]
def name : String #

[View source]
def per_request_limits_completion_tokens : Int32? #

[View source]
def per_request_limits_prompt_tokens : Int32? #

[View source]
def pricing_completion : String #

[View source]
def pricing_image : String #

[View source]
def pricing_prompt : String #

[View source]
def pricing_request : String #

[View source]
def to_s #
Description copied from class Object

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.


[View source]
def top_provider_context_length : Int32 | Nil #

[View source]
def top_provider_is_moderated : Bool #

[View source]
def top_provider_max_completion_tokens : Int32 | Nil #

[View source]