Documentation
¶
Overview ¶
Package nexus is a composable AI gateway library for Go. Route, cache, guard, and observe LLM traffic at scale.
Nexus is a library, not a SaaS. Import it, compose your AI gateway, and own your infrastructure.
gw := nexus.New(
nexus.WithProvider(openai.New("sk-...")),
nexus.WithProvider(anthropic.New("sk-ant-...")),
nexus.WithRouter(router.NewCostOptimized()),
nexus.WithCache(cache.NewRedis(redisClient)),
nexus.WithGuard(guard.NewPII(guard.ActionRedact)),
)
gw.Initialize(ctx)
gw.Mount(router, "/ai")
Index ¶
- Variables
- func RefuseUnpriced(ctx context.Context, tenantID, providerName, modelID string) error
- type CompletionRequest
- type CompletionResponse
- type Config
- type Engine
- func (e *Engine) Complete(ctx context.Context, req *provider.CompletionRequest) (*provider.CompletionResponse, error)
- func (e *Engine) CompleteStream(ctx context.Context, req *provider.CompletionRequest) (provider.Stream, error)
- func (e *Engine) Embed(ctx context.Context, req *provider.EmbeddingRequest) (*provider.EmbeddingResponse, error)
- func (e *Engine) Gateway() *Gateway
- func (e *Engine) ListModels(ctx context.Context) ([]provider.Model, error)
- type Gateway
- func (gw *Gateway) Aliases() []model.Alias
- func (gw *Gateway) Cache() cache.Service
- func (gw *Gateway) CacheKinds() (completion, stream string)
- func (gw *Gateway) Config() *Config
- func (gw *Gateway) Engine() *Engine
- func (gw *Gateway) EnsureBootstrapAdminKey(ctx context.Context) error
- func (gw *Gateway) Extensions() *plugin.Registry
- func (gw *Gateway) FlushUsage(ctx context.Context) error
- func (gw *Gateway) Guard() guard.Service
- func (gw *Gateway) Health(_ context.Context) error
- func (gw *Gateway) Initialize(_ context.Context) error
- func (gw *Gateway) Initialized() bool
- func (gw *Gateway) Keys() key.Service
- func (gw *Gateway) Limiter() ratelimit.Limiter
- func (gw *Gateway) LimiterErrors() int64
- func (gw *Gateway) Logger() Logger
- func (gw *Gateway) Models() model.Service
- func (gw *Gateway) Mount(mux Router, basePath ...string)
- func (gw *Gateway) Pipeline() pipeline.Service
- func (gw *Gateway) PipelineStages() []pipeline.Stage
- func (gw *Gateway) PriceBook() *model.PriceBook
- func (gw *Gateway) Providers() provider.Registry
- func (gw *Gateway) RouterService() router.Service
- func (gw *Gateway) RoutingStrategy() string
- func (gw *Gateway) Shutdown(ctx context.Context) error
- func (gw *Gateway) Store() store.Store
- func (gw *Gateway) Tenants() tenant.Service
- func (gw *Gateway) Transforms() *transform.Registry
- func (gw *Gateway) Usage() usage.Service
- func (gw *Gateway) UsageInsertErrors() int64
- type ID
- type Logger
- type Message
- type Option
- func WithAlias(name string, targets ...model.AliasTarget) Option
- func WithAuth(a auth.Provider) Optiondeprecated
- func WithBasePath(path string) Option
- func WithBootstrapAdminKey(raw string) Option
- func WithCache(c cache.Cache) Option
- func WithCacheEnabled(on bool) Option
- func WithConfig(cfg *Config) Option
- func WithCredentialProvider(cp provider.CredentialProvider) Option
- func WithDatabase(s store.Store) Option
- func WithExtension(e plugin.Extension) Option
- func WithGuard(g guard.Guard) Option
- func WithHealthTracker(h provider.HealthTracker) Option
- func WithKeyService(s key.Service) Option
- func WithLimiter(l ratelimit.Limiter) Option
- func WithLogger(l Logger) Option
- func WithMaxRetries(n int) Option
- func WithMetrics(m gometrics.Metrics) Option
- func WithMiddleware(m pipeline.Middleware) Option
- func WithPipeline(p pipeline.Service) Option
- func WithPriceOverrides(overrides ...model.PriceOverride) Option
- func WithProvider(p provider.Provider) Option
- func WithProviderTransport(wrap func(http.RoundTripper) http.RoundTripper) Option
- func WithRateLimit(rpm int) Option
- func WithRequireAPIKey(on bool) Option
- func WithRouter(r router.Strategy) Option
- func WithStreamCache(sc cache.StreamCache, opts cache.StreamCacheOptions) Option
- func WithStreamGuard(g guard.StreamGuard) Option
- func WithStreamGuardStrategy(s guard.StreamStrategy) Option
- func WithStreamLifecycleConfig(cfg middlewares.StreamLifecycleConfig) Option
- func WithTenantAlias(tenantID, name string, targets ...model.AliasTarget) Option
- func WithTenantService(s tenant.Service) Option
- func WithTimeout(d time.Duration) Option
- func WithTracer(t observability.Tracer) Option
- func WithTransforms(r *transform.Registry) Option
- func WithUnpricedPolicy(p UnpricedPolicy) Option
- func WithUsageEnabled(on bool) Option
- func WithUsageService(s usage.Service) Option
- type Prefix
- type RefusalError
- type Router
- type Stream
- type UnpricedPolicy
Constants ¶
This section is empty.
Variables ¶
var ( // Provider errors ErrProviderNotFound = errors.New("nexus: provider not found") ErrModelNotSupported = errors.New("nexus: model not supported by provider") ErrAllProvidersFailed = errors.New("nexus: all providers failed") // Auth errors ErrAPIKeyInvalid = errors.New("nexus: invalid API key") ErrAPIKeyRevoked = errors.New("nexus: API key revoked") // Tenant errors ErrTenantNotFound = errors.New("nexus: tenant not found") ErrTenantDisabled = errors.New("nexus: tenant disabled") ErrQuotaExceeded = errors.New("nexus: quota exceeded") ErrBudgetExceeded = errors.New("nexus: budget exceeded") // Rate limiting ErrRateLimited = errors.New("nexus: rate limited") // Guardrail errors ErrContentBlocked = errors.New("nexus: content blocked by guardrail") ErrPIIDetected = errors.New("nexus: PII detected in request") ErrInjectionDetected = errors.New("nexus: prompt injection detected") // Cache errors ErrCacheNotConfigured = errors.New("nexus: cache not configured") // Pipeline errors ErrPipelineAborted = errors.New("nexus: pipeline aborted") ErrCircuitOpen = errors.New("nexus: circuit breaker open") // Context & tokens ErrContextOverflow = errors.New("nexus: request exceeds context window") ErrTokenEstimateFailed = errors.New("nexus: token estimation failed") // Model aliases ErrAliasNotFound = errors.New("nexus: model alias not found") ErrNoTargetsAvailable = errors.New("nexus: no alias targets available") // Extended thinking ErrThinkingNotSupported = errors.New("nexus: provider does not support extended thinking") // Batch ErrBatchTooLarge = errors.New("nexus: batch exceeds maximum size") ErrBatchNotFound = errors.New("nexus: batch job not found") // ErrModelUnpriced refuses a request for a model with no price at the // provider it was routed to (RefuseUnpriced). It is a *RefusalError with // code model_unpriced and status 400. ErrModelUnpriced = middlewares.ErrModelUnpriced // Credentials ErrCredentialExpired = errors.New("nexus: provider credential expired") // ErrCredentialNotFound is provider.ErrCredentialNotFound: a credential // provider returns it to serve a request with the provider's own key. ErrCredentialNotFound = provider.ErrCredentialNotFound // be resolved, or that the chosen provider cannot use // (WithCredentialProvider). It is a *RefusalError with code unavailable // and status 503; nothing is sent to the provider. ErrCredentialUnavailable = middlewares.ErrCredentialUnavailable )
var ErrNotInitialized = errors.New("nexus: gateway not initialized")
ErrNotInitialized is returned by the engine's calls before Gateway.Initialize has finished.
Functions ¶
Types ¶
type CompletionRequest ¶
type CompletionRequest = provider.CompletionRequest
CompletionRequest is an alias for provider.CompletionRequest.
type CompletionResponse ¶
type CompletionResponse = provider.CompletionResponse
CompletionResponse is an alias for provider.CompletionResponse.
type Config ¶
type Config struct {
// BasePath is the HTTP base path for routes (default: "/nexus").
BasePath string
// DefaultTimeout is the default timeout for provider requests (default: 30s).
DefaultTimeout time.Duration
// DefaultMaxRetries is the default number of retries per request (default: 2).
DefaultMaxRetries int
// EnableUsage enables usage tracking (default: true).
EnableUsage bool
// EnableCache enables caching (default: false, must provide cache).
EnableCache bool
// RequireAPIKey makes the HTTP edges (api, proxy) refuse a request
// without a valid nxs_ key. Default true. False keeps an open gateway
// for local work; a key that is presented is still checked.
RequireAPIKey bool
// GlobalRateLimit is the global rate limit in requests per minute (0 = unlimited).
GlobalRateLimit int
// LogLevel is the log level for the internal logger (default: "info").
LogLevel string
}
Config holds the gateway configuration.
func DefaultConfig ¶
func DefaultConfig() *Config
DefaultConfig returns the default gateway configuration.
type Engine ¶
type Engine struct {
// contains filtered or unexported fields
}
Engine processes AI requests without any HTTP concerns. It delegates to the pipeline for the actual processing.
The engine exists from New on, but Complete, CompleteStream, Embed and ListModels return ErrNotInitialized until Gateway.Initialize finishes.
func (*Engine) Complete ¶
func (e *Engine) Complete(ctx context.Context, req *provider.CompletionRequest) (*provider.CompletionResponse, error)
Complete sends a chat completion request through the full pipeline.
func (*Engine) CompleteStream ¶
func (e *Engine) CompleteStream(ctx context.Context, req *provider.CompletionRequest) (provider.Stream, error)
CompleteStream sends a streaming chat completion request.
func (*Engine) Embed ¶
func (e *Engine) Embed(ctx context.Context, req *provider.EmbeddingRequest) (*provider.EmbeddingResponse, error)
Embed sends an embedding request.
type Gateway ¶
type Gateway struct {
// contains filtered or unexported fields
}
Gateway is the root Nexus instance. It can be used standalone or mounted into a Forge application.
func (*Gateway) CacheKinds ¶
CacheKinds reports completion and stream cache backends separately. A custom cache without a Kind method is unknown; an absent cache is none.
func (*Gateway) EnsureBootstrapAdminKey ¶
EnsureBootstrapAdminKey makes sure the key set with WithBootstrapAdminKey exists, so an operator can reach the admin API without writing Go. It does nothing when no key was set. Otherwise it finds or creates the active tenant with slug "operator", then stores the key there with the admin scope. Running it again changes nothing.
A key revoked since the last run stays revoked and is reported with a warning that names its id, so revoking the bootstrap key retires it. The same warning covers a key that exists without the admin scope or under another tenant. An "operator" tenant that is not active is an error. A key of the wrong shape is an error that gives its length. The raw key never appears in an error or a log line.
Call it after the gateway is initialized and the store is migrated: Store().Migrate() must have run, or the lookups fail. The Forge extension does this in Start.
func (*Gateway) Extensions ¶
Extensions returns the extension registry.
func (*Gateway) FlushUsage ¶
FlushUsage waits until every usage record taken so far is stored, without closing the stage. It also waits for streams that are still open, until ctx ends. Shutdown flushes on its own.
func (*Gateway) Health ¶
Health reports whether the gateway serves requests. It returns ErrNotInitialized before Initialize and after Shutdown, as the engine does.
func (*Gateway) Initialize ¶
Initialize sets up all services and validates configuration. A second call on an initialized gateway does nothing. After Shutdown it fails with an error that wraps ErrNotInitialized: a gateway is not restarted, so create a new one.
func (*Gateway) Initialized ¶
Initialized reports whether Initialize has succeeded and Shutdown has not run since. The engine serves requests only while it is true.
func (*Gateway) LimiterErrors ¶
LimiterErrors counts limiter failures that let a request through.
func (*Gateway) PipelineStages ¶
PipelineStages lists the pipeline's stages in the order they run, or nil for a custom pipeline that cannot list them.
func (*Gateway) PriceBook ¶
PriceBook returns the price book the usage stage prices requests with. It exists from New, so overrides can be set before Initialize.
func (*Gateway) RouterService ¶
RouterService returns the routing service.
func (*Gateway) RoutingStrategy ¶
RoutingStrategy is the name of the routing strategy in use.
func (*Gateway) Shutdown ¶
Shutdown gracefully stops all services. It stops the usage stage taking new records, waits until ctx is done for the streams still open and the records still being stored, then closes the store only if the gateway built it. A store passed to WithDatabase belongs to the caller, who closes it after Shutdown. When ctx ends first, the records not yet stored are lost: Shutdown logs how many and returns the flush error, joined with any error from closing the store.
Shutdown clears Gateway.Initialized, so the engine refuses new calls with ErrNotInitialized. It is safe on a gateway that was never initialized. A gateway is not restarted after Shutdown: Initialize returns an error.
func (*Gateway) Transforms ¶
Transforms returns the transform registry, or nil when none is configured.
func (*Gateway) UsageInsertErrors ¶
UsageInsertErrors is how many usage records failed to store since start.
type Logger ¶
type Logger interface {
Debug(msg string, args ...any)
Info(msg string, args ...any)
Warn(msg string, args ...any)
Error(msg string, args ...any)
}
Logger is a minimal structured logger interface. Compatible with slog, zap, Forge logger, etc.
func NewLevelLogger ¶
NewLevelLogger drops messages below level: "debug", "info", "warn" or "error". Any other value means "info".
func NewNoopLogger ¶
func NewNoopLogger() Logger
NewNoopLogger returns a Logger that discards all output.
type Option ¶
type Option func(*Gateway)
Option configures a Gateway.
func WithAlias ¶
func WithAlias(name string, targets ...model.AliasTarget) Option
WithAlias registers a model alias that maps a virtual model name to one or more concrete provider+model targets.
Example:
nexus.WithAlias("fast", model.AliasTarget{Provider: "anthropic", Model: "claude-3.5-haiku"})
nexus.WithAlias("cheap",
model.AliasTarget{Provider: "openai", Model: "gpt-4o-mini", Weight: 0.7},
model.AliasTarget{Provider: "anthropic", Model: "claude-3.5-haiku", Weight: 0.3},
)
func WithAuth
deprecated
func WithBootstrapAdminKey ¶
WithBootstrapAdminKey sets the raw value of the first admin key. After Initialize and Store().Migrate(), EnsureBootstrapAdminKey stores it under the "operator" tenant with the admin scope, so the admin API is reachable without writing Go. The value must be "nxs_" and 64 lowercase hex digits, for example "nxs_" + the output of `openssl rand -hex 32`. It is a secret: keep it out of source control.
func WithCacheEnabled ¶
WithCacheEnabled turns the response cache on. Without WithCache it is an in-memory cache with the default size and TTL.
func WithConfig ¶
WithConfig replaces the whole gateway configuration. Start from DefaultConfig() and change fields: a zero Config has EnableUsage false, so the gateway records no usage, and no timeout or retries.
func WithCredentialProvider ¶
func WithCredentialProvider(cp provider.CredentialProvider) Option
WithCredentialProvider resolves the credential for each provider call, so one gateway serves every tenant on its own key (and, for an OpenAI-compatible provider, its own base URL), with each provider's configured key as the fallback. The gateway asks cp after routing and the unpriced policy, once per attempt, with pipeline.TenantID(ctx) set to the request's nexus tenant. A cp that implements provider.CredentialResolver can set the base URL as well; any other gives only a key.
provider.ErrCredentialNotFound (or an empty credential) serves the request with the provider's own key. Any other error refuses it with ErrCredentialUnavailable (503) and sends nothing: there is no silent fall back to the operator's key when a tenant's key store is down. A credential for a provider that cannot take one (not provider.CredentialAware) is refused the same way. Anthropic, OpenAI and opencompat take them. Like the unpriced policy, it is part of the default pipeline only (add middlewares.NewProviderCall(...).WithCredentialProvider to one set with WithPipeline).
func WithDatabase ¶
WithDatabase sets the persistence store. The caller owns it: Shutdown does not close it.
func WithExtension ¶
WithExtension registers a lifecycle extension (audit_hook, observability, relay_hook, etc.).
func WithGuard ¶
WithGuard adds a guardrail to the pipeline. A guard whose phase is output or both also checks streamed replies; see WithStreamGuardStrategy.
func WithHealthTracker ¶
func WithHealthTracker(h provider.HealthTracker) Option
WithHealthTracker sets the provider health tracker.
func WithKeyService ¶
WithKeyService replaces the API key service Initialize would build.
func WithLimiter ¶
WithLimiter sets the RPM and TPM limiter. The default is in-process (ratelimit.NewMemory), which applies per replica.
func WithMaxRetries ¶
WithMaxRetries sets the default max retries.
func WithMetrics ¶
WithMetrics records the gateway's metrics on m: the GenAI client duration and token histograms, time to first chunk, requests by outcome, guardrail blocks, cache lookups, usage insert failures and limiter failures. In a Forge app pass app.Metrics(); the Forge extension does this for you. A nil m records nothing. Spans need no option: they go to the global tracer provider, which forge.New installs.
func WithMiddleware ¶
func WithMiddleware(m pipeline.Middleware) Option
WithMiddleware adds a custom middleware to the pipeline.
func WithPipeline ¶
WithPipeline sets a fully custom pipeline, replacing the default. The default carries the access stage (tenant status and key scopes) and the quota stage (token cap, daily requests, budget, RPM, TPM). A custom pipeline without them enforces none of that, while the HTTP edge still authenticates keys, so a key without the completions scope is served. Include middlewares.NewAccess ahead of middlewares.NewQuota: quota reads the tenant access publishes.
func WithPriceOverrides ¶
func WithPriceOverrides(overrides ...model.PriceOverride) Option
WithPriceOverrides prices models at the providers that serve them, over the providers' own list prices and for models they do not list. Each override names the provider by its registered name. Overrides from every WithPriceOverrides add up; a later one for the same model and provider wins. To replace them all at runtime, call PriceBook().SetOverrides.
An override the price book rejects (see model.PriceBook.SetOverrides) leaves the overrides unset, and Initialize returns the error unless a later PriceBook().SetOverrides call with valid prices succeeds first.
func WithProvider ¶
WithProvider registers an LLM provider.
func WithProviderTransport ¶
func WithProviderTransport(wrap func(http.RoundTripper) http.RoundTripper) Option
WithProviderTransport wraps the HTTP transport of every registered provider that implements provider.TransportWrapper, once, when the gateway is initialized. The Forge extension passes forge.InstrumentTransport, so each call to a provider gets an HTTP client span under its GenAI span. Outside Forge, pass otelhttp.NewTransport or your own wrapper. Providers registered after Initialize are not wrapped.
func WithRateLimit ¶
WithRateLimit sets global rate limit (requests per minute).
func WithRequireAPIKey ¶
WithRequireAPIKey turns key enforcement at the HTTP edges on or off.
func WithStreamCache ¶
func WithStreamCache(sc cache.StreamCache, opts cache.StreamCacheOptions) Option
WithStreamCache enables record-and-replay caching for streaming responses using the given backend and options. Streams that produce a cache hit are served from the recorded frames; misses pass through and are recorded for later use. Independent of WithCache (which only handles non-streaming).
func WithStreamGuard ¶
func WithStreamGuard(g guard.StreamGuard) Option
WithStreamGuard adds a guard that checks every streamed chunk, under guard.StrategyBuffer before anything is delivered and under guard.StrategyChunkwise before each chunk goes out. guard.StrategyPassthrough does not run it. It is not one of the WithGuard guards: its Check method is not called.
func WithStreamGuardStrategy ¶
func WithStreamGuardStrategy(s guard.StreamStrategy) Option
WithStreamGuardStrategy sets when streamed output reaches the consumer relative to the output guards' verdict. Output guards are the WithGuard guards whose phase is output or both.
- guard.StrategyBuffer (the default) delivers nothing until the whole reply has passed. A block ends the stream with *guard.BlockedError, and a redacting guard's rewrite is what the consumer receives.
- guard.StrategyPassthrough streams as the provider answers and checks the reply when it ends: a block replaces io.EOF with *guard.BlockedError, so run tool calls only after a clean end. A rewrite comes too late to apply; it is logged as a warning and the stream ends normally. Pick guard.StrategyBuffer when a redacting guard must take effect.
- guard.StrategyChunkwise runs the WithStreamGuard guards on every chunk before delivering it, then checks the reply as StrategyPassthrough does.
func WithStreamLifecycleConfig ¶
func WithStreamLifecycleConfig(cfg middlewares.StreamLifecycleConfig) Option
WithStreamLifecycleConfig tunes per-chunk plugin hook fan-out for streamed responses. Default (zero value) emits OnChunkReceived for every chunk.
Set EmitEveryNChunks to 16 or 32 in latency-sensitive deployments where per-chunk hooks would otherwise dominate the hot path.
func WithTenantAlias ¶
func WithTenantAlias(tenantID, name string, targets ...model.AliasTarget) Option
WithTenantAlias registers a per-tenant model alias override.
func WithTenantService ¶
WithTenantService replaces the tenant service Initialize would build.
func WithTimeout ¶
WithTimeout sets the default request timeout.
func WithTracer ¶
func WithTracer(t observability.Tracer) Option
WithTracer adds a stage that reports each request to t, for a tracer that is not OpenTelemetry. The gateway already starts OpenTelemetry spans on the global tracer provider without it (see the observability docs), so with an OpenTelemetry bridge you would see each request twice.
func WithTransforms ¶
WithTransforms sets the transform registry for input/output transforms.
func WithUnpricedPolicy ¶
func WithUnpricedPolicy(p UnpricedPolicy) Option
WithUnpricedPolicy sets the policy for requests to models with no price. Without one every such request is served, counted in nexus_usage_unpriced_total and warned about once per provider and model. Pass RefuseUnpriced so per-tenant budgets cannot miss spend on unpriced models. A priced call whose token counts never arrive (a stream that fails or is closed before its usage, a mid-stream StreamGuard block) still records an unknown cost; usage Series counts those in Unpriced. The policy is part of the default pipeline: one set with WithPipeline does not get it (add middlewares.NewProviderCall(...).WithUnpricedPolicy yourself).
func WithUsageEnabled ¶
WithUsageEnabled turns usage recording on or off (default on). Off is the one way to stop recording; the usage service is still built for reads.
func WithUsageService ¶
WithUsageService replaces the usage service Initialize would build.
type RefusalError ¶
type RefusalError = pipeline.RefusalError
RefusalError is the typed refusal every enforcement stage returns. It lives in pipeline so stages can return it without importing this package.
type Router ¶
type Router interface {
http.Handler
Handle(pattern string, handler http.Handler)
HandleFunc(pattern string, handler http.HandlerFunc)
}
Router is a minimal interface for HTTP routing. Compatible with chi.Router, forge.Router, http.ServeMux, etc.
type UnpricedPolicy ¶
UnpricedPolicy decides whether a request for a model with no price may reach its provider. The gateway asks it after routing and before each provider call, and only when the routed model has no price at the routed provider for the kind of request: no input or output price for a completion or a stream, no embedding price for an embedding. tenantID is the request's nexus tenant, empty for an unattributed request.
A nil error lets the call through: it is served and recorded with an unknown cost, which no budget counts. A refusal such as ErrModelUnpriced refuses the request at $0; any other error fails it. Neither is retried.
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
_examples
|
|
|
forge
command
Example: using Nexus as a Forge extension.
|
Example: using Nexus as a Forge extension. |
|
multi-tenant
command
Example: multi-tenant SaaS with API keys and usage tracking.
|
Example: multi-tenant SaaS with API keys and usage tracking. |
|
proxy
command
Example: OpenAI-compatible proxy server.
|
Example: OpenAI-compatible proxy server. |
|
standalone
command
Example: standalone Nexus gateway usage (no Forge).
|
Example: standalone Nexus gateway usage (no Forge). |
|
streaming
command
Example: streaming completions via the channel-based Go API.
|
Example: streaming completions via the channel-based Go API. |
|
Package api provides HTTP handlers for the Nexus gateway.
|
Package api provides HTTP handlers for the Nexus gateway. |
|
Package audit_hook provides the audit extension for Nexus.
|
Package audit_hook provides the audit extension for Nexus. |
|
Package auth authenticates gateway keys at the HTTP and gRPC edges: KeyAuth, RequireScope, Authenticate and AuthenticateWithTenants.
|
Package auth authenticates gateway keys at the HTTP and gRPC edges: KeyAuth, RequireScope, Authenticate and AuthenticateWithTenants. |
|
authsome
Package authsome provides an adapter that bridges an external Authsome authentication service to the Nexus auth.Provider interface.
|
Package authsome provides an adapter that bridges an external Authsome authentication service to the Nexus auth.Provider interface. |
|
Package batch provides batch processing for multiple LLM requests.
|
Package batch provides batch processing for multiple LLM requests. |
|
Package cache defines the caching interface for Nexus.
|
Package cache defines the caching interface for Nexus. |
|
stores
Package stores provides cache implementations for Nexus.
|
Package stores provides cache implementations for Nexus. |
|
config
module
|
|
|
Package extension provides the Forge extension adapter for Nexus.
|
Package extension provides the Forge extension adapter for Nexus. |
|
contract
Package contract serves the operator-wide Nexus dashboard contract.
|
Package contract serves the operator-wide Nexus dashboard contract. |
|
Package fallback defines the resilience and fallback subsystem.
|
Package fallback defines the resilience and fallback subsystem. |
|
Package guard defines the guardrails subsystem for content safety.
|
Package guard defines the guardrails subsystem for content safety. |
|
guards
Package guards provides built-in guardrail implementations.
|
Package guards provides built-in guardrail implementations. |
|
shieldadapter
Package shieldadapter provides a guardrail adapter that bridges an external Shield content safety engine to the Nexus guard.Guard interface.
|
Package shieldadapter provides a guardrail adapter that bridges an external Shield content safety engine to the Nexus guard.Guard interface. |
|
Package httpstream provides HTTP streaming wire formats for Nexus.
|
Package httpstream provides HTTP streaming wire formats for Nexus. |
|
Package id defines TypeID-based identity types for all Nexus entities.
|
Package id defines TypeID-based identity types for all Nexus entities. |
|
internal
|
|
|
telemetry
Package telemetry holds the OpenTelemetry plumbing Nexus's stages share: the tracer, the span attribute keys, how an error is named, and the metric families recorded on a go-utils metrics sink.
|
Package telemetry holds the OpenTelemetry plumbing Nexus's stages share: the tracer, the span attribute keys, how an error is named, and the metric families recorded on a go-utils metrics sink. |
|
telemetry/telemetrytest
Package telemetrytest records the spans and metrics Nexus emits, so a test can assert on them without a Forge app.
|
Package telemetrytest records the spans and metrics Nexus emits, so a test can assert on them without a Forge app. |
|
Package key defines the API key management types and service.
|
Package key defines the API key management types and service. |
|
Package mcp provides Model Context Protocol support for Nexus.
|
Package mcp provides Model Context Protocol support for Nexus. |
|
Package model defines model alias resolution and model metadata services.
|
Package model defines model alias resolution and model metadata services. |
|
Package money holds exact amounts of US dollars.
|
Package money holds exact amounts of US dollars. |
|
Package observability provides tracing and metrics middleware for Nexus.
|
Package observability provides tracing and metrics middleware for Nexus. |
|
Package paging holds the cursor rules every Nexus list shares.
|
Package paging holds the cursor rules every Nexus list shares. |
|
Package pipeline defines the composable middleware pipeline that processes every request through an ordered chain of middleware.
|
Package pipeline defines the composable middleware pipeline that processes every request through an ordered chain of middleware. |
|
middlewares
Package middlewares provides built-in pipeline middleware for Nexus.
|
Package middlewares provides built-in pipeline middleware for Nexus. |
|
Package plugin defines the extension system for Nexus.
|
Package plugin defines the extension system for Nexus. |
|
Package provider defines the unified interface for LLM providers.
|
Package provider defines the unified interface for LLM providers. |
|
providers
|
|
|
ai21
module
|
|
|
anthropic
module
|
|
|
anyscale
module
|
|
|
azureopenai
module
|
|
|
bedrock
module
|
|
|
cerebras
module
|
|
|
cohere
module
|
|
|
deepinfra
module
|
|
|
deepseek
module
|
|
|
fireworks
module
|
|
|
gemini
module
|
|
|
groq
module
|
|
|
hyperbolic
module
|
|
|
jinaai
module
|
|
|
lepton
module
|
|
|
lmstudio
module
|
|
|
mistral
module
|
|
|
nebius
module
|
|
|
novita
module
|
|
|
nvidia
module
|
|
|
ollama
module
|
|
|
openai
module
|
|
|
opencompat
module
|
|
|
openrouter
module
|
|
|
perplexity
module
|
|
|
sambanova
module
|
|
|
together
module
|
|
|
vertex
module
|
|
|
voyageai
module
|
|
|
xai
module
|
|
|
Package providertest provides shared test utilities for provider conformance testing.
|
Package providertest provides shared test utilities for provider conformance testing. |
|
Package proxy provides an OpenAI-compatible HTTP server.
|
Package proxy provides an OpenAI-compatible HTTP server. |
|
Package ratelimit counts requests and tokens in fixed windows for the quota stage's RPM and TPM checks.
|
Package ratelimit counts requests and tokens in fixed windows for the quota stage's RPM and TPM checks. |
|
redislimit
Package redislimit is a ratelimit.Limiter whose windows live in Redis, so every replica shares them.
|
Package redislimit is a ratelimit.Limiter whose windows live in Redis, so every replica shares them. |
|
Package relay_hook bridges Nexus lifecycle events to webhook notifications.
|
Package relay_hook bridges Nexus lifecycle events to webhook notifications. |
|
Package router defines the routing engine that selects the best provider for a request.
|
Package router defines the routing engine that selects the best provider for a request. |
|
strategies
Package strategies provides built-in routing strategies for Nexus.
|
Package strategies provides built-in routing strategies for Nexus. |
|
Package store defines the aggregate persistence interface for Nexus.
|
Package store defines the aggregate persistence interface for Nexus. |
|
internal/conv
Package conv holds the conversions every database backend uses at its model boundary, so the backends cannot each invent their own.
|
Package conv holds the conversions every database backend uses at its model boundary, so the backends cannot each invent their own. |
|
mongo
Package mongo provides a MongoDB-backed store implementation for Nexus using grove ORM with the mongodriver.
|
Package mongo provides a MongoDB-backed store implementation for Nexus using grove ORM with the mongodriver. |
|
postgres
Package postgres provides a PostgreSQL-backed store implementation for Nexus using grove ORM with programmatic migrations.
|
Package postgres provides a PostgreSQL-backed store implementation for Nexus using grove ORM with programmatic migrations. |
|
sqlite
Package sqlite provides a SQLite-backed store implementation for Nexus using grove ORM with programmatic migrations.
|
Package sqlite provides a SQLite-backed store implementation for Nexus using grove ORM with programmatic migrations. |
|
storetest
Package storetest runs one conformance test body against every Nexus store backend: memory and SQLite always, PostgreSQL when NEXUS_TEST_POSTGRES_DSN is set and MongoDB when NEXUS_TEST_MONGO_URI is set.
|
Package storetest runs one conformance test body against every Nexus store backend: memory and SQLite always, PostgreSQL when NEXUS_TEST_POSTGRES_DSN is set and MongoDB when NEXUS_TEST_MONGO_URI is set. |
|
Package tenant defines the multi-tenant management types and service.
|
Package tenant defines the multi-tenant management types and service. |
|
Package testutil provides shared test utilities including mock HTTP servers.
|
Package testutil provides shared test utilities including mock HTTP servers. |
|
Package transform provides request/response transformation middleware for Nexus.
|
Package transform provides request/response transformation middleware for Nexus. |
|
Package usage defines usage tracking types and service.
|
Package usage defines usage tracking types and service. |