Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ The Claude SDK for Go provides access to the [Claude API](https://docs.anthropic

Full documentation is available at **[platform.claude.com/docs/en/api/sdks/go](https://platform.claude.com/docs/en/api/sdks/go)**.

> **Note:** Managed agent outcome events (e.g., `user.define_outcome`) are not yet supported in the Go SDK.
> The Go example in the managed agents documentation currently references types that do not exist in `anthropic-sdk-go`.
> Please use the Python or TypeScript SDKs for this feature until Go support is added.

## Installation

<!-- x-release-please-start-version -->
Expand Down
50 changes: 50 additions & 0 deletions examples/session-basic/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
package main

import (
"context"
"fmt"

"github.com/anthropics/anthropic-sdk-go"
)

func main() {
client := anthropic.NewClient()
ctx := context.TODO()

// NOTE: Outcome events (user.define_outcome) are not yet supported in the Go SDK.

// Create an environment
environment, err := client.Beta.Environments.New(ctx, anthropic.BetaEnvironmentNewParams{
Name: "example-environment",
})
if err != nil {
panic(err)
}

// Create an agent
agent, err := client.Beta.Agents.New(ctx, anthropic.BetaAgentNewParams{
Name: "example-agent",
Model: anthropic.BetaManagedAgentsModelConfigParams{
ID: anthropic.BetaManagedAgentsModelClaudeSonnet4_6,
},
})
if err != nil {
panic(err)
}

// Create a session
session, err := client.Beta.Sessions.New(ctx, anthropic.BetaSessionNewParams{
EnvironmentID: environment.ID,
Agent: anthropic.BetaSessionNewParamsAgentUnion{
OfBetaManagedAgentsAgents: &anthropic.BetaManagedAgentsAgentParams{
ID: agent.ID,
Type: anthropic.BetaManagedAgentsAgentParamsTypeAgent,
},
},
})
if err != nil {
panic(err)
}

fmt.Println("Created session:", session.ID)
}