Go quickstart
Install the SDK, copy the example, and make your first call -- the identity whoami lookup. It is read-only, so it is safe to run as-is.
Prerequisites
You need an AgentRouter API key and the API base URL.
- Create an API key with the Platform API type -- it is shown once, as
<keyid>.<secret>. Copy it now. - Base URL
https://api.tetrate.ai(or your tenant's). SetAGENTROUTER_API_KEYand optionallyAGENTROUTER_BASE_URLin your environment.
Install
Download the Go SDK tarball from the SDKs page and extract it into ./third_party, then wire it in go.mod (the only supported install -- no `go get`). Open the SDKs page
Install
mkdir -p third_party && tar -xzf agentrouter-go-0.1.1.tar.gz -C third_party/
# go.mod:
require github.com/tetrateio/agentrouter-go v0.1.0
replace github.com/tetrateio/agentrouter-go => ./third_party/agentrouter-go-0.1.1
go mod tidy
Your first call -- whoami
Resolve the identity behind your API key with a read-only GET /v1/me call. Copy the files below. Save the program as main.go, then run `go run .`.
// 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)
}
module github.com/tetrateio/agentrouter-go-examples/me/getme
go 1.26
require github.com/tetrateio/agentrouter-go v0.1.1
// Point this at the directory you extracted the downloaded Go SDK tarball into.
// The directory name matches the tarball stem on the Download SDK page.
replace github.com/tetrateio/agentrouter-go => ./third_party/agentrouter-go-0.1.1