gateway
WebSocket client with full handshake, 120+ typed RPC methods, device identity auth, streaming events, and node mode.
Explore
Connect agents, stream responses, discover gateways โ typed and production-ready.

go get github.com/a3tai/openclaw-go@latestRequires Go 1.24+. Single external dependency: gorilla/websocket.
package main
import (
"context"
"encoding/json"
"fmt"
"log"
"github.com/a3tai/openclaw-go/gateway"
"github.com/a3tai/openclaw-go/identity"
"github.com/a3tai/openclaw-go/protocol"
)
func main() {
// Load or generate a device keypair for authenticated access.
store, _ := identity.NewStore("~/.openclaw-go/identity")
id, _ := store.LoadOrGenerate()
deviceToken := store.LoadDeviceToken()
client := gateway.NewClient(
gateway.WithToken("my-token"),
gateway.WithIdentity(id, deviceToken),
gateway.WithRole(protocol.RoleOperator),
gateway.WithScopes(protocol.ScopeOperatorRead, protocol.ScopeOperatorWrite),
gateway.WithOnEvent(func(ev protocol.Event) {
if ev.EventName == "chat" {
var chat protocol.ChatEvent
json.Unmarshal(ev.Payload, &chat)
if chat.State == "delta" {
fmt.Print(string(chat.Message))
}
}
}),
)
defer client.Close()
ctx := context.Background()
if err := client.Connect(ctx, "wss://my-gateway.example.com"); err != nil {
log.Fatal(err)
}
// Send a message โ streaming deltas arrive via the event handler above.
result, err := client.ChatSend(ctx, protocol.ChatSendParams{
SessionKey: "main",
Message: "Hello from Go!",
IdempotencyKey: "hello-1",
})
if err != nil {
log.Fatal(err)
}
fmt.Printf("Run started: %s\n", result.RunID)
}openclaw-go is maintained by A3T โ the enterprise agent platform built on OpenClaw.