llm

package
v0.28.0 Latest Latest
Warning

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

Go to latest
Published: Nov 7, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package llm contains shared types for interacting with language model APIs.

Index

Constants

View Source
const (
	// ProxyPathPrefix is where Obot serves its LLM proxy.
	ProxyPathPrefix = "/api/llm-proxy/"
)

Variables

This section is empty.

Functions

func DatedVersionOf added in v0.28.0

func DatedVersionOf(alias, id string) (string, bool)

DatedVersionOf reports whether id is a dated version of alias, as Anthropic names them: "claude-sonnet-4-5-20250929" is a version of "claude-sonnet-4-5", which Anthropic's API accepts as an alias of its latest version. It returns the version's date (YYYYMMDD), which orders versions.

func IsFirstPartyProvider added in v0.28.0

func IsFirstPartyProvider(provider string) bool

IsFirstPartyProvider reports whether a gateway provider serves only its own company's models.

func IsProxyPath added in v0.28.0

func IsProxyPath(path string) bool

IsProxyPath reports whether path is on Obot's LLM proxy.

func SetSubscriptionAttempt added in v0.28.0

func SetSubscriptionAttempt(ctx *schemas.BifrostContext, admitted bool)

SetSubscriptionAttempt classifies an engine-admitted attempt before access and budget hooks. Only trusted engine code may set this marker; it carries no token.

func SubscriptionAttempt added in v0.28.0

func SubscriptionAttempt(ctx *schemas.BifrostContext) (admitted, classified bool)

SubscriptionAttempt distinguishes an explicit engine decision from legacy callers that have not classified an attempt.

func WriteError added in v0.28.0

func WriteError(w http.ResponseWriter, req *http.Request, message string, code int)

WriteError writes an error response to an LLM proxy request in the API format the request expects, so API clients and SDKs report the error as they would the provider's own.

Types

type Dialect

type Dialect string

Dialect identifies the API format used by an LLM provider.

const (
	// DialectAnthropicMessages is the Anthropic Messages API format.
	DialectAnthropicMessages Dialect = "AnthropicMessages"
	// DialectOpenAIResponses is the OpenAI Responses API format.
	DialectOpenAIResponses Dialect = "OpenAIResponses"
	// DialectOpenResponses is the provider-neutral OpenResponses API format.
	DialectOpenResponses Dialect = "OpenResponses"
	// DialectOpenAIChatCompletions is the OpenAI Chat Completions API format.
	DialectOpenAIChatCompletions Dialect = "OpenAIChatCompletions"
)

func ErrorDialect added in v0.28.0

func ErrorDialect(req *http.Request) Dialect

ErrorDialect is the API format an LLM proxy request expects its errors in: Anthropic's for the Messages API and for Anthropic clients (which send anthropic-version on every request, including model listing), and OpenAI's otherwise.

Jump to

Keyboard shortcuts

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