API Reference

The authoritative symbol-level API documentation is on pkg.go.dev. The guides in this section explain the configuration and integration boundaries around those APIs.

Reference Guides

GuideDescription
Configuration Reference →Credentials, model selection, generation options, runtimes, and YAML settings
LLM Providers →llm-go-backed provider constructors, streaming, embeddings, and Codex subscription access
CLI Reference →dspy-cli commands and flags

Package Documentation

Core Framework

  • pkg/core: signatures, modules, LLM capability interfaces, execution state, and runtime model resolution
  • pkg/modules: Predict, ChainOfThought, ReAct, Refine, Parallel, and other DSPy modules
  • pkg/optimizers: GEPA, MIPRO, SIMBA, BootstrapFewShot, COPRO, and optimizer utilities
  • pkg/config: typed file and environment configuration loading

Models and Agents

  • pkg/llms: adapters from llm-go generators to dspy-go’s compatibility interfaces, plus dspy-go-owned embedding clients
  • pkg/agents: provider-neutral execution loops, harnesses, typed events, and traces
  • pkg/agents/native: provider-native tool-calling agents and sessions
  • pkg/tools: tool contracts, registries, composition, and built-in toolsets

Current LLM Boundary

Provider generation protocols and model metadata live in llm-go. pkg/llms preserves the core.LLM integration used by existing dspy-go modules and agents. dspy-go continues to own Gemini and OpenAI-compatible embeddings because embedding is part of that compatibility contract.

New consumers should depend on the smallest core capability interface they need, such as core.TextGenerator, core.StreamGenerator, core.Embedder, or core.ToolCallingChatLLM, rather than requiring the full core.LLM interface unnecessarily.

Common Patterns

Configure a Default Model

llm, err := llms.NewLLM(apiKey, core.ModelGoogleGeminiFlash)
if err != nil {
    return err
}
core.SetDefaultLLM(llm)

Configure One Module

predictor := modules.NewPredict(signature)
predictor.SetLLM(llm)

Configure One Request

ctx := core.WithRuntime(context.Background(), &core.Runtime{
    DefaultLLM: llm,
})
result, err := predictor.Process(ctx, inputs)

Configure One Generation Call

response, err := llm.Generate(ctx, prompt,
    core.WithMaxTokens(1024),
    core.WithTemperature(0.2),
)

Use context.WithTimeout or context.WithCancel to control an operation’s lifetime. Streaming calls return a core.StreamResponse; consume ChunkChannel and call Cancel if you stop before the stream completes.

Model IDs and Capabilities

Use the exported core.ModelID constants instead of copying model strings when possible. Model catalogs change more frequently than this documentation, so consult the current pkg/core GoDoc and provider documentation for available models and limits.

Capability support is model-specific. Check llm.Capabilities() at runtime when your application requires streaming, JSON, tool calling, vision, audio, or embeddings.

Next Steps