[Enhancement]: Add Go (v2) example: Converse API with extended/adaptive thinking (Bedrock Runtime)

Author: vizvasrjCreated Aug 8, 2026Updated Aug 24, 2026
LabelsGo-v2New example request

Background story

The Bedrock Runtime docs for extended thinking and adaptive thinking (https://docs.aws.amazon.com/bedrock/latest/userguide/claude-messages-extended-thinking.html and .../claude-messages-adaptive-thinking.html) only include CLI, Python, and TypeScript code snippets. There's no Go (v2) example anywhere in the docs or in this repo's gov2/bedrock-runtime folder showing how to enable thinking through the Converse API or how to parse the resulting reasoningContent block from the response.

I had to reverse-engineer the correct approach from the generated SDK type definitions on pkg.go.dev rather than from any example, which is error-prone (union member names, pointer vs. value fields, etc. aren't obvious without a working reference). A canonical Go example would save other Go developers the same trial and error.

What does this example accomplish?

Shows how to call the Converse API with thinking enabled on a Claude model on Bedrock, and how to read the reasoning content back out of the response alongside the normal text block. Specifically it should cover:

  1. Setting additionalModelRequestFields via the bedrockruntime/document package to enable thinking (both the newer adaptive mode with an effort level, and the older manual mode with budget_tokens, since support differs by model).
  2. Setting InferenceConfig.MaxTokens appropriately alongside thinking.
  3. Parsing types.ContentBlockMemberReasoningContent out of the response message content, distinct from types.ContentBlockMemberText.
  4. A note on when ConverseStream is required instead of Converse (e.g. once MaxTokens exceeds the streaming threshold).

Which AWS service(s)?

Amazon Bedrock Runtime (Converse API)

Which AWS SDKs or tools?

  • All languages
  • .NET
  • C++
  • Go (v2)
  • Java
  • Java (v2)
  • JavaScript
  • JavaScript (v3)
  • Kotlin
  • PHP
  • Python
  • Ruby
  • Rust
  • Swift
  • Not applicable

Are there existing code examples to leverage?

Do you have any reference code?

bash
thinkingConfig := document.NewLazyDocument(map[string]interface{}{
	"thinking": map[string]interface{}{
		"type":   "adaptive",
		"effort": "high",
	},
})

input := &bedrockruntime.ConverseInput{
	ModelId:  aws.String("us.anthropic.claude-opus-4-6-v1"),
	Messages: []types.Message{message},
	InferenceConfig: &types.InferenceConfiguration{
		MaxTokens: aws.Int32(16000),
	},
	AdditionalModelRequestFields: thinkingConfig,
}

response, err := client.Converse(ctx, input)
if err != nil {
	log.Fatalf("Error calling model: %v", err)
}

if msg, ok := response.Output.(*types.ConverseOutputMemberMessage); ok {
	for _, block := range msg.Value.Content {
		switch v := block.(type) {
		case *types.ContentBlockMemberReasoningContent:
			if rt, ok := v.Value.(*types.ReasoningContentBlockMemberReasoningText); ok {
				fmt.Println("--- Thinking ---")
				fmt.Println(aws.ToString(rt.Value.Text))
			}
		case *types.ContentBlockMemberText:
			fmt.Println(v.Value)
		}
	}
}

Source: awsdocs/aws-doc-sdk-examples