Skip to content

Install weft and choose a module

View as Markdown

Run go get github.com/weftgo/weft@v0.20.2 in a module on Go 1.26 or newer: that one module is the whole framework — the loop, the provider adapters, sessions, recording and Studio. If you want the agent loop and nothing else, go get github.com/weftgo/weft/core@v0.20.2 instead. The weft command line installs separately, with go install.

Terminal window
go get github.com/weftgo/weft@v0.20.2

A typical app then imports the root package, one provider adapter and the recorder:

install/main.go
import (
"context"
"fmt"
"log"
"github.com/weftgo/weft" // the loop: Tool, New, Generate
"github.com/weftgo/weft/anthropic" // a provider adapter
"github.com/weftgo/weft/otel" // the recorder: otel.Install
)

install/main.go on GitHub

weft is two Go modules tagged at the same version. github.com/weftgo/weft holds the root package and every layer (openai, anthropic, google, mcp, mw, wefttest, thread, otel, obsdb, studio, runtime, scope). github.com/weftgo/weft/core holds the loop alone and depends only on the OpenTelemetry API. The root package re-exports core: weft.Agent is core.Agent.

Your go.mod lists every layer’s dependencies, but Go compiles only the packages you import. weft/otel brings in SQLite (modernc.org/sqlite) for its local sink; the ClickHouse driver is linked only through weft/obsdb/clickhouse, which the weft command imports.

You wantgo getYou import
The framework: the loop plus any layergithub.com/weftgo/weft@v0.20.2weft, and weft/anthropic, weft/otel, weft/thread, … as needed
The loop alone, with the smallest dependency listgithub.com/weftgo/weft/core@v0.20.2core, core/wefttest, core/mw

Choose the framework unless your service must not carry the other layers’ dependencies in its module graph. The two are interchangeable at the type level, so you can start with core and move to weft later without changing a type.

weft requires Go 1.26 or newer:

Terminal window
go version

The current and the previous Go release are supported, and CI tests both.

The first-party adapters for OpenAI, Anthropic and Google are packages of the framework module: import github.com/weftgo/weft/openai, …/anthropic or …/google and run go mod tidy, which fetches the vendor SDK the adapter wraps. Each adapter reads its key from the environment by default:

AdapterConstructorKey read by default
weft/anthropicanthropic.Model(name, opts...)ANTHROPIC_API_KEY
weft/openaiopenai.Model(name, opts...)OPENAI_API_KEY
weft/googlegoogle.Model(name, opts...)GOOGLE_API_KEY or GEMINI_API_KEY, then application default credentials

Each adapter’s APIKey option sets the key in code instead. Connect a model provider covers every adapter option.

The weft binary serves Studio for apps in any language, runs the dev loop, and lists, opens and exports runs. It is the package cmd/weft of the framework module:

Terminal window
go install github.com/weftgo/weft/cmd/weft@v0.20.2
weft version
v0.20.2

weft --help lists its commands: studio, dev, runs, open, export, doctor, mcp, vacuum and version. The weft CLI reference documents every flag.

The file the imports above come from: it records one run of an Anthropic-backed agent.

install/main.go
// Command install is the Install page's program: the usual import set of a
// weft app — the framework's root package, one provider adapter, and the
// recorder — in one file that builds and runs.
package main
import (
"context"
"fmt"
"log"
"github.com/weftgo/weft" // the loop: Tool, New, Generate
"github.com/weftgo/weft/anthropic" // a provider adapter
"github.com/weftgo/weft/otel" // the recorder: otel.Install
)
// run records one run of an agent over model and returns its answer.
func run(ctx context.Context, model weft.Model) (string, error) {
defer otel.Install(otel.Local(""))() // ./.weft/weft.db, plus any Studio the environment names
agt := weft.New(model, weft.Instructions("Answer in one sentence."))
res, err := agt.Generate(ctx, weft.Prompt("What is a goroutine?"))
if err != nil {
return "", err
}
return res.Text(), nil
}
func main() {
// Reads $ANTHROPIC_API_KEY.
text, err := run(context.Background(), anthropic.Model("claude-sonnet-5"))
if err != nil {
log.Fatal(err)
}
fmt.Println(text)
}

View install/main.go on GitHub

Terminal window
export ANTHROPIC_API_KEY=… # your key
go mod tidy
go run .
go test ./...

The page’s test runs the same run function on a scripted model and reads the recorded run back from the local database (install/main_test.go).

  • Run go mod tidy after adding an adapter import. go get github.com/weftgo/weft does not record the vendor SDK’s checksums; until go mod tidy runs, the build fails with missing go.sum entry. (Source: observed with go run . in a fresh module)
  • Do not mix the retired per-layer modules with 0.9.0 or later. Before 0.9.0 each layer (thread, otel, …) was its own module. A go.mod that requires one of those paths and the framework fails with an ambiguous-import error; MIGRATION-0.9.md in the weft repository is the fix. (Source: ADR 0027, Consequences)
  • Keep test suites off the network. Set WEFT_MODEL_REQUESTS=deny and every first-party adapter that built its own client refuses to call its provider, failing with ErrModelRequestsDenied. (Source: AGENTS.md; install/main_test.go:TestAnthropicDenied)

Symbols used: weft.Tool · weft.Agent · core.Agent · weft.New · weft.Instructions · weft.Prompt · weft.ErrModelRequestsDenied · anthropic.Model · anthropic.APIKey · openai.Model · google.Model · otel.Install