Documentation
¶
Overview ¶
Package llmkit provides utilities for working with Large Language Models.
llmkit is a standalone toolkit extracted from flowgraph, designed to be imported à la carte. Each subpackage can be used independently:
- claude: Claude CLI wrapper with OAuth credential management
- template: Prompt template rendering with {{variable}} syntax
- tokens: Token counting and budget management
- parser: Extract JSON, YAML, and code blocks from LLM responses
- truncate: Token-aware text truncation strategies
- model: Model selection, cost tracking, and escalation chains
Quick Start ¶
Token counting:
import "github.com/randalmurphal/llmkit/tokens"
counter := tokens.NewEstimatingCounter()
count := counter.Count("Hello, World!")
Template rendering:
import "github.com/randalmurphal/llmkit/template"
engine := template.NewEngine()
result, _ := engine.Render("Hello {{name}}", map[string]any{"name": "World"})
Claude CLI:
import "github.com/randalmurphal/llmkit/claude"
client := claude.NewCLI()
resp, _ := client.Complete(ctx, claude.CompletionRequest{...})
Design Philosophy ¶
llmkit follows these principles:
- Zero external dependencies (stdlib only)
- Each package usable independently
- Stable, semver-friendly API
- Sensible defaults with full configurability
- Interfaces for extensibility, concrete types for simplicity
Directories
¶
| Path | Synopsis |
|---|---|
|
Package claude provides interfaces and implementations for the Claude Code CLI.
|
Package claude provides interfaces and implementations for the Claude Code CLI. |
|
session
Package session provides long-running Claude CLI session management with bidirectional stream-json I/O.
|
Package session provides long-running Claude CLI session management with bidirectional stream-json I/O. |
|
Package claudeconfig provides utilities for parsing Claude Code's native configuration formats.
|
Package claudeconfig provides utilities for parsing Claude Code's native configuration formats. |
|
Package codex provides a Go wrapper for the OpenAI Codex CLI.
|
Package codex provides a Go wrapper for the OpenAI Codex CLI. |
|
Package gemini provides a Go wrapper for the Gemini CLI binary.
|
Package gemini provides a Go wrapper for the Gemini CLI binary. |
|
Package local provides a client for local LLM models via a Python sidecar process.
|
Package local provides a client for local LLM models via a Python sidecar process. |
|
Package model provides model selection, cost tracking, and escalation chains.
|
Package model provides model selection, cost tracking, and escalation chains. |
|
Package opencode provides a client for the OpenCode CLI.
|
Package opencode provides a client for the OpenCode CLI. |
|
Package parser extracts structured content from LLM responses.
|
Package parser extracts structured content from LLM responses. |
|
Package provider defines the unified interface for LLM CLI providers.
|
Package provider defines the unified interface for LLM CLI providers. |
|
Package template provides prompt template rendering with variable substitution.
|
Package template provides prompt template rendering with variable substitution. |
|
Package tokens provides token counting and budget management for LLM prompts.
|
Package tokens provides token counting and budget management for LLM prompts. |
|
Package truncate provides text truncation utilities for managing LLM context.
|
Package truncate provides text truncation utilities for managing LLM context. |
Click to show internal directories.
Click to hide internal directories.