zoobzio February 20, 2026 Edit this page

Quickstart

Get cogito running in your project in 5 minutes.

Prerequisites

  • Go 1.24 or later
  • An LLM provider (OpenAI, Anthropic, or compatible)

Installation

go get github.com/zoobz-io/cogito

Basic Usage

1. Configure Provider

package main

import (
    "context"
    "github.com/zoobz-io/cogito"
    "github.com/zoobz-io/zyn/provider/openai"
)

func main() {
    // Set up LLM provider
    provider := openai.New(os.Getenv("OPENAI_API_KEY"))
    cogito.SetProvider(provider)
}

2. Create and Process a Thought

func processTicket(ctx context.Context, ticketText string) error {
    // Create a thought
    thought := cogito.New(ctx, "triage support ticket")

    // Add initial context
    thought.SetContent(ctx, "ticket", ticketText, "input")

    // Build a pipeline
    pipeline := cogito.Sequence(pipz.NewIdentity("ticket-triage", "Triage support tickets"),
        cogito.NewAnalyze[TicketData]("parse", "extract customer info and issue"),
        cogito.NewCategorize("category", "what type of issue?",
            []string{"billing", "technical", "account"}),
        cogito.NewDecide("escalate", "should this be escalated?").
            WithIntrospection(),
    )

    // Process
    result, err := pipeline.Process(ctx, thought)
    if err != nil {
        return err
    }

    // Read results
    category, _ := result.GetContent("category")
    escalate, _ := result.GetContent("escalate")

    fmt.Printf("Category: %s, Escalate: %s\n", category, escalate)
    return nil
}

Complete Example

package main

import (
    "context"
    "fmt"
    "log"
    "os"

    "github.com/zoobz-io/cogito"
    "github.com/zoobz-io/zyn/provider/openai"
)

type TicketData struct {
    CustomerName string `json:"customer_name"`
    Issue        string `json:"issue"`
    Urgency      string `json:"urgency"`
}

func main() {
    ctx := context.Background()

    // Configure provider
    provider := openai.New(os.Getenv("OPENAI_API_KEY"))
    cogito.SetProvider(provider)

    // Create thought
    thought := cogito.New(ctx, "analyse feedback")

    // Add input
    thought.SetContent(ctx, "feedback", "Your product is amazing!", "input")

    // Simple decision
    decide := cogito.NewDecide("positive", "is this positive feedback?")
    result, err := decide.Process(ctx, thought)
    if err != nil {
        log.Fatal(err)
    }

    positive, _ := result.GetContent("positive")
    fmt.Printf("Positive feedback: %s\n", positive)
}

Next Steps