-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Open
Labels
enhancementNew feature or requestNew feature or request
Description
Overview
In the anthropic sonnet and opus models, the think mode is not returned correctly
https://docs.anthropic.com/en/api/messages#body-thinking-budget-tokens
Problem phenomenon
Curl Request
$ llminvoker_test git:(master) ✗ curl https://api.anthropic.com/v1/messages \
--header "x-api-key: $ANTHROPIC_API_KEY" \
--header "anthropic-version: 2023-06-01" \
--header "content-type: application/json" \
--data \ '{
"model": "claude-sonnet-4-20250514",
"max_tokens": 1500,
"messages": [
{"role": "user", "content": "Analyze Apple business model"}
],
"thinking": {"budget_tokens": 1024, "type": "enabled"}
}'
Curl output
{
"id":"....",
"type":"message",
"role":"assistant",
"model":"claude-sonnet-4-20250514",
"content":[
{"type":"thinking","thinking":"I'll analyze Apple's business model comprehensively, covering their key components, revenue streams, competitive advantages, and strategic approach.","signature":"..."},
{"type":"text","text":"# Apple's Business Model Analysis\n\n## Core Business Model Components\n......."}
],
"stop_reason":"end_turn",
"stop_sequence":null,
"usage":{"input_tokens":40,"cache_creation_input_tokens":0,"cache_read_input_tokens":0,"output_tokens":943,"service_tier":"standard"}}%
SDK request
package main
import (
"context"
"fmt"
"os"
openai "github.com/sashabaranov/go-openai"
)
func main() {
cfg := openai.DefaultConfig(os.Getenv("ANTHROPIC_API_KEY"))
cfg.BaseURL = "https://api.anthropic.com/v1"
cfg.APIVersion = "2023-06-01"
client := openai.NewClientWithConfig(cfg)
resp, err := client.CreateChatCompletion(
context.Background(),
openai.ChatCompletionRequest{
Model: "claude-sonnet-4-20250514",
Messages: []openai.ChatCompletionMessage{
{
Role: openai.ChatMessageRoleUser,
Content: "Analyze Apple business model",
},
},
MaxTokens: 1500,
ChatTemplateKwargs: map[string]any{
"thinking": map[string]any{
"budget_tokens": 1024,
"type": "enabled",
},
},
},
)
if err != nil {
fmt.Printf("ChatCompletion error: %v\n", err)
return
}
fmt.Println(resp.Choices[0].Message.Content)
fmt.Println(resp.Choices[0].Message.ReasoningContent)
}
SDK output
Content: # Apple's Business Model Analysis .........
Reasoning:
Hope Behavior
I would expect ReasoningContent to return the text of think, since the two are similar.
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request
Projects
Milestone
Relationships
Development
Select code repository
Activity