openrouter

package module
v0.0.0-...-a4c929e Latest Latest
Warning

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

Go to latest
Published: Dec 23, 2025 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Overview

Package openrouter provides a Genkit plugin for OpenRouter. OpenRouter provides a unified API to access various LLM providers.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsDefinedModel

func IsDefinedModel(g *genkit.Genkit, name string) bool

IsDefinedModel reports whether a model is defined.

func Model

func Model(g *genkit.Genkit, name string) ai.Model

Model returns the ai.Model with the given name.

Types

type ModelDefinition

type ModelDefinition struct {
	// Name is an optional label for the model (e.g., "fast", "expensive").
	// If provided, the model registers as "openrouter/{Name}" (e.g., "openrouter/fast").
	// If empty, the first model in Models is used as the name (e.g., "openrouter/anthropic/claude-3-opus").
	Name string
	// Models is the list of OpenRouter model IDs to use, in order of preference.
	// If multiple models are specified, OpenRouter will try them in order as fallbacks.
	// At least one model must be specified.
	Models []string
	// Label is an optional human-readable label for display purposes.
	Label string
}

ModelDefinition represents a model configuration.

type OpenRouter

type OpenRouter struct {
	// APIKey is the OpenRouter API key. If empty, reads from OPENROUTER_API_KEY env var.
	APIKey string
	// SiteName is an optional site name for OpenRouter analytics.
	SiteName string
	// SiteURL is an optional site URL for OpenRouter analytics.
	SiteURL string
	// contains filtered or unexported fields
}

OpenRouter provides configuration options for the plugin.

func (*OpenRouter) DefineModel

func (o *OpenRouter) DefineModel(g *genkit.Genkit, model ModelDefinition, opts *ai.ModelOptions) ai.Model

DefineModel registers a model with Genkit.

func (*OpenRouter) Init

func (o *OpenRouter) Init(ctx context.Context) []api.Action

Init initializes the plugin.

func (*OpenRouter) Name

func (o *OpenRouter) Name() string

Name returns the provider name.