openrouter

package
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 21, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type OpenRouterClient

type OpenRouterClient struct {
	// contains filtered or unexported fields
}

OpenRouterClient handles communication with the OpenRouter API. OpenRouter is an OpenAI-compatible gateway that provides access to hundreds of models from providers like Anthropic, OpenAI, Meta, etc.

func NewOpenRouterClient

func NewOpenRouterClient(apiKey, model string) *OpenRouterClient

NewOpenRouterClient creates a new OpenRouter client. The default model is "google/gemini-2.5-flash-lite" if none is specified. Find available models at https://openrouter.ai/models

func (*OpenRouterClient) Chat

func (c *OpenRouterClient) Chat(messages []llm.Message) (string, error)

Chat sends a non-streaming chat request and returns the complete response.

func (*OpenRouterClient) ChatStream

func (c *OpenRouterClient) ChatStream(messages []llm.Message, callback llm.StreamCallback) (string, error)

ChatStream sends a streaming chat request using SSE and calls callback for each chunk. Returns the complete response when streaming finishes.

func (*OpenRouterClient) CheckConnection

func (c *OpenRouterClient) CheckConnection() error

CheckConnection verifies that the OpenRouter API is reachable and the key is valid by fetching the models list (a cheap, read-only endpoint).

func (*OpenRouterClient) GetModel

func (c *OpenRouterClient) GetModel() string

GetModel returns the model identifier being used.

type OpenRouterProvider

type OpenRouterProvider struct{}

OpenRouterProvider implements Provider for the OpenRouter gateway. OpenRouter is an OpenAI-compatible API that provides access to hundreds of models (Claude, GPT-4, Llama, Gemini, etc.) through a single endpoint. Find available models at https://openrouter.ai/models

func (*OpenRouterProvider) BuildClient

func (p *OpenRouterProvider) BuildClient(values map[string]string, model string) (llm.LLMClient, error)

func (*OpenRouterProvider) DefaultModel

func (p *OpenRouterProvider) DefaultModel() string

func (*OpenRouterProvider) DisplayName

func (p *OpenRouterProvider) DisplayName() string

func (*OpenRouterProvider) ID

func (p *OpenRouterProvider) ID() string

func (*OpenRouterProvider) SetupFields

func (p *OpenRouterProvider) SetupFields() []llm.SetupField

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL