Skip to content

Commit 782d5a5

Browse files
feat(api): Releasing claude-sonnet-4-6
Releasing claude-sonnet-4-6 and GAing advanced tool use features.
1 parent 701f08f commit 782d5a5

9 files changed

Lines changed: 8728 additions & 2891 deletions

File tree

.stats.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
configured_endpoints: 34
2-
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/anthropic%2Fanthropic-57d3ae933fceba3cc19aa3cc6704469a5413f652e392203f29778a98428e1225.yml
3-
openapi_spec_hash: d5543958074cd2bd74096cd69f3bb4f9
4-
config_hash: dc2442d3731249bf23dd4352141b5ff6
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/anthropic%2Fanthropic-53a0f3638030e47f4fc5c6602e89ff9c2cade948bac544937cfda79a1a5726a9.yml
3+
openapi_spec_hash: b5ae0f2c5bdf4e8db48be39df7182ef1
4+
config_hash: 409a17b0a2807d809e958c50c09f9665

api.md

Lines changed: 79 additions & 0 deletions
Large diffs are not rendered by default.

betamessage.go

Lines changed: 880 additions & 162 deletions
Large diffs are not rendered by default.

message.go

Lines changed: 7566 additions & 2717 deletions
Large diffs are not rendered by default.

message_test.go

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ func TestMessageNewWithOptionalParams(t *testing.T) {
5151
Role: anthropic.MessageParamRoleUser,
5252
}},
5353
Model: anthropic.ModelClaudeOpus4_6,
54+
Container: anthropic.String("container"),
5455
InferenceGeo: anthropic.String("inference_geo"),
5556
Metadata: anthropic.MetadataParam{
5657
UserID: anthropic.String("13803d75-b4b5-4c3e-b2a2-6f21399b021b"),
@@ -64,6 +65,7 @@ func TestMessageNewWithOptionalParams(t *testing.T) {
6465
},
6566
},
6667
ServiceTier: anthropic.MessageNewParamsServiceTierAuto,
68+
Speed: anthropic.MessageNewParamsSpeedStandard,
6769
StopSequences: []string{"string"},
6870
System: []anthropic.TextBlockParam{{
6971
Text: "Today's date is 2024-06-01.",
@@ -100,14 +102,19 @@ func TestMessageNewWithOptionalParams(t *testing.T) {
100102
},
101103
Required: []string{"location"},
102104
},
103-
Name: "name",
105+
Name: "name",
106+
AllowedCallers: []string{"direct"},
104107
CacheControl: anthropic.CacheControlEphemeralParam{
105108
TTL: anthropic.CacheControlEphemeralTTLTTL5m,
106109
},
110+
DeferLoading: anthropic.Bool(true),
107111
Description: anthropic.String("Get the current weather in a given location"),
108112
EagerInputStreaming: anthropic.Bool(true),
109-
Strict: anthropic.Bool(true),
110-
Type: anthropic.ToolTypeCustom,
113+
InputExamples: []map[string]any{{
114+
"foo": "bar",
115+
}},
116+
Strict: anthropic.Bool(true),
117+
Type: anthropic.ToolTypeCustom,
111118
},
112119
}},
113120
TopK: anthropic.Int(5),
@@ -164,6 +171,7 @@ func TestMessageCountTokensWithOptionalParams(t *testing.T) {
164171
},
165172
},
166173
},
174+
Speed: anthropic.MessageCountTokensParamsSpeedStandard,
167175
System: anthropic.MessageCountTokensParamsSystemUnion{
168176
OfTextBlockArray: []anthropic.TextBlockParam{{
169177
Text: "Today's date is 2024-06-01.",
@@ -200,14 +208,19 @@ func TestMessageCountTokensWithOptionalParams(t *testing.T) {
200208
},
201209
Required: []string{"location"},
202210
},
203-
Name: "name",
211+
Name: "name",
212+
AllowedCallers: []string{"direct"},
204213
CacheControl: anthropic.CacheControlEphemeralParam{
205214
TTL: anthropic.CacheControlEphemeralTTLTTL5m,
206215
},
216+
DeferLoading: anthropic.Bool(true),
207217
Description: anthropic.String("Get the current weather in a given location"),
208218
EagerInputStreaming: anthropic.Bool(true),
209-
Strict: anthropic.Bool(true),
210-
Type: anthropic.ToolTypeCustom,
219+
InputExamples: []map[string]any{{
220+
"foo": "bar",
221+
}},
222+
Strict: anthropic.Bool(true),
223+
Type: anthropic.ToolTypeCustom,
211224
},
212225
}},
213226
})

messagebatch.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -614,6 +614,8 @@ type MessageBatchNewParamsRequestParams struct {
614614
// [models](https://docs.anthropic.com/en/docs/models-overview) for additional
615615
// details and options.
616616
Model Model `json:"model,omitzero,required"`
617+
// Container identifier for reuse across requests.
618+
Container param.Opt[string] `json:"container,omitzero"`
617619
// Specifies the geographic region for inference processing. If not specified, the
618620
// workspace's `default_inference_geo` is used.
619621
InferenceGeo param.Opt[string] `json:"inference_geo,omitzero"`
@@ -648,6 +650,11 @@ type MessageBatchNewParamsRequestParams struct {
648650
// Recommended for advanced use cases only. You usually only need to use
649651
// `temperature`.
650652
TopP param.Opt[float64] `json:"top_p,omitzero"`
653+
// The inference speed mode for this request. `"fast"` enables high
654+
// output-tokens-per-second inference.
655+
//
656+
// Any of "standard", "fast".
657+
Speed string `json:"speed,omitzero"`
651658
// An object describing metadata about the request.
652659
Metadata MetadataParam `json:"metadata,omitzero"`
653660
// Configuration options for the model's output, such as the output format.
@@ -786,6 +793,9 @@ func init() {
786793
apijson.RegisterFieldValidator[MessageBatchNewParamsRequestParams](
787794
"service_tier", "auto", "standard_only",
788795
)
796+
apijson.RegisterFieldValidator[MessageBatchNewParamsRequestParams](
797+
"speed", "standard", "fast",
798+
)
789799
}
790800

791801
type MessageBatchListParams struct {

messagebatch_test.go

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ func TestMessageBatchNew(t *testing.T) {
5151
Role: anthropic.MessageParamRoleUser,
5252
}},
5353
Model: anthropic.ModelClaudeOpus4_6,
54+
Container: anthropic.String("container"),
5455
InferenceGeo: anthropic.String("inference_geo"),
5556
Metadata: anthropic.MetadataParam{
5657
UserID: anthropic.String("13803d75-b4b5-4c3e-b2a2-6f21399b021b"),
@@ -64,6 +65,7 @@ func TestMessageBatchNew(t *testing.T) {
6465
},
6566
},
6667
ServiceTier: "auto",
68+
Speed: "standard",
6769
StopSequences: []string{"string"},
6870
Stream: anthropic.Bool(true),
6971
System: []anthropic.TextBlockParam{{
@@ -101,14 +103,19 @@ func TestMessageBatchNew(t *testing.T) {
101103
},
102104
Required: []string{"location"},
103105
},
104-
Name: "name",
106+
Name: "name",
107+
AllowedCallers: []string{"direct"},
105108
CacheControl: anthropic.CacheControlEphemeralParam{
106109
TTL: anthropic.CacheControlEphemeralTTLTTL5m,
107110
},
111+
DeferLoading: anthropic.Bool(true),
108112
Description: anthropic.String("Get the current weather in a given location"),
109113
EagerInputStreaming: anthropic.Bool(true),
110-
Strict: anthropic.Bool(true),
111-
Type: anthropic.ToolTypeCustom,
114+
InputExamples: []map[string]any{{
115+
"foo": "bar",
116+
}},
117+
Strict: anthropic.Bool(true),
118+
Type: anthropic.ToolTypeCustom,
112119
},
113120
}},
114121
TopK: anthropic.Int(5),

messageutil.go

Lines changed: 147 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
"fmt"
66

77
"github.com/anthropics/anthropic-sdk-go/internal/paramutil"
8+
"github.com/anthropics/anthropic-sdk-go/packages/param"
89
)
910

1011
// Accumulate builds up the Message incrementally from a MessageStreamEvent. The Message then can be used as
@@ -225,6 +226,7 @@ func (r ServerToolUseBlock) ToParam() ServerToolUseBlockParam {
225226
p.Type = r.Type
226227
p.ID = r.ID
227228
p.Input = r.Input
229+
p.Name = ServerToolUseBlockParamName(r.Name)
228230
return p
229231
}
230232

@@ -261,3 +263,148 @@ func (r WebSearchToolResultBlockContentUnion) ToParam() WebSearchToolResultBlock
261263
}
262264
return p
263265
}
266+
267+
func (variant WebFetchToolResultBlock) toParamUnion() ContentBlockParamUnion {
268+
p := variant.ToParam()
269+
return ContentBlockParamUnion{OfWebFetchToolResult: &p}
270+
}
271+
272+
func (variant CodeExecutionToolResultBlock) toParamUnion() ContentBlockParamUnion {
273+
p := variant.ToParam()
274+
return ContentBlockParamUnion{OfCodeExecutionToolResult: &p}
275+
}
276+
277+
func (variant BashCodeExecutionToolResultBlock) toParamUnion() ContentBlockParamUnion {
278+
p := variant.ToParam()
279+
return ContentBlockParamUnion{OfBashCodeExecutionToolResult: &p}
280+
}
281+
282+
func (variant TextEditorCodeExecutionToolResultBlock) toParamUnion() ContentBlockParamUnion {
283+
p := variant.ToParam()
284+
return ContentBlockParamUnion{OfTextEditorCodeExecutionToolResult: &p}
285+
}
286+
287+
func (variant ToolSearchToolResultBlock) toParamUnion() ContentBlockParamUnion {
288+
p := variant.ToParam()
289+
return ContentBlockParamUnion{OfToolSearchToolResult: &p}
290+
}
291+
292+
func (variant ContainerUploadBlock) toParamUnion() ContentBlockParamUnion {
293+
p := variant.ToParam()
294+
return ContentBlockParamUnion{OfContainerUpload: &p}
295+
}
296+
297+
func (r WebFetchToolResultBlock) ToParam() WebFetchToolResultBlockParam {
298+
var p WebFetchToolResultBlockParam
299+
p.Type = r.Type
300+
p.ToolUseID = r.ToolUseID
301+
return p
302+
}
303+
304+
func (r ContainerUploadBlock) ToParam() ContainerUploadBlockParam {
305+
var p ContainerUploadBlockParam
306+
p.Type = r.Type
307+
p.FileID = r.FileID
308+
return p
309+
}
310+
311+
func (r BashCodeExecutionToolResultBlock) ToParam() BashCodeExecutionToolResultBlockParam {
312+
var p BashCodeExecutionToolResultBlockParam
313+
p.Type = r.Type
314+
p.ToolUseID = r.ToolUseID
315+
316+
if r.Content.JSON.ErrorCode.Valid() {
317+
p.Content.OfRequestBashCodeExecutionToolResultError = &BashCodeExecutionToolResultErrorParam{
318+
ErrorCode: BashCodeExecutionToolResultErrorCode(r.Content.ErrorCode),
319+
}
320+
} else {
321+
requestBashContentResult := &BashCodeExecutionResultBlockParam{
322+
ReturnCode: r.Content.ReturnCode,
323+
Stderr: r.Content.Stderr,
324+
Stdout: r.Content.Stdout,
325+
}
326+
for _, block := range r.Content.Content {
327+
requestBashContentResult.Content = append(requestBashContentResult.Content, block.ToParam())
328+
}
329+
p.Content.OfRequestBashCodeExecutionResultBlock = requestBashContentResult
330+
}
331+
332+
return p
333+
}
334+
335+
func (r BashCodeExecutionOutputBlock) ToParam() BashCodeExecutionOutputBlockParam {
336+
var p BashCodeExecutionOutputBlockParam
337+
p.Type = r.Type
338+
p.FileID = r.FileID
339+
return p
340+
}
341+
342+
func (r CodeExecutionToolResultBlock) ToParam() CodeExecutionToolResultBlockParam {
343+
var p CodeExecutionToolResultBlockParam
344+
p.Type = r.Type
345+
p.ToolUseID = r.ToolUseID
346+
if r.Content.JSON.ErrorCode.Valid() {
347+
p.Content.OfRequestCodeExecutionToolResultError = &CodeExecutionToolResultErrorParam{
348+
ErrorCode: r.Content.ErrorCode,
349+
}
350+
} else {
351+
p.Content.OfRequestCodeExecutionResultBlock = &CodeExecutionResultBlockParam{
352+
ReturnCode: r.Content.ReturnCode,
353+
Stderr: r.Content.Stderr,
354+
Stdout: r.Content.Stdout,
355+
}
356+
for _, block := range r.Content.Content {
357+
p.Content.OfRequestCodeExecutionResultBlock.Content = append(p.Content.OfRequestCodeExecutionResultBlock.Content, block.ToParam())
358+
}
359+
}
360+
return p
361+
}
362+
363+
func (r CodeExecutionOutputBlock) ToParam() CodeExecutionOutputBlockParam {
364+
var p CodeExecutionOutputBlockParam
365+
p.Type = r.Type
366+
p.FileID = r.FileID
367+
return p
368+
}
369+
370+
func (r TextEditorCodeExecutionToolResultBlock) ToParam() TextEditorCodeExecutionToolResultBlockParam {
371+
var p TextEditorCodeExecutionToolResultBlockParam
372+
p.Type = r.Type
373+
p.ToolUseID = r.ToolUseID
374+
if r.Content.JSON.ErrorCode.Valid() {
375+
p.Content.OfRequestTextEditorCodeExecutionToolResultError = &TextEditorCodeExecutionToolResultErrorParam{
376+
ErrorCode: TextEditorCodeExecutionToolResultErrorCode(r.Content.ErrorCode),
377+
ErrorMessage: paramutil.ToOpt(r.Content.ErrorMessage, r.Content.JSON.ErrorMessage),
378+
}
379+
} else {
380+
p.Content = param.Override[TextEditorCodeExecutionToolResultBlockParamContentUnion](r.Content.RawJSON())
381+
}
382+
return p
383+
}
384+
385+
func (r ToolSearchToolResultBlock) ToParam() ToolSearchToolResultBlockParam {
386+
var p ToolSearchToolResultBlockParam
387+
p.Type = r.Type
388+
p.ToolUseID = r.ToolUseID
389+
if r.Content.JSON.ErrorCode.Valid() {
390+
p.Content.OfRequestToolSearchToolResultError = &ToolSearchToolResultErrorParam{
391+
ErrorCode: ToolSearchToolResultErrorCode(r.Content.ErrorCode),
392+
}
393+
} else {
394+
p.Content.OfRequestToolSearchToolSearchResultBlock = &ToolSearchToolSearchResultBlockParam{}
395+
for _, block := range r.Content.ToolReferences {
396+
p.Content.OfRequestToolSearchToolSearchResultBlock.ToolReferences = append(
397+
p.Content.OfRequestToolSearchToolSearchResultBlock.ToolReferences,
398+
block.ToParam(),
399+
)
400+
}
401+
}
402+
return p
403+
}
404+
405+
func (r ToolReferenceBlock) ToParam() ToolReferenceBlockParam {
406+
var p ToolReferenceBlockParam
407+
p.Type = r.Type
408+
p.ToolName = r.ToolName
409+
return p
410+
}

0 commit comments

Comments
 (0)