openrouter

package module
v0.14.0 Latest Latest
Warning

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

Go to latest
Published: Sep 1, 2026 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package openrouter exposes OpenRouter chat adapters. NewChat targets its OpenAI-compatible endpoint; NewMessages targets its Anthropic-compatible endpoint.

Index

Constants

View Source
const (
	OpenAIRequestExtensionKey        = "openrouter/openai_request"
	OpenAIResponseExtensionKey       = "openrouter/openai_response"
	OpenAIStreamChunkExtensionKey    = "openrouter/openai_stream_chunk"
	AnthropicRequestExtensionKey     = "openrouter/anthropic_request"
	AnthropicResponseExtensionKey    = "openrouter/anthropic_response"
	AnthropicStreamEventExtensionKey = "openrouter/anthropic_stream_event"
)

Namespacing preserves provider-specific data without promoting it into the shared Core protocol or colliding with another provider.

View Source
const (
	// BaseURL is OpenRouter's production endpoint.
	BaseURL = "https://openrouter.ai/api/v1"

	// ModelAuto delegates per-request model selection to OpenRouter's
	// task-aware Auto Router.
	ModelAuto = "openrouter/auto"
)
View Source
const (
	// HeaderReferer is the standard HTTP Referer header used by
	// OpenRouter for app attribution / analytics. Pass your app's
	// homepage URL.
	HeaderReferer = "HTTP-Referer"

	// HeaderAppTitle is the X-Title header OpenRouter shows on
	// leaderboards / rankings. Pass your app's display name.
	HeaderAppTitle = "X-Title"
)
View Source
const (
	Provider = "OpenRouter"
)

Provider is the stable backend name for host-side attribution.

Variables

This section is empty.

Functions

This section is empty.

Types

type Chat added in v0.13.0

type Chat = openai.ChatCompletions

Chat implements OpenRouter's OpenAI-compatible endpoint.

func NewChat added in v0.13.0

func NewChat(config ChatConfig) (*Chat, error)

NewChat rejects an invalid provider binding before the first chat call.

type ChatConfig added in v0.13.0

type ChatConfig struct {
	APIKey         string
	DefaultOptions corechat.Options
	BaseURL        string
	AppURL         string
	AppTitle       string
	HTTPClient     *http.Client
}

ChatConfig binds provider access and defaults shared by every chat call.

func (ChatConfig) Validate added in v0.13.0

func (c ChatConfig) Validate() error

type Messages added in v0.13.0

type Messages = anthropic.Messages

Messages implements OpenRouter's Anthropic-compatible endpoint.

func NewMessages added in v0.13.0

func NewMessages(config MessagesConfig) (*Messages, error)

NewMessages rejects an invalid provider binding before the first Messages call.

type MessagesConfig added in v0.13.0

type MessagesConfig struct {
	APIKey         string
	DefaultOptions corechat.Options
	BaseURL        string
	AppURL         string
	AppTitle       string
	HTTPClient     *http.Client
}

MessagesConfig binds provider access and defaults shared by every Messages call.

func (MessagesConfig) Validate added in v0.13.0

func (m MessagesConfig) Validate() error

Jump to

Keyboard shortcuts

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