Nexus
1.x
Docs/Nexus/Transforms
Open

Reading1 min
Updated31 Jul 2026
Sourcev1/core/transforms.mdx

Transforms modify requests before they reach the provider (input transforms) or responses before they reach the client (output transforms).

Transform Interface01

type Transform interface {
    Name() string
    Phase() Phase   // Input or Output
    Apply(ctx context.Context, data *TransformData) error
}

Built-in Transforms02

System Prompt Injection

Prepend a system prompt to every request:

import "github.com/xraph/nexus/transform"

registry := transform.NewRegistry()
registry.Register(transform.NewSystemPrompt(
    "You are a helpful assistant for Acme Corp.",
))

nexus.WithTransforms(registry)

RAG Context Injection

Inject retrieval-augmented generation context:

registry.Register(transform.NewRAG(ragRetriever))

Data Anonymization

Strip sensitive data before sending to the provider:

registry.Register(transform.NewAnonymizer())

Output Normalization

Normalize response format across providers:

registry.Register(transform.NewNormalizer())

Per-Tenant Transforms03

Combine transforms with tenant context for per-customer system prompts:

registry.Register(transform.NewSystemPrompt(
    "You are a support agent for {{tenant}}.",
    transform.WithTenantAware(true),
))