Skip to main content

Documentation Index

Fetch the complete documentation index at: https://whyops.com/docs/llms.txt

Use this file to discover all available pages before exploring further.

The Go SDK is optimized for backend services that want strongly typed runtime telemetry plus a reusable transport for provider requests. This page is the basic setup path.

Proxy Transport

Read this next if you want OpenAI or Anthropic traffic to go through WhyOps using ProxyHTTPClient().

Runtime Events

Add tool spans, prompt-caching usage, hybrid patterns, and self-hosted settings.

SDK Overview

Compare Go with the TypeScript and Python packages.

Before you start

You needWhy
WHYOPS_API_KEYAuthenticates agent init, manual events, and proxied model traffic to WhyOps
A stable AgentNameKeeps proxy traffic and runtime events attached to the same agent identity
AgentMetadata with SystemPromptLets WhyOps version the agent and show the correct configuration in the UI
Your provider key in the WhyOps dashboardLets WhyOps authenticate upstream when it forwards OpenAI or Anthropic traffic

1. Install the module

go get github.com/whyops-org/whyops-op/packages/sdk-go@latest

2. Create the WhyOps client once

package main

import whyops "github.com/whyops-org/whyops-op/packages/sdk-go"

var sdk = whyops.New(whyops.Config{
	APIKey:    os.Getenv("WHYOPS_API_KEY"),
	AgentName: "customer-support-agent",
	AgentMetadata: whyops.AgentMetadata{
		SystemPrompt: "You are a precise customer support assistant.",
		Description:  "Handles support, billing, and order status flows.",
		Tools: []whyops.AgentTool{
			{
				Name:         "search_orders",
				Description:  "Look up order state by ID",
				InputSchema:  `{"type":"object","properties":{"orderId":{"type":"string"}},"required":["orderId"]}`,
				OutputSchema: `{"type":"object","properties":{"status":{"type":"string"}}}`,
			},
		},
	},
})
If the agent has tools, include them in AgentMetadata.Tools. If it has no tools, using an empty slice keeps the registered definition unambiguous.

3. Initialize the agent during startup

info := sdk.InitAgent(ctx)
_ = info
You do not have to call this manually because trace methods initialize on first event, but early registration is the better default because configuration problems fail before live traffic.

4. Send your first runtime event

trace := sdk.Trace("session-123")

_ = trace.UserMessage(ctx, []whyops.MessageItem{
	{Role: "user", Content: "Reset my password."},
}, whyops.UserMessageOptions{})

5. Move to proxy transport or richer runtime tracing

Go SDK Proxy Transport

Learn the Go-specific proxy flow: ProxyHTTPClient() injects headers only, so your provider client must still point at the WhyOps proxy host.

Go SDK Runtime Events

Add tool spans, prompt-caching usage, hybrid patterns, self-hosted overrides, and a full method map.