openrouter

package
v0.0.0 Latest Latest
Warning

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

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

Documentation

Overview

Package openrouter implements the OpenRouter provider.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func WithCapabilities

func WithCapabilities(m model.Model, info SupportedParameters, inputModalities []string) model.Model

WithCapabilities adds capabilities to a model based on supported parameters and input modalities.

Types

type Client

type Client struct {
	*openrouter.Client
	// contains filtered or unexported fields
}

Client wraps the OpenRouter API client with Fantasy for chat.

func New

func New(url, token string, timeout time.Duration) *Client

New creates an OpenRouter client with the given URL, token, and response timeout.

func (*Client) Chat

func (c *Client) Chat(
	ctx context.Context,
	req request.Request,
	streamFunc stream.Func,
) (message.Message, usage.Usage, error)

Chat sends a chat completion request via Fantasy with streaming support.

func (*Client) Embed

Embed generates embeddings for the given input texts.

func (*Client) Estimate

func (c *Client) Estimate(_ context.Context, _ request.Request, _ string) (int, error)

Estimate is not supported by the OpenRouter provider.

func (*Client) Model

func (c *Client) Model(ctx context.Context, name string) (model.Model, error)

Model returns metadata for the specified model by name. Uses a lazy-loaded cache to avoid re-fetching the full model list on every call.

func (*Client) Models

func (c *Client) Models(ctx context.Context) (model.Models, error)

Models fetches all available models including chat and embedding models.

type SupportedParameters

type SupportedParameters []string

SupportedParameters contains parameter names supported by a model.

Jump to

Keyboard shortcuts

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