Type-Safe LLM Orchestration for Go. Synapses. Sessions. Structure.

Interact with LLMs through typed synapses that return validated Go structs, not raw strings. Sessions maintain conversation context across calls, and pipz integration provides retry, timeout, and circuit breaking out of the box.

Getting Started
import "github.com/zoobz-io/zyn"

type Contact struct {
    Name  string `json:"name"`
    Email string `json:"email"`
    Role  string `json:"role"`
}

func (c Contact) Validate() error {
    if c.Email == "" {
        return errors.New("email required")
    }
    return nil
}

// Type-safe extraction — LLM output → validated struct
extractor, _ := zyn.Extract[Contact]("contact information", provider)

// Sessions carry conversation context across calls
session := zyn.NewSession()
contact, _ := extractor.Fire(ctx, session, "Reach John at john@acme.com, he's the CTO")
// contact.Name = "John", contact.Email = "john@acme.com", contact.Role = "CTO"

// 8 synapse types for different reasoning tasks
decision, _ := zyn.Binary("Is this a business email?", provider)
result, _ := decision.Fire(ctx, session, contact.Email) // true

category, _ := zyn.Classification("department", provider, "engineering", "sales", "support")
dept, _ := category.Fire(ctx, session, "I need help with the API integration")
// dept = "engineering"
93%Test Coverage
A+Go Report
MITLicense
1.24+Go Version
v1.0.6Latest Release

Why Zyn?

Structured, type-safe LLM interactions with conversational context and built-in reliability.

Type-Safe at the Edges

Generics ensure LLM outputs match expected types at compile time. Invalid responses fail validation before reaching your code.

8 Synapse Types

Binary, Classification, Ranking, Sentiment, Extract, Transform, Analyze, Convert — each with structured prompts that prevent output divergence.

Conversational Sessions

Sessions carry full conversation history across synapse calls. Transactional updates — session only changes on successful completion.

Built-In Reliability

Pipz integration for retry with backoff, timeout, circuit breaker, rate limiting, and fallback synapses. No boilerplate.

Automatic Observability

Capitan signals fire at every LLM operation — RequestStarted, ProviderCallCompleted, ResponseParseFailed. No instrumentation needed.

Validator Pattern

Custom types implement Validate() error for runtime validation of LLM responses. Catches malformed outputs before they propagate.

Capabilities

Typed synapses, conversational sessions, and reliability patterns for production LLM applications.

FeatureDescriptionLink
Extraction SynapsesExtract structured data into validated Go types. Analyze structured input into text. Convert between types via LLM reasoning.Extraction Pipelines
Decision SynapsesBinary yes/no, Classification into categories, Ranking by criteria, Sentiment analysis with emotional scoring.Classification Workflows
Session ManagementPrune, Truncate, Clear, Insert, Replace operations on conversation history. Context accumulates naturally across calls.Sessions
Provider ConfigurationSimple Provider interface. OpenAI included, mock provider for testing. Any LLM backend via one method.Providers
Reliability PatternsRetry with exponential backoff, timeout protection, circuit breakers, rate limiting, and fallback chains.Reliability
Error HandlingStructured error responses with context. Validation failures, provider errors, and parse failures all typed and actionable.Error Handling

Articles

Browse the full zyn documentation.

OverviewType-safe LLM orchestration framework with composable reliability patterns

Learn

QuickstartBuild your first synapse in 10 minutes
Core ConceptsUnderstanding synapses, sessions, and providers
ArchitectureHow zyn works under the hood

Guides

InstallationInstalling and configuring zyn
ProvidersConfiguring and using LLM providers
SessionsManaging conversation context with sessions
ReliabilityRetry, timeout, circuit breaker, and rate limiting
ObservabilityMonitoring LLM interactions with hooks
TestingTesting strategies for LLM-powered applications
Best PracticesProduction guidelines for LLM applications

Cookbook

Classification WorkflowsReal-world classification patterns with zyn
Extraction PipelinesExtracting structured data from unstructured text
Multi-Turn ConversationsBuilding complex workflows with session context
Error HandlingRobust error handling patterns for LLM applications

Reference

CheatsheetQuick reference for zyn API
OptionsConfiguration options for synapses
SessionSession API reference
TestingTesting package API reference

Synapses

Analyze SynapseAnalyze structured data and produce text analysis
Binary SynapseYes/no decisions with confidence scores
Classification SynapseCategorize text into predefined classes
Convert SynapseConvert between struct types
Extraction SynapseExtract structured data from text
Ranking SynapseOrder items by specified criteria
Sentiment SynapseAnalyze emotional tone with detailed breakdown
Transform SynapseTransform text to text