---
title: Install weft and choose a module
description: go get github.com/weftgo/weft@v0.20.2 for the whole framework, or github.com/weftgo/weft/core for the loop alone; Go 1.26 or newer; providers are packages, and the weft command installs with go install.
url: https://weftgo.dev/docs/get-started/install/
type: how-to
sources:
  - weft/README.md:7-15 (one go get is the framework; core is the loop alone, its only dependency the OTel API)
  - weft/README.md:17-26 (the package table; weft/core row)
  - weft/README.md:1034-1037 (Go 1.26 or newer; the current and previous Go releases, both tested in CI)
  - weft/go.mod:3 (go 1.26.0); core/go.mod:3-9 (go 1.26; requires only go.opentelemetry.io/otel, otel/log, otel/trace)
  - 'weft/docs/adr/0027-framework-module-and-core.md (Decision 1-4; Consequences: only imported packages are compiled; ambiguous import with retired module paths, MIGRATION-0.9.md)'
  - 'weft/AGENTS.md intro (facades: weft.Agent is core.Agent; core + core/wefttest + core/mw); block 7 (go install github.com/weftgo/weft/cmd/weft; cmd/weft holds the clickhouse driver)'
  - weft/go.mod:24 (modernc.org/sqlite); obsdb/clickhouse is the only package importing clickhouse-go
  - 'weft/README.md:350-352 (cmd/weft: the one place that imports the ClickHouse driver)'
  - 'weft/README.md:875-885 (Providers: first-party adapters ship in the framework module)'
  - weft/anthropic, openai, google godoc APIKey (default $ANTHROPIC_API_KEY, $OPENAI_API_KEY, $GOOGLE_API_KEY / $GEMINI_API_KEY then application default credentials)
  - weft/cmd/weft (weft --help, weft version → v0.17.0)
  - 'observed: go get github.com/weftgo/weft@v0.20.2 then go run . with an adapter import fails ''missing go.sum entry'' until go mod tidy'
  - docs-site/examples/install/main_test.go:TestRun, TestAnthropicDenied
---

# Install weft and choose a module

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`.

```sh
go get github.com/weftgo/weft@v0.20.2
```

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

```go title="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](https://github.com/weftgo/weftgo.dev/blob/main/docs-site/examples/install/main.go)

## How it works

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.

## Choose a module

| You want | `go get` | You import |
|---|---|---|
| The framework: the loop plus any layer | `github.com/weftgo/weft@v0.20.2` | `weft`, and `weft/anthropic`, `weft/otel`, `weft/thread`, … as needed |
| The loop alone, with the smallest dependency list | `github.com/weftgo/weft/core@v0.20.2` | `core`, `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.

## Check your Go version

weft requires Go 1.26 or newer:

```sh
go version
```

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

## Add a provider

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:

| Adapter | Constructor | Key read by default |
|---|---|---|
| `weft/anthropic` | [`anthropic.Model(name, opts...)`](https://pkg.go.dev/github.com/weftgo/weft@v0.20.2/anthropic#Model) | `ANTHROPIC_API_KEY` |
| `weft/openai` | [`openai.Model(name, opts...)`](https://pkg.go.dev/github.com/weftgo/weft@v0.20.2/openai#Model) | `OPENAI_API_KEY` |
| `weft/google` | [`google.Model(name, opts...)`](https://pkg.go.dev/github.com/weftgo/weft@v0.20.2/google#Model) | `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](https://weftgo.dev/docs/guides/providers/) covers every adapter option.

## Install the weft command

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:

```sh
go install github.com/weftgo/weft/cmd/weft@v0.20.2
weft version
```

```text
v0.20.2
```

`weft --help` lists its commands: `studio`, `dev`, `runs`, `open`, `export`, `doctor`, `mcp`, `vacuum` and `version`. [The weft CLI reference](https://weftgo.dev/docs/reference/cli/) documents every flag.

## Complete example

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

```go title="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)
}
```

[install/main.go on GitHub](https://github.com/weftgo/weftgo.dev/blob/main/docs-site/examples/install/main.go)

```sh
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`](https://github.com/weftgo/weftgo.dev/blob/main/docs-site/examples/install/main_test.go)).

## Best practices & gotchas

- **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`)

## See also

- [What is weft, and when should you not use it?](https://weftgo.dev/docs/get-started/what-is-weft/)
- [How weft is put together](https://weftgo.dev/docs/explanation/architecture/)
- [Connect a model provider: OpenAI, Anthropic, Gemini](https://weftgo.dev/docs/guides/providers/)
- [Use the weft command](https://weftgo.dev/docs/observe/cli/)
- [Upgrade weft](https://weftgo.dev/docs/production/upgrading/)

Symbols used: [`weft.Tool`](https://pkg.go.dev/github.com/weftgo/weft@v0.20.2#Tool) · [`weft.Agent`](https://pkg.go.dev/github.com/weftgo/weft@v0.20.2#Agent) · [`core.Agent`](https://pkg.go.dev/github.com/weftgo/weft/core@v0.20.2#Agent) · [`weft.New`](https://pkg.go.dev/github.com/weftgo/weft@v0.20.2#New) · [`weft.Instructions`](https://pkg.go.dev/github.com/weftgo/weft@v0.20.2#Instructions) · [`weft.Prompt`](https://pkg.go.dev/github.com/weftgo/weft@v0.20.2#Prompt) · [`weft.ErrModelRequestsDenied`](https://pkg.go.dev/github.com/weftgo/weft@v0.20.2#ErrModelRequestsDenied) · [`anthropic.Model`](https://pkg.go.dev/github.com/weftgo/weft@v0.20.2/anthropic#Model) · [`anthropic.APIKey`](https://pkg.go.dev/github.com/weftgo/weft@v0.20.2/anthropic#APIKey) · [`openai.Model`](https://pkg.go.dev/github.com/weftgo/weft@v0.20.2/openai#Model) · [`google.Model`](https://pkg.go.dev/github.com/weftgo/weft@v0.20.2/google#Model) · [`otel.Install`](https://pkg.go.dev/github.com/weftgo/weft@v0.20.2/otel#Install)
