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 does not patch provider clients directly. Instead, it gives you a proxy-aware *http.Client transport. This is the page to read when you want OpenAI or Anthropic traffic to go through WhyOps from Go.

Quickstart

Start there first if you have not created and initialized the WhyOps client yet.

Runtime Events

Add runtime tracing after the proxy flow is already working.

Direct Proxy APIs

Use the direct proxy pages only if you are bypassing the Go package.

Which API key goes where

CredentialWhere it livesWhat it is used for
WHYOPS_API_KEYYour app environmentAuthenticates agent init, manual events, and the proxy transport talking to WhyOps
Provider credential in the WhyOps dashboardWhyOps provider settingsLets WhyOps authenticate upstream when it forwards the proxied request
A stable trace or session IDYour request contextBest for explicit continuity between proxied model calls and later tool or runtime events
1

1. Store the provider credential in WhyOps

Add your OpenAI or Anthropic provider key in the WhyOps dashboard so WhyOps can forward proxied requests upstream.
2

2. Create and initialize the WhyOps client

Build the Go Client and call InitAgent(ctx) during startup.
3

3. Get a proxy-aware http client

Call sdk.ProxyHTTPClient() and supply that client anywhere your provider SDK accepts a custom *http.Client.
4

4. Point the provider SDK at the WhyOps proxy host

The transport only injects headers. You still have to set the provider base URL to WhyOps.
ProxyHTTPClient() injects WhyOps headers, but it does not rewrite the destination host. Your provider SDK or raw HTTP request must still target the WhyOps proxy URL.

Raw HTTP example

client := sdk.ProxyHTTPClient()
traceID := "session-123"

req, _ := http.NewRequest("POST", "https://proxy.whyops.com/v1/chat/completions", bytes.NewBuffer(body))
req.Header.Set("Content-Type", "application/json")
req.Header.Set("X-Trace-ID", traceID)
req.Header.Set("X-Thread-ID", traceID)

resp, err := client.Do(req)

Provider SDK pattern

// Use sdk.ProxyHTTPClient() anywhere your provider SDK accepts *http.Client.
//
// Then point that provider SDK at the WhyOps proxy base URL:
//   https://proxy.whyops.com        for Anthropic-style endpoints
//   https://proxy.whyops.com/v1     for OpenAI-style endpoints
//
// The exact constructor varies by provider library, but the pattern is:
//   1. supply ProxyHTTPClient()
//   2. set the provider base URL to the WhyOps proxy

Common mistakes

  • Passing ProxyHTTPClient() to the provider SDK but forgetting to change the provider base URL to WhyOps.
  • Sending provider requests to the real upstream host and expecting the transport alone to proxy them.
  • Using different AgentName values between proxied traffic and runtime events.
  • Relying only on auto-generated trace IDs when later tool or runtime events need to join the same thread.