Documentation
¶
Overview ¶
Package llm contains shared types for interacting with language model APIs.
Index ¶
- Constants
- func DatedVersionOf(alias, id string) (string, bool)
- func IsFirstPartyProvider(provider string) bool
- func IsProxyPath(path string) bool
- func SetSubscriptionAttempt(ctx *schemas.BifrostContext, admitted bool)
- func SubscriptionAttempt(ctx *schemas.BifrostContext) (admitted, classified bool)
- func WriteError(w http.ResponseWriter, req *http.Request, message string, code int)
- type Dialect
Constants ¶
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
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
IsFirstPartyProvider reports whether a gateway provider serves only its own company's models.
func IsProxyPath ¶ added in v0.28.0
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
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
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.