class OpenRouter::Client
 
  - OpenRouter::Client
- Reference
- Object
Overview
Client for the OpenRouter API
Defined in:
openrouter/client.crConstant Summary
- 
        BASE_URL = "https://openrouter.ai/api/v1"
Constructors
- 
        .new(api_key : String, app_name : String | Nil = nil, app_url : String | Nil = nil)
        
          Initialize a new OpenRouter::Client 
Instance Method Summary
- #api_key : String
- #api_key=(api_key : String)
- 
        #app_name : String | Nil
        
          It tells OpenRouter which app is using the API see #app_url 
- 
        #app_name=(app_name : String | Nil)
        
          It tells OpenRouter which app is using the API see #app_url 
- 
        #app_url : String | Nil
        
          Together with #app_name it tells OpenRouter which app is using the API 
- 
        #app_url=(app_url : String | Nil)
        
          Together with #app_name it tells OpenRouter which app is using the API 
- 
        #complete(prompt : String, model : String) : Response
        
          Send a completion request for a text prompt using the specified model 
- 
        #complete(request : CompletionRequest) : Response
        
          Send a completion request using the specified CompletionRequest object 
- 
        #get(endpoint : String) : JSON::Any
        
          Get a specific endpoint 
- 
        #get_models : Array(Model)
        
          Returns an array of Model structs representing the available models currently supported by OpenRouter 
- 
        #post(endpoint : String, body : String | Nil) : JSON::Any
        
          Post to a specific endpoint 
Constructor Detail
Initialize a new OpenRouter::Client
The api_key is generally required to use the API (though an invalid key seems to allow querying for models.) app_name and app_url are optional and tell OpenRouter about your application.
Instance Method Detail
It tells OpenRouter which app is using the API see #app_url
Together with #app_name it tells OpenRouter which app is using the API
Send a completion request for a text prompt using the specified model
Send a completion request using the specified CompletionRequest object
Get a specific endpoint
This is a low-level method that is available for edge cases.
Returns an array of Model structs representing the available models currently supported by OpenRouter
Post to a specific endpoint
This is a low-level method that is available for edge cases.