Documentation
¶
Overview ¶
Package inference owns provider validation, credential shapes, and runtime rendering for the tenant inference plane.
Index ¶
- Constants
- func AgentRoutePath(namespace, name, path string) string
- func CredentialPath(namespace, name string, kind agentzv1alpha1.InferenceProviderKind, ...) string
- func CredentialsForCreate(spec agentzv1alpha1.InferenceProviderSpec, values CredentialValues) (map[string]any, error)
- func CredentialsForUpdate(spec agentzv1alpha1.InferenceProviderSpec, values CredentialValues) (map[string]any, bool, error)
- func DelegatedProviderEndpoints(kind agentzv1alpha1.InferenceProviderKind) []string
- func Gateway(namespace string) *gwv1.Gateway
- func IndexPools(ctx context.Context, idx client.FieldIndexer) error
- func IndexSandboxes(ctx context.Context, idx client.FieldIndexer) error
- func PoolProviderSecretName(pool, provider string) string
- func ProviderAPI(kind agentzv1alpha1.InferenceProviderKind, model agentzv1alpha1.InferenceModel) agentzv1alpha1.InferenceModelAPI
- func ProviderProtocol(kind agentzv1alpha1.InferenceProviderKind, model agentzv1alpha1.InferenceModel) agentzv1alpha1.InferenceProtocol
- func RenderInferenceAuthPolicy(namespace, backend string, section *gwv1.SectionName, provider, pool string) *agentgatewayv1alpha1.AgentgatewayPolicy
- func RenderPoolBackend(pool *agentzv1alpha1.InferencePool, definition PoolDefinition) (*agentgatewayv1alpha1.AgentgatewayBackend, error)
- func ResolvePool(ctx context.Context, reader client.Reader, pool *agentzv1alpha1.InferencePool) (PoolDefinition, []Issue, error)
- func SandboxPoolPath(sandboxName, poolName string) string
- func SandboxProviderPath(sandboxName, providerName string) string
- func SandboxProviderRuntimeName(sandboxName, providerName string) string
- func SubscriptionRecordData(record SubscriptionRecord) (map[string]any, error)
- func SupportsPoolAPI(poolAPI, memberAPI agentzv1alpha1.InferenceModelAPI) bool
- type Catalog
- func (c *Catalog) Entries(query string) (string, []CatalogEntry)
- func (c *Catalog) SubscriptionModels(ctx context.Context, record SubscriptionRecord) ([]agentzv1alpha1.InferenceModel, CatalogProvenance, error)
- func (c *Catalog) Suggestions(ctx context.Context, providerID string, ...) ([]agentzv1alpha1.InferenceModel, CatalogProvenance, error)
- type CatalogEntry
- type CatalogProvenance
- type CredentialValues
- type DelegatedRequest
- type InputError
- type Issue
- type PoolDefinition
- type ProviderTarget
- type ResolvedPoolMember
- type Runtime
- type SandboxTarget
- type SandboxTargetRuntime
- type SubscriptionRecord
Constants ¶
const ( // SandboxByProviderIndex indexes Sandboxes by referenced provider ID. SandboxByProviderIndex = "spec.inference.models.provider" // SandboxByProviderModelIndex indexes Sandboxes by provider and model ID. SandboxByProviderModelIndex = "spec.inference.models.providerModel" )
const ( // PoolLabel identifies resources owned by an InferencePool. PoolLabel = "agentz.accuknox.com/inference-pool" // PoolByProviderIndex indexes Pools by referenced provider ID. PoolByProviderIndex = "spec.members.provider" // SandboxByPoolIndex indexes Sandboxes by referenced Pool ID. SandboxByPoolIndex = "spec.inference.models.pool" )
const ( // ProviderLabel identifies resources owned by an InferenceProvider. ProviderLabel = "agentz.accuknox.com/inference-provider" // ProviderKindLabel identifies the provider implementation of a resource. ProviderKindLabel = "agentz.accuknox.com/inference-provider-kind" // SubscriptionCredentialPathDir isolates subscription tokens from API-key // credentials so extAuth can receive the narrowest possible OpenBao policy. SubscriptionCredentialPathDir = "inference-subscriptions" // OpenAICodexClientID is OpenAI's public Codex OAuth client identifier. OpenAICodexClientID = "app_EMoamEEZ73f0CkXaXp7hrann" // OpenAICodexTokenEndpoint exchanges and refreshes Codex tokens. OpenAICodexTokenEndpoint = "https://auth.openai.com/oauth/token" // OpenAICodexModelsEndpoint serves the authenticated Codex model catalog. OpenAICodexModelsEndpoint = "https://chatgpt.com/backend-api/codex/models" )
const ( // GatewayName is the namespace-local inference Gateway and Service name. GatewayName = "inference" // ParametersName configures only the inference Gateway deployment. ParametersName = "inference-clusterip" // SandboxLabel identifies the Sandbox that owns an inference route. SandboxLabel = "agentz.accuknox.com/inference-sandbox" // SandboxHeader carries controller-owned route identity to extAuth. SandboxHeader = "x-agentz-inference-sandbox" // SandboxNamespaceHeader binds the route to its source Workspace. SandboxNamespaceHeader = "x-agentz-inference-sandbox-namespace" )
const SupersededCredentialsAnnotation = "agentz.accuknox.com/superseded-credentials"
SupersededCredentialsAnnotation retains old paths until runtime synchronization.
Variables ¶
This section is empty.
Functions ¶
func AgentRoutePath ¶ added in v0.31.0
AgentRoutePath binds an inference target to the caller's workspace and agent. The gateway network policy permits each agent to use only its own prefix.
func CredentialPath ¶
func CredentialPath(namespace, name string, kind agentzv1alpha1.InferenceProviderKind, revision string) string
CredentialPath resolves a credential revision. An empty revision preserves the legacy path until the provider is reauthenticated.
func CredentialsForCreate ¶
func CredentialsForCreate(spec agentzv1alpha1.InferenceProviderSpec, values CredentialValues) (map[string]any, error)
CredentialsForCreate validates and returns the complete OpenBao record for a newly created provider. A nil record means credentials are not required.
func CredentialsForUpdate ¶
func CredentialsForUpdate(spec agentzv1alpha1.InferenceProviderSpec, values CredentialValues) (map[string]any, bool, error)
CredentialsForUpdate validates complete replacement semantics. A nil record and false changed result means the stored record must remain untouched.
func DelegatedProviderEndpoints ¶ added in v0.29.0
func DelegatedProviderEndpoints(kind agentzv1alpha1.InferenceProviderKind) []string
DelegatedProviderEndpoints returns the client APIs that Agentgateway can translate to the provider's configured format. Routes alone do not establish support: Responses cannot be translated to Anthropic Messages or Gemini.
func IndexPools ¶
func IndexPools(ctx context.Context, idx client.FieldIndexer) error
IndexPools registers Pool/provider and Sandbox/Pool reference indexes.
func IndexSandboxes ¶
func IndexSandboxes(ctx context.Context, idx client.FieldIndexer) error
IndexSandboxes registers provider and provider/model reference indexes.
func PoolProviderSecretName ¶
PoolProviderSecretName returns the Pool-local credential projection name for an inherited Organisation provider.
func ProviderAPI ¶
func ProviderAPI(kind agentzv1alpha1.InferenceProviderKind, model agentzv1alpha1.InferenceModel) agentzv1alpha1.InferenceModelAPI
ProviderAPI returns the native request format used by a provider model.
func ProviderProtocol ¶
func ProviderProtocol(kind agentzv1alpha1.InferenceProviderKind, model agentzv1alpha1.InferenceModel) agentzv1alpha1.InferenceProtocol
ProviderProtocol returns the request family used by a provider kind.
func RenderInferenceAuthPolicy ¶
func RenderInferenceAuthPolicy(namespace, backend string, section *gwv1.SectionName, provider, pool string) *agentgatewayv1alpha1.AgentgatewayPolicy
RenderInferenceAuthPolicy applies fail-closed target authorization and credential injection to a direct provider or one named Pool member.
func RenderPoolBackend ¶
func RenderPoolBackend(pool *agentzv1alpha1.InferencePool, definition PoolDefinition) (*agentgatewayv1alpha1.AgentgatewayBackend, error)
RenderPoolBackend composes one ordered AgentGateway priority group per Pool member. Passive eviction changes only subsequent request selection.
func ResolvePool ¶
func ResolvePool(ctx context.Context, reader client.Reader, pool *agentzv1alpha1.InferencePool) (PoolDefinition, []Issue, error)
ResolvePool validates references and derives the conservative Pool contract.
func SandboxPoolPath ¶
SandboxPoolPath returns the controller-owned prefix for one Sandbox/Pool pair.
func SandboxProviderPath ¶
SandboxProviderPath returns the controller-owned OpenAI-compatible prefix for one Sandbox/provider pair.
func SandboxProviderRuntimeName ¶
SandboxProviderRuntimeName returns the bounded stable identity shared by a route and its authorization policy.
func SubscriptionRecordData ¶
func SubscriptionRecordData(record SubscriptionRecord) (map[string]any, error)
SubscriptionRecordData encodes a typed subscription record for OpenBao.
func SupportsPoolAPI ¶
func SupportsPoolAPI(poolAPI, memberAPI agentzv1alpha1.InferenceModelAPI) bool
SupportsPoolAPI reports whether AgentGateway can translate the Pool request format to a member's native format.
Types ¶
type Catalog ¶
type Catalog struct {
// contains filtered or unexported fields
}
Catalog fetches and retains a parsed Models.dev projection.
func NewCatalog ¶
NewCatalog creates a bounded Models.dev catalog client. A nil client uses a five-second HTTP timeout.
func (*Catalog) Entries ¶
func (c *Catalog) Entries(query string) (string, []CatalogEntry)
Entries returns the pinned supported catalog variants matching query.
func (*Catalog) SubscriptionModels ¶
func (c *Catalog) SubscriptionModels(ctx context.Context, record SubscriptionRecord) ([]agentzv1alpha1.InferenceModel, CatalogProvenance, error)
SubscriptionModels returns models available to one authenticated subscription. Provider endpoints determine entitlement; Models.dev only supplies capability metadata that subscription endpoints omit.
func (*Catalog) Suggestions ¶
func (c *Catalog) Suggestions(ctx context.Context, providerID string, providerKind agentzv1alpha1.InferenceProviderKind) ([]agentzv1alpha1.InferenceModel, CatalogProvenance, error)
Suggestions returns models for one pinned provider/runtime variant and reports whether they came from the live response, cache, or snapshot.
type CatalogEntry ¶
type CatalogEntry struct {
ProviderID string
Name string
Kind agentzv1alpha1.InferenceProviderKind
BaseURL string
BaseURLTemplate string
AuthHeader string
AuthPrefix string
Doc string
}
CatalogEntry is one selectable provider and configuration kind.
type CatalogProvenance ¶
type CatalogProvenance string
CatalogProvenance identifies the source of model suggestions.
const ( // CatalogProvenanceLive identifies a successful Models.dev response. CatalogProvenanceLive CatalogProvenance = "live" // CatalogProvenanceCache identifies the last successful parsed response. CatalogProvenanceCache CatalogProvenance = "cache" // CatalogProvenanceSnapshot identifies the reviewed embedded fallback. CatalogProvenanceSnapshot CatalogProvenance = "snapshot" )
type CredentialValues ¶
type CredentialValues struct {
APIKey string
BearerToken string
ServiceAccountJSON string
AccessKey string
SecretKey string
SessionToken string
ClientID string
TenantID string
ClientSecret string
}
CredentialValues is the complete typed write-only credential input surface.
type DelegatedRequest ¶ added in v0.29.0
type DelegatedRequest struct {
Model string `json:"model"`
Stream bool `json:"stream"`
Store *bool `json:"store"`
Background bool `json:"background"`
PreviousResponseID string `json:"previous_response_id"`
Conversation json.RawMessage `json:"conversation"`
Prompt json.RawMessage `json:"prompt"`
WebSearchOptions json.RawMessage `json:"web_search_options"`
Tools []inferenceTool `json:"tools"`
Input json.RawMessage `json:"input"`
Messages []inferenceInputItem `json:"messages"`
// contains filtered or unexported fields
}
DelegatedRequest contains validated inference input for a delegated model.
func ValidateDelegatedMessages ¶ added in v0.30.0
func ValidateDelegatedMessages(body []byte, countTokens bool) (*DelegatedRequest, error)
ValidateDelegatedMessages admits inline Anthropic input and client-executed tools. A model grant never authorizes provider files, containers or hosted MCP.
func ValidateDelegatedRequest ¶ added in v0.29.0
func ValidateDelegatedRequest(body []byte, responses bool) (*DelegatedRequest, error)
ValidateDelegatedRequest validates the resource-bearing portions of the OpenAI request. Case-sensitive decoding matches the upstream contract, while strict duplicate detection prevents two parsers from authorizing different values.
func (*DelegatedRequest) ValidateProvider ¶ added in v0.29.0
func (input *DelegatedRequest) ValidateProvider(kind agentzv1alpha1.InferenceProviderKind) error
ValidateProvider checks the selected provider before forwarding a validated request to an upstream whose errors must remain private.
type InputError ¶
InputError reports one invalid write-only credential field without its value.
func (*InputError) Error ¶
func (e *InputError) Error() string
Error returns a safe credential validation error.
type Issue ¶
Issue identifies one invalid provider input field.
func ValidateModelRemoval ¶
func ValidateModelRemoval(ctx context.Context, reader client.Reader, current, desired *agentzv1alpha1.InferenceProvider) ([]Issue, error)
ValidateModelRemoval rejects removal of models referenced by Pools or Sandboxes.
func ValidateProvider ¶
func ValidateProvider(spec agentzv1alpha1.InferenceProviderSpec) []Issue
ValidateProvider defensively validates the provider union and safe endpoint controls before admission or rendering.
type PoolDefinition ¶
type PoolDefinition struct {
Contract agentzv1alpha1.InferencePoolContract
Protocol agentzv1alpha1.InferenceProtocol
Warnings []agentzv1alpha1.InferencePoolWarning
Members []ResolvedPoolMember
}
PoolDefinition contains the validated, derived Pool configuration consumed by reconciliation, gateway reads, and Agent configuration rendering.
type ProviderTarget ¶
type ProviderTarget struct {
LLM agentgatewayv1alpha1.LLMProvider
Policies *agentgatewayv1alpha1.BackendWithAI
AdditionalHosts []string
// contains filtered or unexported fields
}
ProviderTarget contains one provider's complete member-scoped AgentGateway configuration. Model is empty for direct provider backends and set for Pool members so the logical Pool ID never reaches an upstream.
func RenderProviderTarget ¶
func RenderProviderTarget(provider *agentzv1alpha1.InferenceProvider, model string) (ProviderTarget, error)
RenderProviderTarget converts an admitted provider into one reusable target. The optional model override binds a Pool member to its real upstream model.
type ResolvedPoolMember ¶
type ResolvedPoolMember struct {
Ref agentzv1alpha1.InferencePoolMember
Provider *agentzv1alpha1.InferenceProvider
Model agentzv1alpha1.InferenceModel
API agentzv1alpha1.InferenceModelAPI
Protocol agentzv1alpha1.InferenceProtocol
Section gwv1.SectionName
}
ResolvedPoolMember binds one Pool reference to its typed Provider and model.
type Runtime ¶
type Runtime struct {
ExternalSecret *externalsecretsv1.ExternalSecret
Backend *agentgatewayv1alpha1.AgentgatewayBackend
AuthPolicy *agentgatewayv1alpha1.AgentgatewayPolicy
SecretKeys []string
}
Runtime contains the resources needed to route and authenticate a provider. ExternalSecret is nil for subscription or unauthenticated providers.
func RenderRuntime ¶
func RenderRuntime(provider *agentzv1alpha1.InferenceProvider, storeName string, refresh time.Duration) (Runtime, error)
RenderRuntime converts an admitted provider into its complete runtime resources without reading credential values.
type SandboxTarget ¶
type SandboxTarget struct {
Name string
Backend string
BackendNamespace string
Path string
Models []string
Labels map[string]string
ExtAuth bool
Retries int
}
SandboxTarget describes one logical inference target exposed by a Sandbox.
type SandboxTargetRuntime ¶
type SandboxTargetRuntime struct {
Route *gwv1.HTTPRoute
Policy *agentgatewayv1alpha1.AgentgatewayPolicy
}
SandboxTargetRuntime contains the fail-closed route and authorization policy for one Sandbox inference target.
func RenderSandboxTarget ¶
func RenderSandboxTarget(namespace, sandboxName string, target SandboxTarget, agents []api.Agent) SandboxTargetRuntime
RenderSandboxTarget creates a route and fail-closed logical model policy.
type SubscriptionRecord ¶
type SubscriptionRecord struct {
Kind agentzv1alpha1.InferenceProviderKind `json:"kind"`
AccountID string `json:"accountId,omitempty"`
ClientID string `json:"clientId,omitempty"`
Token *oauth2.Token `json:"token"`
Scopes []string `json:"scopes,omitempty"`
UpdatedAt time.Time `json:"updatedAt"`
}
SubscriptionRecord is the complete credential record retained only in OpenBao for a subscription-backed inference provider.
func DecodeSubscriptionRecord ¶
func DecodeSubscriptionRecord(data map[string]any) (SubscriptionRecord, error)
DecodeSubscriptionRecord decodes one controlled OpenBao record strictly.
func RefreshSubscription ¶
func RefreshSubscription(ctx context.Context, client *http.Client, record SubscriptionRecord) (SubscriptionRecord, bool, error)
RefreshSubscription returns a usable subscription record, refreshing Codex credentials when they are inside the shared expiry safety window.