# SDK quickstart for Go

> Install the typed Agent Router Go SDK from the local tarball and make a first read-only identity (whoami) call against the gateway.

# SDK quickstart for Go

  This quickstart installs the typed Agent Router SDK for Go, then makes a first read-only identity lookup (whoami) against the gateway. The lookup resolves the identity behind an API key with a <code>GET /v1/me</code> call and is safe to run as-is, so it confirms that the SDK, the key, and the base URL are wired together correctly before any billable request is sent.

## Prerequisites

Two values and a toolchain are required before starting:

- **An Agent Router API key.** Keys are minted in the Console or with the `tare` CLI. The secret is shown once, in the form `<keyid>.<secret>`, so it must be copied immediately. See [Make an API call](/agent-router-service/quickstarts/make-an-api-call) for the key-minting steps.
- **The gateway base URL** for the deployment, in the form `https://api.<your-domain>`. For the hosted service this is `https://api.tetrate.ai`.
- **Go 1.26 or later**, which the SDK module requires.

The SDK reads both values from the environment:

```bash
export AGENTROUTER_BASE_URL=https://api.<your-domain>
export AGENTROUTER_API_KEY=<keyid>.<secret>
```

## Install the SDK

The Go SDK is distributed as a source tarball from the public stable channel and is installed from the local file system. This is the only supported install path: `go get` is not used. Replace `<version>` with the version shown on the [SDKs](/reference/sdk/) page.

Download and extract the tarball into `./third_party`:

```bash
curl -fLO https://tare.tetrate.ai/tools/sdks/stable/agentrouter-go-<version>.tar.gz
mkdir -p third_party && tar -xzf agentrouter-go-<version>.tar.gz -C third_party/
```

Add `require` and `replace` directives so the module resolves to the extracted copy rather than a public registry, then tidy the module graph:

```text title="go.mod"
module example.com/agentrouter-quickstart

go 1.26

require github.com/tetrateio/agentrouter-go v0.1.0

// Point replace at the extracted tarball directory.
// Its name matches the tarball stem from the SDKs download page.
replace github.com/tetrateio/agentrouter-go => ./third_party/agentrouter-go-<version>
```

```bash
go mod tidy
```

## Make the first call

Save the program below as `main.go`. It constructs a client from the two environment variables, calls `client.Me().Get(ctx)` (the read-only `GET /v1/me` endpoint), and prints the resolved identity.

```go title="main.go"
// Command example is a runnable example for the AgentRouter Go SDK.
// Set AGENTROUTER_BASE_URL and AGENTROUTER_API_KEY in the environment, then `go run .`.
package main

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

	agentrouter "github.com/tetrateio/agentrouter-go"
)

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

	client, err := agentrouter.New(ctx,
		agentrouter.WithBaseURL(os.Getenv("AGENTROUTER_BASE_URL")),
		agentrouter.WithAPIKey(os.Getenv("AGENTROUTER_API_KEY")),
	)
	if err != nil {
		log.Fatalf("client: %v", err)
	}

	result, err := client.Me().Get(ctx)
	if err != nil {
		log.Fatalf("call: %v", err)
	}

	fmt.Printf("%+v\n", result)
}
```

Run the program from the directory containing `main.go` and `go.mod`:

```bash
go run .
```

A successful run prints the identity associated with the API key. Because `GET /v1/me` only reads identity metadata, the call incurs no model usage and can be repeated freely while verifying setup.

Related references

  <Link to="/reference/sdk/" className="tare-nav-card">
    SDK Reference
    Download the SDK archives and API specifications, with versions and checksums.
  </Link>
  <Link to="/agent-router-service/quickstarts/make-an-api-call" className="tare-nav-card">
    Make an API call
    Mint a key with the tare CLI and make a first routed request across languages.
  </Link>
  <Link to="/reference/api/" className="tare-nav-card">
    Management API reference
    The HTTP endpoints the SDK calls, including the identity and inference APIs.
  </Link>
