# Okapi install guide — Go

Okapi speaks the Sentry ingest wire format: this is the standard `github.com/getsentry/sentry-go` SDK, pointed at your own Okapi instance instead of Sentry's.

The DSN in this generic guide is a placeholder. Get the real DSN from Project → Settings → DSN Keys. An agent with an admin Okapi MCP credential can also call `get_dsn`. Do not invent a DSN.

Do not run the Sentry wizard or any setup that signs in to Sentry's hosted service; nothing in this setup should contact it.

## 1. Install

```bash
go get github.com/getsentry/sentry-go
```

## 2. Initialize

### `main.go`

```go
package main

import (
	"log"
	"time"

	"github.com/getsentry/sentry-go"
)

func main() {
	if err := sentry.Init(sentry.ClientOptions{
		Dsn:         "http://YOUR_PUBLIC_KEY@YOUR_OKAPI_HOST/YOUR_PROJECT_ID",
		Environment: "production",
	}); err != nil {
		log.Fatalf("sentry.Init: %s", err)
	}
	// Flush buffered events before the program exits.
	defer sentry.Flush(2 * time.Second)
	// ...
}
```

Keep the deferred flush so short-lived processes send their buffered events; add your framework's Sentry middleware to capture request panics.

## 3. Send a test event

```go
// Add "errors" to the imports in main.go.
sentry.CaptureException(errors.New("Okapi test event"))
sentry.Flush(2 * time.Second)
```

## 4. Verify

Open the instance's dashboard → Issues. The test event should appear within a few seconds as a new issue. If the instance's MCP server exposes a `verify_installation` tool, call that instead of checking by hand — it reports the SDK name/version and whether only a synthetic test event has arrived yet.

## More

- Structured logs (same DSN, no separate shipper) and source map uploads: https://useokapi.app/docs/sdk-setup
- Connect over MCP once the SDK is wired up: https://useokapi.app/docs/mcp-agents
