Creates a new OpenRouter API client instance
Optional
key: stringOpenRouter API key (obtain from platform.er-api.biz.id)
Generate a response from an AI model
The model ID to use (e.g. "anthropic/claude-3-opus")
User prompt/query text
Optional
params: ModelParamsOptional parameters for the model
Promise resolving to the model response
Get the current API key
The current OpenRouter API key
Get a list of all available AI models
Promise resolving to the model list response
Generate a response with step-by-step reasoning
The model ID to use
User prompt/query text
Optional
params: ModelParamsOptional parameters for the model
Promise resolving to the model response with reasoning
Set OpenRouter API key
OpenRouter API key
Generate a streaming response from an AI model
The model ID to use
User prompt/query text
Callback function for data chunks
Callback function for errors
Callback function called when stream is complete
Optional
params: ModelParamsOptional parameters for the model
Static
fromCreate OpenRouter client from environment variables
An initialized OpenRouter API client
OpenRouter client for accessing AI models through ER-API