github.com/anthropics/anthropic-sdk-go@v1.70.1/message.go (about) 1 // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 3 package anthropic 4 5 import ( 6 "context" 7 "encoding/json" 8 "fmt" 9 "net/http" 10 "reflect" 11 "slices" 12 "time" 13 14 "github.com/anthropics/anthropic-sdk-go/internal/apijson" 15 "github.com/anthropics/anthropic-sdk-go/internal/paramutil" 16 "github.com/anthropics/anthropic-sdk-go/internal/requestconfig" 17 "github.com/anthropics/anthropic-sdk-go/option" 18 "github.com/anthropics/anthropic-sdk-go/packages/param" 19 "github.com/anthropics/anthropic-sdk-go/packages/respjson" 20 "github.com/anthropics/anthropic-sdk-go/packages/ssestream" 21 "github.com/anthropics/anthropic-sdk-go/shared/constant" 22 "github.com/tidwall/gjson" 23 ) 24 25 // MessageService contains methods and other services that help with interacting 26 // with the anthropic API. 27 // 28 // Note, unlike clients, this service does not read variables from the environment 29 // automatically. You should not instantiate this service directly, and instead use 30 // the [NewMessageService] method instead. 31 type MessageService struct { 32 Options []option.RequestOption 33 Batches MessageBatchService 34 } 35 36 // NewMessageService generates a new service that applies the given options to each 37 // request. These options are applied after the parent client's options (if there 38 // is one), and before any request-specific options. 39 func NewMessageService(opts ...option.RequestOption) (r MessageService) { 40 r = MessageService{} 41 r.Options = opts 42 r.Batches = NewMessageBatchService(opts...) 43 return 44 } 45 46 // Send a structured list of input messages with text and/or image content, and the 47 // model will generate the next message in the conversation. 48 // 49 // The Messages API can be used for either single queries or stateless multi-turn 50 // conversations. 51 // 52 // Learn more about the Messages API in our 53 // [user guide](https://platform.claude.com/docs/en/get-started) 54 // 55 // Note: If you choose to set a timeout for this request, we recommend 10 minutes. 56 func (r *MessageService) New(ctx context.Context, params MessageNewParams, opts ...option.RequestOption) (res *Message, err error) { 57 if !param.IsOmitted(params.UserProfileID) { 58 opts = append(opts, option.WithHeader("anthropic-user-profile-id", fmt.Sprintf("%v", params.UserProfileID.Value))) 59 } 60 if !param.IsOmitted(params.WorkspaceID) { 61 opts = append(opts, option.WithHeader("anthropic-workspace-id", fmt.Sprintf("%v", params.WorkspaceID.Value))) 62 } 63 opts = slices.Concat(r.Options, opts) 64 warnIfThinkingEnabled(params.Model, params.Thinking.OfEnabled != nil) 65 66 // For non-streaming requests, calculate the appropriate timeout based on maxTokens 67 // and check against model-specific limits 68 timeout, timeoutErr := CalculateNonStreamingTimeout(int(params.MaxTokens), params.Model, opts) 69 if timeoutErr != nil { 70 return nil, timeoutErr 71 } 72 opts = append(opts, option.WithRequestTimeout(timeout)) 73 74 path := "v1/messages" 75 err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, params, &res, opts...) 76 return res, err 77 } 78 79 // Send a structured list of input messages with text and/or image content, and the 80 // model will generate the next message in the conversation. 81 // 82 // The Messages API can be used for either single queries or stateless multi-turn 83 // conversations. 84 // 85 // Learn more about the Messages API in our 86 // [user guide](https://platform.claude.com/docs/en/get-started) 87 // 88 // Note: If you choose to set a timeout for this request, we recommend 10 minutes. 89 func (r *MessageService) NewStreaming(ctx context.Context, params MessageNewParams, opts ...option.RequestOption) (stream *ssestream.Stream[MessageStreamEventUnion]) { 90 var ( 91 raw *http.Response 92 err error 93 ) 94 if !param.IsOmitted(params.UserProfileID) { 95 opts = append(opts, option.WithHeader("anthropic-user-profile-id", fmt.Sprintf("%v", params.UserProfileID.Value))) 96 } 97 if !param.IsOmitted(params.WorkspaceID) { 98 opts = append(opts, option.WithHeader("anthropic-workspace-id", fmt.Sprintf("%v", params.WorkspaceID.Value))) 99 } 100 opts = slices.Concat(r.Options, opts) 101 warnIfThinkingEnabled(params.Model, params.Thinking.OfEnabled != nil) 102 opts = append(opts, option.WithJSONSet("stream", true)) 103 path := "v1/messages" 104 err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, params, &raw, opts...) 105 return ssestream.NewStream[MessageStreamEventUnion](ssestream.NewDecoder(raw), err) 106 } 107 108 // Count the number of tokens in a Message. 109 // 110 // The Token Count API can be used to count the number of tokens in a Message, 111 // including tools, images, and documents, without creating it. 112 // 113 // Learn more about token counting in our 114 // [user guide](https://platform.claude.com/docs/en/build-with-claude/token-counting) 115 func (r *MessageService) CountTokens(ctx context.Context, params MessageCountTokensParams, opts ...option.RequestOption) (res *MessageTokensCount, err error) { 116 if !param.IsOmitted(params.UserProfileID) { 117 opts = append(opts, option.WithHeader("anthropic-user-profile-id", fmt.Sprintf("%v", params.UserProfileID.Value))) 118 } 119 if !param.IsOmitted(params.WorkspaceID) { 120 opts = append(opts, option.WithHeader("anthropic-workspace-id", fmt.Sprintf("%v", params.WorkspaceID.Value))) 121 } 122 opts = slices.Concat(r.Options, opts) 123 path := "v1/messages/count_tokens" 124 err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, params, &res, opts...) 125 return res, err 126 } 127 128 // The properties Data, MediaType, Type are required. 129 type Base64ImageSourceParam struct { 130 Data string `json:"data" api:"required" format:"byte"` 131 // Any of "image/jpeg", "image/png", "image/gif", "image/webp". 132 MediaType Base64ImageSourceMediaType `json:"media_type,omitzero" api:"required"` 133 // This field can be elided, and will marshal its zero value as "base64". 134 Type constant.Base64 `json:"type" default:"base64"` 135 paramObj 136 } 137 138 func (r Base64ImageSourceParam) MarshalJSON() (data []byte, err error) { 139 type shadow Base64ImageSourceParam 140 return param.MarshalObject(r, (*shadow)(&r)) 141 } 142 func (r *Base64ImageSourceParam) UnmarshalJSON(data []byte) error { 143 return apijson.UnmarshalRoot(data, r) 144 } 145 146 type Base64ImageSourceMediaType string 147 148 const ( 149 Base64ImageSourceMediaTypeImageJPEG Base64ImageSourceMediaType = "image/jpeg" 150 Base64ImageSourceMediaTypeImagePNG Base64ImageSourceMediaType = "image/png" 151 Base64ImageSourceMediaTypeImageGIF Base64ImageSourceMediaType = "image/gif" 152 Base64ImageSourceMediaTypeImageWebP Base64ImageSourceMediaType = "image/webp" 153 ) 154 155 type Base64PDFSource struct { 156 Data string `json:"data" api:"required" format:"byte"` 157 MediaType constant.ApplicationPDF `json:"media_type" default:"application/pdf"` 158 Type constant.Base64 `json:"type" default:"base64"` 159 // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. 160 JSON struct { 161 Data respjson.Field 162 MediaType respjson.Field 163 Type respjson.Field 164 ExtraFields map[string]respjson.Field 165 raw string 166 } `json:"-"` 167 } 168 169 // Returns the unmodified JSON received from the API 170 func (r Base64PDFSource) RawJSON() string { return r.JSON.raw } 171 func (r *Base64PDFSource) UnmarshalJSON(data []byte) error { 172 return apijson.UnmarshalRoot(data, r) 173 } 174 175 // ToParam converts this Base64PDFSource to a Base64PDFSourceParam. 176 // 177 // Warning: the fields of the param type will not be present. ToParam should only 178 // be used at the last possible moment before sending a request. Test for this with 179 // Base64PDFSourceParam.Overrides() 180 func (r Base64PDFSource) ToParam() Base64PDFSourceParam { 181 return param.Override[Base64PDFSourceParam](json.RawMessage(r.RawJSON())) 182 } 183 184 // The properties Data, MediaType, Type are required. 185 type Base64PDFSourceParam struct { 186 Data string `json:"data" api:"required" format:"byte"` 187 // This field can be elided, and will marshal its zero value as "application/pdf". 188 MediaType constant.ApplicationPDF `json:"media_type" default:"application/pdf"` 189 // This field can be elided, and will marshal its zero value as "base64". 190 Type constant.Base64 `json:"type" default:"base64"` 191 paramObj 192 } 193 194 func (r Base64PDFSourceParam) MarshalJSON() (data []byte, err error) { 195 type shadow Base64PDFSourceParam 196 return param.MarshalObject(r, (*shadow)(&r)) 197 } 198 func (r *Base64PDFSourceParam) UnmarshalJSON(data []byte) error { 199 return apijson.UnmarshalRoot(data, r) 200 } 201 202 type BashCodeExecutionOutputBlock struct { 203 FileID string `json:"file_id" api:"required"` 204 Type constant.BashCodeExecutionOutput `json:"type" default:"bash_code_execution_output"` 205 // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. 206 JSON struct { 207 FileID respjson.Field 208 Type respjson.Field 209 ExtraFields map[string]respjson.Field 210 raw string 211 } `json:"-"` 212 } 213 214 // Returns the unmodified JSON received from the API 215 func (r BashCodeExecutionOutputBlock) RawJSON() string { return r.JSON.raw } 216 func (r *BashCodeExecutionOutputBlock) UnmarshalJSON(data []byte) error { 217 return apijson.UnmarshalRoot(data, r) 218 } 219 220 // The properties FileID, Type are required. 221 type BashCodeExecutionOutputBlockParam struct { 222 FileID string `json:"file_id" api:"required"` 223 // This field can be elided, and will marshal its zero value as 224 // "bash_code_execution_output". 225 Type constant.BashCodeExecutionOutput `json:"type" default:"bash_code_execution_output"` 226 paramObj 227 } 228 229 func (r BashCodeExecutionOutputBlockParam) MarshalJSON() (data []byte, err error) { 230 type shadow BashCodeExecutionOutputBlockParam 231 return param.MarshalObject(r, (*shadow)(&r)) 232 } 233 func (r *BashCodeExecutionOutputBlockParam) UnmarshalJSON(data []byte) error { 234 return apijson.UnmarshalRoot(data, r) 235 } 236 237 type BashCodeExecutionResultBlock struct { 238 Content []BashCodeExecutionOutputBlock `json:"content" api:"required"` 239 ReturnCode int64 `json:"return_code" api:"required"` 240 Stderr string `json:"stderr" api:"required"` 241 Stdout string `json:"stdout" api:"required"` 242 Type constant.BashCodeExecutionResult `json:"type" default:"bash_code_execution_result"` 243 // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. 244 JSON struct { 245 Content respjson.Field 246 ReturnCode respjson.Field 247 Stderr respjson.Field 248 Stdout respjson.Field 249 Type respjson.Field 250 ExtraFields map[string]respjson.Field 251 raw string 252 } `json:"-"` 253 } 254 255 // Returns the unmodified JSON received from the API 256 func (r BashCodeExecutionResultBlock) RawJSON() string { return r.JSON.raw } 257 func (r *BashCodeExecutionResultBlock) UnmarshalJSON(data []byte) error { 258 return apijson.UnmarshalRoot(data, r) 259 } 260 261 // The properties Content, ReturnCode, Stderr, Stdout, Type are required. 262 type BashCodeExecutionResultBlockParam struct { 263 Content []BashCodeExecutionOutputBlockParam `json:"content,omitzero" api:"required"` 264 ReturnCode int64 `json:"return_code" api:"required"` 265 Stderr string `json:"stderr" api:"required"` 266 Stdout string `json:"stdout" api:"required"` 267 // This field can be elided, and will marshal its zero value as 268 // "bash_code_execution_result". 269 Type constant.BashCodeExecutionResult `json:"type" default:"bash_code_execution_result"` 270 paramObj 271 } 272 273 func (r BashCodeExecutionResultBlockParam) MarshalJSON() (data []byte, err error) { 274 type shadow BashCodeExecutionResultBlockParam 275 return param.MarshalObject(r, (*shadow)(&r)) 276 } 277 func (r *BashCodeExecutionResultBlockParam) UnmarshalJSON(data []byte) error { 278 return apijson.UnmarshalRoot(data, r) 279 } 280 281 type BashCodeExecutionToolResultBlock struct { 282 Content BashCodeExecutionToolResultBlockContentUnion `json:"content" api:"required"` 283 ToolUseID string `json:"tool_use_id" api:"required"` 284 Type constant.BashCodeExecutionToolResult `json:"type" default:"bash_code_execution_tool_result"` 285 // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. 286 JSON struct { 287 Content respjson.Field 288 ToolUseID respjson.Field 289 Type respjson.Field 290 ExtraFields map[string]respjson.Field 291 raw string 292 } `json:"-"` 293 } 294 295 // Returns the unmodified JSON received from the API 296 func (r BashCodeExecutionToolResultBlock) RawJSON() string { return r.JSON.raw } 297 func (r *BashCodeExecutionToolResultBlock) UnmarshalJSON(data []byte) error { 298 return apijson.UnmarshalRoot(data, r) 299 } 300 301 // BashCodeExecutionToolResultBlockContentUnion contains all possible properties 302 // and values from [BashCodeExecutionToolResultError], 303 // [BashCodeExecutionResultBlock]. 304 // 305 // Use the methods beginning with 'As' to cast the union to one of its variants. 306 type BashCodeExecutionToolResultBlockContentUnion struct { 307 // This field is from variant [BashCodeExecutionToolResultError]. 308 ErrorCode BashCodeExecutionToolResultErrorCode `json:"error_code"` 309 Type string `json:"type"` 310 // This field is from variant [BashCodeExecutionResultBlock]. 311 Content []BashCodeExecutionOutputBlock `json:"content"` 312 // This field is from variant [BashCodeExecutionResultBlock]. 313 ReturnCode int64 `json:"return_code"` 314 // This field is from variant [BashCodeExecutionResultBlock]. 315 Stderr string `json:"stderr"` 316 // This field is from variant [BashCodeExecutionResultBlock]. 317 Stdout string `json:"stdout"` 318 JSON struct { 319 ErrorCode respjson.Field 320 Type respjson.Field 321 Content respjson.Field 322 ReturnCode respjson.Field 323 Stderr respjson.Field 324 Stdout respjson.Field 325 raw string 326 } `json:"-"` 327 } 328 329 func (u BashCodeExecutionToolResultBlockContentUnion) AsResponseBashCodeExecutionToolResultError() (v BashCodeExecutionToolResultError) { 330 apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) 331 return 332 } 333 334 func (u BashCodeExecutionToolResultBlockContentUnion) AsResponseBashCodeExecutionResultBlock() (v BashCodeExecutionResultBlock) { 335 apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) 336 return 337 } 338 339 // Returns the unmodified JSON received from the API 340 func (u BashCodeExecutionToolResultBlockContentUnion) RawJSON() string { return u.JSON.raw } 341 342 func (r *BashCodeExecutionToolResultBlockContentUnion) UnmarshalJSON(data []byte) error { 343 return apijson.UnmarshalRoot(data, r) 344 } 345 346 // The properties Content, ToolUseID, Type are required. 347 type BashCodeExecutionToolResultBlockParam struct { 348 Content BashCodeExecutionToolResultBlockParamContentUnion `json:"content,omitzero" api:"required"` 349 ToolUseID string `json:"tool_use_id" api:"required"` 350 // Create a cache control breakpoint at this content block. 351 CacheControl CacheControlEphemeralParam `json:"cache_control,omitzero"` 352 // This field can be elided, and will marshal its zero value as 353 // "bash_code_execution_tool_result". 354 Type constant.BashCodeExecutionToolResult `json:"type" default:"bash_code_execution_tool_result"` 355 paramObj 356 } 357 358 func (r BashCodeExecutionToolResultBlockParam) MarshalJSON() (data []byte, err error) { 359 type shadow BashCodeExecutionToolResultBlockParam 360 return param.MarshalObject(r, (*shadow)(&r)) 361 } 362 func (r *BashCodeExecutionToolResultBlockParam) UnmarshalJSON(data []byte) error { 363 return apijson.UnmarshalRoot(data, r) 364 } 365 366 // Only one field can be non-zero. 367 // 368 // Use [param.IsOmitted] to confirm if a field is set. 369 type BashCodeExecutionToolResultBlockParamContentUnion struct { 370 OfRequestBashCodeExecutionToolResultError *BashCodeExecutionToolResultErrorParam `json:",omitzero,inline"` 371 OfRequestBashCodeExecutionResultBlock *BashCodeExecutionResultBlockParam `json:",omitzero,inline"` 372 paramUnion 373 } 374 375 func (u BashCodeExecutionToolResultBlockParamContentUnion) MarshalJSON() ([]byte, error) { 376 return param.MarshalUnion(u, u.OfRequestBashCodeExecutionToolResultError, u.OfRequestBashCodeExecutionResultBlock) 377 } 378 func (u *BashCodeExecutionToolResultBlockParamContentUnion) UnmarshalJSON(data []byte) error { 379 return apijson.UnmarshalRoot(data, u) 380 } 381 382 func (u *BashCodeExecutionToolResultBlockParamContentUnion) asAny() any { 383 if !param.IsOmitted(u.OfRequestBashCodeExecutionToolResultError) { 384 return u.OfRequestBashCodeExecutionToolResultError 385 } else if !param.IsOmitted(u.OfRequestBashCodeExecutionResultBlock) { 386 return u.OfRequestBashCodeExecutionResultBlock 387 } 388 return nil 389 } 390 391 // Returns a pointer to the underlying variant's property, if present. 392 func (u BashCodeExecutionToolResultBlockParamContentUnion) GetErrorCode() *string { 393 if vt := u.OfRequestBashCodeExecutionToolResultError; vt != nil { 394 return (*string)(&vt.ErrorCode) 395 } 396 return nil 397 } 398 399 // Returns a pointer to the underlying variant's property, if present. 400 func (u BashCodeExecutionToolResultBlockParamContentUnion) GetContent() []BashCodeExecutionOutputBlockParam { 401 if vt := u.OfRequestBashCodeExecutionResultBlock; vt != nil { 402 return vt.Content 403 } 404 return nil 405 } 406 407 // Returns a pointer to the underlying variant's property, if present. 408 func (u BashCodeExecutionToolResultBlockParamContentUnion) GetReturnCode() *int64 { 409 if vt := u.OfRequestBashCodeExecutionResultBlock; vt != nil { 410 return &vt.ReturnCode 411 } 412 return nil 413 } 414 415 // Returns a pointer to the underlying variant's property, if present. 416 func (u BashCodeExecutionToolResultBlockParamContentUnion) GetStderr() *string { 417 if vt := u.OfRequestBashCodeExecutionResultBlock; vt != nil { 418 return &vt.Stderr 419 } 420 return nil 421 } 422 423 // Returns a pointer to the underlying variant's property, if present. 424 func (u BashCodeExecutionToolResultBlockParamContentUnion) GetStdout() *string { 425 if vt := u.OfRequestBashCodeExecutionResultBlock; vt != nil { 426 return &vt.Stdout 427 } 428 return nil 429 } 430 431 // Returns a pointer to the underlying variant's property, if present. 432 func (u BashCodeExecutionToolResultBlockParamContentUnion) GetType() *string { 433 if vt := u.OfRequestBashCodeExecutionToolResultError; vt != nil { 434 return (*string)(&vt.Type) 435 } else if vt := u.OfRequestBashCodeExecutionResultBlock; vt != nil { 436 return (*string)(&vt.Type) 437 } 438 return nil 439 } 440 441 type BashCodeExecutionToolResultError struct { 442 // Any of "invalid_tool_input", "unavailable", "too_many_requests", 443 // "execution_time_exceeded", "output_file_too_large". 444 ErrorCode BashCodeExecutionToolResultErrorCode `json:"error_code" api:"required"` 445 Type constant.BashCodeExecutionToolResultError `json:"type" default:"bash_code_execution_tool_result_error"` 446 // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. 447 JSON struct { 448 ErrorCode respjson.Field 449 Type respjson.Field 450 ExtraFields map[string]respjson.Field 451 raw string 452 } `json:"-"` 453 } 454 455 // Returns the unmodified JSON received from the API 456 func (r BashCodeExecutionToolResultError) RawJSON() string { return r.JSON.raw } 457 func (r *BashCodeExecutionToolResultError) UnmarshalJSON(data []byte) error { 458 return apijson.UnmarshalRoot(data, r) 459 } 460 461 type BashCodeExecutionToolResultErrorCode string 462 463 const ( 464 BashCodeExecutionToolResultErrorCodeInvalidToolInput BashCodeExecutionToolResultErrorCode = "invalid_tool_input" 465 BashCodeExecutionToolResultErrorCodeUnavailable BashCodeExecutionToolResultErrorCode = "unavailable" 466 BashCodeExecutionToolResultErrorCodeTooManyRequests BashCodeExecutionToolResultErrorCode = "too_many_requests" 467 BashCodeExecutionToolResultErrorCodeExecutionTimeExceeded BashCodeExecutionToolResultErrorCode = "execution_time_exceeded" 468 BashCodeExecutionToolResultErrorCodeOutputFileTooLarge BashCodeExecutionToolResultErrorCode = "output_file_too_large" 469 ) 470 471 // The properties ErrorCode, Type are required. 472 type BashCodeExecutionToolResultErrorParam struct { 473 // Any of "invalid_tool_input", "unavailable", "too_many_requests", 474 // "execution_time_exceeded", "output_file_too_large". 475 ErrorCode BashCodeExecutionToolResultErrorCode `json:"error_code,omitzero" api:"required"` 476 // This field can be elided, and will marshal its zero value as 477 // "bash_code_execution_tool_result_error". 478 Type constant.BashCodeExecutionToolResultError `json:"type" default:"bash_code_execution_tool_result_error"` 479 paramObj 480 } 481 482 func (r BashCodeExecutionToolResultErrorParam) MarshalJSON() (data []byte, err error) { 483 type shadow BashCodeExecutionToolResultErrorParam 484 return param.MarshalObject(r, (*shadow)(&r)) 485 } 486 func (r *BashCodeExecutionToolResultErrorParam) UnmarshalJSON(data []byte) error { 487 return apijson.UnmarshalRoot(data, r) 488 } 489 490 // `close_tab`'s config overrides. 491 type BrowserCloseTabConfigParam struct { 492 // Defer loading for this member. Must resolve to the same value on every enabled 493 // member of the toolset. 494 DeferLoading param.Opt[bool] `json:"defer_loading,omitzero"` 495 // Whether this member is offered to the model. Default is per member, per the 496 // toolset's documentation. A member whose enabled resolves false is withheld from 497 // the served schema. 498 Enabled param.Opt[bool] `json:"enabled,omitzero"` 499 paramObj 500 } 501 502 func (r BrowserCloseTabConfigParam) MarshalJSON() (data []byte, err error) { 503 type shadow BrowserCloseTabConfigParam 504 return param.MarshalObject(r, (*shadow)(&r)) 505 } 506 func (r *BrowserCloseTabConfigParam) UnmarshalJSON(data []byte) error { 507 return apijson.UnmarshalRoot(data, r) 508 } 509 510 // `double_click`'s config overrides. 511 type BrowserDoubleClickConfigParam struct { 512 // Defer loading for this member. Must resolve to the same value on every enabled 513 // member of the toolset. 514 DeferLoading param.Opt[bool] `json:"defer_loading,omitzero"` 515 // Whether this member is offered to the model. Default is per member, per the 516 // toolset's documentation. A member whose enabled resolves false is withheld from 517 // the served schema. 518 Enabled param.Opt[bool] `json:"enabled,omitzero"` 519 paramObj 520 } 521 522 func (r BrowserDoubleClickConfigParam) MarshalJSON() (data []byte, err error) { 523 type shadow BrowserDoubleClickConfigParam 524 return param.MarshalObject(r, (*shadow)(&r)) 525 } 526 func (r *BrowserDoubleClickConfigParam) UnmarshalJSON(data []byte) error { 527 return apijson.UnmarshalRoot(data, r) 528 } 529 530 // `file_upload`'s config overrides. 531 type BrowserFileUploadConfigParam struct { 532 // Defer loading for this member. Must resolve to the same value on every enabled 533 // member of the toolset. 534 DeferLoading param.Opt[bool] `json:"defer_loading,omitzero"` 535 // Whether this member is offered to the model. Default is per member, per the 536 // toolset's documentation. A member whose enabled resolves false is withheld from 537 // the served schema. 538 Enabled param.Opt[bool] `json:"enabled,omitzero"` 539 paramObj 540 } 541 542 func (r BrowserFileUploadConfigParam) MarshalJSON() (data []byte, err error) { 543 type shadow BrowserFileUploadConfigParam 544 return param.MarshalObject(r, (*shadow)(&r)) 545 } 546 func (r *BrowserFileUploadConfigParam) UnmarshalJSON(data []byte) error { 547 return apijson.UnmarshalRoot(data, r) 548 } 549 550 // `find`'s config overrides. 551 type BrowserFindConfigParam struct { 552 // Defer loading for this member. Must resolve to the same value on every enabled 553 // member of the toolset. 554 DeferLoading param.Opt[bool] `json:"defer_loading,omitzero"` 555 // Whether this member is offered to the model. Default is per member, per the 556 // toolset's documentation. A member whose enabled resolves false is withheld from 557 // the served schema. 558 Enabled param.Opt[bool] `json:"enabled,omitzero"` 559 paramObj 560 } 561 562 func (r BrowserFindConfigParam) MarshalJSON() (data []byte, err error) { 563 type shadow BrowserFindConfigParam 564 return param.MarshalObject(r, (*shadow)(&r)) 565 } 566 func (r *BrowserFindConfigParam) UnmarshalJSON(data []byte) error { 567 return apijson.UnmarshalRoot(data, r) 568 } 569 570 // `form_input`'s config overrides. 571 type BrowserFormInputConfigParam struct { 572 // Defer loading for this member. Must resolve to the same value on every enabled 573 // member of the toolset. 574 DeferLoading param.Opt[bool] `json:"defer_loading,omitzero"` 575 // Whether this member is offered to the model. Default is per member, per the 576 // toolset's documentation. A member whose enabled resolves false is withheld from 577 // the served schema. 578 Enabled param.Opt[bool] `json:"enabled,omitzero"` 579 paramObj 580 } 581 582 func (r BrowserFormInputConfigParam) MarshalJSON() (data []byte, err error) { 583 type shadow BrowserFormInputConfigParam 584 return param.MarshalObject(r, (*shadow)(&r)) 585 } 586 func (r *BrowserFormInputConfigParam) UnmarshalJSON(data []byte) error { 587 return apijson.UnmarshalRoot(data, r) 588 } 589 590 // `get_page_text`'s config overrides. 591 type BrowserGetPageTextConfigParam struct { 592 // Defer loading for this member. Must resolve to the same value on every enabled 593 // member of the toolset. 594 DeferLoading param.Opt[bool] `json:"defer_loading,omitzero"` 595 // Whether this member is offered to the model. Default is per member, per the 596 // toolset's documentation. A member whose enabled resolves false is withheld from 597 // the served schema. 598 Enabled param.Opt[bool] `json:"enabled,omitzero"` 599 paramObj 600 } 601 602 func (r BrowserGetPageTextConfigParam) MarshalJSON() (data []byte, err error) { 603 type shadow BrowserGetPageTextConfigParam 604 return param.MarshalObject(r, (*shadow)(&r)) 605 } 606 func (r *BrowserGetPageTextConfigParam) UnmarshalJSON(data []byte) error { 607 return apijson.UnmarshalRoot(data, r) 608 } 609 610 // `hold_key`'s config overrides. 611 type BrowserHoldKeyConfigParam struct { 612 // Defer loading for this member. Must resolve to the same value on every enabled 613 // member of the toolset. 614 DeferLoading param.Opt[bool] `json:"defer_loading,omitzero"` 615 // Whether this member is offered to the model. Default is per member, per the 616 // toolset's documentation. A member whose enabled resolves false is withheld from 617 // the served schema. 618 Enabled param.Opt[bool] `json:"enabled,omitzero"` 619 paramObj 620 } 621 622 func (r BrowserHoldKeyConfigParam) MarshalJSON() (data []byte, err error) { 623 type shadow BrowserHoldKeyConfigParam 624 return param.MarshalObject(r, (*shadow)(&r)) 625 } 626 func (r *BrowserHoldKeyConfigParam) UnmarshalJSON(data []byte) error { 627 return apijson.UnmarshalRoot(data, r) 628 } 629 630 // `hover`'s config overrides. 631 type BrowserHoverConfigParam struct { 632 // Defer loading for this member. Must resolve to the same value on every enabled 633 // member of the toolset. 634 DeferLoading param.Opt[bool] `json:"defer_loading,omitzero"` 635 // Whether this member is offered to the model. Default is per member, per the 636 // toolset's documentation. A member whose enabled resolves false is withheld from 637 // the served schema. 638 Enabled param.Opt[bool] `json:"enabled,omitzero"` 639 paramObj 640 } 641 642 func (r BrowserHoverConfigParam) MarshalJSON() (data []byte, err error) { 643 type shadow BrowserHoverConfigParam 644 return param.MarshalObject(r, (*shadow)(&r)) 645 } 646 func (r *BrowserHoverConfigParam) UnmarshalJSON(data []byte) error { 647 return apijson.UnmarshalRoot(data, r) 648 } 649 650 // `javascript_exec`'s config overrides. 651 type BrowserJavascriptExecConfigParam struct { 652 // Defer loading for this member. Must resolve to the same value on every enabled 653 // member of the toolset. 654 DeferLoading param.Opt[bool] `json:"defer_loading,omitzero"` 655 // Whether this member is offered to the model. Default is per member, per the 656 // toolset's documentation. A member whose enabled resolves false is withheld from 657 // the served schema. 658 Enabled param.Opt[bool] `json:"enabled,omitzero"` 659 paramObj 660 } 661 662 func (r BrowserJavascriptExecConfigParam) MarshalJSON() (data []byte, err error) { 663 type shadow BrowserJavascriptExecConfigParam 664 return param.MarshalObject(r, (*shadow)(&r)) 665 } 666 func (r *BrowserJavascriptExecConfigParam) UnmarshalJSON(data []byte) error { 667 return apijson.UnmarshalRoot(data, r) 668 } 669 670 // `key`'s config overrides. 671 type BrowserKeyConfigParam struct { 672 // Defer loading for this member. Must resolve to the same value on every enabled 673 // member of the toolset. 674 DeferLoading param.Opt[bool] `json:"defer_loading,omitzero"` 675 // Whether this member is offered to the model. Default is per member, per the 676 // toolset's documentation. A member whose enabled resolves false is withheld from 677 // the served schema. 678 Enabled param.Opt[bool] `json:"enabled,omitzero"` 679 paramObj 680 } 681 682 func (r BrowserKeyConfigParam) MarshalJSON() (data []byte, err error) { 683 type shadow BrowserKeyConfigParam 684 return param.MarshalObject(r, (*shadow)(&r)) 685 } 686 func (r *BrowserKeyConfigParam) UnmarshalJSON(data []byte) error { 687 return apijson.UnmarshalRoot(data, r) 688 } 689 690 // `left_click`'s config overrides. 691 type BrowserLeftClickConfigParam struct { 692 // Defer loading for this member. Must resolve to the same value on every enabled 693 // member of the toolset. 694 DeferLoading param.Opt[bool] `json:"defer_loading,omitzero"` 695 // Whether this member is offered to the model. Default is per member, per the 696 // toolset's documentation. A member whose enabled resolves false is withheld from 697 // the served schema. 698 Enabled param.Opt[bool] `json:"enabled,omitzero"` 699 paramObj 700 } 701 702 func (r BrowserLeftClickConfigParam) MarshalJSON() (data []byte, err error) { 703 type shadow BrowserLeftClickConfigParam 704 return param.MarshalObject(r, (*shadow)(&r)) 705 } 706 func (r *BrowserLeftClickConfigParam) UnmarshalJSON(data []byte) error { 707 return apijson.UnmarshalRoot(data, r) 708 } 709 710 // `left_click_drag`'s config overrides. 711 type BrowserLeftClickDragConfigParam struct { 712 // Defer loading for this member. Must resolve to the same value on every enabled 713 // member of the toolset. 714 DeferLoading param.Opt[bool] `json:"defer_loading,omitzero"` 715 // Whether this member is offered to the model. Default is per member, per the 716 // toolset's documentation. A member whose enabled resolves false is withheld from 717 // the served schema. 718 Enabled param.Opt[bool] `json:"enabled,omitzero"` 719 paramObj 720 } 721 722 func (r BrowserLeftClickDragConfigParam) MarshalJSON() (data []byte, err error) { 723 type shadow BrowserLeftClickDragConfigParam 724 return param.MarshalObject(r, (*shadow)(&r)) 725 } 726 func (r *BrowserLeftClickDragConfigParam) UnmarshalJSON(data []byte) error { 727 return apijson.UnmarshalRoot(data, r) 728 } 729 730 // `left_mouse_down`'s config overrides. 731 type BrowserLeftMouseDownConfigParam struct { 732 // Defer loading for this member. Must resolve to the same value on every enabled 733 // member of the toolset. 734 DeferLoading param.Opt[bool] `json:"defer_loading,omitzero"` 735 // Whether this member is offered to the model. Default is per member, per the 736 // toolset's documentation. A member whose enabled resolves false is withheld from 737 // the served schema. 738 Enabled param.Opt[bool] `json:"enabled,omitzero"` 739 paramObj 740 } 741 742 func (r BrowserLeftMouseDownConfigParam) MarshalJSON() (data []byte, err error) { 743 type shadow BrowserLeftMouseDownConfigParam 744 return param.MarshalObject(r, (*shadow)(&r)) 745 } 746 func (r *BrowserLeftMouseDownConfigParam) UnmarshalJSON(data []byte) error { 747 return apijson.UnmarshalRoot(data, r) 748 } 749 750 // `left_mouse_up`'s config overrides. 751 type BrowserLeftMouseUpConfigParam struct { 752 // Defer loading for this member. Must resolve to the same value on every enabled 753 // member of the toolset. 754 DeferLoading param.Opt[bool] `json:"defer_loading,omitzero"` 755 // Whether this member is offered to the model. Default is per member, per the 756 // toolset's documentation. A member whose enabled resolves false is withheld from 757 // the served schema. 758 Enabled param.Opt[bool] `json:"enabled,omitzero"` 759 paramObj 760 } 761 762 func (r BrowserLeftMouseUpConfigParam) MarshalJSON() (data []byte, err error) { 763 type shadow BrowserLeftMouseUpConfigParam 764 return param.MarshalObject(r, (*shadow)(&r)) 765 } 766 func (r *BrowserLeftMouseUpConfigParam) UnmarshalJSON(data []byte) error { 767 return apijson.UnmarshalRoot(data, r) 768 } 769 770 // `list_tabs`'s config overrides. 771 type BrowserListTabsConfigParam struct { 772 // Defer loading for this member. Must resolve to the same value on every enabled 773 // member of the toolset. 774 DeferLoading param.Opt[bool] `json:"defer_loading,omitzero"` 775 // Whether this member is offered to the model. Default is per member, per the 776 // toolset's documentation. A member whose enabled resolves false is withheld from 777 // the served schema. 778 Enabled param.Opt[bool] `json:"enabled,omitzero"` 779 paramObj 780 } 781 782 func (r BrowserListTabsConfigParam) MarshalJSON() (data []byte, err error) { 783 type shadow BrowserListTabsConfigParam 784 return param.MarshalObject(r, (*shadow)(&r)) 785 } 786 func (r *BrowserListTabsConfigParam) UnmarshalJSON(data []byte) error { 787 return apijson.UnmarshalRoot(data, r) 788 } 789 790 // `middle_click`'s config overrides. 791 type BrowserMiddleClickConfigParam struct { 792 // Defer loading for this member. Must resolve to the same value on every enabled 793 // member of the toolset. 794 DeferLoading param.Opt[bool] `json:"defer_loading,omitzero"` 795 // Whether this member is offered to the model. Default is per member, per the 796 // toolset's documentation. A member whose enabled resolves false is withheld from 797 // the served schema. 798 Enabled param.Opt[bool] `json:"enabled,omitzero"` 799 paramObj 800 } 801 802 func (r BrowserMiddleClickConfigParam) MarshalJSON() (data []byte, err error) { 803 type shadow BrowserMiddleClickConfigParam 804 return param.MarshalObject(r, (*shadow)(&r)) 805 } 806 func (r *BrowserMiddleClickConfigParam) UnmarshalJSON(data []byte) error { 807 return apijson.UnmarshalRoot(data, r) 808 } 809 810 // `mouse_move`'s config overrides. 811 type BrowserMouseMoveConfigParam struct { 812 // Defer loading for this member. Must resolve to the same value on every enabled 813 // member of the toolset. 814 DeferLoading param.Opt[bool] `json:"defer_loading,omitzero"` 815 // Whether this member is offered to the model. Default is per member, per the 816 // toolset's documentation. A member whose enabled resolves false is withheld from 817 // the served schema. 818 Enabled param.Opt[bool] `json:"enabled,omitzero"` 819 paramObj 820 } 821 822 func (r BrowserMouseMoveConfigParam) MarshalJSON() (data []byte, err error) { 823 type shadow BrowserMouseMoveConfigParam 824 return param.MarshalObject(r, (*shadow)(&r)) 825 } 826 func (r *BrowserMouseMoveConfigParam) UnmarshalJSON(data []byte) error { 827 return apijson.UnmarshalRoot(data, r) 828 } 829 830 // `navigate`'s config overrides. 831 type BrowserNavigateConfigParam struct { 832 // Defer loading for this member. Must resolve to the same value on every enabled 833 // member of the toolset. 834 DeferLoading param.Opt[bool] `json:"defer_loading,omitzero"` 835 // Whether this member is offered to the model. Default is per member, per the 836 // toolset's documentation. A member whose enabled resolves false is withheld from 837 // the served schema. 838 Enabled param.Opt[bool] `json:"enabled,omitzero"` 839 paramObj 840 } 841 842 func (r BrowserNavigateConfigParam) MarshalJSON() (data []byte, err error) { 843 type shadow BrowserNavigateConfigParam 844 return param.MarshalObject(r, (*shadow)(&r)) 845 } 846 func (r *BrowserNavigateConfigParam) UnmarshalJSON(data []byte) error { 847 return apijson.UnmarshalRoot(data, r) 848 } 849 850 // `new_tab`'s config overrides. 851 type BrowserNewTabConfigParam struct { 852 // Defer loading for this member. Must resolve to the same value on every enabled 853 // member of the toolset. 854 DeferLoading param.Opt[bool] `json:"defer_loading,omitzero"` 855 // Whether this member is offered to the model. Default is per member, per the 856 // toolset's documentation. A member whose enabled resolves false is withheld from 857 // the served schema. 858 Enabled param.Opt[bool] `json:"enabled,omitzero"` 859 paramObj 860 } 861 862 func (r BrowserNewTabConfigParam) MarshalJSON() (data []byte, err error) { 863 type shadow BrowserNewTabConfigParam 864 return param.MarshalObject(r, (*shadow)(&r)) 865 } 866 func (r *BrowserNewTabConfigParam) UnmarshalJSON(data []byte) error { 867 return apijson.UnmarshalRoot(data, r) 868 } 869 870 // `read_console`'s config overrides. 871 type BrowserReadConsoleConfigParam struct { 872 // Defer loading for this member. Must resolve to the same value on every enabled 873 // member of the toolset. 874 DeferLoading param.Opt[bool] `json:"defer_loading,omitzero"` 875 // Whether this member is offered to the model. Default is per member, per the 876 // toolset's documentation. A member whose enabled resolves false is withheld from 877 // the served schema. 878 Enabled param.Opt[bool] `json:"enabled,omitzero"` 879 paramObj 880 } 881 882 func (r BrowserReadConsoleConfigParam) MarshalJSON() (data []byte, err error) { 883 type shadow BrowserReadConsoleConfigParam 884 return param.MarshalObject(r, (*shadow)(&r)) 885 } 886 func (r *BrowserReadConsoleConfigParam) UnmarshalJSON(data []byte) error { 887 return apijson.UnmarshalRoot(data, r) 888 } 889 890 // `read_network`'s config overrides. 891 type BrowserReadNetworkConfigParam struct { 892 // Defer loading for this member. Must resolve to the same value on every enabled 893 // member of the toolset. 894 DeferLoading param.Opt[bool] `json:"defer_loading,omitzero"` 895 // Whether this member is offered to the model. Default is per member, per the 896 // toolset's documentation. A member whose enabled resolves false is withheld from 897 // the served schema. 898 Enabled param.Opt[bool] `json:"enabled,omitzero"` 899 paramObj 900 } 901 902 func (r BrowserReadNetworkConfigParam) MarshalJSON() (data []byte, err error) { 903 type shadow BrowserReadNetworkConfigParam 904 return param.MarshalObject(r, (*shadow)(&r)) 905 } 906 func (r *BrowserReadNetworkConfigParam) UnmarshalJSON(data []byte) error { 907 return apijson.UnmarshalRoot(data, r) 908 } 909 910 // `read_page`'s config overrides. 911 type BrowserReadPageConfigParam struct { 912 // Defer loading for this member. Must resolve to the same value on every enabled 913 // member of the toolset. 914 DeferLoading param.Opt[bool] `json:"defer_loading,omitzero"` 915 // Whether this member is offered to the model. Default is per member, per the 916 // toolset's documentation. A member whose enabled resolves false is withheld from 917 // the served schema. 918 Enabled param.Opt[bool] `json:"enabled,omitzero"` 919 paramObj 920 } 921 922 func (r BrowserReadPageConfigParam) MarshalJSON() (data []byte, err error) { 923 type shadow BrowserReadPageConfigParam 924 return param.MarshalObject(r, (*shadow)(&r)) 925 } 926 func (r *BrowserReadPageConfigParam) UnmarshalJSON(data []byte) error { 927 return apijson.UnmarshalRoot(data, r) 928 } 929 930 // `right_click`'s config overrides. 931 type BrowserRightClickConfigParam struct { 932 // Defer loading for this member. Must resolve to the same value on every enabled 933 // member of the toolset. 934 DeferLoading param.Opt[bool] `json:"defer_loading,omitzero"` 935 // Whether this member is offered to the model. Default is per member, per the 936 // toolset's documentation. A member whose enabled resolves false is withheld from 937 // the served schema. 938 Enabled param.Opt[bool] `json:"enabled,omitzero"` 939 paramObj 940 } 941 942 func (r BrowserRightClickConfigParam) MarshalJSON() (data []byte, err error) { 943 type shadow BrowserRightClickConfigParam 944 return param.MarshalObject(r, (*shadow)(&r)) 945 } 946 func (r *BrowserRightClickConfigParam) UnmarshalJSON(data []byte) error { 947 return apijson.UnmarshalRoot(data, r) 948 } 949 950 // `screenshot`'s config overrides. 951 type BrowserScreenshotConfigParam struct { 952 // Defer loading for this member. Must resolve to the same value on every enabled 953 // member of the toolset. 954 DeferLoading param.Opt[bool] `json:"defer_loading,omitzero"` 955 // Whether this member is offered to the model. Default is per member, per the 956 // toolset's documentation. A member whose enabled resolves false is withheld from 957 // the served schema. 958 Enabled param.Opt[bool] `json:"enabled,omitzero"` 959 paramObj 960 } 961 962 func (r BrowserScreenshotConfigParam) MarshalJSON() (data []byte, err error) { 963 type shadow BrowserScreenshotConfigParam 964 return param.MarshalObject(r, (*shadow)(&r)) 965 } 966 func (r *BrowserScreenshotConfigParam) UnmarshalJSON(data []byte) error { 967 return apijson.UnmarshalRoot(data, r) 968 } 969 970 // `scroll`'s config overrides. 971 type BrowserScrollConfigParam struct { 972 // Defer loading for this member. Must resolve to the same value on every enabled 973 // member of the toolset. 974 DeferLoading param.Opt[bool] `json:"defer_loading,omitzero"` 975 // Whether this member is offered to the model. Default is per member, per the 976 // toolset's documentation. A member whose enabled resolves false is withheld from 977 // the served schema. 978 Enabled param.Opt[bool] `json:"enabled,omitzero"` 979 paramObj 980 } 981 982 func (r BrowserScrollConfigParam) MarshalJSON() (data []byte, err error) { 983 type shadow BrowserScrollConfigParam 984 return param.MarshalObject(r, (*shadow)(&r)) 985 } 986 func (r *BrowserScrollConfigParam) UnmarshalJSON(data []byte) error { 987 return apijson.UnmarshalRoot(data, r) 988 } 989 990 // `scroll_to`'s config overrides. 991 type BrowserScrollToConfigParam struct { 992 // Defer loading for this member. Must resolve to the same value on every enabled 993 // member of the toolset. 994 DeferLoading param.Opt[bool] `json:"defer_loading,omitzero"` 995 // Whether this member is offered to the model. Default is per member, per the 996 // toolset's documentation. A member whose enabled resolves false is withheld from 997 // the served schema. 998 Enabled param.Opt[bool] `json:"enabled,omitzero"` 999 paramObj 1000 } 1001 1002 func (r BrowserScrollToConfigParam) MarshalJSON() (data []byte, err error) { 1003 type shadow BrowserScrollToConfigParam 1004 return param.MarshalObject(r, (*shadow)(&r)) 1005 } 1006 func (r *BrowserScrollToConfigParam) UnmarshalJSON(data []byte) error { 1007 return apijson.UnmarshalRoot(data, r) 1008 } 1009 1010 // The caller's browser state after a browser toolset member call — the full 1011 // inventory of open tabs, which tab is active, and any side effects (tabs opened, 1012 // download state changes) the call produced. 1013 // 1014 // At most one per `tool_result`, only on a non-error result answering a browser 1015 // toolset member `tool_use`. The server renders the model-visible text from it; 1016 // the model never sees the raw fields. 1017 // 1018 // The properties Tabs, Type are required. 1019 type BrowserStateBlockParam struct { 1020 // All tabs open in the browser after this call — the full inventory, not a delta. 1021 // May be empty. Whenever non-empty, exactly one entry carries `active: true`. 1022 Tabs []BrowserStateTabEntryParam `json:"tabs,omitzero" api:"required"` 1023 // Tabs opened and download state changes during this call. "Nothing to report" is 1024 // expressed by omitting the field, never by an empty list. 1025 StateChanges []BrowserStateChangeUnionParam `json:"state_changes,omitzero"` 1026 // Create a cache control breakpoint at this content block. 1027 CacheControl CacheControlEphemeralParam `json:"cache_control,omitzero"` 1028 // This field can be elided, and will marshal its zero value as "browser_state". 1029 Type constant.BrowserState `json:"type" default:"browser_state"` 1030 paramObj 1031 } 1032 1033 func (r BrowserStateBlockParam) MarshalJSON() (data []byte, err error) { 1034 type shadow BrowserStateBlockParam 1035 return param.MarshalObject(r, (*shadow)(&r)) 1036 } 1037 func (r *BrowserStateBlockParam) UnmarshalJSON(data []byte) error { 1038 return apijson.UnmarshalRoot(data, r) 1039 } 1040 1041 func BrowserStateChangeParamOfTabOpened(tabID string) BrowserStateChangeUnionParam { 1042 var tabOpened BrowserStateChangeTabOpenedParam 1043 tabOpened.TabID = tabID 1044 return BrowserStateChangeUnionParam{OfTabOpened: &tabOpened} 1045 } 1046 1047 func BrowserStateChangeParamOfDownloadStarted(downloadID string, url string) BrowserStateChangeUnionParam { 1048 var downloadStarted BrowserStateChangeDownloadStartedParam 1049 downloadStarted.DownloadID = downloadID 1050 downloadStarted.URL = url 1051 return BrowserStateChangeUnionParam{OfDownloadStarted: &downloadStarted} 1052 } 1053 1054 func BrowserStateChangeParamOfDownloadCompleted(downloadID string, url string) BrowserStateChangeUnionParam { 1055 var downloadCompleted BrowserStateChangeDownloadCompletedParam 1056 downloadCompleted.DownloadID = downloadID 1057 downloadCompleted.URL = url 1058 return BrowserStateChangeUnionParam{OfDownloadCompleted: &downloadCompleted} 1059 } 1060 1061 func BrowserStateChangeParamOfDownloadFailed(downloadID string, url string) BrowserStateChangeUnionParam { 1062 var downloadFailed BrowserStateChangeDownloadFailedParam 1063 downloadFailed.DownloadID = downloadID 1064 downloadFailed.URL = url 1065 return BrowserStateChangeUnionParam{OfDownloadFailed: &downloadFailed} 1066 } 1067 1068 // Only one field can be non-zero. 1069 // 1070 // Use [param.IsOmitted] to confirm if a field is set. 1071 type BrowserStateChangeUnionParam struct { 1072 OfTabOpened *BrowserStateChangeTabOpenedParam `json:",omitzero,inline"` 1073 OfDownloadStarted *BrowserStateChangeDownloadStartedParam `json:",omitzero,inline"` 1074 OfDownloadCompleted *BrowserStateChangeDownloadCompletedParam `json:",omitzero,inline"` 1075 OfDownloadFailed *BrowserStateChangeDownloadFailedParam `json:",omitzero,inline"` 1076 paramUnion 1077 } 1078 1079 func (u BrowserStateChangeUnionParam) MarshalJSON() ([]byte, error) { 1080 return param.MarshalUnion(u, u.OfTabOpened, u.OfDownloadStarted, u.OfDownloadCompleted, u.OfDownloadFailed) 1081 } 1082 func (u *BrowserStateChangeUnionParam) UnmarshalJSON(data []byte) error { 1083 return apijson.UnmarshalRoot(data, u) 1084 } 1085 1086 func (u *BrowserStateChangeUnionParam) asAny() any { 1087 if !param.IsOmitted(u.OfTabOpened) { 1088 return u.OfTabOpened 1089 } else if !param.IsOmitted(u.OfDownloadStarted) { 1090 return u.OfDownloadStarted 1091 } else if !param.IsOmitted(u.OfDownloadCompleted) { 1092 return u.OfDownloadCompleted 1093 } else if !param.IsOmitted(u.OfDownloadFailed) { 1094 return u.OfDownloadFailed 1095 } 1096 return nil 1097 } 1098 1099 // Returns a pointer to the underlying variant's property, if present. 1100 func (u BrowserStateChangeUnionParam) GetTabID() *string { 1101 if vt := u.OfTabOpened; vt != nil { 1102 return &vt.TabID 1103 } 1104 return nil 1105 } 1106 1107 // Returns a pointer to the underlying variant's property, if present. 1108 func (u BrowserStateChangeUnionParam) GetPath() *string { 1109 if vt := u.OfDownloadCompleted; vt != nil && vt.Path.Valid() { 1110 return &vt.Path.Value 1111 } 1112 return nil 1113 } 1114 1115 // Returns a pointer to the underlying variant's property, if present. 1116 func (u BrowserStateChangeUnionParam) GetSizeBytes() *int64 { 1117 if vt := u.OfDownloadCompleted; vt != nil && vt.SizeBytes.Valid() { 1118 return &vt.SizeBytes.Value 1119 } 1120 return nil 1121 } 1122 1123 // Returns a pointer to the underlying variant's property, if present. 1124 func (u BrowserStateChangeUnionParam) GetError() *string { 1125 if vt := u.OfDownloadFailed; vt != nil && vt.Error.Valid() { 1126 return &vt.Error.Value 1127 } 1128 return nil 1129 } 1130 1131 // Returns a pointer to the underlying variant's property, if present. 1132 func (u BrowserStateChangeUnionParam) GetType() *string { 1133 if vt := u.OfTabOpened; vt != nil { 1134 return (*string)(&vt.Type) 1135 } else if vt := u.OfDownloadStarted; vt != nil { 1136 return (*string)(&vt.Type) 1137 } else if vt := u.OfDownloadCompleted; vt != nil { 1138 return (*string)(&vt.Type) 1139 } else if vt := u.OfDownloadFailed; vt != nil { 1140 return (*string)(&vt.Type) 1141 } 1142 return nil 1143 } 1144 1145 // Returns a pointer to the underlying variant's property, if present. 1146 func (u BrowserStateChangeUnionParam) GetDownloadID() *string { 1147 if vt := u.OfDownloadStarted; vt != nil { 1148 return (*string)(&vt.DownloadID) 1149 } else if vt := u.OfDownloadCompleted; vt != nil { 1150 return (*string)(&vt.DownloadID) 1151 } else if vt := u.OfDownloadFailed; vt != nil { 1152 return (*string)(&vt.DownloadID) 1153 } 1154 return nil 1155 } 1156 1157 // Returns a pointer to the underlying variant's property, if present. 1158 func (u BrowserStateChangeUnionParam) GetURL() *string { 1159 if vt := u.OfDownloadStarted; vt != nil { 1160 return (*string)(&vt.URL) 1161 } else if vt := u.OfDownloadCompleted; vt != nil { 1162 return (*string)(&vt.URL) 1163 } else if vt := u.OfDownloadFailed; vt != nil { 1164 return (*string)(&vt.URL) 1165 } 1166 return nil 1167 } 1168 1169 func init() { 1170 apijson.RegisterUnion[BrowserStateChangeUnionParam]( 1171 "type", 1172 apijson.Discriminator[BrowserStateChangeTabOpenedParam]("tab_opened"), 1173 apijson.Discriminator[BrowserStateChangeDownloadStartedParam]("download_started"), 1174 apijson.Discriminator[BrowserStateChangeDownloadCompletedParam]("download_completed"), 1175 apijson.Discriminator[BrowserStateChangeDownloadFailedParam]("download_failed"), 1176 ) 1177 } 1178 1179 // A file download that finished during this call, reported with the same 1180 // `download_id` as its `download_started` — or without a prior `download_started`, 1181 // when the download finished during the call that started it (at most one state 1182 // change per `download_id` per result). 1183 // 1184 // The properties DownloadID, Type, URL are required. 1185 type BrowserStateChangeDownloadCompletedParam struct { 1186 // The caller-assigned identifier for this download, stable across the state 1187 // changes reporting it. 1188 DownloadID string `json:"download_id" api:"required"` 1189 // The final post-redirect URL the download was served from. 1190 URL string `json:"url" api:"required"` 1191 // Where the executor saved the file, on the executor's filesystem. Only included 1192 // when another tool in the same environment can read the file at that path. 1193 Path param.Opt[string] `json:"path,omitzero"` 1194 // The completed download's size. 1195 SizeBytes param.Opt[int64] `json:"size_bytes,omitzero"` 1196 // This field can be elided, and will marshal its zero value as 1197 // "download_completed". 1198 Type constant.DownloadCompleted `json:"type" default:"download_completed"` 1199 paramObj 1200 } 1201 1202 func (r BrowserStateChangeDownloadCompletedParam) MarshalJSON() (data []byte, err error) { 1203 type shadow BrowserStateChangeDownloadCompletedParam 1204 return param.MarshalObject(r, (*shadow)(&r)) 1205 } 1206 func (r *BrowserStateChangeDownloadCompletedParam) UnmarshalJSON(data []byte) error { 1207 return apijson.UnmarshalRoot(data, r) 1208 } 1209 1210 // A file download that failed — or was cancelled — during this call. 1211 // 1212 // The properties DownloadID, Type, URL are required. 1213 type BrowserStateChangeDownloadFailedParam struct { 1214 // The caller-assigned identifier for this download, stable across the state 1215 // changes reporting it. 1216 DownloadID string `json:"download_id" api:"required"` 1217 // The final post-redirect URL the download was served from. 1218 URL string `json:"url" api:"required"` 1219 // The failure or cancellation detail, when known. 1220 Error param.Opt[string] `json:"error,omitzero"` 1221 // This field can be elided, and will marshal its zero value as "download_failed". 1222 Type constant.DownloadFailed `json:"type" default:"download_failed"` 1223 paramObj 1224 } 1225 1226 func (r BrowserStateChangeDownloadFailedParam) MarshalJSON() (data []byte, err error) { 1227 type shadow BrowserStateChangeDownloadFailedParam 1228 return param.MarshalObject(r, (*shadow)(&r)) 1229 } 1230 func (r *BrowserStateChangeDownloadFailedParam) UnmarshalJSON(data []byte) error { 1231 return apijson.UnmarshalRoot(data, r) 1232 } 1233 1234 // A file download that started during this call. 1235 // 1236 // The properties DownloadID, Type, URL are required. 1237 type BrowserStateChangeDownloadStartedParam struct { 1238 // The caller-assigned identifier for this download, stable across the state 1239 // changes reporting it. 1240 DownloadID string `json:"download_id" api:"required"` 1241 // The final post-redirect URL the download was served from. 1242 URL string `json:"url" api:"required"` 1243 // This field can be elided, and will marshal its zero value as "download_started". 1244 Type constant.DownloadStarted `json:"type" default:"download_started"` 1245 paramObj 1246 } 1247 1248 func (r BrowserStateChangeDownloadStartedParam) MarshalJSON() (data []byte, err error) { 1249 type shadow BrowserStateChangeDownloadStartedParam 1250 return param.MarshalObject(r, (*shadow)(&r)) 1251 } 1252 func (r *BrowserStateChangeDownloadStartedParam) UnmarshalJSON(data []byte) error { 1253 return apijson.UnmarshalRoot(data, r) 1254 } 1255 1256 // A tab this call's execution opened that remains open at its end — the creation 1257 // delta of the `tabs` inventory, not an event log. 1258 // 1259 // Carries only the `tab_id`; the tab's `title` and `url` live on its `tabs` entry, 1260 // which must include the same `tab_id`. A tab opened during a failed call gets no 1261 // deferred `tab_opened`; it simply appears in the next result's `tabs` inventory. 1262 // 1263 // The properties TabID, Type are required. 1264 type BrowserStateChangeTabOpenedParam struct { 1265 // The `tab_id` of the opened tab, present in `tabs`. 1266 TabID string `json:"tab_id" api:"required"` 1267 // This field can be elided, and will marshal its zero value as "tab_opened". 1268 Type constant.TabOpened `json:"type" default:"tab_opened"` 1269 paramObj 1270 } 1271 1272 func (r BrowserStateChangeTabOpenedParam) MarshalJSON() (data []byte, err error) { 1273 type shadow BrowserStateChangeTabOpenedParam 1274 return param.MarshalObject(r, (*shadow)(&r)) 1275 } 1276 func (r *BrowserStateChangeTabOpenedParam) UnmarshalJSON(data []byte) error { 1277 return apijson.UnmarshalRoot(data, r) 1278 } 1279 1280 // One open browser tab reported in a `browser_state` block's `tabs` inventory. 1281 // 1282 // `tab_id` is the caller-assigned identifier for the tab; `title` and `url` 1283 // describe the page the tab is currently showing and may be empty strings (a blank 1284 // tab legitimately has both empty). `active` marks the tab that is active after 1285 // this call; whenever `tabs` is non-empty, exactly one entry is marked. 1286 // 1287 // The properties TabID, Title, URL are required. 1288 type BrowserStateTabEntryParam struct { 1289 // The caller-assigned identifier for this tab, unique within the inventory. 1290 TabID string `json:"tab_id" api:"required"` 1291 // The title of the page the tab is showing. May be empty. 1292 Title string `json:"title" api:"required"` 1293 // The URL of the page the tab is showing. May be empty. 1294 URL string `json:"url" api:"required"` 1295 // Whether this tab is the active tab after this call. Whenever `tabs` is 1296 // non-empty, exactly one entry is marked `active: true`. 1297 Active param.Opt[bool] `json:"active,omitzero"` 1298 paramObj 1299 } 1300 1301 func (r BrowserStateTabEntryParam) MarshalJSON() (data []byte, err error) { 1302 type shadow BrowserStateTabEntryParam 1303 return param.MarshalObject(r, (*shadow)(&r)) 1304 } 1305 func (r *BrowserStateTabEntryParam) UnmarshalJSON(data []byte) error { 1306 return apijson.UnmarshalRoot(data, r) 1307 } 1308 1309 // `switch_tab`'s config overrides. 1310 type BrowserSwitchTabConfigParam struct { 1311 // Defer loading for this member. Must resolve to the same value on every enabled 1312 // member of the toolset. 1313 DeferLoading param.Opt[bool] `json:"defer_loading,omitzero"` 1314 // Whether this member is offered to the model. Default is per member, per the 1315 // toolset's documentation. A member whose enabled resolves false is withheld from 1316 // the served schema. 1317 Enabled param.Opt[bool] `json:"enabled,omitzero"` 1318 paramObj 1319 } 1320 1321 func (r BrowserSwitchTabConfigParam) MarshalJSON() (data []byte, err error) { 1322 type shadow BrowserSwitchTabConfigParam 1323 return param.MarshalObject(r, (*shadow)(&r)) 1324 } 1325 func (r *BrowserSwitchTabConfigParam) UnmarshalJSON(data []byte) error { 1326 return apijson.UnmarshalRoot(data, r) 1327 } 1328 1329 // The browser toolset: a single `tools[]` entry (carrying no `name`) that declares 1330 // the browser tool family. The model is served the family's tool with any members 1331 // disabled via `configs` removed from its schema. 1332 // 1333 // The property Type is required. 1334 type BrowserToolset20260801Param struct { 1335 // Create a cache control breakpoint at this content block. 1336 CacheControl CacheControlEphemeralParam `json:"cache_control,omitzero"` 1337 // Per-member configuration for `browser_toolset_20260801`: one optional field per 1338 // member tool, keyed by the member name — the same name the member's `tool_use` 1339 // blocks carry. Every member is an accepted key, and a member's defaults apply 1340 // wherever its key is absent. Unknown keys are rejected: the field set is this 1341 // toolset version's complete member set. 1342 Configs BrowserToolsetConfigsParam `json:"configs,omitzero"` 1343 // This field can be elided, and will marshal its zero value as 1344 // "browser_toolset_20260801". 1345 Type constant.BrowserToolset20260801 `json:"type" default:"browser_toolset_20260801"` 1346 paramObj 1347 } 1348 1349 func (r BrowserToolset20260801Param) MarshalJSON() (data []byte, err error) { 1350 type shadow BrowserToolset20260801Param 1351 return param.MarshalObject(r, (*shadow)(&r)) 1352 } 1353 func (r *BrowserToolset20260801Param) UnmarshalJSON(data []byte) error { 1354 return apijson.UnmarshalRoot(data, r) 1355 } 1356 1357 // Per-member configuration for `browser_toolset_20260801`: one optional field per 1358 // member tool, keyed by the member name — the same name the member's `tool_use` 1359 // blocks carry. Every member is an accepted key, and a member's defaults apply 1360 // wherever its key is absent. Unknown keys are rejected: the field set is this 1361 // toolset version's complete member set. 1362 type BrowserToolsetConfigsParam struct { 1363 // `close_tab`'s config overrides. 1364 CloseTab BrowserCloseTabConfigParam `json:"close_tab,omitzero"` 1365 // `double_click`'s config overrides. 1366 DoubleClick BrowserDoubleClickConfigParam `json:"double_click,omitzero"` 1367 // `file_upload`'s config overrides. 1368 FileUpload BrowserFileUploadConfigParam `json:"file_upload,omitzero"` 1369 // `find`'s config overrides. 1370 Find BrowserFindConfigParam `json:"find,omitzero"` 1371 // `form_input`'s config overrides. 1372 FormInput BrowserFormInputConfigParam `json:"form_input,omitzero"` 1373 // `get_page_text`'s config overrides. 1374 GetPageText BrowserGetPageTextConfigParam `json:"get_page_text,omitzero"` 1375 // `hold_key`'s config overrides. 1376 HoldKey BrowserHoldKeyConfigParam `json:"hold_key,omitzero"` 1377 // `hover`'s config overrides. 1378 Hover BrowserHoverConfigParam `json:"hover,omitzero"` 1379 // `javascript_exec`'s config overrides. 1380 JavascriptExec BrowserJavascriptExecConfigParam `json:"javascript_exec,omitzero"` 1381 // `key`'s config overrides. 1382 Key BrowserKeyConfigParam `json:"key,omitzero"` 1383 // `left_click`'s config overrides. 1384 LeftClick BrowserLeftClickConfigParam `json:"left_click,omitzero"` 1385 // `left_click_drag`'s config overrides. 1386 LeftClickDrag BrowserLeftClickDragConfigParam `json:"left_click_drag,omitzero"` 1387 // `left_mouse_down`'s config overrides. 1388 LeftMouseDown BrowserLeftMouseDownConfigParam `json:"left_mouse_down,omitzero"` 1389 // `left_mouse_up`'s config overrides. 1390 LeftMouseUp BrowserLeftMouseUpConfigParam `json:"left_mouse_up,omitzero"` 1391 // `list_tabs`'s config overrides. 1392 ListTabs BrowserListTabsConfigParam `json:"list_tabs,omitzero"` 1393 // `middle_click`'s config overrides. 1394 MiddleClick BrowserMiddleClickConfigParam `json:"middle_click,omitzero"` 1395 // `mouse_move`'s config overrides. 1396 MouseMove BrowserMouseMoveConfigParam `json:"mouse_move,omitzero"` 1397 // `navigate`'s config overrides. 1398 Navigate BrowserNavigateConfigParam `json:"navigate,omitzero"` 1399 // `new_tab`'s config overrides. 1400 NewTab BrowserNewTabConfigParam `json:"new_tab,omitzero"` 1401 // `read_console`'s config overrides. 1402 ReadConsole BrowserReadConsoleConfigParam `json:"read_console,omitzero"` 1403 // `read_network`'s config overrides. 1404 ReadNetwork BrowserReadNetworkConfigParam `json:"read_network,omitzero"` 1405 // `read_page`'s config overrides. 1406 ReadPage BrowserReadPageConfigParam `json:"read_page,omitzero"` 1407 // `right_click`'s config overrides. 1408 RightClick BrowserRightClickConfigParam `json:"right_click,omitzero"` 1409 // `screenshot`'s config overrides. 1410 Screenshot BrowserScreenshotConfigParam `json:"screenshot,omitzero"` 1411 // `scroll`'s config overrides. 1412 Scroll BrowserScrollConfigParam `json:"scroll,omitzero"` 1413 // `scroll_to`'s config overrides. 1414 ScrollTo BrowserScrollToConfigParam `json:"scroll_to,omitzero"` 1415 // `switch_tab`'s config overrides. 1416 SwitchTab BrowserSwitchTabConfigParam `json:"switch_tab,omitzero"` 1417 // `triple_click`'s config overrides. 1418 TripleClick BrowserTripleClickConfigParam `json:"triple_click,omitzero"` 1419 // `type`'s config overrides. 1420 Type BrowserTypeConfigParam `json:"type,omitzero"` 1421 // `wait`'s config overrides. 1422 Wait BrowserWaitConfigParam `json:"wait,omitzero"` 1423 // `zoom`'s config overrides. 1424 Zoom BrowserZoomConfigParam `json:"zoom,omitzero"` 1425 paramObj 1426 } 1427 1428 func (r BrowserToolsetConfigsParam) MarshalJSON() (data []byte, err error) { 1429 type shadow BrowserToolsetConfigsParam 1430 return param.MarshalObject(r, (*shadow)(&r)) 1431 } 1432 func (r *BrowserToolsetConfigsParam) UnmarshalJSON(data []byte) error { 1433 return apijson.UnmarshalRoot(data, r) 1434 } 1435 1436 // `triple_click`'s config overrides. 1437 type BrowserTripleClickConfigParam struct { 1438 // Defer loading for this member. Must resolve to the same value on every enabled 1439 // member of the toolset. 1440 DeferLoading param.Opt[bool] `json:"defer_loading,omitzero"` 1441 // Whether this member is offered to the model. Default is per member, per the 1442 // toolset's documentation. A member whose enabled resolves false is withheld from 1443 // the served schema. 1444 Enabled param.Opt[bool] `json:"enabled,omitzero"` 1445 paramObj 1446 } 1447 1448 func (r BrowserTripleClickConfigParam) MarshalJSON() (data []byte, err error) { 1449 type shadow BrowserTripleClickConfigParam 1450 return param.MarshalObject(r, (*shadow)(&r)) 1451 } 1452 func (r *BrowserTripleClickConfigParam) UnmarshalJSON(data []byte) error { 1453 return apijson.UnmarshalRoot(data, r) 1454 } 1455 1456 // `type`'s config overrides. 1457 type BrowserTypeConfigParam struct { 1458 // Defer loading for this member. Must resolve to the same value on every enabled 1459 // member of the toolset. 1460 DeferLoading param.Opt[bool] `json:"defer_loading,omitzero"` 1461 // Whether this member is offered to the model. Default is per member, per the 1462 // toolset's documentation. A member whose enabled resolves false is withheld from 1463 // the served schema. 1464 Enabled param.Opt[bool] `json:"enabled,omitzero"` 1465 paramObj 1466 } 1467 1468 func (r BrowserTypeConfigParam) MarshalJSON() (data []byte, err error) { 1469 type shadow BrowserTypeConfigParam 1470 return param.MarshalObject(r, (*shadow)(&r)) 1471 } 1472 func (r *BrowserTypeConfigParam) UnmarshalJSON(data []byte) error { 1473 return apijson.UnmarshalRoot(data, r) 1474 } 1475 1476 // `wait`'s config overrides. 1477 type BrowserWaitConfigParam struct { 1478 // Defer loading for this member. Must resolve to the same value on every enabled 1479 // member of the toolset. 1480 DeferLoading param.Opt[bool] `json:"defer_loading,omitzero"` 1481 // Whether this member is offered to the model. Default is per member, per the 1482 // toolset's documentation. A member whose enabled resolves false is withheld from 1483 // the served schema. 1484 Enabled param.Opt[bool] `json:"enabled,omitzero"` 1485 paramObj 1486 } 1487 1488 func (r BrowserWaitConfigParam) MarshalJSON() (data []byte, err error) { 1489 type shadow BrowserWaitConfigParam 1490 return param.MarshalObject(r, (*shadow)(&r)) 1491 } 1492 func (r *BrowserWaitConfigParam) UnmarshalJSON(data []byte) error { 1493 return apijson.UnmarshalRoot(data, r) 1494 } 1495 1496 // `zoom`'s config overrides. 1497 type BrowserZoomConfigParam struct { 1498 // Defer loading for this member. Must resolve to the same value on every enabled 1499 // member of the toolset. 1500 DeferLoading param.Opt[bool] `json:"defer_loading,omitzero"` 1501 // Whether this member is offered to the model. Default is per member, per the 1502 // toolset's documentation. A member whose enabled resolves false is withheld from 1503 // the served schema. 1504 Enabled param.Opt[bool] `json:"enabled,omitzero"` 1505 paramObj 1506 } 1507 1508 func (r BrowserZoomConfigParam) MarshalJSON() (data []byte, err error) { 1509 type shadow BrowserZoomConfigParam 1510 return param.MarshalObject(r, (*shadow)(&r)) 1511 } 1512 func (r *BrowserZoomConfigParam) UnmarshalJSON(data []byte) error { 1513 return apijson.UnmarshalRoot(data, r) 1514 } 1515 1516 func NewCacheControlEphemeralParam() CacheControlEphemeralParam { 1517 return CacheControlEphemeralParam{ 1518 Type: "ephemeral", 1519 } 1520 } 1521 1522 // This struct has a constant value, construct it with 1523 // [NewCacheControlEphemeralParam]. 1524 type CacheControlEphemeralParam struct { 1525 // The time-to-live for the cache control breakpoint. 1526 // 1527 // This may be one the following values: 1528 // 1529 // - `5m`: 5 minutes 1530 // - `1h`: 1 hour 1531 // 1532 // Defaults to `5m`. See 1533 // [prompt caching pricing](https://platform.claude.com/docs/en/build-with-claude/prompt-caching) 1534 // for details. 1535 // 1536 // Any of "5m", "1h". 1537 TTL CacheControlEphemeralTTL `json:"ttl,omitzero"` 1538 Type constant.Ephemeral `json:"type" default:"ephemeral"` 1539 paramObj 1540 } 1541 1542 func (r CacheControlEphemeralParam) MarshalJSON() (data []byte, err error) { 1543 type shadow CacheControlEphemeralParam 1544 return param.MarshalObject(r, (*shadow)(&r)) 1545 } 1546 func (r *CacheControlEphemeralParam) UnmarshalJSON(data []byte) error { 1547 return apijson.UnmarshalRoot(data, r) 1548 } 1549 1550 // The time-to-live for the cache control breakpoint. 1551 // 1552 // This may be one the following values: 1553 // 1554 // - `5m`: 5 minutes 1555 // - `1h`: 1 hour 1556 // 1557 // Defaults to `5m`. See 1558 // [prompt caching pricing](https://platform.claude.com/docs/en/build-with-claude/prompt-caching) 1559 // for details. 1560 type CacheControlEphemeralTTL string 1561 1562 const ( 1563 CacheControlEphemeralTTLTTL5m CacheControlEphemeralTTL = "5m" 1564 CacheControlEphemeralTTLTTL1h CacheControlEphemeralTTL = "1h" 1565 ) 1566 1567 type CacheCreation struct { 1568 // The number of input tokens used to create the 1 hour cache entry. 1569 Ephemeral1hInputTokens int64 `json:"ephemeral_1h_input_tokens" api:"required"` 1570 // The number of input tokens used to create the 5 minute cache entry. 1571 Ephemeral5mInputTokens int64 `json:"ephemeral_5m_input_tokens" api:"required"` 1572 // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. 1573 JSON struct { 1574 Ephemeral1hInputTokens respjson.Field 1575 Ephemeral5mInputTokens respjson.Field 1576 ExtraFields map[string]respjson.Field 1577 raw string 1578 } `json:"-"` 1579 } 1580 1581 // Returns the unmodified JSON received from the API 1582 func (r CacheCreation) RawJSON() string { return r.JSON.raw } 1583 func (r *CacheCreation) UnmarshalJSON(data []byte) error { 1584 return apijson.UnmarshalRoot(data, r) 1585 } 1586 1587 type CitationCharLocation struct { 1588 CitedText string `json:"cited_text" api:"required"` 1589 DocumentIndex int64 `json:"document_index" api:"required"` 1590 DocumentTitle string `json:"document_title" api:"required"` 1591 EndCharIndex int64 `json:"end_char_index" api:"required"` 1592 FileID string `json:"file_id" api:"required"` 1593 StartCharIndex int64 `json:"start_char_index" api:"required"` 1594 Type constant.CharLocation `json:"type" default:"char_location"` 1595 // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. 1596 JSON struct { 1597 CitedText respjson.Field 1598 DocumentIndex respjson.Field 1599 DocumentTitle respjson.Field 1600 EndCharIndex respjson.Field 1601 FileID respjson.Field 1602 StartCharIndex respjson.Field 1603 Type respjson.Field 1604 ExtraFields map[string]respjson.Field 1605 raw string 1606 } `json:"-"` 1607 } 1608 1609 // Returns the unmodified JSON received from the API 1610 func (r CitationCharLocation) RawJSON() string { return r.JSON.raw } 1611 func (r *CitationCharLocation) UnmarshalJSON(data []byte) error { 1612 return apijson.UnmarshalRoot(data, r) 1613 } 1614 1615 // The properties CitedText, DocumentIndex, DocumentTitle, EndCharIndex, 1616 // StartCharIndex, Type are required. 1617 type CitationCharLocationParam struct { 1618 DocumentTitle param.Opt[string] `json:"document_title,omitzero" api:"required"` 1619 CitedText string `json:"cited_text" api:"required"` 1620 DocumentIndex int64 `json:"document_index" api:"required"` 1621 EndCharIndex int64 `json:"end_char_index" api:"required"` 1622 StartCharIndex int64 `json:"start_char_index" api:"required"` 1623 // This field can be elided, and will marshal its zero value as "char_location". 1624 Type constant.CharLocation `json:"type" default:"char_location"` 1625 paramObj 1626 } 1627 1628 func (r CitationCharLocationParam) MarshalJSON() (data []byte, err error) { 1629 type shadow CitationCharLocationParam 1630 return param.MarshalObject(r, (*shadow)(&r)) 1631 } 1632 func (r *CitationCharLocationParam) UnmarshalJSON(data []byte) error { 1633 return apijson.UnmarshalRoot(data, r) 1634 } 1635 1636 type CitationContentBlockLocation struct { 1637 // The full text of the cited block range, concatenated. 1638 // 1639 // Always equals the contents of `content[start_block_index:end_block_index]` 1640 // joined together. The text block is the minimal citable unit; this field is never 1641 // a substring of a single block. Not counted toward output tokens, and not counted 1642 // toward input tokens when sent back in subsequent turns. 1643 CitedText string `json:"cited_text" api:"required"` 1644 DocumentIndex int64 `json:"document_index" api:"required"` 1645 DocumentTitle string `json:"document_title" api:"required"` 1646 // Exclusive 0-based end index of the cited block range in the source's `content` 1647 // array. 1648 // 1649 // Always greater than `start_block_index`; a single-block citation has 1650 // `end_block_index = start_block_index + 1`. 1651 EndBlockIndex int64 `json:"end_block_index" api:"required"` 1652 FileID string `json:"file_id" api:"required"` 1653 // 0-based index of the first cited block in the source's `content` array. 1654 StartBlockIndex int64 `json:"start_block_index" api:"required"` 1655 Type constant.ContentBlockLocation `json:"type" default:"content_block_location"` 1656 // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. 1657 JSON struct { 1658 CitedText respjson.Field 1659 DocumentIndex respjson.Field 1660 DocumentTitle respjson.Field 1661 EndBlockIndex respjson.Field 1662 FileID respjson.Field 1663 StartBlockIndex respjson.Field 1664 Type respjson.Field 1665 ExtraFields map[string]respjson.Field 1666 raw string 1667 } `json:"-"` 1668 } 1669 1670 // Returns the unmodified JSON received from the API 1671 func (r CitationContentBlockLocation) RawJSON() string { return r.JSON.raw } 1672 func (r *CitationContentBlockLocation) UnmarshalJSON(data []byte) error { 1673 return apijson.UnmarshalRoot(data, r) 1674 } 1675 1676 // The properties CitedText, DocumentIndex, DocumentTitle, EndBlockIndex, 1677 // StartBlockIndex, Type are required. 1678 type CitationContentBlockLocationParam struct { 1679 DocumentTitle param.Opt[string] `json:"document_title,omitzero" api:"required"` 1680 // The full text of the cited block range, concatenated. 1681 // 1682 // Always equals the contents of `content[start_block_index:end_block_index]` 1683 // joined together. The text block is the minimal citable unit; this field is never 1684 // a substring of a single block. Not counted toward output tokens, and not counted 1685 // toward input tokens when sent back in subsequent turns. 1686 CitedText string `json:"cited_text" api:"required"` 1687 DocumentIndex int64 `json:"document_index" api:"required"` 1688 // Exclusive 0-based end index of the cited block range in the source's `content` 1689 // array. 1690 // 1691 // Always greater than `start_block_index`; a single-block citation has 1692 // `end_block_index = start_block_index + 1`. 1693 EndBlockIndex int64 `json:"end_block_index" api:"required"` 1694 // 0-based index of the first cited block in the source's `content` array. 1695 StartBlockIndex int64 `json:"start_block_index" api:"required"` 1696 // This field can be elided, and will marshal its zero value as 1697 // "content_block_location". 1698 Type constant.ContentBlockLocation `json:"type" default:"content_block_location"` 1699 paramObj 1700 } 1701 1702 func (r CitationContentBlockLocationParam) MarshalJSON() (data []byte, err error) { 1703 type shadow CitationContentBlockLocationParam 1704 return param.MarshalObject(r, (*shadow)(&r)) 1705 } 1706 func (r *CitationContentBlockLocationParam) UnmarshalJSON(data []byte) error { 1707 return apijson.UnmarshalRoot(data, r) 1708 } 1709 1710 type CitationPageLocation struct { 1711 CitedText string `json:"cited_text" api:"required"` 1712 DocumentIndex int64 `json:"document_index" api:"required"` 1713 DocumentTitle string `json:"document_title" api:"required"` 1714 EndPageNumber int64 `json:"end_page_number" api:"required"` 1715 FileID string `json:"file_id" api:"required"` 1716 StartPageNumber int64 `json:"start_page_number" api:"required"` 1717 Type constant.PageLocation `json:"type" default:"page_location"` 1718 // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. 1719 JSON struct { 1720 CitedText respjson.Field 1721 DocumentIndex respjson.Field 1722 DocumentTitle respjson.Field 1723 EndPageNumber respjson.Field 1724 FileID respjson.Field 1725 StartPageNumber respjson.Field 1726 Type respjson.Field 1727 ExtraFields map[string]respjson.Field 1728 raw string 1729 } `json:"-"` 1730 } 1731 1732 // Returns the unmodified JSON received from the API 1733 func (r CitationPageLocation) RawJSON() string { return r.JSON.raw } 1734 func (r *CitationPageLocation) UnmarshalJSON(data []byte) error { 1735 return apijson.UnmarshalRoot(data, r) 1736 } 1737 1738 // The properties CitedText, DocumentIndex, DocumentTitle, EndPageNumber, 1739 // StartPageNumber, Type are required. 1740 type CitationPageLocationParam struct { 1741 DocumentTitle param.Opt[string] `json:"document_title,omitzero" api:"required"` 1742 CitedText string `json:"cited_text" api:"required"` 1743 DocumentIndex int64 `json:"document_index" api:"required"` 1744 EndPageNumber int64 `json:"end_page_number" api:"required"` 1745 StartPageNumber int64 `json:"start_page_number" api:"required"` 1746 // This field can be elided, and will marshal its zero value as "page_location". 1747 Type constant.PageLocation `json:"type" default:"page_location"` 1748 paramObj 1749 } 1750 1751 func (r CitationPageLocationParam) MarshalJSON() (data []byte, err error) { 1752 type shadow CitationPageLocationParam 1753 return param.MarshalObject(r, (*shadow)(&r)) 1754 } 1755 func (r *CitationPageLocationParam) UnmarshalJSON(data []byte) error { 1756 return apijson.UnmarshalRoot(data, r) 1757 } 1758 1759 // The properties CitedText, EndBlockIndex, SearchResultIndex, Source, 1760 // StartBlockIndex, Title, Type are required. 1761 type CitationSearchResultLocationParam struct { 1762 Title param.Opt[string] `json:"title,omitzero" api:"required"` 1763 // The full text of the cited block range, concatenated. 1764 // 1765 // Always equals the contents of `content[start_block_index:end_block_index]` 1766 // joined together. The text block is the minimal citable unit; this field is never 1767 // a substring of a single block. Not counted toward output tokens, and not counted 1768 // toward input tokens when sent back in subsequent turns. 1769 CitedText string `json:"cited_text" api:"required"` 1770 // Exclusive 0-based end index of the cited block range in the source's `content` 1771 // array. 1772 // 1773 // Always greater than `start_block_index`; a single-block citation has 1774 // `end_block_index = start_block_index + 1`. 1775 EndBlockIndex int64 `json:"end_block_index" api:"required"` 1776 // 0-based index of the cited search result among all `search_result` content 1777 // blocks in the request, in the order they appear across messages and tool 1778 // results. 1779 // 1780 // Counted separately from `document_index`; server-side web search results are not 1781 // included in this count. 1782 SearchResultIndex int64 `json:"search_result_index" api:"required"` 1783 Source string `json:"source" api:"required"` 1784 // 0-based index of the first cited block in the source's `content` array. 1785 StartBlockIndex int64 `json:"start_block_index" api:"required"` 1786 // This field can be elided, and will marshal its zero value as 1787 // "search_result_location". 1788 Type constant.SearchResultLocation `json:"type" default:"search_result_location"` 1789 paramObj 1790 } 1791 1792 func (r CitationSearchResultLocationParam) MarshalJSON() (data []byte, err error) { 1793 type shadow CitationSearchResultLocationParam 1794 return param.MarshalObject(r, (*shadow)(&r)) 1795 } 1796 func (r *CitationSearchResultLocationParam) UnmarshalJSON(data []byte) error { 1797 return apijson.UnmarshalRoot(data, r) 1798 } 1799 1800 // The properties CitedText, EncryptedIndex, Title, Type, URL are required. 1801 type CitationWebSearchResultLocationParam struct { 1802 Title param.Opt[string] `json:"title,omitzero" api:"required"` 1803 CitedText string `json:"cited_text" api:"required"` 1804 EncryptedIndex string `json:"encrypted_index" api:"required"` 1805 URL string `json:"url" api:"required"` 1806 // This field can be elided, and will marshal its zero value as 1807 // "web_search_result_location". 1808 Type constant.WebSearchResultLocation `json:"type" default:"web_search_result_location"` 1809 paramObj 1810 } 1811 1812 func (r CitationWebSearchResultLocationParam) MarshalJSON() (data []byte, err error) { 1813 type shadow CitationWebSearchResultLocationParam 1814 return param.MarshalObject(r, (*shadow)(&r)) 1815 } 1816 func (r *CitationWebSearchResultLocationParam) UnmarshalJSON(data []byte) error { 1817 return apijson.UnmarshalRoot(data, r) 1818 } 1819 1820 type CitationsConfig struct { 1821 Enabled bool `json:"enabled" api:"required"` 1822 // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. 1823 JSON struct { 1824 Enabled respjson.Field 1825 ExtraFields map[string]respjson.Field 1826 raw string 1827 } `json:"-"` 1828 } 1829 1830 // Returns the unmodified JSON received from the API 1831 func (r CitationsConfig) RawJSON() string { return r.JSON.raw } 1832 func (r *CitationsConfig) UnmarshalJSON(data []byte) error { 1833 return apijson.UnmarshalRoot(data, r) 1834 } 1835 1836 type CitationsConfigParam struct { 1837 Enabled param.Opt[bool] `json:"enabled,omitzero"` 1838 paramObj 1839 } 1840 1841 func (r CitationsConfigParam) MarshalJSON() (data []byte, err error) { 1842 type shadow CitationsConfigParam 1843 return param.MarshalObject(r, (*shadow)(&r)) 1844 } 1845 func (r *CitationsConfigParam) UnmarshalJSON(data []byte) error { 1846 return apijson.UnmarshalRoot(data, r) 1847 } 1848 1849 type CitationsDelta struct { 1850 Citation CitationsDeltaCitationUnion `json:"citation" api:"required"` 1851 Type constant.CitationsDelta `json:"type" default:"citations_delta"` 1852 // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. 1853 JSON struct { 1854 Citation respjson.Field 1855 Type respjson.Field 1856 ExtraFields map[string]respjson.Field 1857 raw string 1858 } `json:"-"` 1859 } 1860 1861 // Returns the unmodified JSON received from the API 1862 func (r CitationsDelta) RawJSON() string { return r.JSON.raw } 1863 func (r *CitationsDelta) UnmarshalJSON(data []byte) error { 1864 return apijson.UnmarshalRoot(data, r) 1865 } 1866 1867 // CitationsDeltaCitationUnion contains all possible properties and values from 1868 // [CitationCharLocation], [CitationPageLocation], [CitationContentBlockLocation], 1869 // [CitationsWebSearchResultLocation], [CitationsSearchResultLocation]. 1870 // 1871 // Use the [CitationsDeltaCitationUnion.AsAny] method to switch on the variant. 1872 // 1873 // Use the methods beginning with 'As' to cast the union to one of its variants. 1874 type CitationsDeltaCitationUnion struct { 1875 CitedText string `json:"cited_text"` 1876 DocumentIndex int64 `json:"document_index"` 1877 DocumentTitle string `json:"document_title"` 1878 // This field is from variant [CitationCharLocation]. 1879 EndCharIndex int64 `json:"end_char_index"` 1880 FileID string `json:"file_id"` 1881 // This field is from variant [CitationCharLocation]. 1882 StartCharIndex int64 `json:"start_char_index"` 1883 // Any of "char_location", "page_location", "content_block_location", 1884 // "web_search_result_location", "search_result_location". 1885 Type string `json:"type"` 1886 // This field is from variant [CitationPageLocation]. 1887 EndPageNumber int64 `json:"end_page_number"` 1888 // This field is from variant [CitationPageLocation]. 1889 StartPageNumber int64 `json:"start_page_number"` 1890 EndBlockIndex int64 `json:"end_block_index"` 1891 StartBlockIndex int64 `json:"start_block_index"` 1892 // This field is from variant [CitationsWebSearchResultLocation]. 1893 EncryptedIndex string `json:"encrypted_index"` 1894 Title string `json:"title"` 1895 // This field is from variant [CitationsWebSearchResultLocation]. 1896 URL string `json:"url"` 1897 // This field is from variant [CitationsSearchResultLocation]. 1898 SearchResultIndex int64 `json:"search_result_index"` 1899 // This field is from variant [CitationsSearchResultLocation]. 1900 Source string `json:"source"` 1901 JSON struct { 1902 CitedText respjson.Field 1903 DocumentIndex respjson.Field 1904 DocumentTitle respjson.Field 1905 EndCharIndex respjson.Field 1906 FileID respjson.Field 1907 StartCharIndex respjson.Field 1908 Type respjson.Field 1909 EndPageNumber respjson.Field 1910 StartPageNumber respjson.Field 1911 EndBlockIndex respjson.Field 1912 StartBlockIndex respjson.Field 1913 EncryptedIndex respjson.Field 1914 Title respjson.Field 1915 URL respjson.Field 1916 SearchResultIndex respjson.Field 1917 Source respjson.Field 1918 raw string 1919 } `json:"-"` 1920 } 1921 1922 // anyCitationsDeltaCitation is implemented by each variant of 1923 // [CitationsDeltaCitationUnion] to add type safety for the return type of 1924 // [CitationsDeltaCitationUnion.AsAny] 1925 type anyCitationsDeltaCitation interface { 1926 implCitationsDeltaCitationUnion() 1927 } 1928 1929 func (CitationCharLocation) implCitationsDeltaCitationUnion() {} 1930 func (CitationPageLocation) implCitationsDeltaCitationUnion() {} 1931 func (CitationContentBlockLocation) implCitationsDeltaCitationUnion() {} 1932 func (CitationsWebSearchResultLocation) implCitationsDeltaCitationUnion() {} 1933 func (CitationsSearchResultLocation) implCitationsDeltaCitationUnion() {} 1934 1935 // Use the following switch statement to find the correct variant 1936 // 1937 // switch variant := CitationsDeltaCitationUnion.AsAny().(type) { 1938 // case anthropic.CitationCharLocation: 1939 // case anthropic.CitationPageLocation: 1940 // case anthropic.CitationContentBlockLocation: 1941 // case anthropic.CitationsWebSearchResultLocation: 1942 // case anthropic.CitationsSearchResultLocation: 1943 // default: 1944 // fmt.Errorf("no variant present") 1945 // } 1946 func (u CitationsDeltaCitationUnion) AsAny() anyCitationsDeltaCitation { 1947 switch u.Type { 1948 case "char_location": 1949 return u.AsCharLocation() 1950 case "page_location": 1951 return u.AsPageLocation() 1952 case "content_block_location": 1953 return u.AsContentBlockLocation() 1954 case "web_search_result_location": 1955 return u.AsWebSearchResultLocation() 1956 case "search_result_location": 1957 return u.AsSearchResultLocation() 1958 } 1959 return nil 1960 } 1961 1962 func (u CitationsDeltaCitationUnion) AsCharLocation() (v CitationCharLocation) { 1963 apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) 1964 return 1965 } 1966 1967 func (u CitationsDeltaCitationUnion) AsPageLocation() (v CitationPageLocation) { 1968 apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) 1969 return 1970 } 1971 1972 func (u CitationsDeltaCitationUnion) AsContentBlockLocation() (v CitationContentBlockLocation) { 1973 apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) 1974 return 1975 } 1976 1977 func (u CitationsDeltaCitationUnion) AsWebSearchResultLocation() (v CitationsWebSearchResultLocation) { 1978 apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) 1979 return 1980 } 1981 1982 func (u CitationsDeltaCitationUnion) AsSearchResultLocation() (v CitationsSearchResultLocation) { 1983 apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) 1984 return 1985 } 1986 1987 // Returns the unmodified JSON received from the API 1988 func (u CitationsDeltaCitationUnion) RawJSON() string { return u.JSON.raw } 1989 1990 func (r *CitationsDeltaCitationUnion) UnmarshalJSON(data []byte) error { 1991 return apijson.UnmarshalRoot(data, r) 1992 } 1993 1994 type CitationsSearchResultLocation struct { 1995 // The full text of the cited block range, concatenated. 1996 // 1997 // Always equals the contents of `content[start_block_index:end_block_index]` 1998 // joined together. The text block is the minimal citable unit; this field is never 1999 // a substring of a single block. Not counted toward output tokens, and not counted 2000 // toward input tokens when sent back in subsequent turns. 2001 CitedText string `json:"cited_text" api:"required"` 2002 // Exclusive 0-based end index of the cited block range in the source's `content` 2003 // array. 2004 // 2005 // Always greater than `start_block_index`; a single-block citation has 2006 // `end_block_index = start_block_index + 1`. 2007 EndBlockIndex int64 `json:"end_block_index" api:"required"` 2008 // 0-based index of the cited search result among all `search_result` content 2009 // blocks in the request, in the order they appear across messages and tool 2010 // results. 2011 // 2012 // Counted separately from `document_index`; server-side web search results are not 2013 // included in this count. 2014 SearchResultIndex int64 `json:"search_result_index" api:"required"` 2015 Source string `json:"source" api:"required"` 2016 // 0-based index of the first cited block in the source's `content` array. 2017 StartBlockIndex int64 `json:"start_block_index" api:"required"` 2018 Title string `json:"title" api:"required"` 2019 Type constant.SearchResultLocation `json:"type" default:"search_result_location"` 2020 // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. 2021 JSON struct { 2022 CitedText respjson.Field 2023 EndBlockIndex respjson.Field 2024 SearchResultIndex respjson.Field 2025 Source respjson.Field 2026 StartBlockIndex respjson.Field 2027 Title respjson.Field 2028 Type respjson.Field 2029 ExtraFields map[string]respjson.Field 2030 raw string 2031 } `json:"-"` 2032 } 2033 2034 // Returns the unmodified JSON received from the API 2035 func (r CitationsSearchResultLocation) RawJSON() string { return r.JSON.raw } 2036 func (r *CitationsSearchResultLocation) UnmarshalJSON(data []byte) error { 2037 return apijson.UnmarshalRoot(data, r) 2038 } 2039 2040 type CitationsWebSearchResultLocation struct { 2041 CitedText string `json:"cited_text" api:"required"` 2042 EncryptedIndex string `json:"encrypted_index" api:"required"` 2043 Title string `json:"title" api:"required"` 2044 Type constant.WebSearchResultLocation `json:"type" default:"web_search_result_location"` 2045 URL string `json:"url" api:"required"` 2046 // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. 2047 JSON struct { 2048 CitedText respjson.Field 2049 EncryptedIndex respjson.Field 2050 Title respjson.Field 2051 Type respjson.Field 2052 URL respjson.Field 2053 ExtraFields map[string]respjson.Field 2054 raw string 2055 } `json:"-"` 2056 } 2057 2058 // Returns the unmodified JSON received from the API 2059 func (r CitationsWebSearchResultLocation) RawJSON() string { return r.JSON.raw } 2060 func (r *CitationsWebSearchResultLocation) UnmarshalJSON(data []byte) error { 2061 return apijson.UnmarshalRoot(data, r) 2062 } 2063 2064 type CodeExecutionOutputBlock struct { 2065 FileID string `json:"file_id" api:"required"` 2066 Type constant.CodeExecutionOutput `json:"type" default:"code_execution_output"` 2067 // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. 2068 JSON struct { 2069 FileID respjson.Field 2070 Type respjson.Field 2071 ExtraFields map[string]respjson.Field 2072 raw string 2073 } `json:"-"` 2074 } 2075 2076 // Returns the unmodified JSON received from the API 2077 func (r CodeExecutionOutputBlock) RawJSON() string { return r.JSON.raw } 2078 func (r *CodeExecutionOutputBlock) UnmarshalJSON(data []byte) error { 2079 return apijson.UnmarshalRoot(data, r) 2080 } 2081 2082 // The properties FileID, Type are required. 2083 type CodeExecutionOutputBlockParam struct { 2084 FileID string `json:"file_id" api:"required"` 2085 // This field can be elided, and will marshal its zero value as 2086 // "code_execution_output". 2087 Type constant.CodeExecutionOutput `json:"type" default:"code_execution_output"` 2088 paramObj 2089 } 2090 2091 func (r CodeExecutionOutputBlockParam) MarshalJSON() (data []byte, err error) { 2092 type shadow CodeExecutionOutputBlockParam 2093 return param.MarshalObject(r, (*shadow)(&r)) 2094 } 2095 func (r *CodeExecutionOutputBlockParam) UnmarshalJSON(data []byte) error { 2096 return apijson.UnmarshalRoot(data, r) 2097 } 2098 2099 type CodeExecutionResultBlock struct { 2100 Content []CodeExecutionOutputBlock `json:"content" api:"required"` 2101 ReturnCode int64 `json:"return_code" api:"required"` 2102 Stderr string `json:"stderr" api:"required"` 2103 Stdout string `json:"stdout" api:"required"` 2104 Type constant.CodeExecutionResult `json:"type" default:"code_execution_result"` 2105 // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. 2106 JSON struct { 2107 Content respjson.Field 2108 ReturnCode respjson.Field 2109 Stderr respjson.Field 2110 Stdout respjson.Field 2111 Type respjson.Field 2112 ExtraFields map[string]respjson.Field 2113 raw string 2114 } `json:"-"` 2115 } 2116 2117 // Returns the unmodified JSON received from the API 2118 func (r CodeExecutionResultBlock) RawJSON() string { return r.JSON.raw } 2119 func (r *CodeExecutionResultBlock) UnmarshalJSON(data []byte) error { 2120 return apijson.UnmarshalRoot(data, r) 2121 } 2122 2123 // The properties Content, ReturnCode, Stderr, Stdout, Type are required. 2124 type CodeExecutionResultBlockParam struct { 2125 Content []CodeExecutionOutputBlockParam `json:"content,omitzero" api:"required"` 2126 ReturnCode int64 `json:"return_code" api:"required"` 2127 Stderr string `json:"stderr" api:"required"` 2128 Stdout string `json:"stdout" api:"required"` 2129 // This field can be elided, and will marshal its zero value as 2130 // "code_execution_result". 2131 Type constant.CodeExecutionResult `json:"type" default:"code_execution_result"` 2132 paramObj 2133 } 2134 2135 func (r CodeExecutionResultBlockParam) MarshalJSON() (data []byte, err error) { 2136 type shadow CodeExecutionResultBlockParam 2137 return param.MarshalObject(r, (*shadow)(&r)) 2138 } 2139 func (r *CodeExecutionResultBlockParam) UnmarshalJSON(data []byte) error { 2140 return apijson.UnmarshalRoot(data, r) 2141 } 2142 2143 // The properties Name, Type are required. 2144 type CodeExecutionTool20250522Param struct { 2145 // If true, tool will not be included in initial system prompt. Only loaded when 2146 // returned via tool_reference from tool search. 2147 DeferLoading param.Opt[bool] `json:"defer_loading,omitzero"` 2148 // When true, guarantees schema validation on tool names and inputs 2149 Strict param.Opt[bool] `json:"strict,omitzero"` 2150 // Any of "direct", "code_execution_20250825", "code_execution_20260120", 2151 // "code_execution_20260521". 2152 AllowedCallers []string `json:"allowed_callers,omitzero"` 2153 // Create a cache control breakpoint at this content block. 2154 CacheControl CacheControlEphemeralParam `json:"cache_control,omitzero"` 2155 // Name of the tool. 2156 // 2157 // This is how the tool will be called by the model and in `tool_use` blocks. 2158 // 2159 // This field can be elided, and will marshal its zero value as "code_execution". 2160 Name constant.CodeExecution `json:"name" default:"code_execution"` 2161 // This field can be elided, and will marshal its zero value as 2162 // "code_execution_20250522". 2163 Type constant.CodeExecution20250522 `json:"type" default:"code_execution_20250522"` 2164 paramObj 2165 } 2166 2167 func (r CodeExecutionTool20250522Param) MarshalJSON() (data []byte, err error) { 2168 type shadow CodeExecutionTool20250522Param 2169 return param.MarshalObject(r, (*shadow)(&r)) 2170 } 2171 func (r *CodeExecutionTool20250522Param) UnmarshalJSON(data []byte) error { 2172 return apijson.UnmarshalRoot(data, r) 2173 } 2174 2175 // The properties Name, Type are required. 2176 type CodeExecutionTool20250825Param struct { 2177 // If true, tool will not be included in initial system prompt. Only loaded when 2178 // returned via tool_reference from tool search. 2179 DeferLoading param.Opt[bool] `json:"defer_loading,omitzero"` 2180 // When true, guarantees schema validation on tool names and inputs 2181 Strict param.Opt[bool] `json:"strict,omitzero"` 2182 // Any of "direct", "code_execution_20250825", "code_execution_20260120", 2183 // "code_execution_20260521". 2184 AllowedCallers []string `json:"allowed_callers,omitzero"` 2185 // Create a cache control breakpoint at this content block. 2186 CacheControl CacheControlEphemeralParam `json:"cache_control,omitzero"` 2187 // Name of the tool. 2188 // 2189 // This is how the tool will be called by the model and in `tool_use` blocks. 2190 // 2191 // This field can be elided, and will marshal its zero value as "code_execution". 2192 Name constant.CodeExecution `json:"name" default:"code_execution"` 2193 // This field can be elided, and will marshal its zero value as 2194 // "code_execution_20250825". 2195 Type constant.CodeExecution20250825 `json:"type" default:"code_execution_20250825"` 2196 paramObj 2197 } 2198 2199 func (r CodeExecutionTool20250825Param) MarshalJSON() (data []byte, err error) { 2200 type shadow CodeExecutionTool20250825Param 2201 return param.MarshalObject(r, (*shadow)(&r)) 2202 } 2203 func (r *CodeExecutionTool20250825Param) UnmarshalJSON(data []byte) error { 2204 return apijson.UnmarshalRoot(data, r) 2205 } 2206 2207 // Code execution tool with REPL state persistence (daemon mode + gVisor 2208 // checkpoint). 2209 // 2210 // The properties Name, Type are required. 2211 type CodeExecutionTool20260120Param struct { 2212 // If true, tool will not be included in initial system prompt. Only loaded when 2213 // returned via tool_reference from tool search. 2214 DeferLoading param.Opt[bool] `json:"defer_loading,omitzero"` 2215 // When true, guarantees schema validation on tool names and inputs 2216 Strict param.Opt[bool] `json:"strict,omitzero"` 2217 // Any of "direct", "code_execution_20250825", "code_execution_20260120", 2218 // "code_execution_20260521". 2219 AllowedCallers []string `json:"allowed_callers,omitzero"` 2220 // Create a cache control breakpoint at this content block. 2221 CacheControl CacheControlEphemeralParam `json:"cache_control,omitzero"` 2222 // Name of the tool. 2223 // 2224 // This is how the tool will be called by the model and in `tool_use` blocks. 2225 // 2226 // This field can be elided, and will marshal its zero value as "code_execution". 2227 Name constant.CodeExecution `json:"name" default:"code_execution"` 2228 // This field can be elided, and will marshal its zero value as 2229 // "code_execution_20260120". 2230 Type constant.CodeExecution20260120 `json:"type" default:"code_execution_20260120"` 2231 paramObj 2232 } 2233 2234 func (r CodeExecutionTool20260120Param) MarshalJSON() (data []byte, err error) { 2235 type shadow CodeExecutionTool20260120Param 2236 return param.MarshalObject(r, (*shadow)(&r)) 2237 } 2238 func (r *CodeExecutionTool20260120Param) UnmarshalJSON(data []byte) error { 2239 return apijson.UnmarshalRoot(data, r) 2240 } 2241 2242 // Code execution tool with REPL state persistence. 2243 // 2244 // The properties Name, Type are required. 2245 type CodeExecutionTool20260521Param struct { 2246 // If true, tool will not be included in initial system prompt. Only loaded when 2247 // returned via tool_reference from tool search. 2248 DeferLoading param.Opt[bool] `json:"defer_loading,omitzero"` 2249 // When true, guarantees schema validation on tool names and inputs 2250 Strict param.Opt[bool] `json:"strict,omitzero"` 2251 // Any of "direct", "code_execution_20250825", "code_execution_20260120", 2252 // "code_execution_20260521". 2253 AllowedCallers []string `json:"allowed_callers,omitzero"` 2254 // Create a cache control breakpoint at this content block. 2255 CacheControl CacheControlEphemeralParam `json:"cache_control,omitzero"` 2256 // Name of the tool. 2257 // 2258 // This is how the tool will be called by the model and in `tool_use` blocks. 2259 // 2260 // This field can be elided, and will marshal its zero value as "code_execution". 2261 Name constant.CodeExecution `json:"name" default:"code_execution"` 2262 // This field can be elided, and will marshal its zero value as 2263 // "code_execution_20260521". 2264 Type constant.CodeExecution20260521 `json:"type" default:"code_execution_20260521"` 2265 paramObj 2266 } 2267 2268 func (r CodeExecutionTool20260521Param) MarshalJSON() (data []byte, err error) { 2269 type shadow CodeExecutionTool20260521Param 2270 return param.MarshalObject(r, (*shadow)(&r)) 2271 } 2272 func (r *CodeExecutionTool20260521Param) UnmarshalJSON(data []byte) error { 2273 return apijson.UnmarshalRoot(data, r) 2274 } 2275 2276 type CodeExecutionToolResultBlock struct { 2277 // Code execution result with encrypted stdout for PFC + web_search results. 2278 Content CodeExecutionToolResultBlockContentUnion `json:"content" api:"required"` 2279 ToolUseID string `json:"tool_use_id" api:"required"` 2280 Type constant.CodeExecutionToolResult `json:"type" default:"code_execution_tool_result"` 2281 // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. 2282 JSON struct { 2283 Content respjson.Field 2284 ToolUseID respjson.Field 2285 Type respjson.Field 2286 ExtraFields map[string]respjson.Field 2287 raw string 2288 } `json:"-"` 2289 } 2290 2291 // Returns the unmodified JSON received from the API 2292 func (r CodeExecutionToolResultBlock) RawJSON() string { return r.JSON.raw } 2293 func (r *CodeExecutionToolResultBlock) UnmarshalJSON(data []byte) error { 2294 return apijson.UnmarshalRoot(data, r) 2295 } 2296 2297 // CodeExecutionToolResultBlockContentUnion contains all possible properties and 2298 // values from [CodeExecutionToolResultError], [CodeExecutionResultBlock], 2299 // [EncryptedCodeExecutionResultBlock]. 2300 // 2301 // Use the methods beginning with 'As' to cast the union to one of its variants. 2302 type CodeExecutionToolResultBlockContentUnion struct { 2303 // This field is from variant [CodeExecutionToolResultError]. 2304 ErrorCode CodeExecutionToolResultErrorCode `json:"error_code"` 2305 Type string `json:"type"` 2306 Content []CodeExecutionOutputBlock `json:"content"` 2307 ReturnCode int64 `json:"return_code"` 2308 Stderr string `json:"stderr"` 2309 // This field is from variant [CodeExecutionResultBlock]. 2310 Stdout string `json:"stdout"` 2311 // This field is from variant [EncryptedCodeExecutionResultBlock]. 2312 EncryptedStdout string `json:"encrypted_stdout"` 2313 JSON struct { 2314 ErrorCode respjson.Field 2315 Type respjson.Field 2316 Content respjson.Field 2317 ReturnCode respjson.Field 2318 Stderr respjson.Field 2319 Stdout respjson.Field 2320 EncryptedStdout respjson.Field 2321 raw string 2322 } `json:"-"` 2323 } 2324 2325 func (u CodeExecutionToolResultBlockContentUnion) AsResponseCodeExecutionToolResultError() (v CodeExecutionToolResultError) { 2326 apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) 2327 return 2328 } 2329 2330 func (u CodeExecutionToolResultBlockContentUnion) AsResponseCodeExecutionResultBlock() (v CodeExecutionResultBlock) { 2331 apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) 2332 return 2333 } 2334 2335 func (u CodeExecutionToolResultBlockContentUnion) AsResponseEncryptedCodeExecutionResultBlock() (v EncryptedCodeExecutionResultBlock) { 2336 apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) 2337 return 2338 } 2339 2340 // Returns the unmodified JSON received from the API 2341 func (u CodeExecutionToolResultBlockContentUnion) RawJSON() string { return u.JSON.raw } 2342 2343 func (r *CodeExecutionToolResultBlockContentUnion) UnmarshalJSON(data []byte) error { 2344 return apijson.UnmarshalRoot(data, r) 2345 } 2346 2347 // The properties Content, ToolUseID, Type are required. 2348 type CodeExecutionToolResultBlockParam struct { 2349 // Code execution result with encrypted stdout for PFC + web_search results. 2350 Content CodeExecutionToolResultBlockParamContentUnion `json:"content,omitzero" api:"required"` 2351 ToolUseID string `json:"tool_use_id" api:"required"` 2352 // Create a cache control breakpoint at this content block. 2353 CacheControl CacheControlEphemeralParam `json:"cache_control,omitzero"` 2354 // This field can be elided, and will marshal its zero value as 2355 // "code_execution_tool_result". 2356 Type constant.CodeExecutionToolResult `json:"type" default:"code_execution_tool_result"` 2357 paramObj 2358 } 2359 2360 func (r CodeExecutionToolResultBlockParam) MarshalJSON() (data []byte, err error) { 2361 type shadow CodeExecutionToolResultBlockParam 2362 return param.MarshalObject(r, (*shadow)(&r)) 2363 } 2364 func (r *CodeExecutionToolResultBlockParam) UnmarshalJSON(data []byte) error { 2365 return apijson.UnmarshalRoot(data, r) 2366 } 2367 2368 func CodeExecutionToolResultBlockParamContentOfRequestCodeExecutionToolResultError(errorCode CodeExecutionToolResultErrorCode) CodeExecutionToolResultBlockParamContentUnion { 2369 var variant CodeExecutionToolResultErrorParam 2370 variant.ErrorCode = errorCode 2371 return CodeExecutionToolResultBlockParamContentUnion{OfRequestCodeExecutionToolResultError: &variant} 2372 } 2373 2374 // Only one field can be non-zero. 2375 // 2376 // Use [param.IsOmitted] to confirm if a field is set. 2377 type CodeExecutionToolResultBlockParamContentUnion struct { 2378 OfRequestCodeExecutionToolResultError *CodeExecutionToolResultErrorParam `json:",omitzero,inline"` 2379 OfRequestCodeExecutionResultBlock *CodeExecutionResultBlockParam `json:",omitzero,inline"` 2380 OfRequestEncryptedCodeExecutionResultBlock *EncryptedCodeExecutionResultBlockParam `json:",omitzero,inline"` 2381 paramUnion 2382 } 2383 2384 func (u CodeExecutionToolResultBlockParamContentUnion) MarshalJSON() ([]byte, error) { 2385 return param.MarshalUnion(u, u.OfRequestCodeExecutionToolResultError, u.OfRequestCodeExecutionResultBlock, u.OfRequestEncryptedCodeExecutionResultBlock) 2386 } 2387 func (u *CodeExecutionToolResultBlockParamContentUnion) UnmarshalJSON(data []byte) error { 2388 return apijson.UnmarshalRoot(data, u) 2389 } 2390 2391 func (u *CodeExecutionToolResultBlockParamContentUnion) asAny() any { 2392 if !param.IsOmitted(u.OfRequestCodeExecutionToolResultError) { 2393 return u.OfRequestCodeExecutionToolResultError 2394 } else if !param.IsOmitted(u.OfRequestCodeExecutionResultBlock) { 2395 return u.OfRequestCodeExecutionResultBlock 2396 } else if !param.IsOmitted(u.OfRequestEncryptedCodeExecutionResultBlock) { 2397 return u.OfRequestEncryptedCodeExecutionResultBlock 2398 } 2399 return nil 2400 } 2401 2402 // Returns a pointer to the underlying variant's property, if present. 2403 func (u CodeExecutionToolResultBlockParamContentUnion) GetErrorCode() *string { 2404 if vt := u.OfRequestCodeExecutionToolResultError; vt != nil { 2405 return (*string)(&vt.ErrorCode) 2406 } 2407 return nil 2408 } 2409 2410 // Returns a pointer to the underlying variant's property, if present. 2411 func (u CodeExecutionToolResultBlockParamContentUnion) GetStdout() *string { 2412 if vt := u.OfRequestCodeExecutionResultBlock; vt != nil { 2413 return &vt.Stdout 2414 } 2415 return nil 2416 } 2417 2418 // Returns a pointer to the underlying variant's property, if present. 2419 func (u CodeExecutionToolResultBlockParamContentUnion) GetEncryptedStdout() *string { 2420 if vt := u.OfRequestEncryptedCodeExecutionResultBlock; vt != nil { 2421 return &vt.EncryptedStdout 2422 } 2423 return nil 2424 } 2425 2426 // Returns a pointer to the underlying variant's property, if present. 2427 func (u CodeExecutionToolResultBlockParamContentUnion) GetType() *string { 2428 if vt := u.OfRequestCodeExecutionToolResultError; vt != nil { 2429 return (*string)(&vt.Type) 2430 } else if vt := u.OfRequestCodeExecutionResultBlock; vt != nil { 2431 return (*string)(&vt.Type) 2432 } else if vt := u.OfRequestEncryptedCodeExecutionResultBlock; vt != nil { 2433 return (*string)(&vt.Type) 2434 } 2435 return nil 2436 } 2437 2438 // Returns a pointer to the underlying variant's property, if present. 2439 func (u CodeExecutionToolResultBlockParamContentUnion) GetReturnCode() *int64 { 2440 if vt := u.OfRequestCodeExecutionResultBlock; vt != nil { 2441 return (*int64)(&vt.ReturnCode) 2442 } else if vt := u.OfRequestEncryptedCodeExecutionResultBlock; vt != nil { 2443 return (*int64)(&vt.ReturnCode) 2444 } 2445 return nil 2446 } 2447 2448 // Returns a pointer to the underlying variant's property, if present. 2449 func (u CodeExecutionToolResultBlockParamContentUnion) GetStderr() *string { 2450 if vt := u.OfRequestCodeExecutionResultBlock; vt != nil { 2451 return (*string)(&vt.Stderr) 2452 } else if vt := u.OfRequestEncryptedCodeExecutionResultBlock; vt != nil { 2453 return (*string)(&vt.Stderr) 2454 } 2455 return nil 2456 } 2457 2458 // Returns a pointer to the underlying variant's Content property, if present. 2459 func (u CodeExecutionToolResultBlockParamContentUnion) GetContent() []CodeExecutionOutputBlockParam { 2460 if vt := u.OfRequestCodeExecutionResultBlock; vt != nil { 2461 return vt.Content 2462 } else if vt := u.OfRequestEncryptedCodeExecutionResultBlock; vt != nil { 2463 return vt.Content 2464 } 2465 return nil 2466 } 2467 2468 type CodeExecutionToolResultError struct { 2469 // Any of "invalid_tool_input", "unavailable", "too_many_requests", 2470 // "execution_time_exceeded". 2471 ErrorCode CodeExecutionToolResultErrorCode `json:"error_code" api:"required"` 2472 Type constant.CodeExecutionToolResultError `json:"type" default:"code_execution_tool_result_error"` 2473 // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. 2474 JSON struct { 2475 ErrorCode respjson.Field 2476 Type respjson.Field 2477 ExtraFields map[string]respjson.Field 2478 raw string 2479 } `json:"-"` 2480 } 2481 2482 // Returns the unmodified JSON received from the API 2483 func (r CodeExecutionToolResultError) RawJSON() string { return r.JSON.raw } 2484 func (r *CodeExecutionToolResultError) UnmarshalJSON(data []byte) error { 2485 return apijson.UnmarshalRoot(data, r) 2486 } 2487 2488 type CodeExecutionToolResultErrorCode string 2489 2490 const ( 2491 CodeExecutionToolResultErrorCodeInvalidToolInput CodeExecutionToolResultErrorCode = "invalid_tool_input" 2492 CodeExecutionToolResultErrorCodeUnavailable CodeExecutionToolResultErrorCode = "unavailable" 2493 CodeExecutionToolResultErrorCodeTooManyRequests CodeExecutionToolResultErrorCode = "too_many_requests" 2494 CodeExecutionToolResultErrorCodeExecutionTimeExceeded CodeExecutionToolResultErrorCode = "execution_time_exceeded" 2495 ) 2496 2497 // The properties ErrorCode, Type are required. 2498 type CodeExecutionToolResultErrorParam struct { 2499 // Any of "invalid_tool_input", "unavailable", "too_many_requests", 2500 // "execution_time_exceeded". 2501 ErrorCode CodeExecutionToolResultErrorCode `json:"error_code,omitzero" api:"required"` 2502 // This field can be elided, and will marshal its zero value as 2503 // "code_execution_tool_result_error". 2504 Type constant.CodeExecutionToolResultError `json:"type" default:"code_execution_tool_result_error"` 2505 paramObj 2506 } 2507 2508 func (r CodeExecutionToolResultErrorParam) MarshalJSON() (data []byte, err error) { 2509 type shadow CodeExecutionToolResultErrorParam 2510 return param.MarshalObject(r, (*shadow)(&r)) 2511 } 2512 func (r *CodeExecutionToolResultErrorParam) UnmarshalJSON(data []byte) error { 2513 return apijson.UnmarshalRoot(data, r) 2514 } 2515 2516 // `cursor_position`'s config overrides. 2517 type ComputerCursorPositionConfigParam struct { 2518 // Defer loading for this member. Must resolve to the same value on every enabled 2519 // member of the toolset. 2520 DeferLoading param.Opt[bool] `json:"defer_loading,omitzero"` 2521 // Whether this member is offered to the model. Default is per member, per the 2522 // toolset's documentation. A member whose enabled resolves false is withheld from 2523 // the served schema. 2524 Enabled param.Opt[bool] `json:"enabled,omitzero"` 2525 paramObj 2526 } 2527 2528 func (r ComputerCursorPositionConfigParam) MarshalJSON() (data []byte, err error) { 2529 type shadow ComputerCursorPositionConfigParam 2530 return param.MarshalObject(r, (*shadow)(&r)) 2531 } 2532 func (r *ComputerCursorPositionConfigParam) UnmarshalJSON(data []byte) error { 2533 return apijson.UnmarshalRoot(data, r) 2534 } 2535 2536 // `double_click`'s config overrides. 2537 type ComputerDoubleClickConfigParam struct { 2538 // Defer loading for this member. Must resolve to the same value on every enabled 2539 // member of the toolset. 2540 DeferLoading param.Opt[bool] `json:"defer_loading,omitzero"` 2541 // Whether this member is offered to the model. Default is per member, per the 2542 // toolset's documentation. A member whose enabled resolves false is withheld from 2543 // the served schema. 2544 Enabled param.Opt[bool] `json:"enabled,omitzero"` 2545 paramObj 2546 } 2547 2548 func (r ComputerDoubleClickConfigParam) MarshalJSON() (data []byte, err error) { 2549 type shadow ComputerDoubleClickConfigParam 2550 return param.MarshalObject(r, (*shadow)(&r)) 2551 } 2552 func (r *ComputerDoubleClickConfigParam) UnmarshalJSON(data []byte) error { 2553 return apijson.UnmarshalRoot(data, r) 2554 } 2555 2556 // `hold_key`'s config overrides. 2557 type ComputerHoldKeyConfigParam struct { 2558 // Defer loading for this member. Must resolve to the same value on every enabled 2559 // member of the toolset. 2560 DeferLoading param.Opt[bool] `json:"defer_loading,omitzero"` 2561 // Whether this member is offered to the model. Default is per member, per the 2562 // toolset's documentation. A member whose enabled resolves false is withheld from 2563 // the served schema. 2564 Enabled param.Opt[bool] `json:"enabled,omitzero"` 2565 paramObj 2566 } 2567 2568 func (r ComputerHoldKeyConfigParam) MarshalJSON() (data []byte, err error) { 2569 type shadow ComputerHoldKeyConfigParam 2570 return param.MarshalObject(r, (*shadow)(&r)) 2571 } 2572 func (r *ComputerHoldKeyConfigParam) UnmarshalJSON(data []byte) error { 2573 return apijson.UnmarshalRoot(data, r) 2574 } 2575 2576 // `key`'s config overrides. 2577 type ComputerKeyConfigParam struct { 2578 // Defer loading for this member. Must resolve to the same value on every enabled 2579 // member of the toolset. 2580 DeferLoading param.Opt[bool] `json:"defer_loading,omitzero"` 2581 // Whether this member is offered to the model. Default is per member, per the 2582 // toolset's documentation. A member whose enabled resolves false is withheld from 2583 // the served schema. 2584 Enabled param.Opt[bool] `json:"enabled,omitzero"` 2585 paramObj 2586 } 2587 2588 func (r ComputerKeyConfigParam) MarshalJSON() (data []byte, err error) { 2589 type shadow ComputerKeyConfigParam 2590 return param.MarshalObject(r, (*shadow)(&r)) 2591 } 2592 func (r *ComputerKeyConfigParam) UnmarshalJSON(data []byte) error { 2593 return apijson.UnmarshalRoot(data, r) 2594 } 2595 2596 // `left_click`'s config overrides. 2597 type ComputerLeftClickConfigParam struct { 2598 // Defer loading for this member. Must resolve to the same value on every enabled 2599 // member of the toolset. 2600 DeferLoading param.Opt[bool] `json:"defer_loading,omitzero"` 2601 // Whether this member is offered to the model. Default is per member, per the 2602 // toolset's documentation. A member whose enabled resolves false is withheld from 2603 // the served schema. 2604 Enabled param.Opt[bool] `json:"enabled,omitzero"` 2605 paramObj 2606 } 2607 2608 func (r ComputerLeftClickConfigParam) MarshalJSON() (data []byte, err error) { 2609 type shadow ComputerLeftClickConfigParam 2610 return param.MarshalObject(r, (*shadow)(&r)) 2611 } 2612 func (r *ComputerLeftClickConfigParam) UnmarshalJSON(data []byte) error { 2613 return apijson.UnmarshalRoot(data, r) 2614 } 2615 2616 // `left_click_drag`'s config overrides. 2617 type ComputerLeftClickDragConfigParam struct { 2618 // Defer loading for this member. Must resolve to the same value on every enabled 2619 // member of the toolset. 2620 DeferLoading param.Opt[bool] `json:"defer_loading,omitzero"` 2621 // Whether this member is offered to the model. Default is per member, per the 2622 // toolset's documentation. A member whose enabled resolves false is withheld from 2623 // the served schema. 2624 Enabled param.Opt[bool] `json:"enabled,omitzero"` 2625 paramObj 2626 } 2627 2628 func (r ComputerLeftClickDragConfigParam) MarshalJSON() (data []byte, err error) { 2629 type shadow ComputerLeftClickDragConfigParam 2630 return param.MarshalObject(r, (*shadow)(&r)) 2631 } 2632 func (r *ComputerLeftClickDragConfigParam) UnmarshalJSON(data []byte) error { 2633 return apijson.UnmarshalRoot(data, r) 2634 } 2635 2636 // `left_mouse_down`'s config overrides. 2637 type ComputerLeftMouseDownConfigParam struct { 2638 // Defer loading for this member. Must resolve to the same value on every enabled 2639 // member of the toolset. 2640 DeferLoading param.Opt[bool] `json:"defer_loading,omitzero"` 2641 // Whether this member is offered to the model. Default is per member, per the 2642 // toolset's documentation. A member whose enabled resolves false is withheld from 2643 // the served schema. 2644 Enabled param.Opt[bool] `json:"enabled,omitzero"` 2645 paramObj 2646 } 2647 2648 func (r ComputerLeftMouseDownConfigParam) MarshalJSON() (data []byte, err error) { 2649 type shadow ComputerLeftMouseDownConfigParam 2650 return param.MarshalObject(r, (*shadow)(&r)) 2651 } 2652 func (r *ComputerLeftMouseDownConfigParam) UnmarshalJSON(data []byte) error { 2653 return apijson.UnmarshalRoot(data, r) 2654 } 2655 2656 // `left_mouse_up`'s config overrides. 2657 type ComputerLeftMouseUpConfigParam struct { 2658 // Defer loading for this member. Must resolve to the same value on every enabled 2659 // member of the toolset. 2660 DeferLoading param.Opt[bool] `json:"defer_loading,omitzero"` 2661 // Whether this member is offered to the model. Default is per member, per the 2662 // toolset's documentation. A member whose enabled resolves false is withheld from 2663 // the served schema. 2664 Enabled param.Opt[bool] `json:"enabled,omitzero"` 2665 paramObj 2666 } 2667 2668 func (r ComputerLeftMouseUpConfigParam) MarshalJSON() (data []byte, err error) { 2669 type shadow ComputerLeftMouseUpConfigParam 2670 return param.MarshalObject(r, (*shadow)(&r)) 2671 } 2672 func (r *ComputerLeftMouseUpConfigParam) UnmarshalJSON(data []byte) error { 2673 return apijson.UnmarshalRoot(data, r) 2674 } 2675 2676 // `middle_click`'s config overrides. 2677 type ComputerMiddleClickConfigParam struct { 2678 // Defer loading for this member. Must resolve to the same value on every enabled 2679 // member of the toolset. 2680 DeferLoading param.Opt[bool] `json:"defer_loading,omitzero"` 2681 // Whether this member is offered to the model. Default is per member, per the 2682 // toolset's documentation. A member whose enabled resolves false is withheld from 2683 // the served schema. 2684 Enabled param.Opt[bool] `json:"enabled,omitzero"` 2685 paramObj 2686 } 2687 2688 func (r ComputerMiddleClickConfigParam) MarshalJSON() (data []byte, err error) { 2689 type shadow ComputerMiddleClickConfigParam 2690 return param.MarshalObject(r, (*shadow)(&r)) 2691 } 2692 func (r *ComputerMiddleClickConfigParam) UnmarshalJSON(data []byte) error { 2693 return apijson.UnmarshalRoot(data, r) 2694 } 2695 2696 // `mouse_move`'s config overrides. 2697 type ComputerMouseMoveConfigParam struct { 2698 // Defer loading for this member. Must resolve to the same value on every enabled 2699 // member of the toolset. 2700 DeferLoading param.Opt[bool] `json:"defer_loading,omitzero"` 2701 // Whether this member is offered to the model. Default is per member, per the 2702 // toolset's documentation. A member whose enabled resolves false is withheld from 2703 // the served schema. 2704 Enabled param.Opt[bool] `json:"enabled,omitzero"` 2705 paramObj 2706 } 2707 2708 func (r ComputerMouseMoveConfigParam) MarshalJSON() (data []byte, err error) { 2709 type shadow ComputerMouseMoveConfigParam 2710 return param.MarshalObject(r, (*shadow)(&r)) 2711 } 2712 func (r *ComputerMouseMoveConfigParam) UnmarshalJSON(data []byte) error { 2713 return apijson.UnmarshalRoot(data, r) 2714 } 2715 2716 // `right_click`'s config overrides. 2717 type ComputerRightClickConfigParam struct { 2718 // Defer loading for this member. Must resolve to the same value on every enabled 2719 // member of the toolset. 2720 DeferLoading param.Opt[bool] `json:"defer_loading,omitzero"` 2721 // Whether this member is offered to the model. Default is per member, per the 2722 // toolset's documentation. A member whose enabled resolves false is withheld from 2723 // the served schema. 2724 Enabled param.Opt[bool] `json:"enabled,omitzero"` 2725 paramObj 2726 } 2727 2728 func (r ComputerRightClickConfigParam) MarshalJSON() (data []byte, err error) { 2729 type shadow ComputerRightClickConfigParam 2730 return param.MarshalObject(r, (*shadow)(&r)) 2731 } 2732 func (r *ComputerRightClickConfigParam) UnmarshalJSON(data []byte) error { 2733 return apijson.UnmarshalRoot(data, r) 2734 } 2735 2736 // `screenshot`'s config overrides. 2737 type ComputerScreenshotConfigParam struct { 2738 // Defer loading for this member. Must resolve to the same value on every enabled 2739 // member of the toolset. 2740 DeferLoading param.Opt[bool] `json:"defer_loading,omitzero"` 2741 // Whether this member is offered to the model. Default is per member, per the 2742 // toolset's documentation. A member whose enabled resolves false is withheld from 2743 // the served schema. 2744 Enabled param.Opt[bool] `json:"enabled,omitzero"` 2745 paramObj 2746 } 2747 2748 func (r ComputerScreenshotConfigParam) MarshalJSON() (data []byte, err error) { 2749 type shadow ComputerScreenshotConfigParam 2750 return param.MarshalObject(r, (*shadow)(&r)) 2751 } 2752 func (r *ComputerScreenshotConfigParam) UnmarshalJSON(data []byte) error { 2753 return apijson.UnmarshalRoot(data, r) 2754 } 2755 2756 // `scroll`'s config overrides. 2757 type ComputerScrollConfigParam struct { 2758 // Defer loading for this member. Must resolve to the same value on every enabled 2759 // member of the toolset. 2760 DeferLoading param.Opt[bool] `json:"defer_loading,omitzero"` 2761 // Whether this member is offered to the model. Default is per member, per the 2762 // toolset's documentation. A member whose enabled resolves false is withheld from 2763 // the served schema. 2764 Enabled param.Opt[bool] `json:"enabled,omitzero"` 2765 paramObj 2766 } 2767 2768 func (r ComputerScrollConfigParam) MarshalJSON() (data []byte, err error) { 2769 type shadow ComputerScrollConfigParam 2770 return param.MarshalObject(r, (*shadow)(&r)) 2771 } 2772 func (r *ComputerScrollConfigParam) UnmarshalJSON(data []byte) error { 2773 return apijson.UnmarshalRoot(data, r) 2774 } 2775 2776 // The computer toolset: a single `tools[]` entry (carrying no `name`) that 2777 // declares the computer tool family. The model is served the family's tool with 2778 // any members disabled via `configs` removed from its schema. Every member is 2779 // enabled by default, zoom included. The single-tool options `display_number` and 2780 // `enable_zoom` are not fields of a toolset entry — it carries only `type`, 2781 // `configs`, and `cache_control`; zoom is controlled via `configs.zoom.enabled`. 2782 // 2783 // The property Type is required. 2784 type ComputerToolset20260801Param struct { 2785 // Create a cache control breakpoint at this content block. 2786 CacheControl CacheControlEphemeralParam `json:"cache_control,omitzero"` 2787 // Per-member configuration for `computer_toolset_20260801`: one optional field per 2788 // member tool, keyed by the member name — the same name the member's `tool_use` 2789 // blocks carry. Every member is an accepted key, and a member's defaults apply 2790 // wherever its key is absent. Unknown keys are rejected: the field set is this 2791 // toolset version's complete member set. 2792 Configs ComputerToolsetConfigsParam `json:"configs,omitzero"` 2793 // This field can be elided, and will marshal its zero value as 2794 // "computer_toolset_20260801". 2795 Type constant.ComputerToolset20260801 `json:"type" default:"computer_toolset_20260801"` 2796 paramObj 2797 } 2798 2799 func (r ComputerToolset20260801Param) MarshalJSON() (data []byte, err error) { 2800 type shadow ComputerToolset20260801Param 2801 return param.MarshalObject(r, (*shadow)(&r)) 2802 } 2803 func (r *ComputerToolset20260801Param) UnmarshalJSON(data []byte) error { 2804 return apijson.UnmarshalRoot(data, r) 2805 } 2806 2807 // Per-member configuration for `computer_toolset_20260801`: one optional field per 2808 // member tool, keyed by the member name — the same name the member's `tool_use` 2809 // blocks carry. Every member is an accepted key, and a member's defaults apply 2810 // wherever its key is absent. Unknown keys are rejected: the field set is this 2811 // toolset version's complete member set. 2812 type ComputerToolsetConfigsParam struct { 2813 // `cursor_position`'s config overrides. 2814 CursorPosition ComputerCursorPositionConfigParam `json:"cursor_position,omitzero"` 2815 // `double_click`'s config overrides. 2816 DoubleClick ComputerDoubleClickConfigParam `json:"double_click,omitzero"` 2817 // `hold_key`'s config overrides. 2818 HoldKey ComputerHoldKeyConfigParam `json:"hold_key,omitzero"` 2819 // `key`'s config overrides. 2820 Key ComputerKeyConfigParam `json:"key,omitzero"` 2821 // `left_click`'s config overrides. 2822 LeftClick ComputerLeftClickConfigParam `json:"left_click,omitzero"` 2823 // `left_click_drag`'s config overrides. 2824 LeftClickDrag ComputerLeftClickDragConfigParam `json:"left_click_drag,omitzero"` 2825 // `left_mouse_down`'s config overrides. 2826 LeftMouseDown ComputerLeftMouseDownConfigParam `json:"left_mouse_down,omitzero"` 2827 // `left_mouse_up`'s config overrides. 2828 LeftMouseUp ComputerLeftMouseUpConfigParam `json:"left_mouse_up,omitzero"` 2829 // `middle_click`'s config overrides. 2830 MiddleClick ComputerMiddleClickConfigParam `json:"middle_click,omitzero"` 2831 // `mouse_move`'s config overrides. 2832 MouseMove ComputerMouseMoveConfigParam `json:"mouse_move,omitzero"` 2833 // `right_click`'s config overrides. 2834 RightClick ComputerRightClickConfigParam `json:"right_click,omitzero"` 2835 // `screenshot`'s config overrides. 2836 Screenshot ComputerScreenshotConfigParam `json:"screenshot,omitzero"` 2837 // `scroll`'s config overrides. 2838 Scroll ComputerScrollConfigParam `json:"scroll,omitzero"` 2839 // `triple_click`'s config overrides. 2840 TripleClick ComputerTripleClickConfigParam `json:"triple_click,omitzero"` 2841 // `type`'s config overrides. 2842 Type ComputerTypeConfigParam `json:"type,omitzero"` 2843 // `wait`'s config overrides. 2844 Wait ComputerWaitConfigParam `json:"wait,omitzero"` 2845 // `zoom`'s config overrides. 2846 Zoom ComputerZoomConfigParam `json:"zoom,omitzero"` 2847 paramObj 2848 } 2849 2850 func (r ComputerToolsetConfigsParam) MarshalJSON() (data []byte, err error) { 2851 type shadow ComputerToolsetConfigsParam 2852 return param.MarshalObject(r, (*shadow)(&r)) 2853 } 2854 func (r *ComputerToolsetConfigsParam) UnmarshalJSON(data []byte) error { 2855 return apijson.UnmarshalRoot(data, r) 2856 } 2857 2858 // `triple_click`'s config overrides. 2859 type ComputerTripleClickConfigParam struct { 2860 // Defer loading for this member. Must resolve to the same value on every enabled 2861 // member of the toolset. 2862 DeferLoading param.Opt[bool] `json:"defer_loading,omitzero"` 2863 // Whether this member is offered to the model. Default is per member, per the 2864 // toolset's documentation. A member whose enabled resolves false is withheld from 2865 // the served schema. 2866 Enabled param.Opt[bool] `json:"enabled,omitzero"` 2867 paramObj 2868 } 2869 2870 func (r ComputerTripleClickConfigParam) MarshalJSON() (data []byte, err error) { 2871 type shadow ComputerTripleClickConfigParam 2872 return param.MarshalObject(r, (*shadow)(&r)) 2873 } 2874 func (r *ComputerTripleClickConfigParam) UnmarshalJSON(data []byte) error { 2875 return apijson.UnmarshalRoot(data, r) 2876 } 2877 2878 // `type`'s config overrides. 2879 type ComputerTypeConfigParam struct { 2880 // Defer loading for this member. Must resolve to the same value on every enabled 2881 // member of the toolset. 2882 DeferLoading param.Opt[bool] `json:"defer_loading,omitzero"` 2883 // Whether this member is offered to the model. Default is per member, per the 2884 // toolset's documentation. A member whose enabled resolves false is withheld from 2885 // the served schema. 2886 Enabled param.Opt[bool] `json:"enabled,omitzero"` 2887 paramObj 2888 } 2889 2890 func (r ComputerTypeConfigParam) MarshalJSON() (data []byte, err error) { 2891 type shadow ComputerTypeConfigParam 2892 return param.MarshalObject(r, (*shadow)(&r)) 2893 } 2894 func (r *ComputerTypeConfigParam) UnmarshalJSON(data []byte) error { 2895 return apijson.UnmarshalRoot(data, r) 2896 } 2897 2898 // `wait`'s config overrides. 2899 type ComputerWaitConfigParam struct { 2900 // Defer loading for this member. Must resolve to the same value on every enabled 2901 // member of the toolset. 2902 DeferLoading param.Opt[bool] `json:"defer_loading,omitzero"` 2903 // Whether this member is offered to the model. Default is per member, per the 2904 // toolset's documentation. A member whose enabled resolves false is withheld from 2905 // the served schema. 2906 Enabled param.Opt[bool] `json:"enabled,omitzero"` 2907 paramObj 2908 } 2909 2910 func (r ComputerWaitConfigParam) MarshalJSON() (data []byte, err error) { 2911 type shadow ComputerWaitConfigParam 2912 return param.MarshalObject(r, (*shadow)(&r)) 2913 } 2914 func (r *ComputerWaitConfigParam) UnmarshalJSON(data []byte) error { 2915 return apijson.UnmarshalRoot(data, r) 2916 } 2917 2918 // `zoom`'s config overrides. 2919 type ComputerZoomConfigParam struct { 2920 // Defer loading for this member. Must resolve to the same value on every enabled 2921 // member of the toolset. 2922 DeferLoading param.Opt[bool] `json:"defer_loading,omitzero"` 2923 // Whether this member is offered to the model. Default is per member, per the 2924 // toolset's documentation. A member whose enabled resolves false is withheld from 2925 // the served schema. 2926 Enabled param.Opt[bool] `json:"enabled,omitzero"` 2927 paramObj 2928 } 2929 2930 func (r ComputerZoomConfigParam) MarshalJSON() (data []byte, err error) { 2931 type shadow ComputerZoomConfigParam 2932 return param.MarshalObject(r, (*shadow)(&r)) 2933 } 2934 func (r *ComputerZoomConfigParam) UnmarshalJSON(data []byte) error { 2935 return apijson.UnmarshalRoot(data, r) 2936 } 2937 2938 // Information about the container used in the request (for the code execution 2939 // tool) 2940 type Container struct { 2941 // Identifier for the container used in this request 2942 ID string `json:"id" api:"required"` 2943 // The time at which the container will expire. 2944 ExpiresAt time.Time `json:"expires_at" api:"required" format:"date-time"` 2945 // Skills loaded in the container 2946 Skills []ContainerSkill `json:"skills" api:"required"` 2947 // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. 2948 JSON struct { 2949 ID respjson.Field 2950 ExpiresAt respjson.Field 2951 Skills respjson.Field 2952 ExtraFields map[string]respjson.Field 2953 raw string 2954 } `json:"-"` 2955 } 2956 2957 // Returns the unmodified JSON received from the API 2958 func (r Container) RawJSON() string { return r.JSON.raw } 2959 func (r *Container) UnmarshalJSON(data []byte) error { 2960 return apijson.UnmarshalRoot(data, r) 2961 } 2962 2963 // Container parameters with skills to be loaded. 2964 type ContainerParams struct { 2965 // Container id 2966 ID param.Opt[string] `json:"id,omitzero"` 2967 // List of skills to load in the container 2968 Skills []SkillParams `json:"skills,omitzero"` 2969 paramObj 2970 } 2971 2972 func (r ContainerParams) MarshalJSON() (data []byte, err error) { 2973 type shadow ContainerParams 2974 return param.MarshalObject(r, (*shadow)(&r)) 2975 } 2976 func (r *ContainerParams) UnmarshalJSON(data []byte) error { 2977 return apijson.UnmarshalRoot(data, r) 2978 } 2979 2980 // A skill that was loaded in a container (response model). 2981 type ContainerSkill struct { 2982 // Skill ID 2983 SkillID string `json:"skill_id" api:"required"` 2984 // Type of skill - either 'anthropic' (built-in) or 'custom' (user-defined) 2985 // 2986 // Any of "anthropic", "custom". 2987 Type ContainerSkillType `json:"type" api:"required"` 2988 // The resolved version: a skill version ID for custom skills. 2989 Version string `json:"version" api:"required"` 2990 // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. 2991 JSON struct { 2992 SkillID respjson.Field 2993 Type respjson.Field 2994 Version respjson.Field 2995 ExtraFields map[string]respjson.Field 2996 raw string 2997 } `json:"-"` 2998 } 2999 3000 // Returns the unmodified JSON received from the API 3001 func (r ContainerSkill) RawJSON() string { return r.JSON.raw } 3002 func (r *ContainerSkill) UnmarshalJSON(data []byte) error { 3003 return apijson.UnmarshalRoot(data, r) 3004 } 3005 3006 // Type of skill - either 'anthropic' (built-in) or 'custom' (user-defined) 3007 type ContainerSkillType string 3008 3009 const ( 3010 ContainerSkillTypeAnthropic ContainerSkillType = "anthropic" 3011 ContainerSkillTypeCustom ContainerSkillType = "custom" 3012 ) 3013 3014 // Response model for a file uploaded to the container. 3015 type ContainerUploadBlock struct { 3016 FileID string `json:"file_id" api:"required"` 3017 Type constant.ContainerUpload `json:"type" default:"container_upload"` 3018 // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. 3019 JSON struct { 3020 FileID respjson.Field 3021 Type respjson.Field 3022 ExtraFields map[string]respjson.Field 3023 raw string 3024 } `json:"-"` 3025 } 3026 3027 // Returns the unmodified JSON received from the API 3028 func (r ContainerUploadBlock) RawJSON() string { return r.JSON.raw } 3029 func (r *ContainerUploadBlock) UnmarshalJSON(data []byte) error { 3030 return apijson.UnmarshalRoot(data, r) 3031 } 3032 3033 // A content block that represents a file to be uploaded to the container Files 3034 // uploaded via this block will be available in the container's input directory. 3035 // 3036 // The properties FileID, Type are required. 3037 type ContainerUploadBlockParam struct { 3038 FileID string `json:"file_id" api:"required"` 3039 // Create a cache control breakpoint at this content block. 3040 CacheControl CacheControlEphemeralParam `json:"cache_control,omitzero"` 3041 // This field can be elided, and will marshal its zero value as "container_upload". 3042 Type constant.ContainerUpload `json:"type" default:"container_upload"` 3043 paramObj 3044 } 3045 3046 func (r ContainerUploadBlockParam) MarshalJSON() (data []byte, err error) { 3047 type shadow ContainerUploadBlockParam 3048 return param.MarshalObject(r, (*shadow)(&r)) 3049 } 3050 func (r *ContainerUploadBlockParam) UnmarshalJSON(data []byte) error { 3051 return apijson.UnmarshalRoot(data, r) 3052 } 3053 3054 // ContentBlockUnion contains all possible properties and values from [TextBlock], 3055 // [ThinkingBlock], [RedactedThinkingBlock], [ToolUseBlock], [ServerToolUseBlock], 3056 // [WebSearchToolResultBlock], [WebFetchToolResultBlock], 3057 // [CodeExecutionToolResultBlock], [BashCodeExecutionToolResultBlock], 3058 // [TextEditorCodeExecutionToolResultBlock], [ToolSearchToolResultBlock], 3059 // [ContainerUploadBlock]. 3060 // 3061 // Use the [ContentBlockUnion.AsAny] method to switch on the variant. 3062 // 3063 // Use the methods beginning with 'As' to cast the union to one of its variants. 3064 type ContentBlockUnion struct { 3065 // This field is from variant [TextBlock]. 3066 Citations []TextCitationUnion `json:"citations"` 3067 // This field is from variant [TextBlock]. 3068 Text string `json:"text"` 3069 // Any of "text", "thinking", "redacted_thinking", "tool_use", "server_tool_use", 3070 // "web_search_tool_result", "web_fetch_tool_result", "code_execution_tool_result", 3071 // "bash_code_execution_tool_result", "text_editor_code_execution_tool_result", 3072 // "tool_search_tool_result", "container_upload". 3073 Type string `json:"type"` 3074 // This field is from variant [ThinkingBlock]. 3075 Signature string `json:"signature"` 3076 // This field is from variant [ThinkingBlock]. 3077 Thinking string `json:"thinking"` 3078 // This field is from variant [RedactedThinkingBlock]. 3079 Data string `json:"data"` 3080 ID string `json:"id"` 3081 // necessary custom code modification 3082 Input json.RawMessage `json:"input"` 3083 Name string `json:"name"` 3084 // This field is from variant [ToolUseBlock]. 3085 ToolsetName string `json:"toolset_name"` 3086 // This field is from variant [WebSearchToolResultBlock]. 3087 Content WebSearchToolResultBlockContentUnion `json:"content"` 3088 // This field is from variant [WebSearchToolResultBlock]. 3089 ToolUseID string `json:"tool_use_id"` 3090 JSON struct { 3091 Citations respjson.Field 3092 Text respjson.Field 3093 Type respjson.Field 3094 Signature respjson.Field 3095 Thinking respjson.Field 3096 Data respjson.Field 3097 ID respjson.Field 3098 Caller respjson.Field 3099 Input respjson.Field 3100 Name respjson.Field 3101 ToolsetName respjson.Field 3102 Content respjson.Field 3103 ToolUseID respjson.Field 3104 FileID respjson.Field 3105 raw string 3106 } `json:"-"` 3107 } 3108 3109 // anyContentBlock is implemented by each variant of [ContentBlockUnion] to add 3110 // type safety for the return type of [ContentBlockUnion.AsAny] 3111 type anyContentBlock interface { 3112 implContentBlockUnion() 3113 toParamUnion() ContentBlockParamUnion 3114 } 3115 3116 func (TextBlock) implContentBlockUnion() {} 3117 func (ThinkingBlock) implContentBlockUnion() {} 3118 func (RedactedThinkingBlock) implContentBlockUnion() {} 3119 func (ToolUseBlock) implContentBlockUnion() {} 3120 func (ServerToolUseBlock) implContentBlockUnion() {} 3121 func (WebSearchToolResultBlock) implContentBlockUnion() {} 3122 func (WebFetchToolResultBlock) implContentBlockUnion() {} 3123 func (CodeExecutionToolResultBlock) implContentBlockUnion() {} 3124 func (BashCodeExecutionToolResultBlock) implContentBlockUnion() {} 3125 func (TextEditorCodeExecutionToolResultBlock) implContentBlockUnion() {} 3126 func (ToolSearchToolResultBlock) implContentBlockUnion() {} 3127 func (ContainerUploadBlock) implContentBlockUnion() {} 3128 3129 // Use the following switch statement to find the correct variant 3130 // 3131 // switch variant := ContentBlockUnion.AsAny().(type) { 3132 // case anthropic.TextBlock: 3133 // case anthropic.ThinkingBlock: 3134 // case anthropic.RedactedThinkingBlock: 3135 // case anthropic.ToolUseBlock: 3136 // case anthropic.ServerToolUseBlock: 3137 // case anthropic.WebSearchToolResultBlock: 3138 // case anthropic.WebFetchToolResultBlock: 3139 // case anthropic.CodeExecutionToolResultBlock: 3140 // case anthropic.BashCodeExecutionToolResultBlock: 3141 // case anthropic.TextEditorCodeExecutionToolResultBlock: 3142 // case anthropic.ToolSearchToolResultBlock: 3143 // case anthropic.ContainerUploadBlock: 3144 // default: 3145 // fmt.Errorf("no variant present") 3146 // } 3147 func (u ContentBlockUnion) AsAny() anyContentBlock { 3148 switch u.Type { 3149 case "text": 3150 return u.AsText() 3151 case "thinking": 3152 return u.AsThinking() 3153 case "redacted_thinking": 3154 return u.AsRedactedThinking() 3155 case "tool_use": 3156 return u.AsToolUse() 3157 case "server_tool_use": 3158 return u.AsServerToolUse() 3159 case "web_search_tool_result": 3160 return u.AsWebSearchToolResult() 3161 case "web_fetch_tool_result": 3162 return u.AsWebFetchToolResult() 3163 case "code_execution_tool_result": 3164 return u.AsCodeExecutionToolResult() 3165 case "bash_code_execution_tool_result": 3166 return u.AsBashCodeExecutionToolResult() 3167 case "text_editor_code_execution_tool_result": 3168 return u.AsTextEditorCodeExecutionToolResult() 3169 case "tool_search_tool_result": 3170 return u.AsToolSearchToolResult() 3171 case "container_upload": 3172 return u.AsContainerUpload() 3173 } 3174 return nil 3175 } 3176 3177 func (u ContentBlockUnion) AsText() (v TextBlock) { 3178 apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) 3179 return 3180 } 3181 3182 func (u ContentBlockUnion) AsThinking() (v ThinkingBlock) { 3183 apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) 3184 return 3185 } 3186 3187 func (u ContentBlockUnion) AsRedactedThinking() (v RedactedThinkingBlock) { 3188 apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) 3189 return 3190 } 3191 3192 func (u ContentBlockUnion) AsToolUse() (v ToolUseBlock) { 3193 apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) 3194 return 3195 } 3196 3197 func (u ContentBlockUnion) AsServerToolUse() (v ServerToolUseBlock) { 3198 apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) 3199 return 3200 } 3201 3202 func (u ContentBlockUnion) AsWebSearchToolResult() (v WebSearchToolResultBlock) { 3203 apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) 3204 return 3205 } 3206 3207 func (u ContentBlockUnion) AsWebFetchToolResult() (v WebFetchToolResultBlock) { 3208 apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) 3209 return 3210 } 3211 3212 func (u ContentBlockUnion) AsCodeExecutionToolResult() (v CodeExecutionToolResultBlock) { 3213 apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) 3214 return 3215 } 3216 3217 func (u ContentBlockUnion) AsBashCodeExecutionToolResult() (v BashCodeExecutionToolResultBlock) { 3218 apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) 3219 return 3220 } 3221 3222 func (u ContentBlockUnion) AsTextEditorCodeExecutionToolResult() (v TextEditorCodeExecutionToolResultBlock) { 3223 apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) 3224 return 3225 } 3226 3227 func (u ContentBlockUnion) AsToolSearchToolResult() (v ToolSearchToolResultBlock) { 3228 apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) 3229 return 3230 } 3231 3232 func (u ContentBlockUnion) AsContainerUpload() (v ContainerUploadBlock) { 3233 apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) 3234 return 3235 } 3236 3237 // Returns the unmodified JSON received from the API 3238 func (u ContentBlockUnion) RawJSON() string { return u.JSON.raw } 3239 3240 func (r *ContentBlockUnion) UnmarshalJSON(data []byte) error { 3241 return apijson.UnmarshalRoot(data, r) 3242 } 3243 3244 // ContentBlockUnionCaller is an implicit subunion of [ContentBlockUnion]. 3245 // ContentBlockUnionCaller provides convenient access to the sub-properties of the 3246 // union. 3247 // 3248 // For type safety it is recommended to directly use a variant of the 3249 // [ContentBlockUnion]. 3250 type ContentBlockUnionCaller struct { 3251 Type string `json:"type"` 3252 ToolID string `json:"tool_id"` 3253 JSON struct { 3254 Type respjson.Field 3255 ToolID respjson.Field 3256 raw string 3257 } `json:"-"` 3258 } 3259 3260 func (r *ContentBlockUnionCaller) UnmarshalJSON(data []byte) error { 3261 return apijson.UnmarshalRoot(data, r) 3262 } 3263 3264 // ContentBlockUnionContent is an implicit subunion of [ContentBlockUnion]. 3265 // ContentBlockUnionContent provides convenient access to the sub-properties of the 3266 // union. 3267 // 3268 // For type safety it is recommended to directly use a variant of the 3269 // [ContentBlockUnion]. 3270 // 3271 // If the underlying value is not a json object, one of the following properties 3272 // will be valid: OfWebSearchResultBlockArray] 3273 type ContentBlockUnionContent struct { 3274 // This field will be present if the value is a [[]WebSearchResultBlock] instead of 3275 // an object. 3276 OfWebSearchResultBlockArray []WebSearchResultBlock `json:",inline"` 3277 ErrorCode string `json:"error_code"` 3278 Type string `json:"type"` 3279 // This field is a union of [DocumentBlock], [[]CodeExecutionOutputBlock], 3280 // [[]CodeExecutionOutputBlock], [[]BashCodeExecutionOutputBlock], [string] 3281 Content ContentBlockUnionContentContent `json:"content"` 3282 // This field is from variant [WebFetchToolResultBlockContentUnion]. 3283 RetrievedAt string `json:"retrieved_at"` 3284 // This field is from variant [WebFetchToolResultBlockContentUnion]. 3285 URL string `json:"url"` 3286 ReturnCode int64 `json:"return_code"` 3287 Stderr string `json:"stderr"` 3288 Stdout string `json:"stdout"` 3289 // This field is from variant [CodeExecutionToolResultBlockContentUnion]. 3290 EncryptedStdout string `json:"encrypted_stdout"` 3291 ErrorMessage string `json:"error_message"` 3292 // This field is from variant [TextEditorCodeExecutionToolResultBlockContentUnion]. 3293 FileType TextEditorCodeExecutionViewResultBlockFileType `json:"file_type"` 3294 // This field is from variant [TextEditorCodeExecutionToolResultBlockContentUnion]. 3295 NumLines int64 `json:"num_lines"` 3296 // This field is from variant [TextEditorCodeExecutionToolResultBlockContentUnion]. 3297 StartLine int64 `json:"start_line"` 3298 // This field is from variant [TextEditorCodeExecutionToolResultBlockContentUnion]. 3299 TotalLines int64 `json:"total_lines"` 3300 // This field is from variant [TextEditorCodeExecutionToolResultBlockContentUnion]. 3301 IsFileUpdate bool `json:"is_file_update"` 3302 // This field is from variant [TextEditorCodeExecutionToolResultBlockContentUnion]. 3303 Lines []string `json:"lines"` 3304 // This field is from variant [TextEditorCodeExecutionToolResultBlockContentUnion]. 3305 NewLines int64 `json:"new_lines"` 3306 // This field is from variant [TextEditorCodeExecutionToolResultBlockContentUnion]. 3307 NewStart int64 `json:"new_start"` 3308 // This field is from variant [TextEditorCodeExecutionToolResultBlockContentUnion]. 3309 OldLines int64 `json:"old_lines"` 3310 // This field is from variant [TextEditorCodeExecutionToolResultBlockContentUnion]. 3311 OldStart int64 `json:"old_start"` 3312 // This field is from variant [ToolSearchToolResultBlockContentUnion]. 3313 ToolReferences []ToolReferenceBlock `json:"tool_references"` 3314 JSON struct { 3315 OfWebSearchResultBlockArray respjson.Field 3316 ErrorCode respjson.Field 3317 Type respjson.Field 3318 Content respjson.Field 3319 RetrievedAt respjson.Field 3320 URL respjson.Field 3321 ReturnCode respjson.Field 3322 Stderr respjson.Field 3323 Stdout respjson.Field 3324 EncryptedStdout respjson.Field 3325 ErrorMessage respjson.Field 3326 FileType respjson.Field 3327 NumLines respjson.Field 3328 StartLine respjson.Field 3329 TotalLines respjson.Field 3330 IsFileUpdate respjson.Field 3331 Lines respjson.Field 3332 NewLines respjson.Field 3333 NewStart respjson.Field 3334 OldLines respjson.Field 3335 OldStart respjson.Field 3336 ToolReferences respjson.Field 3337 raw string 3338 } `json:"-"` 3339 } 3340 3341 func (r *ContentBlockUnionContent) UnmarshalJSON(data []byte) error { 3342 return apijson.UnmarshalRoot(data, r) 3343 } 3344 3345 // ContentBlockUnionContentContent is an implicit subunion of [ContentBlockUnion]. 3346 // ContentBlockUnionContentContent provides convenient access to the sub-properties 3347 // of the union. 3348 // 3349 // For type safety it is recommended to directly use a variant of the 3350 // [ContentBlockUnion]. 3351 // 3352 // If the underlying value is not a json object, one of the following properties 3353 // will be valid: OfContent OfString] 3354 type ContentBlockUnionContentContent struct { 3355 // This field will be present if the value is a [[]CodeExecutionOutputBlock] 3356 // instead of an object. 3357 OfContent []CodeExecutionOutputBlock `json:",inline"` 3358 // This field will be present if the value is a [string] instead of an object. 3359 OfString string `json:",inline"` 3360 // This field is from variant [DocumentBlock]. 3361 Citations CitationsConfig `json:"citations"` 3362 // This field is from variant [DocumentBlock]. 3363 Source DocumentBlockSourceUnion `json:"source"` 3364 // This field is from variant [DocumentBlock]. 3365 Title string `json:"title"` 3366 // This field is from variant [DocumentBlock]. 3367 Type constant.Document `json:"type"` 3368 JSON struct { 3369 OfContent respjson.Field 3370 OfString respjson.Field 3371 Citations respjson.Field 3372 Source respjson.Field 3373 Title respjson.Field 3374 Type respjson.Field 3375 raw string 3376 } `json:"-"` 3377 } 3378 3379 func (r *ContentBlockUnionContentContent) UnmarshalJSON(data []byte) error { 3380 return apijson.UnmarshalRoot(data, r) 3381 } 3382 3383 func NewTextBlock(text string) ContentBlockParamUnion { 3384 var variant TextBlockParam 3385 variant.Text = text 3386 return ContentBlockParamUnion{OfText: &variant} 3387 } 3388 3389 func NewImageBlock[ 3390 T Base64ImageSourceParam | URLImageSourceParam | FileImageSourceParam, 3391 ](source T) ContentBlockParamUnion { 3392 var image ImageBlockParam 3393 switch v := any(source).(type) { 3394 case Base64ImageSourceParam: 3395 image.Source.OfBase64 = &v 3396 case URLImageSourceParam: 3397 image.Source.OfURL = &v 3398 case FileImageSourceParam: 3399 image.Source.OfFile = &v 3400 } 3401 return ContentBlockParamUnion{OfImage: &image} 3402 } 3403 3404 func NewImageBlockBase64(mediaType string, encodedData string) ContentBlockParamUnion { 3405 return ContentBlockParamUnion{ 3406 OfImage: &ImageBlockParam{ 3407 Source: ImageBlockParamSourceUnion{ 3408 OfBase64: &Base64ImageSourceParam{ 3409 Data: encodedData, 3410 MediaType: Base64ImageSourceMediaType(mediaType), 3411 }, 3412 }, 3413 }, 3414 } 3415 } 3416 3417 func NewDocumentBlock[ 3418 T Base64PDFSourceParam | PlainTextSourceParam | ContentBlockSourceParam | URLPDFSourceParam | FileDocumentSourceParam, 3419 ](source T) ContentBlockParamUnion { 3420 var document DocumentBlockParam 3421 switch v := any(source).(type) { 3422 case Base64PDFSourceParam: 3423 document.Source.OfBase64 = &v 3424 case PlainTextSourceParam: 3425 document.Source.OfText = &v 3426 case ContentBlockSourceParam: 3427 document.Source.OfContent = &v 3428 case URLPDFSourceParam: 3429 document.Source.OfURL = &v 3430 case FileDocumentSourceParam: 3431 document.Source.OfFile = &v 3432 } 3433 return ContentBlockParamUnion{OfDocument: &document} 3434 } 3435 3436 func NewSearchResultBlock(content []TextBlockParam, source string, title string) ContentBlockParamUnion { 3437 var searchResult SearchResultBlockParam 3438 searchResult.Content = content 3439 searchResult.Source = source 3440 searchResult.Title = title 3441 return ContentBlockParamUnion{OfSearchResult: &searchResult} 3442 } 3443 3444 func NewThinkingBlock(signature string, thinking string) ContentBlockParamUnion { 3445 var variant ThinkingBlockParam 3446 variant.Signature = signature 3447 variant.Thinking = thinking 3448 return ContentBlockParamUnion{OfThinking: &variant} 3449 } 3450 3451 func NewRedactedThinkingBlock(data string) ContentBlockParamUnion { 3452 var redactedThinking RedactedThinkingBlockParam 3453 redactedThinking.Data = data 3454 return ContentBlockParamUnion{OfRedactedThinking: &redactedThinking} 3455 } 3456 3457 func NewToolUseBlock(id string, input any, name string) ContentBlockParamUnion { 3458 var toolUse ToolUseBlockParam 3459 toolUse.ID = id 3460 toolUse.Input = input 3461 toolUse.Name = name 3462 return ContentBlockParamUnion{OfToolUse: &toolUse} 3463 } 3464 3465 func NewToolResultBlock(toolUseID string, content string, isError bool) ContentBlockParamUnion { 3466 toolBlock := ToolResultBlockParam{ 3467 ToolUseID: toolUseID, 3468 Content: []ToolResultBlockParamContentUnion{ 3469 {OfText: &TextBlockParam{Text: content}}, 3470 }, 3471 IsError: Bool(isError), 3472 } 3473 return ContentBlockParamUnion{OfToolResult: &toolBlock} 3474 } 3475 3476 func NewServerToolUseBlock(id string, input any, name ServerToolUseBlockParamName) ContentBlockParamUnion { 3477 var serverToolUse ServerToolUseBlockParam 3478 serverToolUse.ID = id 3479 serverToolUse.Input = input 3480 serverToolUse.Name = name 3481 return ContentBlockParamUnion{OfServerToolUse: &serverToolUse} 3482 } 3483 3484 func NewWebSearchToolResultBlock[ 3485 T []WebSearchResultBlockParam | WebSearchToolRequestErrorParam, 3486 ](content T, toolUseID string) ContentBlockParamUnion { 3487 var webSearchToolResult WebSearchToolResultBlockParam 3488 switch v := any(content).(type) { 3489 case []WebSearchResultBlockParam: 3490 webSearchToolResult.Content.OfWebSearchToolResultBlockItem = v 3491 case WebSearchToolRequestErrorParam: 3492 webSearchToolResult.Content.OfRequestWebSearchToolResultError = &v 3493 } 3494 webSearchToolResult.ToolUseID = toolUseID 3495 return ContentBlockParamUnion{OfWebSearchToolResult: &webSearchToolResult} 3496 } 3497 3498 func NewWebFetchToolResultBlock[ 3499 T WebFetchToolResultErrorBlockParam | WebFetchBlockParam, 3500 ](content T, toolUseID string) ContentBlockParamUnion { 3501 var webFetchToolResult WebFetchToolResultBlockParam 3502 switch v := any(content).(type) { 3503 case WebFetchToolResultErrorBlockParam: 3504 webFetchToolResult.Content.OfRequestWebFetchToolResultError = &v 3505 case WebFetchBlockParam: 3506 webFetchToolResult.Content.OfRequestWebFetchResultBlock = &v 3507 } 3508 webFetchToolResult.ToolUseID = toolUseID 3509 return ContentBlockParamUnion{OfWebFetchToolResult: &webFetchToolResult} 3510 } 3511 3512 func NewCodeExecutionToolResultBlock[ 3513 T CodeExecutionToolResultErrorParam | CodeExecutionResultBlockParam | EncryptedCodeExecutionResultBlockParam, 3514 ](content T, toolUseID string) ContentBlockParamUnion { 3515 var codeExecutionToolResult CodeExecutionToolResultBlockParam 3516 switch v := any(content).(type) { 3517 case CodeExecutionToolResultErrorParam: 3518 codeExecutionToolResult.Content.OfRequestCodeExecutionToolResultError = &v 3519 case CodeExecutionResultBlockParam: 3520 codeExecutionToolResult.Content.OfRequestCodeExecutionResultBlock = &v 3521 case EncryptedCodeExecutionResultBlockParam: 3522 codeExecutionToolResult.Content.OfRequestEncryptedCodeExecutionResultBlock = &v 3523 } 3524 codeExecutionToolResult.ToolUseID = toolUseID 3525 return ContentBlockParamUnion{OfCodeExecutionToolResult: &codeExecutionToolResult} 3526 } 3527 3528 func NewBashCodeExecutionToolResultBlock[ 3529 T BashCodeExecutionToolResultErrorParam | BashCodeExecutionResultBlockParam, 3530 ](content T, toolUseID string) ContentBlockParamUnion { 3531 var bashCodeExecutionToolResult BashCodeExecutionToolResultBlockParam 3532 switch v := any(content).(type) { 3533 case BashCodeExecutionToolResultErrorParam: 3534 bashCodeExecutionToolResult.Content.OfRequestBashCodeExecutionToolResultError = &v 3535 case BashCodeExecutionResultBlockParam: 3536 bashCodeExecutionToolResult.Content.OfRequestBashCodeExecutionResultBlock = &v 3537 } 3538 bashCodeExecutionToolResult.ToolUseID = toolUseID 3539 return ContentBlockParamUnion{OfBashCodeExecutionToolResult: &bashCodeExecutionToolResult} 3540 } 3541 3542 func NewTextEditorCodeExecutionToolResultBlock[ 3543 T TextEditorCodeExecutionToolResultErrorParam | TextEditorCodeExecutionViewResultBlockParam | TextEditorCodeExecutionCreateResultBlockParam | TextEditorCodeExecutionStrReplaceResultBlockParam, 3544 ](content T, toolUseID string) ContentBlockParamUnion { 3545 var textEditorCodeExecutionToolResult TextEditorCodeExecutionToolResultBlockParam 3546 switch v := any(content).(type) { 3547 case TextEditorCodeExecutionToolResultErrorParam: 3548 textEditorCodeExecutionToolResult.Content.OfRequestTextEditorCodeExecutionToolResultError = &v 3549 case TextEditorCodeExecutionViewResultBlockParam: 3550 textEditorCodeExecutionToolResult.Content.OfRequestTextEditorCodeExecutionViewResultBlock = &v 3551 case TextEditorCodeExecutionCreateResultBlockParam: 3552 textEditorCodeExecutionToolResult.Content.OfRequestTextEditorCodeExecutionCreateResultBlock = &v 3553 case TextEditorCodeExecutionStrReplaceResultBlockParam: 3554 textEditorCodeExecutionToolResult.Content.OfRequestTextEditorCodeExecutionStrReplaceResultBlock = &v 3555 } 3556 textEditorCodeExecutionToolResult.ToolUseID = toolUseID 3557 return ContentBlockParamUnion{OfTextEditorCodeExecutionToolResult: &textEditorCodeExecutionToolResult} 3558 } 3559 3560 func NewToolSearchToolResultBlock[ 3561 T ToolSearchToolResultErrorParam | ToolSearchToolSearchResultBlockParam, 3562 ](content T, toolUseID string) ContentBlockParamUnion { 3563 var toolSearchToolResult ToolSearchToolResultBlockParam 3564 switch v := any(content).(type) { 3565 case ToolSearchToolResultErrorParam: 3566 toolSearchToolResult.Content.OfRequestToolSearchToolResultError = &v 3567 case ToolSearchToolSearchResultBlockParam: 3568 toolSearchToolResult.Content.OfRequestToolSearchToolSearchResultBlock = &v 3569 } 3570 toolSearchToolResult.ToolUseID = toolUseID 3571 return ContentBlockParamUnion{OfToolSearchToolResult: &toolSearchToolResult} 3572 } 3573 3574 func NewContainerUploadBlock(fileID string) ContentBlockParamUnion { 3575 var containerUpload ContainerUploadBlockParam 3576 containerUpload.FileID = fileID 3577 return ContentBlockParamUnion{OfContainerUpload: &containerUpload} 3578 } 3579 3580 // Only one field can be non-zero. 3581 // 3582 // Use [param.IsOmitted] to confirm if a field is set. 3583 type ContentBlockParamUnion struct { 3584 OfText *TextBlockParam `json:",omitzero,inline"` 3585 OfImage *ImageBlockParam `json:",omitzero,inline"` 3586 OfDocument *DocumentBlockParam `json:",omitzero,inline"` 3587 OfSearchResult *SearchResultBlockParam `json:",omitzero,inline"` 3588 OfThinking *ThinkingBlockParam `json:",omitzero,inline"` 3589 OfRedactedThinking *RedactedThinkingBlockParam `json:",omitzero,inline"` 3590 OfToolUse *ToolUseBlockParam `json:",omitzero,inline"` 3591 OfToolResult *ToolResultBlockParam `json:",omitzero,inline"` 3592 OfServerToolUse *ServerToolUseBlockParam `json:",omitzero,inline"` 3593 OfWebSearchToolResult *WebSearchToolResultBlockParam `json:",omitzero,inline"` 3594 OfWebFetchToolResult *WebFetchToolResultBlockParam `json:",omitzero,inline"` 3595 OfCodeExecutionToolResult *CodeExecutionToolResultBlockParam `json:",omitzero,inline"` 3596 OfBashCodeExecutionToolResult *BashCodeExecutionToolResultBlockParam `json:",omitzero,inline"` 3597 OfTextEditorCodeExecutionToolResult *TextEditorCodeExecutionToolResultBlockParam `json:",omitzero,inline"` 3598 OfToolSearchToolResult *ToolSearchToolResultBlockParam `json:",omitzero,inline"` 3599 OfContainerUpload *ContainerUploadBlockParam `json:",omitzero,inline"` 3600 paramUnion 3601 } 3602 3603 func (u ContentBlockParamUnion) MarshalJSON() ([]byte, error) { 3604 return param.MarshalUnion(u, u.OfText, 3605 u.OfImage, 3606 u.OfDocument, 3607 u.OfSearchResult, 3608 u.OfThinking, 3609 u.OfRedactedThinking, 3610 u.OfToolUse, 3611 u.OfToolResult, 3612 u.OfServerToolUse, 3613 u.OfWebSearchToolResult, 3614 u.OfWebFetchToolResult, 3615 u.OfCodeExecutionToolResult, 3616 u.OfBashCodeExecutionToolResult, 3617 u.OfTextEditorCodeExecutionToolResult, 3618 u.OfToolSearchToolResult, 3619 u.OfContainerUpload) 3620 } 3621 func (u *ContentBlockParamUnion) UnmarshalJSON(data []byte) error { 3622 return apijson.UnmarshalRoot(data, u) 3623 } 3624 3625 func (u *ContentBlockParamUnion) asAny() any { 3626 if !param.IsOmitted(u.OfText) { 3627 return u.OfText 3628 } else if !param.IsOmitted(u.OfImage) { 3629 return u.OfImage 3630 } else if !param.IsOmitted(u.OfDocument) { 3631 return u.OfDocument 3632 } else if !param.IsOmitted(u.OfSearchResult) { 3633 return u.OfSearchResult 3634 } else if !param.IsOmitted(u.OfThinking) { 3635 return u.OfThinking 3636 } else if !param.IsOmitted(u.OfRedactedThinking) { 3637 return u.OfRedactedThinking 3638 } else if !param.IsOmitted(u.OfToolUse) { 3639 return u.OfToolUse 3640 } else if !param.IsOmitted(u.OfToolResult) { 3641 return u.OfToolResult 3642 } else if !param.IsOmitted(u.OfServerToolUse) { 3643 return u.OfServerToolUse 3644 } else if !param.IsOmitted(u.OfWebSearchToolResult) { 3645 return u.OfWebSearchToolResult 3646 } else if !param.IsOmitted(u.OfWebFetchToolResult) { 3647 return u.OfWebFetchToolResult 3648 } else if !param.IsOmitted(u.OfCodeExecutionToolResult) { 3649 return u.OfCodeExecutionToolResult 3650 } else if !param.IsOmitted(u.OfBashCodeExecutionToolResult) { 3651 return u.OfBashCodeExecutionToolResult 3652 } else if !param.IsOmitted(u.OfTextEditorCodeExecutionToolResult) { 3653 return u.OfTextEditorCodeExecutionToolResult 3654 } else if !param.IsOmitted(u.OfToolSearchToolResult) { 3655 return u.OfToolSearchToolResult 3656 } else if !param.IsOmitted(u.OfContainerUpload) { 3657 return u.OfContainerUpload 3658 } 3659 return nil 3660 } 3661 3662 // Returns a pointer to the underlying variant's property, if present. 3663 func (u ContentBlockParamUnion) GetText() *string { 3664 if vt := u.OfText; vt != nil { 3665 return &vt.Text 3666 } 3667 return nil 3668 } 3669 3670 // Returns a pointer to the underlying variant's property, if present. 3671 func (u ContentBlockParamUnion) GetTransformations() *ImageTransformationsParam { 3672 if vt := u.OfImage; vt != nil { 3673 return &vt.Transformations 3674 } 3675 return nil 3676 } 3677 3678 // Returns a pointer to the underlying variant's property, if present. 3679 func (u ContentBlockParamUnion) GetContext() *string { 3680 if vt := u.OfDocument; vt != nil && vt.Context.Valid() { 3681 return &vt.Context.Value 3682 } 3683 return nil 3684 } 3685 3686 // Returns a pointer to the underlying variant's property, if present. 3687 func (u ContentBlockParamUnion) GetSignature() *string { 3688 if vt := u.OfThinking; vt != nil { 3689 return &vt.Signature 3690 } 3691 return nil 3692 } 3693 3694 // Returns a pointer to the underlying variant's property, if present. 3695 func (u ContentBlockParamUnion) GetThinking() *string { 3696 if vt := u.OfThinking; vt != nil { 3697 return &vt.Thinking 3698 } 3699 return nil 3700 } 3701 3702 // Returns a pointer to the underlying variant's property, if present. 3703 func (u ContentBlockParamUnion) GetData() *string { 3704 if vt := u.OfRedactedThinking; vt != nil { 3705 return &vt.Data 3706 } 3707 return nil 3708 } 3709 3710 // Returns a pointer to the underlying variant's property, if present. 3711 func (u ContentBlockParamUnion) GetIsError() *bool { 3712 if vt := u.OfToolResult; vt != nil && vt.IsError.Valid() { 3713 return &vt.IsError.Value 3714 } 3715 return nil 3716 } 3717 3718 // Returns a pointer to the underlying variant's property, if present. 3719 func (u ContentBlockParamUnion) GetFileID() *string { 3720 if vt := u.OfContainerUpload; vt != nil { 3721 return &vt.FileID 3722 } 3723 return nil 3724 } 3725 3726 // Returns a pointer to the underlying variant's property, if present. 3727 func (u ContentBlockParamUnion) GetType() *string { 3728 if vt := u.OfText; vt != nil { 3729 return (*string)(&vt.Type) 3730 } else if vt := u.OfImage; vt != nil { 3731 return (*string)(&vt.Type) 3732 } else if vt := u.OfDocument; vt != nil { 3733 return (*string)(&vt.Type) 3734 } else if vt := u.OfSearchResult; vt != nil { 3735 return (*string)(&vt.Type) 3736 } else if vt := u.OfThinking; vt != nil { 3737 return (*string)(&vt.Type) 3738 } else if vt := u.OfRedactedThinking; vt != nil { 3739 return (*string)(&vt.Type) 3740 } else if vt := u.OfToolUse; vt != nil { 3741 return (*string)(&vt.Type) 3742 } else if vt := u.OfToolResult; vt != nil { 3743 return (*string)(&vt.Type) 3744 } else if vt := u.OfServerToolUse; vt != nil { 3745 return (*string)(&vt.Type) 3746 } else if vt := u.OfWebSearchToolResult; vt != nil { 3747 return (*string)(&vt.Type) 3748 } else if vt := u.OfWebFetchToolResult; vt != nil { 3749 return (*string)(&vt.Type) 3750 } else if vt := u.OfCodeExecutionToolResult; vt != nil { 3751 return (*string)(&vt.Type) 3752 } else if vt := u.OfBashCodeExecutionToolResult; vt != nil { 3753 return (*string)(&vt.Type) 3754 } else if vt := u.OfTextEditorCodeExecutionToolResult; vt != nil { 3755 return (*string)(&vt.Type) 3756 } else if vt := u.OfToolSearchToolResult; vt != nil { 3757 return (*string)(&vt.Type) 3758 } else if vt := u.OfContainerUpload; vt != nil { 3759 return (*string)(&vt.Type) 3760 } 3761 return nil 3762 } 3763 3764 // Returns a pointer to the underlying variant's property, if present. 3765 func (u ContentBlockParamUnion) GetTitle() *string { 3766 if vt := u.OfDocument; vt != nil && vt.Title.Valid() { 3767 return &vt.Title.Value 3768 } else if vt := u.OfSearchResult; vt != nil { 3769 return (*string)(&vt.Title) 3770 } 3771 return nil 3772 } 3773 3774 // Returns a pointer to the underlying variant's property, if present. 3775 func (u ContentBlockParamUnion) GetID() *string { 3776 if vt := u.OfToolUse; vt != nil { 3777 return (*string)(&vt.ID) 3778 } else if vt := u.OfServerToolUse; vt != nil { 3779 return (*string)(&vt.ID) 3780 } 3781 return nil 3782 } 3783 3784 // Returns a pointer to the underlying variant's property, if present. 3785 func (u ContentBlockParamUnion) GetName() *string { 3786 if vt := u.OfToolUse; vt != nil { 3787 return (*string)(&vt.Name) 3788 } else if vt := u.OfServerToolUse; vt != nil { 3789 return (*string)(&vt.Name) 3790 } 3791 return nil 3792 } 3793 3794 // Returns a pointer to the underlying variant's property, if present. 3795 func (u ContentBlockParamUnion) GetToolsetName() *string { 3796 if vt := u.OfToolUse; vt != nil && vt.ToolsetName.Valid() { 3797 return &vt.ToolsetName.Value 3798 } else if vt := u.OfToolResult; vt != nil && vt.ToolsetName.Valid() { 3799 return &vt.ToolsetName.Value 3800 } 3801 return nil 3802 } 3803 3804 // Returns a pointer to the underlying variant's property, if present. 3805 func (u ContentBlockParamUnion) GetToolUseID() *string { 3806 if vt := u.OfToolResult; vt != nil { 3807 return (*string)(&vt.ToolUseID) 3808 } else if vt := u.OfWebSearchToolResult; vt != nil { 3809 return (*string)(&vt.ToolUseID) 3810 } else if vt := u.OfWebFetchToolResult; vt != nil { 3811 return (*string)(&vt.ToolUseID) 3812 } else if vt := u.OfCodeExecutionToolResult; vt != nil { 3813 return (*string)(&vt.ToolUseID) 3814 } else if vt := u.OfBashCodeExecutionToolResult; vt != nil { 3815 return (*string)(&vt.ToolUseID) 3816 } else if vt := u.OfTextEditorCodeExecutionToolResult; vt != nil { 3817 return (*string)(&vt.ToolUseID) 3818 } else if vt := u.OfToolSearchToolResult; vt != nil { 3819 return (*string)(&vt.ToolUseID) 3820 } 3821 return nil 3822 } 3823 3824 // Returns a pointer to the underlying variant's CacheControl property, if present. 3825 func (u ContentBlockParamUnion) GetCacheControl() *CacheControlEphemeralParam { 3826 if vt := u.OfText; vt != nil { 3827 return &vt.CacheControl 3828 } else if vt := u.OfImage; vt != nil { 3829 return &vt.CacheControl 3830 } else if vt := u.OfDocument; vt != nil { 3831 return &vt.CacheControl 3832 } else if vt := u.OfSearchResult; vt != nil { 3833 return &vt.CacheControl 3834 } else if vt := u.OfToolUse; vt != nil { 3835 return &vt.CacheControl 3836 } else if vt := u.OfToolResult; vt != nil { 3837 return &vt.CacheControl 3838 } else if vt := u.OfServerToolUse; vt != nil { 3839 return &vt.CacheControl 3840 } else if vt := u.OfWebSearchToolResult; vt != nil { 3841 return &vt.CacheControl 3842 } else if vt := u.OfWebFetchToolResult; vt != nil { 3843 return &vt.CacheControl 3844 } else if vt := u.OfCodeExecutionToolResult; vt != nil { 3845 return &vt.CacheControl 3846 } else if vt := u.OfBashCodeExecutionToolResult; vt != nil { 3847 return &vt.CacheControl 3848 } else if vt := u.OfTextEditorCodeExecutionToolResult; vt != nil { 3849 return &vt.CacheControl 3850 } else if vt := u.OfToolSearchToolResult; vt != nil { 3851 return &vt.CacheControl 3852 } else if vt := u.OfContainerUpload; vt != nil { 3853 return &vt.CacheControl 3854 } 3855 return nil 3856 } 3857 3858 // Returns a subunion which exports methods to access subproperties 3859 // 3860 // Or use AsAny() to get the underlying value 3861 func (u ContentBlockParamUnion) GetCitations() (res contentBlockParamUnionCitations) { 3862 if vt := u.OfText; vt != nil { 3863 res.any = &vt.Citations 3864 } else if vt := u.OfDocument; vt != nil { 3865 res.any = &vt.Citations 3866 } else if vt := u.OfSearchResult; vt != nil { 3867 res.any = &vt.Citations 3868 } 3869 return 3870 } 3871 3872 // Can have the runtime types [*[]TextCitationParamUnion], [*CitationsConfigParam] 3873 type contentBlockParamUnionCitations struct{ any } 3874 3875 // Use the following switch statement to get the type of the union: 3876 // 3877 // switch u.AsAny().(type) { 3878 // case *[]anthropic.TextCitationParamUnion: 3879 // case *anthropic.CitationsConfigParam: 3880 // default: 3881 // fmt.Errorf("not present") 3882 // } 3883 func (u contentBlockParamUnionCitations) AsAny() any { return u.any } 3884 3885 // Returns a pointer to the underlying variant's property, if present. 3886 func (u contentBlockParamUnionCitations) GetEnabled() *bool { 3887 switch vt := u.any.(type) { 3888 case *CitationsConfigParam: 3889 return paramutil.AddrIfPresent(vt.Enabled) 3890 } 3891 return nil 3892 } 3893 3894 // Returns a subunion which exports methods to access subproperties 3895 // 3896 // Or use AsAny() to get the underlying value 3897 func (u ContentBlockParamUnion) GetSource() (res contentBlockParamUnionSource) { 3898 if vt := u.OfImage; vt != nil { 3899 res.any = vt.Source.asAny() 3900 } else if vt := u.OfDocument; vt != nil { 3901 res.any = vt.Source.asAny() 3902 } else if vt := u.OfSearchResult; vt != nil { 3903 res.any = &vt.Source 3904 } 3905 return 3906 } 3907 3908 // Can have the runtime types [*Base64ImageSourceParam], [*URLImageSourceParam], 3909 // [*FileImageSourceParam], [*Base64PDFSourceParam], [*PlainTextSourceParam], 3910 // [*ContentBlockSourceParam], [*URLPDFSourceParam], [*FileDocumentSourceParam], 3911 // [*string] 3912 type contentBlockParamUnionSource struct{ any } 3913 3914 // Use the following switch statement to get the type of the union: 3915 // 3916 // switch u.AsAny().(type) { 3917 // case *anthropic.Base64ImageSourceParam: 3918 // case *anthropic.URLImageSourceParam: 3919 // case *anthropic.FileImageSourceParam: 3920 // case *anthropic.Base64PDFSourceParam: 3921 // case *anthropic.PlainTextSourceParam: 3922 // case *anthropic.ContentBlockSourceParam: 3923 // case *anthropic.URLPDFSourceParam: 3924 // case *anthropic.FileDocumentSourceParam: 3925 // case *string: 3926 // default: 3927 // fmt.Errorf("not present") 3928 // } 3929 func (u contentBlockParamUnionSource) AsAny() any { return u.any } 3930 3931 // Returns a pointer to the underlying variant's property, if present. 3932 func (u contentBlockParamUnionSource) GetContent() *ContentBlockSourceContentUnionParam { 3933 switch vt := u.any.(type) { 3934 case *DocumentBlockParamSourceUnion: 3935 return vt.GetContent() 3936 } 3937 return nil 3938 } 3939 3940 // Returns a pointer to the underlying variant's property, if present. 3941 func (u contentBlockParamUnionSource) GetData() *string { 3942 switch vt := u.any.(type) { 3943 case *ImageBlockParamSourceUnion: 3944 return vt.GetData() 3945 case *DocumentBlockParamSourceUnion: 3946 return vt.GetData() 3947 } 3948 return nil 3949 } 3950 3951 // Returns a pointer to the underlying variant's property, if present. 3952 func (u contentBlockParamUnionSource) GetMediaType() *string { 3953 switch vt := u.any.(type) { 3954 case *ImageBlockParamSourceUnion: 3955 return vt.GetMediaType() 3956 case *DocumentBlockParamSourceUnion: 3957 return vt.GetMediaType() 3958 } 3959 return nil 3960 } 3961 3962 // Returns a pointer to the underlying variant's property, if present. 3963 func (u contentBlockParamUnionSource) GetType() *string { 3964 switch vt := u.any.(type) { 3965 case *ImageBlockParamSourceUnion: 3966 return vt.GetType() 3967 case *DocumentBlockParamSourceUnion: 3968 return vt.GetType() 3969 } 3970 return nil 3971 } 3972 3973 // Returns a pointer to the underlying variant's property, if present. 3974 func (u contentBlockParamUnionSource) GetURL() *string { 3975 switch vt := u.any.(type) { 3976 case *ImageBlockParamSourceUnion: 3977 return vt.GetURL() 3978 case *DocumentBlockParamSourceUnion: 3979 return vt.GetURL() 3980 } 3981 return nil 3982 } 3983 3984 // Returns a pointer to the underlying variant's property, if present. 3985 func (u contentBlockParamUnionSource) GetFileID() *string { 3986 switch vt := u.any.(type) { 3987 case *ImageBlockParamSourceUnion: 3988 return vt.GetFileID() 3989 case *DocumentBlockParamSourceUnion: 3990 return vt.GetFileID() 3991 } 3992 return nil 3993 } 3994 3995 // Returns a subunion which exports methods to access subproperties 3996 // 3997 // Or use AsAny() to get the underlying value 3998 func (u ContentBlockParamUnion) GetContent() (res contentBlockParamUnionContent) { 3999 if vt := u.OfSearchResult; vt != nil { 4000 res.any = &vt.Content 4001 } else if vt := u.OfToolResult; vt != nil { 4002 res.any = &vt.Content 4003 } else if vt := u.OfWebSearchToolResult; vt != nil { 4004 res.any = vt.Content.asAny() 4005 } else if vt := u.OfWebFetchToolResult; vt != nil { 4006 res.any = vt.Content.asAny() 4007 } else if vt := u.OfCodeExecutionToolResult; vt != nil { 4008 res.any = vt.Content.asAny() 4009 } else if vt := u.OfBashCodeExecutionToolResult; vt != nil { 4010 res.any = vt.Content.asAny() 4011 } else if vt := u.OfTextEditorCodeExecutionToolResult; vt != nil { 4012 res.any = vt.Content.asAny() 4013 } else if vt := u.OfToolSearchToolResult; vt != nil { 4014 res.any = vt.Content.asAny() 4015 } 4016 return 4017 } 4018 4019 // Can have the runtime types [_[]TextBlockParam], 4020 // [_[]ToolResultBlockParamContentUnion], [*[]WebSearchResultBlockParam], 4021 // [*WebFetchToolResultErrorBlockParam], [*WebFetchBlockParam], 4022 // [*CodeExecutionToolResultErrorParam], [*CodeExecutionResultBlockParam], 4023 // [*EncryptedCodeExecutionResultBlockParam], 4024 // [*BashCodeExecutionToolResultErrorParam], [*BashCodeExecutionResultBlockParam], 4025 // [*TextEditorCodeExecutionToolResultErrorParam], 4026 // [*TextEditorCodeExecutionViewResultBlockParam], 4027 // [*TextEditorCodeExecutionCreateResultBlockParam], 4028 // [*TextEditorCodeExecutionStrReplaceResultBlockParam], 4029 // [*ToolSearchToolResultErrorParam], [*ToolSearchToolSearchResultBlockParam] 4030 type contentBlockParamUnionContent struct{ any } 4031 4032 // Use the following switch statement to get the type of the union: 4033 // 4034 // switch u.AsAny().(type) { 4035 // case *[]anthropic.TextBlockParam: 4036 // case *[]anthropic.ToolResultBlockParamContentUnion: 4037 // case *[]anthropic.WebSearchResultBlockParam: 4038 // case *anthropic.WebFetchToolResultErrorBlockParam: 4039 // case *anthropic.WebFetchBlockParam: 4040 // case *anthropic.CodeExecutionToolResultErrorParam: 4041 // case *anthropic.CodeExecutionResultBlockParam: 4042 // case *anthropic.EncryptedCodeExecutionResultBlockParam: 4043 // case *anthropic.BashCodeExecutionToolResultErrorParam: 4044 // case *anthropic.BashCodeExecutionResultBlockParam: 4045 // case *anthropic.TextEditorCodeExecutionToolResultErrorParam: 4046 // case *anthropic.TextEditorCodeExecutionViewResultBlockParam: 4047 // case *anthropic.TextEditorCodeExecutionCreateResultBlockParam: 4048 // case *anthropic.TextEditorCodeExecutionStrReplaceResultBlockParam: 4049 // case *anthropic.ToolSearchToolResultErrorParam: 4050 // case *anthropic.ToolSearchToolSearchResultBlockParam: 4051 // default: 4052 // fmt.Errorf("not present") 4053 // } 4054 func (u contentBlockParamUnionContent) AsAny() any { return u.any } 4055 4056 // Returns a pointer to the underlying variant's property, if present. 4057 func (u contentBlockParamUnionContent) GetURL() *string { 4058 switch vt := u.any.(type) { 4059 case *WebFetchToolResultBlockParamContentUnion: 4060 return vt.GetURL() 4061 } 4062 return nil 4063 } 4064 4065 // Returns a pointer to the underlying variant's property, if present. 4066 func (u contentBlockParamUnionContent) GetRetrievedAt() *string { 4067 switch vt := u.any.(type) { 4068 case *WebFetchToolResultBlockParamContentUnion: 4069 return vt.GetRetrievedAt() 4070 } 4071 return nil 4072 } 4073 4074 // Returns a pointer to the underlying variant's property, if present. 4075 func (u contentBlockParamUnionContent) GetEncryptedStdout() *string { 4076 switch vt := u.any.(type) { 4077 case *CodeExecutionToolResultBlockParamContentUnion: 4078 return vt.GetEncryptedStdout() 4079 } 4080 return nil 4081 } 4082 4083 // Returns a pointer to the underlying variant's property, if present. 4084 func (u contentBlockParamUnionContent) GetFileType() *string { 4085 switch vt := u.any.(type) { 4086 case *TextEditorCodeExecutionToolResultBlockParamContentUnion: 4087 return vt.GetFileType() 4088 } 4089 return nil 4090 } 4091 4092 // Returns a pointer to the underlying variant's property, if present. 4093 func (u contentBlockParamUnionContent) GetNumLines() *int64 { 4094 switch vt := u.any.(type) { 4095 case *TextEditorCodeExecutionToolResultBlockParamContentUnion: 4096 return vt.GetNumLines() 4097 } 4098 return nil 4099 } 4100 4101 // Returns a pointer to the underlying variant's property, if present. 4102 func (u contentBlockParamUnionContent) GetStartLine() *int64 { 4103 switch vt := u.any.(type) { 4104 case *TextEditorCodeExecutionToolResultBlockParamContentUnion: 4105 return vt.GetStartLine() 4106 } 4107 return nil 4108 } 4109 4110 // Returns a pointer to the underlying variant's property, if present. 4111 func (u contentBlockParamUnionContent) GetTotalLines() *int64 { 4112 switch vt := u.any.(type) { 4113 case *TextEditorCodeExecutionToolResultBlockParamContentUnion: 4114 return vt.GetTotalLines() 4115 } 4116 return nil 4117 } 4118 4119 // Returns a pointer to the underlying variant's property, if present. 4120 func (u contentBlockParamUnionContent) GetIsFileUpdate() *bool { 4121 switch vt := u.any.(type) { 4122 case *TextEditorCodeExecutionToolResultBlockParamContentUnion: 4123 return vt.GetIsFileUpdate() 4124 } 4125 return nil 4126 } 4127 4128 // Returns a pointer to the underlying variant's property, if present. 4129 func (u contentBlockParamUnionContent) GetLines() []string { 4130 switch vt := u.any.(type) { 4131 case *TextEditorCodeExecutionToolResultBlockParamContentUnion: 4132 return vt.GetLines() 4133 } 4134 return nil 4135 } 4136 4137 // Returns a pointer to the underlying variant's property, if present. 4138 func (u contentBlockParamUnionContent) GetNewLines() *int64 { 4139 switch vt := u.any.(type) { 4140 case *TextEditorCodeExecutionToolResultBlockParamContentUnion: 4141 return vt.GetNewLines() 4142 } 4143 return nil 4144 } 4145 4146 // Returns a pointer to the underlying variant's property, if present. 4147 func (u contentBlockParamUnionContent) GetNewStart() *int64 { 4148 switch vt := u.any.(type) { 4149 case *TextEditorCodeExecutionToolResultBlockParamContentUnion: 4150 return vt.GetNewStart() 4151 } 4152 return nil 4153 } 4154 4155 // Returns a pointer to the underlying variant's property, if present. 4156 func (u contentBlockParamUnionContent) GetOldLines() *int64 { 4157 switch vt := u.any.(type) { 4158 case *TextEditorCodeExecutionToolResultBlockParamContentUnion: 4159 return vt.GetOldLines() 4160 } 4161 return nil 4162 } 4163 4164 // Returns a pointer to the underlying variant's property, if present. 4165 func (u contentBlockParamUnionContent) GetOldStart() *int64 { 4166 switch vt := u.any.(type) { 4167 case *TextEditorCodeExecutionToolResultBlockParamContentUnion: 4168 return vt.GetOldStart() 4169 } 4170 return nil 4171 } 4172 4173 // Returns a pointer to the underlying variant's property, if present. 4174 func (u contentBlockParamUnionContent) GetToolReferences() []ToolReferenceBlockParam { 4175 switch vt := u.any.(type) { 4176 case *ToolSearchToolResultBlockParamContentUnion: 4177 return vt.GetToolReferences() 4178 } 4179 return nil 4180 } 4181 4182 // Returns a pointer to the underlying variant's property, if present. 4183 func (u contentBlockParamUnionContent) GetErrorCode() *string { 4184 switch vt := u.any.(type) { 4185 case *WebSearchToolResultBlockParamContentUnion: 4186 if vt.OfRequestWebSearchToolResultError != nil { 4187 return (*string)(&vt.OfRequestWebSearchToolResultError.ErrorCode) 4188 } 4189 case *WebFetchToolResultBlockParamContentUnion: 4190 return vt.GetErrorCode() 4191 case *CodeExecutionToolResultBlockParamContentUnion: 4192 return vt.GetErrorCode() 4193 case *BashCodeExecutionToolResultBlockParamContentUnion: 4194 return vt.GetErrorCode() 4195 case *TextEditorCodeExecutionToolResultBlockParamContentUnion: 4196 return vt.GetErrorCode() 4197 case *ToolSearchToolResultBlockParamContentUnion: 4198 return vt.GetErrorCode() 4199 } 4200 return nil 4201 } 4202 4203 // Returns a pointer to the underlying variant's property, if present. 4204 func (u contentBlockParamUnionContent) GetType() *string { 4205 switch vt := u.any.(type) { 4206 case *WebSearchToolResultBlockParamContentUnion: 4207 if vt.OfRequestWebSearchToolResultError != nil { 4208 return (*string)(&vt.OfRequestWebSearchToolResultError.Type) 4209 } 4210 case *WebFetchToolResultBlockParamContentUnion: 4211 return vt.GetType() 4212 case *CodeExecutionToolResultBlockParamContentUnion: 4213 return vt.GetType() 4214 case *BashCodeExecutionToolResultBlockParamContentUnion: 4215 return vt.GetType() 4216 case *TextEditorCodeExecutionToolResultBlockParamContentUnion: 4217 return vt.GetType() 4218 case *ToolSearchToolResultBlockParamContentUnion: 4219 return vt.GetType() 4220 } 4221 return nil 4222 } 4223 4224 // Returns a pointer to the underlying variant's property, if present. 4225 func (u contentBlockParamUnionContent) GetReturnCode() *int64 { 4226 switch vt := u.any.(type) { 4227 case *CodeExecutionToolResultBlockParamContentUnion: 4228 return vt.GetReturnCode() 4229 case *BashCodeExecutionToolResultBlockParamContentUnion: 4230 return vt.GetReturnCode() 4231 } 4232 return nil 4233 } 4234 4235 // Returns a pointer to the underlying variant's property, if present. 4236 func (u contentBlockParamUnionContent) GetStderr() *string { 4237 switch vt := u.any.(type) { 4238 case *CodeExecutionToolResultBlockParamContentUnion: 4239 return vt.GetStderr() 4240 case *BashCodeExecutionToolResultBlockParamContentUnion: 4241 return vt.GetStderr() 4242 } 4243 return nil 4244 } 4245 4246 // Returns a pointer to the underlying variant's property, if present. 4247 func (u contentBlockParamUnionContent) GetStdout() *string { 4248 switch vt := u.any.(type) { 4249 case *CodeExecutionToolResultBlockParamContentUnion: 4250 return vt.GetStdout() 4251 case *BashCodeExecutionToolResultBlockParamContentUnion: 4252 return vt.GetStdout() 4253 } 4254 return nil 4255 } 4256 4257 // Returns a pointer to the underlying variant's property, if present. 4258 func (u contentBlockParamUnionContent) GetErrorMessage() *string { 4259 switch vt := u.any.(type) { 4260 case *TextEditorCodeExecutionToolResultBlockParamContentUnion: 4261 return vt.GetErrorMessage() 4262 case *ToolSearchToolResultBlockParamContentUnion: 4263 return vt.GetErrorMessage() 4264 } 4265 return nil 4266 } 4267 4268 // Returns a subunion which exports methods to access subproperties 4269 // 4270 // Or use AsAny() to get the underlying value 4271 func (u contentBlockParamUnionContent) GetContent() (res contentBlockParamUnionContentContent) { 4272 switch vt := u.any.(type) { 4273 case *WebFetchToolResultBlockParamContentUnion: 4274 res.any = vt.GetContent() 4275 case *CodeExecutionToolResultBlockParamContentUnion: 4276 res.any = vt.GetContent() 4277 case *BashCodeExecutionToolResultBlockParamContentUnion: 4278 res.any = vt.GetContent() 4279 case *TextEditorCodeExecutionToolResultBlockParamContentUnion: 4280 res.any = vt.GetContent() 4281 } 4282 return res 4283 } 4284 4285 // Can have the runtime types [*DocumentBlockParam], 4286 // [_[]CodeExecutionOutputBlockParam], [_[]BashCodeExecutionOutputBlockParam], 4287 // [*string] 4288 type contentBlockParamUnionContentContent struct{ any } 4289 4290 // Use the following switch statement to get the type of the union: 4291 // 4292 // switch u.AsAny().(type) { 4293 // case *anthropic.DocumentBlockParam: 4294 // case *[]anthropic.CodeExecutionOutputBlockParam: 4295 // case *[]anthropic.BashCodeExecutionOutputBlockParam: 4296 // case *string: 4297 // default: 4298 // fmt.Errorf("not present") 4299 // } 4300 func (u contentBlockParamUnionContentContent) AsAny() any { return u.any } 4301 4302 // Returns a pointer to the underlying variant's Input property, if present. 4303 func (u ContentBlockParamUnion) GetInput() *any { 4304 if vt := u.OfToolUse; vt != nil { 4305 return &vt.Input 4306 } else if vt := u.OfServerToolUse; vt != nil { 4307 return &vt.Input 4308 } 4309 return nil 4310 } 4311 4312 // Returns a subunion which exports methods to access subproperties 4313 // 4314 // Or use AsAny() to get the underlying value 4315 func (u ContentBlockParamUnion) GetCaller() (res contentBlockParamUnionCaller) { 4316 if vt := u.OfToolUse; vt != nil { 4317 res.any = vt.Caller.asAny() 4318 } else if vt := u.OfServerToolUse; vt != nil { 4319 res.any = vt.Caller.asAny() 4320 } else if vt := u.OfWebSearchToolResult; vt != nil { 4321 res.any = vt.Caller.asAny() 4322 } else if vt := u.OfWebFetchToolResult; vt != nil { 4323 res.any = vt.Caller.asAny() 4324 } 4325 return 4326 } 4327 4328 // Can have the runtime types [*DirectCallerParam], [*ServerToolCallerParam], 4329 // [*ServerToolCaller20260120Param] 4330 type contentBlockParamUnionCaller struct{ any } 4331 4332 // Use the following switch statement to get the type of the union: 4333 // 4334 // switch u.AsAny().(type) { 4335 // case *anthropic.DirectCallerParam: 4336 // case *anthropic.ServerToolCallerParam: 4337 // case *anthropic.ServerToolCaller20260120Param: 4338 // default: 4339 // fmt.Errorf("not present") 4340 // } 4341 func (u contentBlockParamUnionCaller) AsAny() any { return u.any } 4342 4343 // Returns a pointer to the underlying variant's property, if present. 4344 func (u contentBlockParamUnionCaller) GetType() *string { 4345 switch vt := u.any.(type) { 4346 case *ToolUseBlockParamCallerUnion: 4347 return vt.GetType() 4348 case *ServerToolUseBlockParamCallerUnion: 4349 return vt.GetType() 4350 case *WebSearchToolResultBlockParamCallerUnion: 4351 return vt.GetType() 4352 case *WebFetchToolResultBlockParamCallerUnion: 4353 return vt.GetType() 4354 } 4355 return nil 4356 } 4357 4358 // Returns a pointer to the underlying variant's property, if present. 4359 func (u contentBlockParamUnionCaller) GetToolID() *string { 4360 switch vt := u.any.(type) { 4361 case *ToolUseBlockParamCallerUnion: 4362 return vt.GetToolID() 4363 case *ServerToolUseBlockParamCallerUnion: 4364 return vt.GetToolID() 4365 case *WebSearchToolResultBlockParamCallerUnion: 4366 return vt.GetToolID() 4367 case *WebFetchToolResultBlockParamCallerUnion: 4368 return vt.GetToolID() 4369 } 4370 return nil 4371 } 4372 4373 func init() { 4374 apijson.RegisterCustomDecoder[[]ContentBlockParamUnion](func(node gjson.Result, value reflect.Value, defaultDecoder func(gjson.Result, reflect.Value) error) error { 4375 if node.Type == gjson.String { 4376 textBlock := TextBlockParam{Text: node.String(), Type: "text"} 4377 contentUnion := ContentBlockParamUnion{OfText: &textBlock} 4378 arrayValue := reflect.MakeSlice(value.Type(), 1, 1) 4379 arrayValue.Index(0).Set(reflect.ValueOf(contentUnion)) 4380 value.Set(arrayValue) 4381 return nil 4382 } 4383 return defaultDecoder(node, value) 4384 }) 4385 } 4386 4387 func init() { 4388 apijson.RegisterCustomDecoder[[]ToolResultBlockParamContentUnion](func(node gjson.Result, value reflect.Value, defaultDecoder func(gjson.Result, reflect.Value) error) error { 4389 if node.Type == gjson.String { 4390 textBlock := TextBlockParam{Text: node.String(), Type: "text"} 4391 contentUnion := ToolResultBlockParamContentUnion{OfText: &textBlock} 4392 arrayValue := reflect.MakeSlice(value.Type(), 1, 1) 4393 arrayValue.Index(0).Set(reflect.ValueOf(contentUnion)) 4394 value.Set(arrayValue) 4395 return nil 4396 } 4397 return defaultDecoder(node, value) 4398 }) 4399 } 4400 4401 func init() { 4402 apijson.RegisterUnion[ContentBlockParamUnion]( 4403 "type", 4404 apijson.Discriminator[TextBlockParam]("text"), 4405 apijson.Discriminator[ImageBlockParam]("image"), 4406 apijson.Discriminator[DocumentBlockParam]("document"), 4407 apijson.Discriminator[SearchResultBlockParam]("search_result"), 4408 apijson.Discriminator[ThinkingBlockParam]("thinking"), 4409 apijson.Discriminator[RedactedThinkingBlockParam]("redacted_thinking"), 4410 apijson.Discriminator[ToolUseBlockParam]("tool_use"), 4411 apijson.Discriminator[ToolResultBlockParam]("tool_result"), 4412 apijson.Discriminator[ServerToolUseBlockParam]("server_tool_use"), 4413 apijson.Discriminator[WebSearchToolResultBlockParam]("web_search_tool_result"), 4414 apijson.Discriminator[WebFetchToolResultBlockParam]("web_fetch_tool_result"), 4415 apijson.Discriminator[CodeExecutionToolResultBlockParam]("code_execution_tool_result"), 4416 apijson.Discriminator[BashCodeExecutionToolResultBlockParam]("bash_code_execution_tool_result"), 4417 apijson.Discriminator[TextEditorCodeExecutionToolResultBlockParam]("text_editor_code_execution_tool_result"), 4418 apijson.Discriminator[ToolSearchToolResultBlockParam]("tool_search_tool_result"), 4419 apijson.Discriminator[ContainerUploadBlockParam]("container_upload"), 4420 ) 4421 } 4422 4423 // The properties Content, Type are required. 4424 type ContentBlockSourceParam struct { 4425 Content ContentBlockSourceContentUnionParam `json:"content,omitzero" api:"required"` 4426 // This field can be elided, and will marshal its zero value as "content". 4427 Type constant.Content `json:"type" default:"content"` 4428 paramObj 4429 } 4430 4431 func (r ContentBlockSourceParam) MarshalJSON() (data []byte, err error) { 4432 type shadow ContentBlockSourceParam 4433 return param.MarshalObject(r, (*shadow)(&r)) 4434 } 4435 func (r *ContentBlockSourceParam) UnmarshalJSON(data []byte) error { 4436 return apijson.UnmarshalRoot(data, r) 4437 } 4438 4439 // Only one field can be non-zero. 4440 // 4441 // Use [param.IsOmitted] to confirm if a field is set. 4442 type ContentBlockSourceContentUnionParam struct { 4443 OfString param.Opt[string] `json:",omitzero,inline"` 4444 OfContentBlockSourceContent []ContentBlockSourceContentItemUnionParam `json:",omitzero,inline"` 4445 paramUnion 4446 } 4447 4448 func (u ContentBlockSourceContentUnionParam) MarshalJSON() ([]byte, error) { 4449 return param.MarshalUnion(u, u.OfString, u.OfContentBlockSourceContent) 4450 } 4451 func (u *ContentBlockSourceContentUnionParam) UnmarshalJSON(data []byte) error { 4452 return apijson.UnmarshalRoot(data, u) 4453 } 4454 4455 func (u *ContentBlockSourceContentUnionParam) asAny() any { 4456 if !param.IsOmitted(u.OfString) { 4457 return &u.OfString.Value 4458 } else if !param.IsOmitted(u.OfContentBlockSourceContent) { 4459 return &u.OfContentBlockSourceContent 4460 } 4461 return nil 4462 } 4463 4464 func ContentBlockSourceContentItemParamOfText(text string) ContentBlockSourceContentItemUnionParam { 4465 var variant TextBlockParam 4466 variant.Text = text 4467 return ContentBlockSourceContentItemUnionParam{OfText: &variant} 4468 } 4469 4470 func ContentBlockSourceContentItemParamOfImage[ 4471 T Base64ImageSourceParam | URLImageSourceParam | FileImageSourceParam, 4472 ](source T) ContentBlockSourceContentItemUnionParam { 4473 var image ImageBlockParam 4474 switch v := any(source).(type) { 4475 case Base64ImageSourceParam: 4476 image.Source.OfBase64 = &v 4477 case URLImageSourceParam: 4478 image.Source.OfURL = &v 4479 case FileImageSourceParam: 4480 image.Source.OfFile = &v 4481 } 4482 return ContentBlockSourceContentItemUnionParam{OfImage: &image} 4483 } 4484 4485 // Only one field can be non-zero. 4486 // 4487 // Use [param.IsOmitted] to confirm if a field is set. 4488 type ContentBlockSourceContentItemUnionParam struct { 4489 OfText *TextBlockParam `json:",omitzero,inline"` 4490 OfImage *ImageBlockParam `json:",omitzero,inline"` 4491 paramUnion 4492 } 4493 4494 func (u ContentBlockSourceContentItemUnionParam) MarshalJSON() ([]byte, error) { 4495 return param.MarshalUnion(u, u.OfText, u.OfImage) 4496 } 4497 func (u *ContentBlockSourceContentItemUnionParam) UnmarshalJSON(data []byte) error { 4498 return apijson.UnmarshalRoot(data, u) 4499 } 4500 4501 func (u *ContentBlockSourceContentItemUnionParam) asAny() any { 4502 if !param.IsOmitted(u.OfText) { 4503 return u.OfText 4504 } else if !param.IsOmitted(u.OfImage) { 4505 return u.OfImage 4506 } 4507 return nil 4508 } 4509 4510 // Returns a pointer to the underlying variant's property, if present. 4511 func (u ContentBlockSourceContentItemUnionParam) GetText() *string { 4512 if vt := u.OfText; vt != nil { 4513 return &vt.Text 4514 } 4515 return nil 4516 } 4517 4518 // Returns a pointer to the underlying variant's property, if present. 4519 func (u ContentBlockSourceContentItemUnionParam) GetCitations() []TextCitationParamUnion { 4520 if vt := u.OfText; vt != nil { 4521 return vt.Citations 4522 } 4523 return nil 4524 } 4525 4526 // Returns a pointer to the underlying variant's property, if present. 4527 func (u ContentBlockSourceContentItemUnionParam) GetSource() *ImageBlockParamSourceUnion { 4528 if vt := u.OfImage; vt != nil { 4529 return &vt.Source 4530 } 4531 return nil 4532 } 4533 4534 // Returns a pointer to the underlying variant's property, if present. 4535 func (u ContentBlockSourceContentItemUnionParam) GetTransformations() *ImageTransformationsParam { 4536 if vt := u.OfImage; vt != nil { 4537 return &vt.Transformations 4538 } 4539 return nil 4540 } 4541 4542 // Returns a pointer to the underlying variant's property, if present. 4543 func (u ContentBlockSourceContentItemUnionParam) GetType() *string { 4544 if vt := u.OfText; vt != nil { 4545 return (*string)(&vt.Type) 4546 } else if vt := u.OfImage; vt != nil { 4547 return (*string)(&vt.Type) 4548 } 4549 return nil 4550 } 4551 4552 // Returns a pointer to the underlying variant's CacheControl property, if present. 4553 func (u ContentBlockSourceContentItemUnionParam) GetCacheControl() *CacheControlEphemeralParam { 4554 if vt := u.OfText; vt != nil { 4555 return &vt.CacheControl 4556 } else if vt := u.OfImage; vt != nil { 4557 return &vt.CacheControl 4558 } 4559 return nil 4560 } 4561 4562 func init() { 4563 apijson.RegisterUnion[ContentBlockSourceContentItemUnionParam]( 4564 "type", 4565 apijson.Discriminator[TextBlockParam]("text"), 4566 apijson.Discriminator[ImageBlockParam]("image"), 4567 ) 4568 } 4569 4570 // Tool invocation directly from the model. 4571 type DirectCaller struct { 4572 Type constant.Direct `json:"type" default:"direct"` 4573 // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. 4574 JSON struct { 4575 Type respjson.Field 4576 ExtraFields map[string]respjson.Field 4577 raw string 4578 } `json:"-"` 4579 } 4580 4581 // Returns the unmodified JSON received from the API 4582 func (r DirectCaller) RawJSON() string { return r.JSON.raw } 4583 func (r *DirectCaller) UnmarshalJSON(data []byte) error { 4584 return apijson.UnmarshalRoot(data, r) 4585 } 4586 4587 // ToParam converts this DirectCaller to a DirectCallerParam. 4588 // 4589 // Warning: the fields of the param type will not be present. ToParam should only 4590 // be used at the last possible moment before sending a request. Test for this with 4591 // DirectCallerParam.Overrides() 4592 func (r DirectCaller) ToParam() DirectCallerParam { 4593 return param.Override[DirectCallerParam](json.RawMessage(r.RawJSON())) 4594 } 4595 4596 func NewDirectCallerParam() DirectCallerParam { 4597 return DirectCallerParam{ 4598 Type: "direct", 4599 } 4600 } 4601 4602 // Tool invocation directly from the model. 4603 // 4604 // This struct has a constant value, construct it with [NewDirectCallerParam]. 4605 type DirectCallerParam struct { 4606 Type constant.Direct `json:"type" default:"direct"` 4607 paramObj 4608 } 4609 4610 func (r DirectCallerParam) MarshalJSON() (data []byte, err error) { 4611 type shadow DirectCallerParam 4612 return param.MarshalObject(r, (*shadow)(&r)) 4613 } 4614 func (r *DirectCallerParam) UnmarshalJSON(data []byte) error { 4615 return apijson.UnmarshalRoot(data, r) 4616 } 4617 4618 type DocumentBlock struct { 4619 // Citation configuration for the document 4620 Citations CitationsConfig `json:"citations" api:"required"` 4621 Source DocumentBlockSourceUnion `json:"source" api:"required"` 4622 // The title of the document 4623 Title string `json:"title" api:"required"` 4624 Type constant.Document `json:"type" default:"document"` 4625 // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. 4626 JSON struct { 4627 Citations respjson.Field 4628 Source respjson.Field 4629 Title respjson.Field 4630 Type respjson.Field 4631 ExtraFields map[string]respjson.Field 4632 raw string 4633 } `json:"-"` 4634 } 4635 4636 // Returns the unmodified JSON received from the API 4637 func (r DocumentBlock) RawJSON() string { return r.JSON.raw } 4638 func (r *DocumentBlock) UnmarshalJSON(data []byte) error { 4639 return apijson.UnmarshalRoot(data, r) 4640 } 4641 4642 // DocumentBlockSourceUnion contains all possible properties and values from 4643 // [Base64PDFSource], [PlainTextSource]. 4644 // 4645 // Use the [DocumentBlockSourceUnion.AsAny] method to switch on the variant. 4646 // 4647 // Use the methods beginning with 'As' to cast the union to one of its variants. 4648 type DocumentBlockSourceUnion struct { 4649 Data string `json:"data"` 4650 MediaType string `json:"media_type"` 4651 // Any of "base64", "text". 4652 Type string `json:"type"` 4653 JSON struct { 4654 Data respjson.Field 4655 MediaType respjson.Field 4656 Type respjson.Field 4657 raw string 4658 } `json:"-"` 4659 } 4660 4661 // anyDocumentBlockSource is implemented by each variant of 4662 // [DocumentBlockSourceUnion] to add type safety for the return type of 4663 // [DocumentBlockSourceUnion.AsAny] 4664 type anyDocumentBlockSource interface { 4665 implDocumentBlockSourceUnion() 4666 } 4667 4668 func (Base64PDFSource) implDocumentBlockSourceUnion() {} 4669 func (PlainTextSource) implDocumentBlockSourceUnion() {} 4670 4671 // Use the following switch statement to find the correct variant 4672 // 4673 // switch variant := DocumentBlockSourceUnion.AsAny().(type) { 4674 // case anthropic.Base64PDFSource: 4675 // case anthropic.PlainTextSource: 4676 // default: 4677 // fmt.Errorf("no variant present") 4678 // } 4679 func (u DocumentBlockSourceUnion) AsAny() anyDocumentBlockSource { 4680 switch u.Type { 4681 case "base64": 4682 return u.AsBase64() 4683 case "text": 4684 return u.AsText() 4685 } 4686 return nil 4687 } 4688 4689 func (u DocumentBlockSourceUnion) AsBase64() (v Base64PDFSource) { 4690 apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) 4691 return 4692 } 4693 4694 func (u DocumentBlockSourceUnion) AsText() (v PlainTextSource) { 4695 apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) 4696 return 4697 } 4698 4699 // Returns the unmodified JSON received from the API 4700 func (u DocumentBlockSourceUnion) RawJSON() string { return u.JSON.raw } 4701 4702 func (r *DocumentBlockSourceUnion) UnmarshalJSON(data []byte) error { 4703 return apijson.UnmarshalRoot(data, r) 4704 } 4705 4706 // The properties Source, Type are required. 4707 type DocumentBlockParam struct { 4708 Source DocumentBlockParamSourceUnion `json:"source,omitzero" api:"required"` 4709 Context param.Opt[string] `json:"context,omitzero"` 4710 Title param.Opt[string] `json:"title,omitzero"` 4711 // Create a cache control breakpoint at this content block. 4712 CacheControl CacheControlEphemeralParam `json:"cache_control,omitzero"` 4713 Citations CitationsConfigParam `json:"citations,omitzero"` 4714 // This field can be elided, and will marshal its zero value as "document". 4715 Type constant.Document `json:"type" default:"document"` 4716 paramObj 4717 } 4718 4719 func (r DocumentBlockParam) MarshalJSON() (data []byte, err error) { 4720 type shadow DocumentBlockParam 4721 return param.MarshalObject(r, (*shadow)(&r)) 4722 } 4723 func (r *DocumentBlockParam) UnmarshalJSON(data []byte) error { 4724 return apijson.UnmarshalRoot(data, r) 4725 } 4726 4727 // Only one field can be non-zero. 4728 // 4729 // Use [param.IsOmitted] to confirm if a field is set. 4730 type DocumentBlockParamSourceUnion struct { 4731 OfBase64 *Base64PDFSourceParam `json:",omitzero,inline"` 4732 OfText *PlainTextSourceParam `json:",omitzero,inline"` 4733 OfContent *ContentBlockSourceParam `json:",omitzero,inline"` 4734 OfURL *URLPDFSourceParam `json:",omitzero,inline"` 4735 OfFile *FileDocumentSourceParam `json:",omitzero,inline"` 4736 paramUnion 4737 } 4738 4739 func (u DocumentBlockParamSourceUnion) MarshalJSON() ([]byte, error) { 4740 return param.MarshalUnion(u, u.OfBase64, 4741 u.OfText, 4742 u.OfContent, 4743 u.OfURL, 4744 u.OfFile) 4745 } 4746 func (u *DocumentBlockParamSourceUnion) UnmarshalJSON(data []byte) error { 4747 return apijson.UnmarshalRoot(data, u) 4748 } 4749 4750 func (u *DocumentBlockParamSourceUnion) asAny() any { 4751 if !param.IsOmitted(u.OfBase64) { 4752 return u.OfBase64 4753 } else if !param.IsOmitted(u.OfText) { 4754 return u.OfText 4755 } else if !param.IsOmitted(u.OfContent) { 4756 return u.OfContent 4757 } else if !param.IsOmitted(u.OfURL) { 4758 return u.OfURL 4759 } else if !param.IsOmitted(u.OfFile) { 4760 return u.OfFile 4761 } 4762 return nil 4763 } 4764 4765 // Returns a pointer to the underlying variant's property, if present. 4766 func (u DocumentBlockParamSourceUnion) GetContent() *ContentBlockSourceContentUnionParam { 4767 if vt := u.OfContent; vt != nil { 4768 return &vt.Content 4769 } 4770 return nil 4771 } 4772 4773 // Returns a pointer to the underlying variant's property, if present. 4774 func (u DocumentBlockParamSourceUnion) GetURL() *string { 4775 if vt := u.OfURL; vt != nil { 4776 return &vt.URL 4777 } 4778 return nil 4779 } 4780 4781 // Returns a pointer to the underlying variant's property, if present. 4782 func (u DocumentBlockParamSourceUnion) GetFileID() *string { 4783 if vt := u.OfFile; vt != nil { 4784 return &vt.FileID 4785 } 4786 return nil 4787 } 4788 4789 // Returns a pointer to the underlying variant's property, if present. 4790 func (u DocumentBlockParamSourceUnion) GetData() *string { 4791 if vt := u.OfBase64; vt != nil { 4792 return (*string)(&vt.Data) 4793 } else if vt := u.OfText; vt != nil { 4794 return (*string)(&vt.Data) 4795 } 4796 return nil 4797 } 4798 4799 // Returns a pointer to the underlying variant's property, if present. 4800 func (u DocumentBlockParamSourceUnion) GetMediaType() *string { 4801 if vt := u.OfBase64; vt != nil { 4802 return (*string)(&vt.MediaType) 4803 } else if vt := u.OfText; vt != nil { 4804 return (*string)(&vt.MediaType) 4805 } 4806 return nil 4807 } 4808 4809 // Returns a pointer to the underlying variant's property, if present. 4810 func (u DocumentBlockParamSourceUnion) GetType() *string { 4811 if vt := u.OfBase64; vt != nil { 4812 return (*string)(&vt.Type) 4813 } else if vt := u.OfText; vt != nil { 4814 return (*string)(&vt.Type) 4815 } else if vt := u.OfContent; vt != nil { 4816 return (*string)(&vt.Type) 4817 } else if vt := u.OfURL; vt != nil { 4818 return (*string)(&vt.Type) 4819 } else if vt := u.OfFile; vt != nil { 4820 return (*string)(&vt.Type) 4821 } 4822 return nil 4823 } 4824 4825 func init() { 4826 apijson.RegisterUnion[DocumentBlockParamSourceUnion]( 4827 "type", 4828 apijson.Discriminator[Base64PDFSourceParam]("base64"), 4829 apijson.Discriminator[PlainTextSourceParam]("text"), 4830 apijson.Discriminator[ContentBlockSourceParam]("content"), 4831 apijson.Discriminator[URLPDFSourceParam]("url"), 4832 apijson.Discriminator[FileDocumentSourceParam]("file"), 4833 ) 4834 } 4835 4836 // Code execution result with encrypted stdout for PFC + web_search results. 4837 type EncryptedCodeExecutionResultBlock struct { 4838 Content []CodeExecutionOutputBlock `json:"content" api:"required"` 4839 EncryptedStdout string `json:"encrypted_stdout" api:"required"` 4840 ReturnCode int64 `json:"return_code" api:"required"` 4841 Stderr string `json:"stderr" api:"required"` 4842 Type constant.EncryptedCodeExecutionResult `json:"type" default:"encrypted_code_execution_result"` 4843 // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. 4844 JSON struct { 4845 Content respjson.Field 4846 EncryptedStdout respjson.Field 4847 ReturnCode respjson.Field 4848 Stderr respjson.Field 4849 Type respjson.Field 4850 ExtraFields map[string]respjson.Field 4851 raw string 4852 } `json:"-"` 4853 } 4854 4855 // Returns the unmodified JSON received from the API 4856 func (r EncryptedCodeExecutionResultBlock) RawJSON() string { return r.JSON.raw } 4857 func (r *EncryptedCodeExecutionResultBlock) UnmarshalJSON(data []byte) error { 4858 return apijson.UnmarshalRoot(data, r) 4859 } 4860 4861 // Code execution result with encrypted stdout for PFC + web_search results. 4862 // 4863 // The properties Content, EncryptedStdout, ReturnCode, Stderr, Type are required. 4864 type EncryptedCodeExecutionResultBlockParam struct { 4865 Content []CodeExecutionOutputBlockParam `json:"content,omitzero" api:"required"` 4866 EncryptedStdout string `json:"encrypted_stdout" api:"required"` 4867 ReturnCode int64 `json:"return_code" api:"required"` 4868 Stderr string `json:"stderr" api:"required"` 4869 // This field can be elided, and will marshal its zero value as 4870 // "encrypted_code_execution_result". 4871 Type constant.EncryptedCodeExecutionResult `json:"type" default:"encrypted_code_execution_result"` 4872 paramObj 4873 } 4874 4875 func (r EncryptedCodeExecutionResultBlockParam) MarshalJSON() (data []byte, err error) { 4876 type shadow EncryptedCodeExecutionResultBlockParam 4877 return param.MarshalObject(r, (*shadow)(&r)) 4878 } 4879 func (r *EncryptedCodeExecutionResultBlockParam) UnmarshalJSON(data []byte) error { 4880 return apijson.UnmarshalRoot(data, r) 4881 } 4882 4883 // The properties FileID, Type are required. 4884 type FileDocumentSourceParam struct { 4885 FileID string `json:"file_id" api:"required"` 4886 // This field can be elided, and will marshal its zero value as "file". 4887 Type constant.File `json:"type" default:"file"` 4888 paramObj 4889 } 4890 4891 func (r FileDocumentSourceParam) MarshalJSON() (data []byte, err error) { 4892 type shadow FileDocumentSourceParam 4893 return param.MarshalObject(r, (*shadow)(&r)) 4894 } 4895 func (r *FileDocumentSourceParam) UnmarshalJSON(data []byte) error { 4896 return apijson.UnmarshalRoot(data, r) 4897 } 4898 4899 // The properties FileID, Type are required. 4900 type FileImageSourceParam struct { 4901 FileID string `json:"file_id" api:"required"` 4902 // This field can be elided, and will marshal its zero value as "file". 4903 Type constant.File `json:"type" default:"file"` 4904 paramObj 4905 } 4906 4907 func (r FileImageSourceParam) MarshalJSON() (data []byte, err error) { 4908 type shadow FileImageSourceParam 4909 return param.MarshalObject(r, (*shadow)(&r)) 4910 } 4911 func (r *FileImageSourceParam) UnmarshalJSON(data []byte) error { 4912 return apijson.UnmarshalRoot(data, r) 4913 } 4914 4915 // The properties Source, Type are required. 4916 type ImageBlockParam struct { 4917 Source ImageBlockParamSourceUnion `json:"source,omitzero" api:"required"` 4918 // Create a cache control breakpoint at this content block. 4919 CacheControl CacheControlEphemeralParam `json:"cache_control,omitzero"` 4920 // Configures the transformations the server applies to this image before the model 4921 // observes it. Each key names a condition the server transforms images for; its 4922 // value selects the transformation applied. Omitted keys keep their default 4923 // behavior, and an empty object is equivalent to omitting the field. 4924 Transformations ImageTransformationsParam `json:"transformations,omitzero"` 4925 // This field can be elided, and will marshal its zero value as "image". 4926 Type constant.Image `json:"type" default:"image"` 4927 paramObj 4928 } 4929 4930 func (r ImageBlockParam) MarshalJSON() (data []byte, err error) { 4931 type shadow ImageBlockParam 4932 return param.MarshalObject(r, (*shadow)(&r)) 4933 } 4934 func (r *ImageBlockParam) UnmarshalJSON(data []byte) error { 4935 return apijson.UnmarshalRoot(data, r) 4936 } 4937 4938 // Only one field can be non-zero. 4939 // 4940 // Use [param.IsOmitted] to confirm if a field is set. 4941 type ImageBlockParamSourceUnion struct { 4942 OfBase64 *Base64ImageSourceParam `json:",omitzero,inline"` 4943 OfURL *URLImageSourceParam `json:",omitzero,inline"` 4944 OfFile *FileImageSourceParam `json:",omitzero,inline"` 4945 paramUnion 4946 } 4947 4948 func (u ImageBlockParamSourceUnion) MarshalJSON() ([]byte, error) { 4949 return param.MarshalUnion(u, u.OfBase64, u.OfURL, u.OfFile) 4950 } 4951 func (u *ImageBlockParamSourceUnion) UnmarshalJSON(data []byte) error { 4952 return apijson.UnmarshalRoot(data, u) 4953 } 4954 4955 func (u *ImageBlockParamSourceUnion) asAny() any { 4956 if !param.IsOmitted(u.OfBase64) { 4957 return u.OfBase64 4958 } else if !param.IsOmitted(u.OfURL) { 4959 return u.OfURL 4960 } else if !param.IsOmitted(u.OfFile) { 4961 return u.OfFile 4962 } 4963 return nil 4964 } 4965 4966 // Returns a pointer to the underlying variant's property, if present. 4967 func (u ImageBlockParamSourceUnion) GetData() *string { 4968 if vt := u.OfBase64; vt != nil { 4969 return &vt.Data 4970 } 4971 return nil 4972 } 4973 4974 // Returns a pointer to the underlying variant's property, if present. 4975 func (u ImageBlockParamSourceUnion) GetMediaType() *string { 4976 if vt := u.OfBase64; vt != nil { 4977 return (*string)(&vt.MediaType) 4978 } 4979 return nil 4980 } 4981 4982 // Returns a pointer to the underlying variant's property, if present. 4983 func (u ImageBlockParamSourceUnion) GetURL() *string { 4984 if vt := u.OfURL; vt != nil { 4985 return &vt.URL 4986 } 4987 return nil 4988 } 4989 4990 // Returns a pointer to the underlying variant's property, if present. 4991 func (u ImageBlockParamSourceUnion) GetFileID() *string { 4992 if vt := u.OfFile; vt != nil { 4993 return &vt.FileID 4994 } 4995 return nil 4996 } 4997 4998 // Returns a pointer to the underlying variant's property, if present. 4999 func (u ImageBlockParamSourceUnion) GetType() *string { 5000 if vt := u.OfBase64; vt != nil { 5001 return (*string)(&vt.Type) 5002 } else if vt := u.OfURL; vt != nil { 5003 return (*string)(&vt.Type) 5004 } else if vt := u.OfFile; vt != nil { 5005 return (*string)(&vt.Type) 5006 } 5007 return nil 5008 } 5009 5010 func init() { 5011 apijson.RegisterUnion[ImageBlockParamSourceUnion]( 5012 "type", 5013 apijson.Discriminator[Base64ImageSourceParam]("base64"), 5014 apijson.Discriminator[URLImageSourceParam]("url"), 5015 apijson.Discriminator[FileImageSourceParam]("file"), 5016 ) 5017 } 5018 5019 // Configures the transformations the server applies to this image before the model 5020 // observes it. Each key names a condition the server transforms images for; its 5021 // value selects the transformation applied. Omitted keys keep their default 5022 // behavior, and an empty object is equivalent to omitting the field. 5023 type ImageTransformationsParam struct { 5024 // What the server does when this image exceeds the model's maximum image size. 5025 // `"downsize"` (the default) scales the image down to fit, which changes the 5026 // dimensions the model observes without telling you. `"error"` instead rejects the 5027 // request with a 400 error naming the image's dimensions and the largest 5028 // dimensions that fit, so you can scale the image deliberately — your image is 5029 // never silently scaled down. 5030 // 5031 // Any of "downsize", "error". 5032 OversizedImage ImageTransformationsParamOversizedImage `json:"oversized_image,omitzero"` 5033 paramObj 5034 } 5035 5036 func (r ImageTransformationsParam) MarshalJSON() (data []byte, err error) { 5037 type shadow ImageTransformationsParam 5038 return param.MarshalObject(r, (*shadow)(&r)) 5039 } 5040 func (r *ImageTransformationsParam) UnmarshalJSON(data []byte) error { 5041 return apijson.UnmarshalRoot(data, r) 5042 } 5043 5044 // What the server does when this image exceeds the model's maximum image size. 5045 // `"downsize"` (the default) scales the image down to fit, which changes the 5046 // dimensions the model observes without telling you. `"error"` instead rejects the 5047 // request with a 400 error naming the image's dimensions and the largest 5048 // dimensions that fit, so you can scale the image deliberately — your image is 5049 // never silently scaled down. 5050 type ImageTransformationsParamOversizedImage string 5051 5052 const ( 5053 ImageTransformationsParamOversizedImageDownsize ImageTransformationsParamOversizedImage = "downsize" 5054 ImageTransformationsParamOversizedImageError ImageTransformationsParamOversizedImage = "error" 5055 ) 5056 5057 type InputJSONDelta struct { 5058 PartialJSON string `json:"partial_json" api:"required"` 5059 Type constant.InputJSONDelta `json:"type" default:"input_json_delta"` 5060 // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. 5061 JSON struct { 5062 PartialJSON respjson.Field 5063 Type respjson.Field 5064 ExtraFields map[string]respjson.Field 5065 raw string 5066 } `json:"-"` 5067 } 5068 5069 // Returns the unmodified JSON received from the API 5070 func (r InputJSONDelta) RawJSON() string { return r.JSON.raw } 5071 func (r *InputJSONDelta) UnmarshalJSON(data []byte) error { 5072 return apijson.UnmarshalRoot(data, r) 5073 } 5074 5075 // The properties Schema, Type are required. 5076 type JSONOutputFormatParam struct { 5077 // The JSON schema of the format 5078 Schema map[string]any `json:"schema,omitzero" api:"required"` 5079 // This field can be elided, and will marshal its zero value as "json_schema". 5080 Type constant.JSONSchema `json:"type" default:"json_schema"` 5081 paramObj 5082 } 5083 5084 func (r JSONOutputFormatParam) MarshalJSON() (data []byte, err error) { 5085 type shadow JSONOutputFormatParam 5086 return param.MarshalObject(r, (*shadow)(&r)) 5087 } 5088 func (r *JSONOutputFormatParam) UnmarshalJSON(data []byte) error { 5089 return apijson.UnmarshalRoot(data, r) 5090 } 5091 5092 // The properties Name, Type are required. 5093 type MemoryTool20250818Param struct { 5094 // If true, tool will not be included in initial system prompt. Only loaded when 5095 // returned via tool_reference from tool search. 5096 DeferLoading param.Opt[bool] `json:"defer_loading,omitzero"` 5097 // When true, guarantees schema validation on tool names and inputs 5098 Strict param.Opt[bool] `json:"strict,omitzero"` 5099 // Any of "direct", "code_execution_20250825", "code_execution_20260120", 5100 // "code_execution_20260521". 5101 AllowedCallers []string `json:"allowed_callers,omitzero"` 5102 // Create a cache control breakpoint at this content block. 5103 CacheControl CacheControlEphemeralParam `json:"cache_control,omitzero"` 5104 InputExamples []map[string]any `json:"input_examples,omitzero"` 5105 // Name of the tool. 5106 // 5107 // This is how the tool will be called by the model and in `tool_use` blocks. 5108 // 5109 // This field can be elided, and will marshal its zero value as "memory". 5110 Name constant.Memory `json:"name" default:"memory"` 5111 // This field can be elided, and will marshal its zero value as "memory_20250818". 5112 Type constant.Memory20250818 `json:"type" default:"memory_20250818"` 5113 paramObj 5114 } 5115 5116 func (r MemoryTool20250818Param) MarshalJSON() (data []byte, err error) { 5117 type shadow MemoryTool20250818Param 5118 return param.MarshalObject(r, (*shadow)(&r)) 5119 } 5120 func (r *MemoryTool20250818Param) UnmarshalJSON(data []byte) error { 5121 return apijson.UnmarshalRoot(data, r) 5122 } 5123 5124 type Message struct { 5125 // Unique object identifier. 5126 // 5127 // The format and length of IDs may change over time. 5128 ID string `json:"id" api:"required"` 5129 // Information about the container used in the request (for the code execution 5130 // tool) 5131 Container Container `json:"container" api:"required"` 5132 // Content generated by the model. 5133 // 5134 // This is an array of content blocks, each of which has a `type` that determines 5135 // its shape. 5136 // 5137 // Example: 5138 // 5139 // ```json 5140 // [{ "type": "text", "text": "Hi, I'm Claude." }] 5141 // ``` 5142 // 5143 // If the request input `messages` ended with an `assistant` turn, then the 5144 // response `content` will continue directly from that last turn. You can use this 5145 // to constrain the model's output. 5146 // 5147 // For example, if the input `messages` were: 5148 // 5149 // ```json 5150 // [ 5151 // 5152 // { 5153 // "role": "user", 5154 // "content": "What's the Greek name for Sun? (A) Sol (B) Helios (C) Sun" 5155 // }, 5156 // { "role": "assistant", "content": "The best answer is (" } 5157 // 5158 // ] 5159 // ``` 5160 // 5161 // Then the response `content` might be: 5162 // 5163 // ```json 5164 // [{ "type": "text", "text": "B)" }] 5165 // ``` 5166 Content []ContentBlockUnion `json:"content" api:"required"` 5167 // The model that will complete your prompt. 5168 // 5169 // See [models](https://docs.anthropic.com/en/docs/models-overview) for additional 5170 // details and options. 5171 Model Model `json:"model" api:"required"` 5172 // Conversational role of the generated message. 5173 // 5174 // This will always be `"assistant"`. 5175 Role constant.Assistant `json:"role" default:"assistant"` 5176 // Structured information about a refusal. 5177 StopDetails RefusalStopDetails `json:"stop_details" api:"required"` 5178 // The reason that we stopped. 5179 // 5180 // This may be one the following values: 5181 // 5182 // - `"end_turn"`: the model reached a natural stopping point 5183 // - `"max_tokens"`: we exceeded the requested `max_tokens` or the model's maximum 5184 // - `"stop_sequence"`: one of your provided custom `stop_sequences` was generated 5185 // - `"tool_use"`: the model invoked one or more tools 5186 // - `"pause_turn"`: we paused a long-running turn. You may provide the response 5187 // back as-is in a subsequent request to let the model continue. 5188 // - `"refusal"`: when streaming classifiers intervene to handle potential policy 5189 // violations 5190 // - `"model_context_window_exceeded"`: we exceeded the model's context window 5191 // 5192 // In non-streaming mode this value is always non-null. In streaming mode, it is 5193 // null in the `message_start` event and non-null otherwise. 5194 // 5195 // Any of "end_turn", "max_tokens", "stop_sequence", "tool_use", "pause_turn", 5196 // "refusal", "model_context_window_exceeded". 5197 StopReason StopReason `json:"stop_reason" api:"required"` 5198 // Which custom stop sequence was generated, if any. 5199 // 5200 // This value will be a non-null string if one of your custom stop sequences was 5201 // generated. 5202 StopSequence string `json:"stop_sequence" api:"required"` 5203 // Object type. 5204 // 5205 // For Messages, this is always `"message"`. 5206 Type constant.Message `json:"type" default:"message"` 5207 // Billing and rate-limit usage. 5208 // 5209 // Anthropic's API bills and rate-limits by token counts, as tokens represent the 5210 // underlying cost to our systems. 5211 // 5212 // Under the hood, the API transforms requests into a format suitable for the 5213 // model. The model's output then goes through a parsing stage before becoming an 5214 // API response. As a result, the token counts in `usage` will not match one-to-one 5215 // with the exact visible content of an API request or response. 5216 // 5217 // For example, `output_tokens` will be non-zero, even for an empty string response 5218 // from Claude. 5219 // 5220 // Total input tokens in a request is the summation of `input_tokens`, 5221 // `cache_creation_input_tokens`, and `cache_read_input_tokens`. 5222 Usage Usage `json:"usage" api:"required"` 5223 // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. 5224 JSON struct { 5225 ID respjson.Field 5226 Container respjson.Field 5227 Content respjson.Field 5228 Model respjson.Field 5229 Role respjson.Field 5230 StopDetails respjson.Field 5231 StopReason respjson.Field 5232 StopSequence respjson.Field 5233 Type respjson.Field 5234 Usage respjson.Field 5235 ExtraFields map[string]respjson.Field 5236 raw string 5237 } `json:"-"` 5238 } 5239 5240 // Returns the unmodified JSON received from the API 5241 func (r Message) RawJSON() string { return r.JSON.raw } 5242 func (r *Message) UnmarshalJSON(data []byte) error { 5243 return apijson.UnmarshalRoot(data, r) 5244 } 5245 5246 func MessageCountTokensToolParamOfTool(inputSchema ToolInputSchemaParam, name string) MessageCountTokensToolUnionParam { 5247 var variant ToolParam 5248 variant.InputSchema = inputSchema 5249 variant.Name = name 5250 return MessageCountTokensToolUnionParam{OfTool: &variant} 5251 } 5252 5253 func MessageCountTokensToolParamOfToolSearchToolBm25_20251119(type_ ToolSearchToolBm25_20251119Type) MessageCountTokensToolUnionParam { 5254 var variant ToolSearchToolBm25_20251119Param 5255 variant.Type = type_ 5256 return MessageCountTokensToolUnionParam{OfToolSearchToolBm25_20251119: &variant} 5257 } 5258 5259 func MessageCountTokensToolParamOfToolSearchToolRegex20251119(type_ ToolSearchToolRegex20251119Type) MessageCountTokensToolUnionParam { 5260 var variant ToolSearchToolRegex20251119Param 5261 variant.Type = type_ 5262 return MessageCountTokensToolUnionParam{OfToolSearchToolRegex20251119: &variant} 5263 } 5264 5265 // Only one field can be non-zero. 5266 // 5267 // Use [param.IsOmitted] to confirm if a field is set. 5268 type MessageCountTokensToolUnionParam struct { 5269 OfTool *ToolParam `json:",omitzero,inline"` 5270 OfBashTool20250124 *ToolBash20250124Param `json:",omitzero,inline"` 5271 OfCodeExecutionTool20250522 *CodeExecutionTool20250522Param `json:",omitzero,inline"` 5272 OfCodeExecutionTool20250825 *CodeExecutionTool20250825Param `json:",omitzero,inline"` 5273 OfCodeExecutionTool20260120 *CodeExecutionTool20260120Param `json:",omitzero,inline"` 5274 OfCodeExecutionTool20260521 *CodeExecutionTool20260521Param `json:",omitzero,inline"` 5275 OfBrowserToolset20260801 *BrowserToolset20260801Param `json:",omitzero,inline"` 5276 OfMemoryTool20250818 *MemoryTool20250818Param `json:",omitzero,inline"` 5277 OfComputerToolset20260801 *ComputerToolset20260801Param `json:",omitzero,inline"` 5278 OfTextEditor20250124 *ToolTextEditor20250124Param `json:",omitzero,inline"` 5279 OfTextEditor20250429 *ToolTextEditor20250429Param `json:",omitzero,inline"` 5280 OfTextEditor20250728 *ToolTextEditor20250728Param `json:",omitzero,inline"` 5281 OfWebSearchTool20250305 *WebSearchTool20250305Param `json:",omitzero,inline"` 5282 OfWebFetchTool20250910 *WebFetchTool20250910Param `json:",omitzero,inline"` 5283 OfWebSearchTool20260209 *WebSearchTool20260209Param `json:",omitzero,inline"` 5284 OfWebFetchTool20260209 *WebFetchTool20260209Param `json:",omitzero,inline"` 5285 OfWebFetchTool20260309 *WebFetchTool20260309Param `json:",omitzero,inline"` 5286 OfWebSearchTool20260318 *WebSearchTool20260318Param `json:",omitzero,inline"` 5287 OfWebFetchTool20260318 *WebFetchTool20260318Param `json:",omitzero,inline"` 5288 OfToolSearchToolBm25_20251119 *ToolSearchToolBm25_20251119Param `json:",omitzero,inline"` 5289 OfToolSearchToolRegex20251119 *ToolSearchToolRegex20251119Param `json:",omitzero,inline"` 5290 paramUnion 5291 } 5292 5293 func (u MessageCountTokensToolUnionParam) MarshalJSON() ([]byte, error) { 5294 return param.MarshalUnion(u, u.OfTool, 5295 u.OfBashTool20250124, 5296 u.OfCodeExecutionTool20250522, 5297 u.OfCodeExecutionTool20250825, 5298 u.OfCodeExecutionTool20260120, 5299 u.OfCodeExecutionTool20260521, 5300 u.OfBrowserToolset20260801, 5301 u.OfMemoryTool20250818, 5302 u.OfComputerToolset20260801, 5303 u.OfTextEditor20250124, 5304 u.OfTextEditor20250429, 5305 u.OfTextEditor20250728, 5306 u.OfWebSearchTool20250305, 5307 u.OfWebFetchTool20250910, 5308 u.OfWebSearchTool20260209, 5309 u.OfWebFetchTool20260209, 5310 u.OfWebFetchTool20260309, 5311 u.OfWebSearchTool20260318, 5312 u.OfWebFetchTool20260318, 5313 u.OfToolSearchToolBm25_20251119, 5314 u.OfToolSearchToolRegex20251119) 5315 } 5316 func (u *MessageCountTokensToolUnionParam) UnmarshalJSON(data []byte) error { 5317 return apijson.UnmarshalRoot(data, u) 5318 } 5319 5320 func (u *MessageCountTokensToolUnionParam) asAny() any { 5321 if !param.IsOmitted(u.OfTool) { 5322 return u.OfTool 5323 } else if !param.IsOmitted(u.OfBashTool20250124) { 5324 return u.OfBashTool20250124 5325 } else if !param.IsOmitted(u.OfCodeExecutionTool20250522) { 5326 return u.OfCodeExecutionTool20250522 5327 } else if !param.IsOmitted(u.OfCodeExecutionTool20250825) { 5328 return u.OfCodeExecutionTool20250825 5329 } else if !param.IsOmitted(u.OfCodeExecutionTool20260120) { 5330 return u.OfCodeExecutionTool20260120 5331 } else if !param.IsOmitted(u.OfCodeExecutionTool20260521) { 5332 return u.OfCodeExecutionTool20260521 5333 } else if !param.IsOmitted(u.OfBrowserToolset20260801) { 5334 return u.OfBrowserToolset20260801 5335 } else if !param.IsOmitted(u.OfMemoryTool20250818) { 5336 return u.OfMemoryTool20250818 5337 } else if !param.IsOmitted(u.OfComputerToolset20260801) { 5338 return u.OfComputerToolset20260801 5339 } else if !param.IsOmitted(u.OfTextEditor20250124) { 5340 return u.OfTextEditor20250124 5341 } else if !param.IsOmitted(u.OfTextEditor20250429) { 5342 return u.OfTextEditor20250429 5343 } else if !param.IsOmitted(u.OfTextEditor20250728) { 5344 return u.OfTextEditor20250728 5345 } else if !param.IsOmitted(u.OfWebSearchTool20250305) { 5346 return u.OfWebSearchTool20250305 5347 } else if !param.IsOmitted(u.OfWebFetchTool20250910) { 5348 return u.OfWebFetchTool20250910 5349 } else if !param.IsOmitted(u.OfWebSearchTool20260209) { 5350 return u.OfWebSearchTool20260209 5351 } else if !param.IsOmitted(u.OfWebFetchTool20260209) { 5352 return u.OfWebFetchTool20260209 5353 } else if !param.IsOmitted(u.OfWebFetchTool20260309) { 5354 return u.OfWebFetchTool20260309 5355 } else if !param.IsOmitted(u.OfWebSearchTool20260318) { 5356 return u.OfWebSearchTool20260318 5357 } else if !param.IsOmitted(u.OfWebFetchTool20260318) { 5358 return u.OfWebFetchTool20260318 5359 } else if !param.IsOmitted(u.OfToolSearchToolBm25_20251119) { 5360 return u.OfToolSearchToolBm25_20251119 5361 } else if !param.IsOmitted(u.OfToolSearchToolRegex20251119) { 5362 return u.OfToolSearchToolRegex20251119 5363 } 5364 return nil 5365 } 5366 5367 // Returns a pointer to the underlying variant's property, if present. 5368 func (u MessageCountTokensToolUnionParam) GetInputSchema() *ToolInputSchemaParam { 5369 if vt := u.OfTool; vt != nil { 5370 return &vt.InputSchema 5371 } 5372 return nil 5373 } 5374 5375 // Returns a pointer to the underlying variant's property, if present. 5376 func (u MessageCountTokensToolUnionParam) GetDescription() *string { 5377 if vt := u.OfTool; vt != nil && vt.Description.Valid() { 5378 return &vt.Description.Value 5379 } 5380 return nil 5381 } 5382 5383 // Returns a pointer to the underlying variant's property, if present. 5384 func (u MessageCountTokensToolUnionParam) GetEagerInputStreaming() *bool { 5385 if vt := u.OfTool; vt != nil && vt.EagerInputStreaming.Valid() { 5386 return &vt.EagerInputStreaming.Value 5387 } 5388 return nil 5389 } 5390 5391 // Returns a pointer to the underlying variant's property, if present. 5392 func (u MessageCountTokensToolUnionParam) GetMaxCharacters() *int64 { 5393 if vt := u.OfTextEditor20250728; vt != nil && vt.MaxCharacters.Valid() { 5394 return &vt.MaxCharacters.Value 5395 } 5396 return nil 5397 } 5398 5399 // Returns a pointer to the underlying variant's property, if present. 5400 func (u MessageCountTokensToolUnionParam) GetName() *string { 5401 if vt := u.OfTool; vt != nil { 5402 return (*string)(&vt.Name) 5403 } else if vt := u.OfBashTool20250124; vt != nil { 5404 return (*string)(&vt.Name) 5405 } else if vt := u.OfCodeExecutionTool20250522; vt != nil { 5406 return (*string)(&vt.Name) 5407 } else if vt := u.OfCodeExecutionTool20250825; vt != nil { 5408 return (*string)(&vt.Name) 5409 } else if vt := u.OfCodeExecutionTool20260120; vt != nil { 5410 return (*string)(&vt.Name) 5411 } else if vt := u.OfCodeExecutionTool20260521; vt != nil { 5412 return (*string)(&vt.Name) 5413 } else if vt := u.OfMemoryTool20250818; vt != nil { 5414 return (*string)(&vt.Name) 5415 } else if vt := u.OfTextEditor20250124; vt != nil { 5416 return (*string)(&vt.Name) 5417 } else if vt := u.OfTextEditor20250429; vt != nil { 5418 return (*string)(&vt.Name) 5419 } else if vt := u.OfTextEditor20250728; vt != nil { 5420 return (*string)(&vt.Name) 5421 } else if vt := u.OfWebSearchTool20250305; vt != nil { 5422 return (*string)(&vt.Name) 5423 } else if vt := u.OfWebFetchTool20250910; vt != nil { 5424 return (*string)(&vt.Name) 5425 } else if vt := u.OfWebSearchTool20260209; vt != nil { 5426 return (*string)(&vt.Name) 5427 } else if vt := u.OfWebFetchTool20260209; vt != nil { 5428 return (*string)(&vt.Name) 5429 } else if vt := u.OfWebFetchTool20260309; vt != nil { 5430 return (*string)(&vt.Name) 5431 } else if vt := u.OfWebSearchTool20260318; vt != nil { 5432 return (*string)(&vt.Name) 5433 } else if vt := u.OfWebFetchTool20260318; vt != nil { 5434 return (*string)(&vt.Name) 5435 } else if vt := u.OfToolSearchToolBm25_20251119; vt != nil { 5436 return (*string)(&vt.Name) 5437 } else if vt := u.OfToolSearchToolRegex20251119; vt != nil { 5438 return (*string)(&vt.Name) 5439 } 5440 return nil 5441 } 5442 5443 // Returns a pointer to the underlying variant's property, if present. 5444 func (u MessageCountTokensToolUnionParam) GetDeferLoading() *bool { 5445 if vt := u.OfTool; vt != nil && vt.DeferLoading.Valid() { 5446 return &vt.DeferLoading.Value 5447 } else if vt := u.OfBashTool20250124; vt != nil && vt.DeferLoading.Valid() { 5448 return &vt.DeferLoading.Value 5449 } else if vt := u.OfCodeExecutionTool20250522; vt != nil && vt.DeferLoading.Valid() { 5450 return &vt.DeferLoading.Value 5451 } else if vt := u.OfCodeExecutionTool20250825; vt != nil && vt.DeferLoading.Valid() { 5452 return &vt.DeferLoading.Value 5453 } else if vt := u.OfCodeExecutionTool20260120; vt != nil && vt.DeferLoading.Valid() { 5454 return &vt.DeferLoading.Value 5455 } else if vt := u.OfCodeExecutionTool20260521; vt != nil && vt.DeferLoading.Valid() { 5456 return &vt.DeferLoading.Value 5457 } else if vt := u.OfMemoryTool20250818; vt != nil && vt.DeferLoading.Valid() { 5458 return &vt.DeferLoading.Value 5459 } else if vt := u.OfTextEditor20250124; vt != nil && vt.DeferLoading.Valid() { 5460 return &vt.DeferLoading.Value 5461 } else if vt := u.OfTextEditor20250429; vt != nil && vt.DeferLoading.Valid() { 5462 return &vt.DeferLoading.Value 5463 } else if vt := u.OfTextEditor20250728; vt != nil && vt.DeferLoading.Valid() { 5464 return &vt.DeferLoading.Value 5465 } else if vt := u.OfWebSearchTool20250305; vt != nil && vt.DeferLoading.Valid() { 5466 return &vt.DeferLoading.Value 5467 } else if vt := u.OfWebFetchTool20250910; vt != nil && vt.DeferLoading.Valid() { 5468 return &vt.DeferLoading.Value 5469 } else if vt := u.OfWebSearchTool20260209; vt != nil && vt.DeferLoading.Valid() { 5470 return &vt.DeferLoading.Value 5471 } else if vt := u.OfWebFetchTool20260209; vt != nil && vt.DeferLoading.Valid() { 5472 return &vt.DeferLoading.Value 5473 } else if vt := u.OfWebFetchTool20260309; vt != nil && vt.DeferLoading.Valid() { 5474 return &vt.DeferLoading.Value 5475 } else if vt := u.OfWebSearchTool20260318; vt != nil && vt.DeferLoading.Valid() { 5476 return &vt.DeferLoading.Value 5477 } else if vt := u.OfWebFetchTool20260318; vt != nil && vt.DeferLoading.Valid() { 5478 return &vt.DeferLoading.Value 5479 } else if vt := u.OfToolSearchToolBm25_20251119; vt != nil && vt.DeferLoading.Valid() { 5480 return &vt.DeferLoading.Value 5481 } else if vt := u.OfToolSearchToolRegex20251119; vt != nil && vt.DeferLoading.Valid() { 5482 return &vt.DeferLoading.Value 5483 } 5484 return nil 5485 } 5486 5487 // Returns a pointer to the underlying variant's property, if present. 5488 func (u MessageCountTokensToolUnionParam) GetStrict() *bool { 5489 if vt := u.OfTool; vt != nil && vt.Strict.Valid() { 5490 return &vt.Strict.Value 5491 } else if vt := u.OfBashTool20250124; vt != nil && vt.Strict.Valid() { 5492 return &vt.Strict.Value 5493 } else if vt := u.OfCodeExecutionTool20250522; vt != nil && vt.Strict.Valid() { 5494 return &vt.Strict.Value 5495 } else if vt := u.OfCodeExecutionTool20250825; vt != nil && vt.Strict.Valid() { 5496 return &vt.Strict.Value 5497 } else if vt := u.OfCodeExecutionTool20260120; vt != nil && vt.Strict.Valid() { 5498 return &vt.Strict.Value 5499 } else if vt := u.OfCodeExecutionTool20260521; vt != nil && vt.Strict.Valid() { 5500 return &vt.Strict.Value 5501 } else if vt := u.OfMemoryTool20250818; vt != nil && vt.Strict.Valid() { 5502 return &vt.Strict.Value 5503 } else if vt := u.OfTextEditor20250124; vt != nil && vt.Strict.Valid() { 5504 return &vt.Strict.Value 5505 } else if vt := u.OfTextEditor20250429; vt != nil && vt.Strict.Valid() { 5506 return &vt.Strict.Value 5507 } else if vt := u.OfTextEditor20250728; vt != nil && vt.Strict.Valid() { 5508 return &vt.Strict.Value 5509 } else if vt := u.OfWebSearchTool20250305; vt != nil && vt.Strict.Valid() { 5510 return &vt.Strict.Value 5511 } else if vt := u.OfWebFetchTool20250910; vt != nil && vt.Strict.Valid() { 5512 return &vt.Strict.Value 5513 } else if vt := u.OfWebSearchTool20260209; vt != nil && vt.Strict.Valid() { 5514 return &vt.Strict.Value 5515 } else if vt := u.OfWebFetchTool20260209; vt != nil && vt.Strict.Valid() { 5516 return &vt.Strict.Value 5517 } else if vt := u.OfWebFetchTool20260309; vt != nil && vt.Strict.Valid() { 5518 return &vt.Strict.Value 5519 } else if vt := u.OfWebSearchTool20260318; vt != nil && vt.Strict.Valid() { 5520 return &vt.Strict.Value 5521 } else if vt := u.OfWebFetchTool20260318; vt != nil && vt.Strict.Valid() { 5522 return &vt.Strict.Value 5523 } else if vt := u.OfToolSearchToolBm25_20251119; vt != nil && vt.Strict.Valid() { 5524 return &vt.Strict.Value 5525 } else if vt := u.OfToolSearchToolRegex20251119; vt != nil && vt.Strict.Valid() { 5526 return &vt.Strict.Value 5527 } 5528 return nil 5529 } 5530 5531 // Returns a pointer to the underlying variant's property, if present. 5532 func (u MessageCountTokensToolUnionParam) GetType() *string { 5533 if vt := u.OfTool; vt != nil { 5534 return (*string)(&vt.Type) 5535 } else if vt := u.OfBashTool20250124; vt != nil { 5536 return (*string)(&vt.Type) 5537 } else if vt := u.OfCodeExecutionTool20250522; vt != nil { 5538 return (*string)(&vt.Type) 5539 } else if vt := u.OfCodeExecutionTool20250825; vt != nil { 5540 return (*string)(&vt.Type) 5541 } else if vt := u.OfCodeExecutionTool20260120; vt != nil { 5542 return (*string)(&vt.Type) 5543 } else if vt := u.OfCodeExecutionTool20260521; vt != nil { 5544 return (*string)(&vt.Type) 5545 } else if vt := u.OfBrowserToolset20260801; vt != nil { 5546 return (*string)(&vt.Type) 5547 } else if vt := u.OfMemoryTool20250818; vt != nil { 5548 return (*string)(&vt.Type) 5549 } else if vt := u.OfComputerToolset20260801; vt != nil { 5550 return (*string)(&vt.Type) 5551 } else if vt := u.OfTextEditor20250124; vt != nil { 5552 return (*string)(&vt.Type) 5553 } else if vt := u.OfTextEditor20250429; vt != nil { 5554 return (*string)(&vt.Type) 5555 } else if vt := u.OfTextEditor20250728; vt != nil { 5556 return (*string)(&vt.Type) 5557 } else if vt := u.OfWebSearchTool20250305; vt != nil { 5558 return (*string)(&vt.Type) 5559 } else if vt := u.OfWebFetchTool20250910; vt != nil { 5560 return (*string)(&vt.Type) 5561 } else if vt := u.OfWebSearchTool20260209; vt != nil { 5562 return (*string)(&vt.Type) 5563 } else if vt := u.OfWebFetchTool20260209; vt != nil { 5564 return (*string)(&vt.Type) 5565 } else if vt := u.OfWebFetchTool20260309; vt != nil { 5566 return (*string)(&vt.Type) 5567 } else if vt := u.OfWebSearchTool20260318; vt != nil { 5568 return (*string)(&vt.Type) 5569 } else if vt := u.OfWebFetchTool20260318; vt != nil { 5570 return (*string)(&vt.Type) 5571 } else if vt := u.OfToolSearchToolBm25_20251119; vt != nil { 5572 return (*string)(&vt.Type) 5573 } else if vt := u.OfToolSearchToolRegex20251119; vt != nil { 5574 return (*string)(&vt.Type) 5575 } 5576 return nil 5577 } 5578 5579 // Returns a pointer to the underlying variant's property, if present. 5580 func (u MessageCountTokensToolUnionParam) GetMaxUses() *int64 { 5581 if vt := u.OfWebSearchTool20250305; vt != nil && vt.MaxUses.Valid() { 5582 return &vt.MaxUses.Value 5583 } else if vt := u.OfWebFetchTool20250910; vt != nil && vt.MaxUses.Valid() { 5584 return &vt.MaxUses.Value 5585 } else if vt := u.OfWebSearchTool20260209; vt != nil && vt.MaxUses.Valid() { 5586 return &vt.MaxUses.Value 5587 } else if vt := u.OfWebFetchTool20260209; vt != nil && vt.MaxUses.Valid() { 5588 return &vt.MaxUses.Value 5589 } else if vt := u.OfWebFetchTool20260309; vt != nil && vt.MaxUses.Valid() { 5590 return &vt.MaxUses.Value 5591 } else if vt := u.OfWebSearchTool20260318; vt != nil && vt.MaxUses.Valid() { 5592 return &vt.MaxUses.Value 5593 } else if vt := u.OfWebFetchTool20260318; vt != nil && vt.MaxUses.Valid() { 5594 return &vt.MaxUses.Value 5595 } 5596 return nil 5597 } 5598 5599 // Returns a pointer to the underlying variant's property, if present. 5600 func (u MessageCountTokensToolUnionParam) GetMaxContentTokens() *int64 { 5601 if vt := u.OfWebFetchTool20250910; vt != nil && vt.MaxContentTokens.Valid() { 5602 return &vt.MaxContentTokens.Value 5603 } else if vt := u.OfWebFetchTool20260209; vt != nil && vt.MaxContentTokens.Valid() { 5604 return &vt.MaxContentTokens.Value 5605 } else if vt := u.OfWebFetchTool20260309; vt != nil && vt.MaxContentTokens.Valid() { 5606 return &vt.MaxContentTokens.Value 5607 } else if vt := u.OfWebFetchTool20260318; vt != nil && vt.MaxContentTokens.Valid() { 5608 return &vt.MaxContentTokens.Value 5609 } 5610 return nil 5611 } 5612 5613 // Returns a pointer to the underlying variant's property, if present. 5614 func (u MessageCountTokensToolUnionParam) GetUseCache() *bool { 5615 if vt := u.OfWebFetchTool20260309; vt != nil && vt.UseCache.Valid() { 5616 return &vt.UseCache.Value 5617 } else if vt := u.OfWebFetchTool20260318; vt != nil && vt.UseCache.Valid() { 5618 return &vt.UseCache.Value 5619 } 5620 return nil 5621 } 5622 5623 // Returns a pointer to the underlying variant's property, if present. 5624 func (u MessageCountTokensToolUnionParam) GetResponseInclusion() *string { 5625 if vt := u.OfWebSearchTool20260318; vt != nil { 5626 return (*string)(&vt.ResponseInclusion) 5627 } else if vt := u.OfWebFetchTool20260318; vt != nil { 5628 return (*string)(&vt.ResponseInclusion) 5629 } 5630 return nil 5631 } 5632 5633 // Returns a pointer to the underlying variant's AllowedCallers property, if 5634 // present. 5635 func (u MessageCountTokensToolUnionParam) GetAllowedCallers() []string { 5636 if vt := u.OfTool; vt != nil { 5637 return vt.AllowedCallers 5638 } else if vt := u.OfBashTool20250124; vt != nil { 5639 return vt.AllowedCallers 5640 } else if vt := u.OfCodeExecutionTool20250522; vt != nil { 5641 return vt.AllowedCallers 5642 } else if vt := u.OfCodeExecutionTool20250825; vt != nil { 5643 return vt.AllowedCallers 5644 } else if vt := u.OfCodeExecutionTool20260120; vt != nil { 5645 return vt.AllowedCallers 5646 } else if vt := u.OfCodeExecutionTool20260521; vt != nil { 5647 return vt.AllowedCallers 5648 } else if vt := u.OfMemoryTool20250818; vt != nil { 5649 return vt.AllowedCallers 5650 } else if vt := u.OfTextEditor20250124; vt != nil { 5651 return vt.AllowedCallers 5652 } else if vt := u.OfTextEditor20250429; vt != nil { 5653 return vt.AllowedCallers 5654 } else if vt := u.OfTextEditor20250728; vt != nil { 5655 return vt.AllowedCallers 5656 } else if vt := u.OfWebSearchTool20250305; vt != nil { 5657 return vt.AllowedCallers 5658 } else if vt := u.OfWebFetchTool20250910; vt != nil { 5659 return vt.AllowedCallers 5660 } else if vt := u.OfWebSearchTool20260209; vt != nil { 5661 return vt.AllowedCallers 5662 } else if vt := u.OfWebFetchTool20260209; vt != nil { 5663 return vt.AllowedCallers 5664 } else if vt := u.OfWebFetchTool20260309; vt != nil { 5665 return vt.AllowedCallers 5666 } else if vt := u.OfWebSearchTool20260318; vt != nil { 5667 return vt.AllowedCallers 5668 } else if vt := u.OfWebFetchTool20260318; vt != nil { 5669 return vt.AllowedCallers 5670 } else if vt := u.OfToolSearchToolBm25_20251119; vt != nil { 5671 return vt.AllowedCallers 5672 } else if vt := u.OfToolSearchToolRegex20251119; vt != nil { 5673 return vt.AllowedCallers 5674 } 5675 return nil 5676 } 5677 5678 // Returns a pointer to the underlying variant's CacheControl property, if present. 5679 func (u MessageCountTokensToolUnionParam) GetCacheControl() *CacheControlEphemeralParam { 5680 if vt := u.OfTool; vt != nil { 5681 return &vt.CacheControl 5682 } else if vt := u.OfBashTool20250124; vt != nil { 5683 return &vt.CacheControl 5684 } else if vt := u.OfCodeExecutionTool20250522; vt != nil { 5685 return &vt.CacheControl 5686 } else if vt := u.OfCodeExecutionTool20250825; vt != nil { 5687 return &vt.CacheControl 5688 } else if vt := u.OfCodeExecutionTool20260120; vt != nil { 5689 return &vt.CacheControl 5690 } else if vt := u.OfCodeExecutionTool20260521; vt != nil { 5691 return &vt.CacheControl 5692 } else if vt := u.OfBrowserToolset20260801; vt != nil { 5693 return &vt.CacheControl 5694 } else if vt := u.OfMemoryTool20250818; vt != nil { 5695 return &vt.CacheControl 5696 } else if vt := u.OfComputerToolset20260801; vt != nil { 5697 return &vt.CacheControl 5698 } else if vt := u.OfTextEditor20250124; vt != nil { 5699 return &vt.CacheControl 5700 } else if vt := u.OfTextEditor20250429; vt != nil { 5701 return &vt.CacheControl 5702 } else if vt := u.OfTextEditor20250728; vt != nil { 5703 return &vt.CacheControl 5704 } else if vt := u.OfWebSearchTool20250305; vt != nil { 5705 return &vt.CacheControl 5706 } else if vt := u.OfWebFetchTool20250910; vt != nil { 5707 return &vt.CacheControl 5708 } else if vt := u.OfWebSearchTool20260209; vt != nil { 5709 return &vt.CacheControl 5710 } else if vt := u.OfWebFetchTool20260209; vt != nil { 5711 return &vt.CacheControl 5712 } else if vt := u.OfWebFetchTool20260309; vt != nil { 5713 return &vt.CacheControl 5714 } else if vt := u.OfWebSearchTool20260318; vt != nil { 5715 return &vt.CacheControl 5716 } else if vt := u.OfWebFetchTool20260318; vt != nil { 5717 return &vt.CacheControl 5718 } else if vt := u.OfToolSearchToolBm25_20251119; vt != nil { 5719 return &vt.CacheControl 5720 } else if vt := u.OfToolSearchToolRegex20251119; vt != nil { 5721 return &vt.CacheControl 5722 } 5723 return nil 5724 } 5725 5726 // Returns a pointer to the underlying variant's InputExamples property, if 5727 // present. 5728 func (u MessageCountTokensToolUnionParam) GetInputExamples() []map[string]any { 5729 if vt := u.OfTool; vt != nil { 5730 return vt.InputExamples 5731 } else if vt := u.OfBashTool20250124; vt != nil { 5732 return vt.InputExamples 5733 } else if vt := u.OfMemoryTool20250818; vt != nil { 5734 return vt.InputExamples 5735 } else if vt := u.OfTextEditor20250124; vt != nil { 5736 return vt.InputExamples 5737 } else if vt := u.OfTextEditor20250429; vt != nil { 5738 return vt.InputExamples 5739 } else if vt := u.OfTextEditor20250728; vt != nil { 5740 return vt.InputExamples 5741 } 5742 return nil 5743 } 5744 5745 // Returns a subunion which exports methods to access subproperties 5746 // 5747 // Or use AsAny() to get the underlying value 5748 func (u MessageCountTokensToolUnionParam) GetConfigs() (res messageCountTokensToolUnionParamConfigs) { 5749 if vt := u.OfBrowserToolset20260801; vt != nil { 5750 res.any = &vt.Configs 5751 } else if vt := u.OfComputerToolset20260801; vt != nil { 5752 res.any = &vt.Configs 5753 } 5754 return 5755 } 5756 5757 // Can have the runtime types [*BrowserToolsetConfigsParam], 5758 // [*ComputerToolsetConfigsParam] 5759 type messageCountTokensToolUnionParamConfigs struct{ any } 5760 5761 // Use the following switch statement to get the type of the union: 5762 // 5763 // switch u.AsAny().(type) { 5764 // case *anthropic.BrowserToolsetConfigsParam: 5765 // case *anthropic.ComputerToolsetConfigsParam: 5766 // default: 5767 // fmt.Errorf("not present") 5768 // } 5769 func (u messageCountTokensToolUnionParamConfigs) AsAny() any { return u.any } 5770 5771 // Returns a pointer to the underlying variant's property, if present. 5772 func (u messageCountTokensToolUnionParamConfigs) GetCloseTab() *BrowserCloseTabConfigParam { 5773 switch vt := u.any.(type) { 5774 case *BrowserToolsetConfigsParam: 5775 return &vt.CloseTab 5776 } 5777 return nil 5778 } 5779 5780 // Returns a pointer to the underlying variant's property, if present. 5781 func (u messageCountTokensToolUnionParamConfigs) GetFileUpload() *BrowserFileUploadConfigParam { 5782 switch vt := u.any.(type) { 5783 case *BrowserToolsetConfigsParam: 5784 return &vt.FileUpload 5785 } 5786 return nil 5787 } 5788 5789 // Returns a pointer to the underlying variant's property, if present. 5790 func (u messageCountTokensToolUnionParamConfigs) GetFind() *BrowserFindConfigParam { 5791 switch vt := u.any.(type) { 5792 case *BrowserToolsetConfigsParam: 5793 return &vt.Find 5794 } 5795 return nil 5796 } 5797 5798 // Returns a pointer to the underlying variant's property, if present. 5799 func (u messageCountTokensToolUnionParamConfigs) GetFormInput() *BrowserFormInputConfigParam { 5800 switch vt := u.any.(type) { 5801 case *BrowserToolsetConfigsParam: 5802 return &vt.FormInput 5803 } 5804 return nil 5805 } 5806 5807 // Returns a pointer to the underlying variant's property, if present. 5808 func (u messageCountTokensToolUnionParamConfigs) GetGetPageText() *BrowserGetPageTextConfigParam { 5809 switch vt := u.any.(type) { 5810 case *BrowserToolsetConfigsParam: 5811 return &vt.GetPageText 5812 } 5813 return nil 5814 } 5815 5816 // Returns a pointer to the underlying variant's property, if present. 5817 func (u messageCountTokensToolUnionParamConfigs) GetHover() *BrowserHoverConfigParam { 5818 switch vt := u.any.(type) { 5819 case *BrowserToolsetConfigsParam: 5820 return &vt.Hover 5821 } 5822 return nil 5823 } 5824 5825 // Returns a pointer to the underlying variant's property, if present. 5826 func (u messageCountTokensToolUnionParamConfigs) GetJavascriptExec() *BrowserJavascriptExecConfigParam { 5827 switch vt := u.any.(type) { 5828 case *BrowserToolsetConfigsParam: 5829 return &vt.JavascriptExec 5830 } 5831 return nil 5832 } 5833 5834 // Returns a pointer to the underlying variant's property, if present. 5835 func (u messageCountTokensToolUnionParamConfigs) GetListTabs() *BrowserListTabsConfigParam { 5836 switch vt := u.any.(type) { 5837 case *BrowserToolsetConfigsParam: 5838 return &vt.ListTabs 5839 } 5840 return nil 5841 } 5842 5843 // Returns a pointer to the underlying variant's property, if present. 5844 func (u messageCountTokensToolUnionParamConfigs) GetNavigate() *BrowserNavigateConfigParam { 5845 switch vt := u.any.(type) { 5846 case *BrowserToolsetConfigsParam: 5847 return &vt.Navigate 5848 } 5849 return nil 5850 } 5851 5852 // Returns a pointer to the underlying variant's property, if present. 5853 func (u messageCountTokensToolUnionParamConfigs) GetNewTab() *BrowserNewTabConfigParam { 5854 switch vt := u.any.(type) { 5855 case *BrowserToolsetConfigsParam: 5856 return &vt.NewTab 5857 } 5858 return nil 5859 } 5860 5861 // Returns a pointer to the underlying variant's property, if present. 5862 func (u messageCountTokensToolUnionParamConfigs) GetReadConsole() *BrowserReadConsoleConfigParam { 5863 switch vt := u.any.(type) { 5864 case *BrowserToolsetConfigsParam: 5865 return &vt.ReadConsole 5866 } 5867 return nil 5868 } 5869 5870 // Returns a pointer to the underlying variant's property, if present. 5871 func (u messageCountTokensToolUnionParamConfigs) GetReadNetwork() *BrowserReadNetworkConfigParam { 5872 switch vt := u.any.(type) { 5873 case *BrowserToolsetConfigsParam: 5874 return &vt.ReadNetwork 5875 } 5876 return nil 5877 } 5878 5879 // Returns a pointer to the underlying variant's property, if present. 5880 func (u messageCountTokensToolUnionParamConfigs) GetReadPage() *BrowserReadPageConfigParam { 5881 switch vt := u.any.(type) { 5882 case *BrowserToolsetConfigsParam: 5883 return &vt.ReadPage 5884 } 5885 return nil 5886 } 5887 5888 // Returns a pointer to the underlying variant's property, if present. 5889 func (u messageCountTokensToolUnionParamConfigs) GetScrollTo() *BrowserScrollToConfigParam { 5890 switch vt := u.any.(type) { 5891 case *BrowserToolsetConfigsParam: 5892 return &vt.ScrollTo 5893 } 5894 return nil 5895 } 5896 5897 // Returns a pointer to the underlying variant's property, if present. 5898 func (u messageCountTokensToolUnionParamConfigs) GetSwitchTab() *BrowserSwitchTabConfigParam { 5899 switch vt := u.any.(type) { 5900 case *BrowserToolsetConfigsParam: 5901 return &vt.SwitchTab 5902 } 5903 return nil 5904 } 5905 5906 // Returns a pointer to the underlying variant's property, if present. 5907 func (u messageCountTokensToolUnionParamConfigs) GetCursorPosition() *ComputerCursorPositionConfigParam { 5908 switch vt := u.any.(type) { 5909 case *ComputerToolsetConfigsParam: 5910 return &vt.CursorPosition 5911 } 5912 return nil 5913 } 5914 5915 // Returns a subunion which exports methods to access subproperties 5916 // 5917 // Or use AsAny() to get the underlying value 5918 func (u messageCountTokensToolUnionParamConfigs) GetDoubleClick() (res messageCountTokensToolUnionParamConfigsDoubleClick) { 5919 switch vt := u.any.(type) { 5920 case *BrowserToolsetConfigsParam: 5921 res.any = &vt.DoubleClick 5922 case *ComputerToolsetConfigsParam: 5923 res.any = &vt.DoubleClick 5924 } 5925 return res 5926 } 5927 5928 // Can have the runtime types [*BrowserDoubleClickConfigParam], 5929 // [*ComputerDoubleClickConfigParam] 5930 type messageCountTokensToolUnionParamConfigsDoubleClick struct{ any } 5931 5932 // Use the following switch statement to get the type of the union: 5933 // 5934 // switch u.AsAny().(type) { 5935 // case *anthropic.BrowserDoubleClickConfigParam: 5936 // case *anthropic.ComputerDoubleClickConfigParam: 5937 // default: 5938 // fmt.Errorf("not present") 5939 // } 5940 func (u messageCountTokensToolUnionParamConfigsDoubleClick) AsAny() any { return u.any } 5941 5942 // Returns a pointer to the underlying variant's property, if present. 5943 func (u messageCountTokensToolUnionParamConfigsDoubleClick) GetDeferLoading() *bool { 5944 switch vt := u.any.(type) { 5945 case *BrowserDoubleClickConfigParam: 5946 return paramutil.AddrIfPresent(vt.DeferLoading) 5947 case *ComputerDoubleClickConfigParam: 5948 return paramutil.AddrIfPresent(vt.DeferLoading) 5949 } 5950 return nil 5951 } 5952 5953 // Returns a pointer to the underlying variant's property, if present. 5954 func (u messageCountTokensToolUnionParamConfigsDoubleClick) GetEnabled() *bool { 5955 switch vt := u.any.(type) { 5956 case *BrowserDoubleClickConfigParam: 5957 return paramutil.AddrIfPresent(vt.Enabled) 5958 case *ComputerDoubleClickConfigParam: 5959 return paramutil.AddrIfPresent(vt.Enabled) 5960 } 5961 return nil 5962 } 5963 5964 // Returns a subunion which exports methods to access subproperties 5965 // 5966 // Or use AsAny() to get the underlying value 5967 func (u messageCountTokensToolUnionParamConfigs) GetHoldKey() (res messageCountTokensToolUnionParamConfigsHoldKey) { 5968 switch vt := u.any.(type) { 5969 case *BrowserToolsetConfigsParam: 5970 res.any = &vt.HoldKey 5971 case *ComputerToolsetConfigsParam: 5972 res.any = &vt.HoldKey 5973 } 5974 return res 5975 } 5976 5977 // Can have the runtime types [*BrowserHoldKeyConfigParam], 5978 // [*ComputerHoldKeyConfigParam] 5979 type messageCountTokensToolUnionParamConfigsHoldKey struct{ any } 5980 5981 // Use the following switch statement to get the type of the union: 5982 // 5983 // switch u.AsAny().(type) { 5984 // case *anthropic.BrowserHoldKeyConfigParam: 5985 // case *anthropic.ComputerHoldKeyConfigParam: 5986 // default: 5987 // fmt.Errorf("not present") 5988 // } 5989 func (u messageCountTokensToolUnionParamConfigsHoldKey) AsAny() any { return u.any } 5990 5991 // Returns a pointer to the underlying variant's property, if present. 5992 func (u messageCountTokensToolUnionParamConfigsHoldKey) GetDeferLoading() *bool { 5993 switch vt := u.any.(type) { 5994 case *BrowserHoldKeyConfigParam: 5995 return paramutil.AddrIfPresent(vt.DeferLoading) 5996 case *ComputerHoldKeyConfigParam: 5997 return paramutil.AddrIfPresent(vt.DeferLoading) 5998 } 5999 return nil 6000 } 6001 6002 // Returns a pointer to the underlying variant's property, if present. 6003 func (u messageCountTokensToolUnionParamConfigsHoldKey) GetEnabled() *bool { 6004 switch vt := u.any.(type) { 6005 case *BrowserHoldKeyConfigParam: 6006 return paramutil.AddrIfPresent(vt.Enabled) 6007 case *ComputerHoldKeyConfigParam: 6008 return paramutil.AddrIfPresent(vt.Enabled) 6009 } 6010 return nil 6011 } 6012 6013 // Returns a subunion which exports methods to access subproperties 6014 // 6015 // Or use AsAny() to get the underlying value 6016 func (u messageCountTokensToolUnionParamConfigs) GetKey() (res messageCountTokensToolUnionParamConfigsKey) { 6017 switch vt := u.any.(type) { 6018 case *BrowserToolsetConfigsParam: 6019 res.any = &vt.Key 6020 case *ComputerToolsetConfigsParam: 6021 res.any = &vt.Key 6022 } 6023 return res 6024 } 6025 6026 // Can have the runtime types [*BrowserKeyConfigParam], [*ComputerKeyConfigParam] 6027 type messageCountTokensToolUnionParamConfigsKey struct{ any } 6028 6029 // Use the following switch statement to get the type of the union: 6030 // 6031 // switch u.AsAny().(type) { 6032 // case *anthropic.BrowserKeyConfigParam: 6033 // case *anthropic.ComputerKeyConfigParam: 6034 // default: 6035 // fmt.Errorf("not present") 6036 // } 6037 func (u messageCountTokensToolUnionParamConfigsKey) AsAny() any { return u.any } 6038 6039 // Returns a pointer to the underlying variant's property, if present. 6040 func (u messageCountTokensToolUnionParamConfigsKey) GetDeferLoading() *bool { 6041 switch vt := u.any.(type) { 6042 case *BrowserKeyConfigParam: 6043 return paramutil.AddrIfPresent(vt.DeferLoading) 6044 case *ComputerKeyConfigParam: 6045 return paramutil.AddrIfPresent(vt.DeferLoading) 6046 } 6047 return nil 6048 } 6049 6050 // Returns a pointer to the underlying variant's property, if present. 6051 func (u messageCountTokensToolUnionParamConfigsKey) GetEnabled() *bool { 6052 switch vt := u.any.(type) { 6053 case *BrowserKeyConfigParam: 6054 return paramutil.AddrIfPresent(vt.Enabled) 6055 case *ComputerKeyConfigParam: 6056 return paramutil.AddrIfPresent(vt.Enabled) 6057 } 6058 return nil 6059 } 6060 6061 // Returns a subunion which exports methods to access subproperties 6062 // 6063 // Or use AsAny() to get the underlying value 6064 func (u messageCountTokensToolUnionParamConfigs) GetLeftClick() (res messageCountTokensToolUnionParamConfigsLeftClick) { 6065 switch vt := u.any.(type) { 6066 case *BrowserToolsetConfigsParam: 6067 res.any = &vt.LeftClick 6068 case *ComputerToolsetConfigsParam: 6069 res.any = &vt.LeftClick 6070 } 6071 return res 6072 } 6073 6074 // Can have the runtime types [*BrowserLeftClickConfigParam], 6075 // [*ComputerLeftClickConfigParam] 6076 type messageCountTokensToolUnionParamConfigsLeftClick struct{ any } 6077 6078 // Use the following switch statement to get the type of the union: 6079 // 6080 // switch u.AsAny().(type) { 6081 // case *anthropic.BrowserLeftClickConfigParam: 6082 // case *anthropic.ComputerLeftClickConfigParam: 6083 // default: 6084 // fmt.Errorf("not present") 6085 // } 6086 func (u messageCountTokensToolUnionParamConfigsLeftClick) AsAny() any { return u.any } 6087 6088 // Returns a pointer to the underlying variant's property, if present. 6089 func (u messageCountTokensToolUnionParamConfigsLeftClick) GetDeferLoading() *bool { 6090 switch vt := u.any.(type) { 6091 case *BrowserLeftClickConfigParam: 6092 return paramutil.AddrIfPresent(vt.DeferLoading) 6093 case *ComputerLeftClickConfigParam: 6094 return paramutil.AddrIfPresent(vt.DeferLoading) 6095 } 6096 return nil 6097 } 6098 6099 // Returns a pointer to the underlying variant's property, if present. 6100 func (u messageCountTokensToolUnionParamConfigsLeftClick) GetEnabled() *bool { 6101 switch vt := u.any.(type) { 6102 case *BrowserLeftClickConfigParam: 6103 return paramutil.AddrIfPresent(vt.Enabled) 6104 case *ComputerLeftClickConfigParam: 6105 return paramutil.AddrIfPresent(vt.Enabled) 6106 } 6107 return nil 6108 } 6109 6110 // Returns a subunion which exports methods to access subproperties 6111 // 6112 // Or use AsAny() to get the underlying value 6113 func (u messageCountTokensToolUnionParamConfigs) GetLeftClickDrag() (res messageCountTokensToolUnionParamConfigsLeftClickDrag) { 6114 switch vt := u.any.(type) { 6115 case *BrowserToolsetConfigsParam: 6116 res.any = &vt.LeftClickDrag 6117 case *ComputerToolsetConfigsParam: 6118 res.any = &vt.LeftClickDrag 6119 } 6120 return res 6121 } 6122 6123 // Can have the runtime types [*BrowserLeftClickDragConfigParam], 6124 // [*ComputerLeftClickDragConfigParam] 6125 type messageCountTokensToolUnionParamConfigsLeftClickDrag struct{ any } 6126 6127 // Use the following switch statement to get the type of the union: 6128 // 6129 // switch u.AsAny().(type) { 6130 // case *anthropic.BrowserLeftClickDragConfigParam: 6131 // case *anthropic.ComputerLeftClickDragConfigParam: 6132 // default: 6133 // fmt.Errorf("not present") 6134 // } 6135 func (u messageCountTokensToolUnionParamConfigsLeftClickDrag) AsAny() any { return u.any } 6136 6137 // Returns a pointer to the underlying variant's property, if present. 6138 func (u messageCountTokensToolUnionParamConfigsLeftClickDrag) GetDeferLoading() *bool { 6139 switch vt := u.any.(type) { 6140 case *BrowserLeftClickDragConfigParam: 6141 return paramutil.AddrIfPresent(vt.DeferLoading) 6142 case *ComputerLeftClickDragConfigParam: 6143 return paramutil.AddrIfPresent(vt.DeferLoading) 6144 } 6145 return nil 6146 } 6147 6148 // Returns a pointer to the underlying variant's property, if present. 6149 func (u messageCountTokensToolUnionParamConfigsLeftClickDrag) GetEnabled() *bool { 6150 switch vt := u.any.(type) { 6151 case *BrowserLeftClickDragConfigParam: 6152 return paramutil.AddrIfPresent(vt.Enabled) 6153 case *ComputerLeftClickDragConfigParam: 6154 return paramutil.AddrIfPresent(vt.Enabled) 6155 } 6156 return nil 6157 } 6158 6159 // Returns a subunion which exports methods to access subproperties 6160 // 6161 // Or use AsAny() to get the underlying value 6162 func (u messageCountTokensToolUnionParamConfigs) GetLeftMouseDown() (res messageCountTokensToolUnionParamConfigsLeftMouseDown) { 6163 switch vt := u.any.(type) { 6164 case *BrowserToolsetConfigsParam: 6165 res.any = &vt.LeftMouseDown 6166 case *ComputerToolsetConfigsParam: 6167 res.any = &vt.LeftMouseDown 6168 } 6169 return res 6170 } 6171 6172 // Can have the runtime types [*BrowserLeftMouseDownConfigParam], 6173 // [*ComputerLeftMouseDownConfigParam] 6174 type messageCountTokensToolUnionParamConfigsLeftMouseDown struct{ any } 6175 6176 // Use the following switch statement to get the type of the union: 6177 // 6178 // switch u.AsAny().(type) { 6179 // case *anthropic.BrowserLeftMouseDownConfigParam: 6180 // case *anthropic.ComputerLeftMouseDownConfigParam: 6181 // default: 6182 // fmt.Errorf("not present") 6183 // } 6184 func (u messageCountTokensToolUnionParamConfigsLeftMouseDown) AsAny() any { return u.any } 6185 6186 // Returns a pointer to the underlying variant's property, if present. 6187 func (u messageCountTokensToolUnionParamConfigsLeftMouseDown) GetDeferLoading() *bool { 6188 switch vt := u.any.(type) { 6189 case *BrowserLeftMouseDownConfigParam: 6190 return paramutil.AddrIfPresent(vt.DeferLoading) 6191 case *ComputerLeftMouseDownConfigParam: 6192 return paramutil.AddrIfPresent(vt.DeferLoading) 6193 } 6194 return nil 6195 } 6196 6197 // Returns a pointer to the underlying variant's property, if present. 6198 func (u messageCountTokensToolUnionParamConfigsLeftMouseDown) GetEnabled() *bool { 6199 switch vt := u.any.(type) { 6200 case *BrowserLeftMouseDownConfigParam: 6201 return paramutil.AddrIfPresent(vt.Enabled) 6202 case *ComputerLeftMouseDownConfigParam: 6203 return paramutil.AddrIfPresent(vt.Enabled) 6204 } 6205 return nil 6206 } 6207 6208 // Returns a subunion which exports methods to access subproperties 6209 // 6210 // Or use AsAny() to get the underlying value 6211 func (u messageCountTokensToolUnionParamConfigs) GetLeftMouseUp() (res messageCountTokensToolUnionParamConfigsLeftMouseUp) { 6212 switch vt := u.any.(type) { 6213 case *BrowserToolsetConfigsParam: 6214 res.any = &vt.LeftMouseUp 6215 case *ComputerToolsetConfigsParam: 6216 res.any = &vt.LeftMouseUp 6217 } 6218 return res 6219 } 6220 6221 // Can have the runtime types [*BrowserLeftMouseUpConfigParam], 6222 // [*ComputerLeftMouseUpConfigParam] 6223 type messageCountTokensToolUnionParamConfigsLeftMouseUp struct{ any } 6224 6225 // Use the following switch statement to get the type of the union: 6226 // 6227 // switch u.AsAny().(type) { 6228 // case *anthropic.BrowserLeftMouseUpConfigParam: 6229 // case *anthropic.ComputerLeftMouseUpConfigParam: 6230 // default: 6231 // fmt.Errorf("not present") 6232 // } 6233 func (u messageCountTokensToolUnionParamConfigsLeftMouseUp) AsAny() any { return u.any } 6234 6235 // Returns a pointer to the underlying variant's property, if present. 6236 func (u messageCountTokensToolUnionParamConfigsLeftMouseUp) GetDeferLoading() *bool { 6237 switch vt := u.any.(type) { 6238 case *BrowserLeftMouseUpConfigParam: 6239 return paramutil.AddrIfPresent(vt.DeferLoading) 6240 case *ComputerLeftMouseUpConfigParam: 6241 return paramutil.AddrIfPresent(vt.DeferLoading) 6242 } 6243 return nil 6244 } 6245 6246 // Returns a pointer to the underlying variant's property, if present. 6247 func (u messageCountTokensToolUnionParamConfigsLeftMouseUp) GetEnabled() *bool { 6248 switch vt := u.any.(type) { 6249 case *BrowserLeftMouseUpConfigParam: 6250 return paramutil.AddrIfPresent(vt.Enabled) 6251 case *ComputerLeftMouseUpConfigParam: 6252 return paramutil.AddrIfPresent(vt.Enabled) 6253 } 6254 return nil 6255 } 6256 6257 // Returns a subunion which exports methods to access subproperties 6258 // 6259 // Or use AsAny() to get the underlying value 6260 func (u messageCountTokensToolUnionParamConfigs) GetMiddleClick() (res messageCountTokensToolUnionParamConfigsMiddleClick) { 6261 switch vt := u.any.(type) { 6262 case *BrowserToolsetConfigsParam: 6263 res.any = &vt.MiddleClick 6264 case *ComputerToolsetConfigsParam: 6265 res.any = &vt.MiddleClick 6266 } 6267 return res 6268 } 6269 6270 // Can have the runtime types [*BrowserMiddleClickConfigParam], 6271 // [*ComputerMiddleClickConfigParam] 6272 type messageCountTokensToolUnionParamConfigsMiddleClick struct{ any } 6273 6274 // Use the following switch statement to get the type of the union: 6275 // 6276 // switch u.AsAny().(type) { 6277 // case *anthropic.BrowserMiddleClickConfigParam: 6278 // case *anthropic.ComputerMiddleClickConfigParam: 6279 // default: 6280 // fmt.Errorf("not present") 6281 // } 6282 func (u messageCountTokensToolUnionParamConfigsMiddleClick) AsAny() any { return u.any } 6283 6284 // Returns a pointer to the underlying variant's property, if present. 6285 func (u messageCountTokensToolUnionParamConfigsMiddleClick) GetDeferLoading() *bool { 6286 switch vt := u.any.(type) { 6287 case *BrowserMiddleClickConfigParam: 6288 return paramutil.AddrIfPresent(vt.DeferLoading) 6289 case *ComputerMiddleClickConfigParam: 6290 return paramutil.AddrIfPresent(vt.DeferLoading) 6291 } 6292 return nil 6293 } 6294 6295 // Returns a pointer to the underlying variant's property, if present. 6296 func (u messageCountTokensToolUnionParamConfigsMiddleClick) GetEnabled() *bool { 6297 switch vt := u.any.(type) { 6298 case *BrowserMiddleClickConfigParam: 6299 return paramutil.AddrIfPresent(vt.Enabled) 6300 case *ComputerMiddleClickConfigParam: 6301 return paramutil.AddrIfPresent(vt.Enabled) 6302 } 6303 return nil 6304 } 6305 6306 // Returns a subunion which exports methods to access subproperties 6307 // 6308 // Or use AsAny() to get the underlying value 6309 func (u messageCountTokensToolUnionParamConfigs) GetMouseMove() (res messageCountTokensToolUnionParamConfigsMouseMove) { 6310 switch vt := u.any.(type) { 6311 case *BrowserToolsetConfigsParam: 6312 res.any = &vt.MouseMove 6313 case *ComputerToolsetConfigsParam: 6314 res.any = &vt.MouseMove 6315 } 6316 return res 6317 } 6318 6319 // Can have the runtime types [*BrowserMouseMoveConfigParam], 6320 // [*ComputerMouseMoveConfigParam] 6321 type messageCountTokensToolUnionParamConfigsMouseMove struct{ any } 6322 6323 // Use the following switch statement to get the type of the union: 6324 // 6325 // switch u.AsAny().(type) { 6326 // case *anthropic.BrowserMouseMoveConfigParam: 6327 // case *anthropic.ComputerMouseMoveConfigParam: 6328 // default: 6329 // fmt.Errorf("not present") 6330 // } 6331 func (u messageCountTokensToolUnionParamConfigsMouseMove) AsAny() any { return u.any } 6332 6333 // Returns a pointer to the underlying variant's property, if present. 6334 func (u messageCountTokensToolUnionParamConfigsMouseMove) GetDeferLoading() *bool { 6335 switch vt := u.any.(type) { 6336 case *BrowserMouseMoveConfigParam: 6337 return paramutil.AddrIfPresent(vt.DeferLoading) 6338 case *ComputerMouseMoveConfigParam: 6339 return paramutil.AddrIfPresent(vt.DeferLoading) 6340 } 6341 return nil 6342 } 6343 6344 // Returns a pointer to the underlying variant's property, if present. 6345 func (u messageCountTokensToolUnionParamConfigsMouseMove) GetEnabled() *bool { 6346 switch vt := u.any.(type) { 6347 case *BrowserMouseMoveConfigParam: 6348 return paramutil.AddrIfPresent(vt.Enabled) 6349 case *ComputerMouseMoveConfigParam: 6350 return paramutil.AddrIfPresent(vt.Enabled) 6351 } 6352 return nil 6353 } 6354 6355 // Returns a subunion which exports methods to access subproperties 6356 // 6357 // Or use AsAny() to get the underlying value 6358 func (u messageCountTokensToolUnionParamConfigs) GetRightClick() (res messageCountTokensToolUnionParamConfigsRightClick) { 6359 switch vt := u.any.(type) { 6360 case *BrowserToolsetConfigsParam: 6361 res.any = &vt.RightClick 6362 case *ComputerToolsetConfigsParam: 6363 res.any = &vt.RightClick 6364 } 6365 return res 6366 } 6367 6368 // Can have the runtime types [*BrowserRightClickConfigParam], 6369 // [*ComputerRightClickConfigParam] 6370 type messageCountTokensToolUnionParamConfigsRightClick struct{ any } 6371 6372 // Use the following switch statement to get the type of the union: 6373 // 6374 // switch u.AsAny().(type) { 6375 // case *anthropic.BrowserRightClickConfigParam: 6376 // case *anthropic.ComputerRightClickConfigParam: 6377 // default: 6378 // fmt.Errorf("not present") 6379 // } 6380 func (u messageCountTokensToolUnionParamConfigsRightClick) AsAny() any { return u.any } 6381 6382 // Returns a pointer to the underlying variant's property, if present. 6383 func (u messageCountTokensToolUnionParamConfigsRightClick) GetDeferLoading() *bool { 6384 switch vt := u.any.(type) { 6385 case *BrowserRightClickConfigParam: 6386 return paramutil.AddrIfPresent(vt.DeferLoading) 6387 case *ComputerRightClickConfigParam: 6388 return paramutil.AddrIfPresent(vt.DeferLoading) 6389 } 6390 return nil 6391 } 6392 6393 // Returns a pointer to the underlying variant's property, if present. 6394 func (u messageCountTokensToolUnionParamConfigsRightClick) GetEnabled() *bool { 6395 switch vt := u.any.(type) { 6396 case *BrowserRightClickConfigParam: 6397 return paramutil.AddrIfPresent(vt.Enabled) 6398 case *ComputerRightClickConfigParam: 6399 return paramutil.AddrIfPresent(vt.Enabled) 6400 } 6401 return nil 6402 } 6403 6404 // Returns a subunion which exports methods to access subproperties 6405 // 6406 // Or use AsAny() to get the underlying value 6407 func (u messageCountTokensToolUnionParamConfigs) GetScreenshot() (res messageCountTokensToolUnionParamConfigsScreenshot) { 6408 switch vt := u.any.(type) { 6409 case *BrowserToolsetConfigsParam: 6410 res.any = &vt.Screenshot 6411 case *ComputerToolsetConfigsParam: 6412 res.any = &vt.Screenshot 6413 } 6414 return res 6415 } 6416 6417 // Can have the runtime types [*BrowserScreenshotConfigParam], 6418 // [*ComputerScreenshotConfigParam] 6419 type messageCountTokensToolUnionParamConfigsScreenshot struct{ any } 6420 6421 // Use the following switch statement to get the type of the union: 6422 // 6423 // switch u.AsAny().(type) { 6424 // case *anthropic.BrowserScreenshotConfigParam: 6425 // case *anthropic.ComputerScreenshotConfigParam: 6426 // default: 6427 // fmt.Errorf("not present") 6428 // } 6429 func (u messageCountTokensToolUnionParamConfigsScreenshot) AsAny() any { return u.any } 6430 6431 // Returns a pointer to the underlying variant's property, if present. 6432 func (u messageCountTokensToolUnionParamConfigsScreenshot) GetDeferLoading() *bool { 6433 switch vt := u.any.(type) { 6434 case *BrowserScreenshotConfigParam: 6435 return paramutil.AddrIfPresent(vt.DeferLoading) 6436 case *ComputerScreenshotConfigParam: 6437 return paramutil.AddrIfPresent(vt.DeferLoading) 6438 } 6439 return nil 6440 } 6441 6442 // Returns a pointer to the underlying variant's property, if present. 6443 func (u messageCountTokensToolUnionParamConfigsScreenshot) GetEnabled() *bool { 6444 switch vt := u.any.(type) { 6445 case *BrowserScreenshotConfigParam: 6446 return paramutil.AddrIfPresent(vt.Enabled) 6447 case *ComputerScreenshotConfigParam: 6448 return paramutil.AddrIfPresent(vt.Enabled) 6449 } 6450 return nil 6451 } 6452 6453 // Returns a subunion which exports methods to access subproperties 6454 // 6455 // Or use AsAny() to get the underlying value 6456 func (u messageCountTokensToolUnionParamConfigs) GetScroll() (res messageCountTokensToolUnionParamConfigsScroll) { 6457 switch vt := u.any.(type) { 6458 case *BrowserToolsetConfigsParam: 6459 res.any = &vt.Scroll 6460 case *ComputerToolsetConfigsParam: 6461 res.any = &vt.Scroll 6462 } 6463 return res 6464 } 6465 6466 // Can have the runtime types [*BrowserScrollConfigParam], 6467 // [*ComputerScrollConfigParam] 6468 type messageCountTokensToolUnionParamConfigsScroll struct{ any } 6469 6470 // Use the following switch statement to get the type of the union: 6471 // 6472 // switch u.AsAny().(type) { 6473 // case *anthropic.BrowserScrollConfigParam: 6474 // case *anthropic.ComputerScrollConfigParam: 6475 // default: 6476 // fmt.Errorf("not present") 6477 // } 6478 func (u messageCountTokensToolUnionParamConfigsScroll) AsAny() any { return u.any } 6479 6480 // Returns a pointer to the underlying variant's property, if present. 6481 func (u messageCountTokensToolUnionParamConfigsScroll) GetDeferLoading() *bool { 6482 switch vt := u.any.(type) { 6483 case *BrowserScrollConfigParam: 6484 return paramutil.AddrIfPresent(vt.DeferLoading) 6485 case *ComputerScrollConfigParam: 6486 return paramutil.AddrIfPresent(vt.DeferLoading) 6487 } 6488 return nil 6489 } 6490 6491 // Returns a pointer to the underlying variant's property, if present. 6492 func (u messageCountTokensToolUnionParamConfigsScroll) GetEnabled() *bool { 6493 switch vt := u.any.(type) { 6494 case *BrowserScrollConfigParam: 6495 return paramutil.AddrIfPresent(vt.Enabled) 6496 case *ComputerScrollConfigParam: 6497 return paramutil.AddrIfPresent(vt.Enabled) 6498 } 6499 return nil 6500 } 6501 6502 // Returns a subunion which exports methods to access subproperties 6503 // 6504 // Or use AsAny() to get the underlying value 6505 func (u messageCountTokensToolUnionParamConfigs) GetTripleClick() (res messageCountTokensToolUnionParamConfigsTripleClick) { 6506 switch vt := u.any.(type) { 6507 case *BrowserToolsetConfigsParam: 6508 res.any = &vt.TripleClick 6509 case *ComputerToolsetConfigsParam: 6510 res.any = &vt.TripleClick 6511 } 6512 return res 6513 } 6514 6515 // Can have the runtime types [*BrowserTripleClickConfigParam], 6516 // [*ComputerTripleClickConfigParam] 6517 type messageCountTokensToolUnionParamConfigsTripleClick struct{ any } 6518 6519 // Use the following switch statement to get the type of the union: 6520 // 6521 // switch u.AsAny().(type) { 6522 // case *anthropic.BrowserTripleClickConfigParam: 6523 // case *anthropic.ComputerTripleClickConfigParam: 6524 // default: 6525 // fmt.Errorf("not present") 6526 // } 6527 func (u messageCountTokensToolUnionParamConfigsTripleClick) AsAny() any { return u.any } 6528 6529 // Returns a pointer to the underlying variant's property, if present. 6530 func (u messageCountTokensToolUnionParamConfigsTripleClick) GetDeferLoading() *bool { 6531 switch vt := u.any.(type) { 6532 case *BrowserTripleClickConfigParam: 6533 return paramutil.AddrIfPresent(vt.DeferLoading) 6534 case *ComputerTripleClickConfigParam: 6535 return paramutil.AddrIfPresent(vt.DeferLoading) 6536 } 6537 return nil 6538 } 6539 6540 // Returns a pointer to the underlying variant's property, if present. 6541 func (u messageCountTokensToolUnionParamConfigsTripleClick) GetEnabled() *bool { 6542 switch vt := u.any.(type) { 6543 case *BrowserTripleClickConfigParam: 6544 return paramutil.AddrIfPresent(vt.Enabled) 6545 case *ComputerTripleClickConfigParam: 6546 return paramutil.AddrIfPresent(vt.Enabled) 6547 } 6548 return nil 6549 } 6550 6551 // Returns a subunion which exports methods to access subproperties 6552 // 6553 // Or use AsAny() to get the underlying value 6554 func (u messageCountTokensToolUnionParamConfigs) GetType() (res messageCountTokensToolUnionParamConfigsType) { 6555 switch vt := u.any.(type) { 6556 case *BrowserToolsetConfigsParam: 6557 res.any = &vt.Type 6558 case *ComputerToolsetConfigsParam: 6559 res.any = &vt.Type 6560 } 6561 return res 6562 } 6563 6564 // Can have the runtime types [*BrowserTypeConfigParam], [*ComputerTypeConfigParam] 6565 type messageCountTokensToolUnionParamConfigsType struct{ any } 6566 6567 // Use the following switch statement to get the type of the union: 6568 // 6569 // switch u.AsAny().(type) { 6570 // case *anthropic.BrowserTypeConfigParam: 6571 // case *anthropic.ComputerTypeConfigParam: 6572 // default: 6573 // fmt.Errorf("not present") 6574 // } 6575 func (u messageCountTokensToolUnionParamConfigsType) AsAny() any { return u.any } 6576 6577 // Returns a pointer to the underlying variant's property, if present. 6578 func (u messageCountTokensToolUnionParamConfigsType) GetDeferLoading() *bool { 6579 switch vt := u.any.(type) { 6580 case *BrowserTypeConfigParam: 6581 return paramutil.AddrIfPresent(vt.DeferLoading) 6582 case *ComputerTypeConfigParam: 6583 return paramutil.AddrIfPresent(vt.DeferLoading) 6584 } 6585 return nil 6586 } 6587 6588 // Returns a pointer to the underlying variant's property, if present. 6589 func (u messageCountTokensToolUnionParamConfigsType) GetEnabled() *bool { 6590 switch vt := u.any.(type) { 6591 case *BrowserTypeConfigParam: 6592 return paramutil.AddrIfPresent(vt.Enabled) 6593 case *ComputerTypeConfigParam: 6594 return paramutil.AddrIfPresent(vt.Enabled) 6595 } 6596 return nil 6597 } 6598 6599 // Returns a subunion which exports methods to access subproperties 6600 // 6601 // Or use AsAny() to get the underlying value 6602 func (u messageCountTokensToolUnionParamConfigs) GetWait() (res messageCountTokensToolUnionParamConfigsWait) { 6603 switch vt := u.any.(type) { 6604 case *BrowserToolsetConfigsParam: 6605 res.any = &vt.Wait 6606 case *ComputerToolsetConfigsParam: 6607 res.any = &vt.Wait 6608 } 6609 return res 6610 } 6611 6612 // Can have the runtime types [*BrowserWaitConfigParam], [*ComputerWaitConfigParam] 6613 type messageCountTokensToolUnionParamConfigsWait struct{ any } 6614 6615 // Use the following switch statement to get the type of the union: 6616 // 6617 // switch u.AsAny().(type) { 6618 // case *anthropic.BrowserWaitConfigParam: 6619 // case *anthropic.ComputerWaitConfigParam: 6620 // default: 6621 // fmt.Errorf("not present") 6622 // } 6623 func (u messageCountTokensToolUnionParamConfigsWait) AsAny() any { return u.any } 6624 6625 // Returns a pointer to the underlying variant's property, if present. 6626 func (u messageCountTokensToolUnionParamConfigsWait) GetDeferLoading() *bool { 6627 switch vt := u.any.(type) { 6628 case *BrowserWaitConfigParam: 6629 return paramutil.AddrIfPresent(vt.DeferLoading) 6630 case *ComputerWaitConfigParam: 6631 return paramutil.AddrIfPresent(vt.DeferLoading) 6632 } 6633 return nil 6634 } 6635 6636 // Returns a pointer to the underlying variant's property, if present. 6637 func (u messageCountTokensToolUnionParamConfigsWait) GetEnabled() *bool { 6638 switch vt := u.any.(type) { 6639 case *BrowserWaitConfigParam: 6640 return paramutil.AddrIfPresent(vt.Enabled) 6641 case *ComputerWaitConfigParam: 6642 return paramutil.AddrIfPresent(vt.Enabled) 6643 } 6644 return nil 6645 } 6646 6647 // Returns a subunion which exports methods to access subproperties 6648 // 6649 // Or use AsAny() to get the underlying value 6650 func (u messageCountTokensToolUnionParamConfigs) GetZoom() (res messageCountTokensToolUnionParamConfigsZoom) { 6651 switch vt := u.any.(type) { 6652 case *BrowserToolsetConfigsParam: 6653 res.any = &vt.Zoom 6654 case *ComputerToolsetConfigsParam: 6655 res.any = &vt.Zoom 6656 } 6657 return res 6658 } 6659 6660 // Can have the runtime types [*BrowserZoomConfigParam], [*ComputerZoomConfigParam] 6661 type messageCountTokensToolUnionParamConfigsZoom struct{ any } 6662 6663 // Use the following switch statement to get the type of the union: 6664 // 6665 // switch u.AsAny().(type) { 6666 // case *anthropic.BrowserZoomConfigParam: 6667 // case *anthropic.ComputerZoomConfigParam: 6668 // default: 6669 // fmt.Errorf("not present") 6670 // } 6671 func (u messageCountTokensToolUnionParamConfigsZoom) AsAny() any { return u.any } 6672 6673 // Returns a pointer to the underlying variant's property, if present. 6674 func (u messageCountTokensToolUnionParamConfigsZoom) GetDeferLoading() *bool { 6675 switch vt := u.any.(type) { 6676 case *BrowserZoomConfigParam: 6677 return paramutil.AddrIfPresent(vt.DeferLoading) 6678 case *ComputerZoomConfigParam: 6679 return paramutil.AddrIfPresent(vt.DeferLoading) 6680 } 6681 return nil 6682 } 6683 6684 // Returns a pointer to the underlying variant's property, if present. 6685 func (u messageCountTokensToolUnionParamConfigsZoom) GetEnabled() *bool { 6686 switch vt := u.any.(type) { 6687 case *BrowserZoomConfigParam: 6688 return paramutil.AddrIfPresent(vt.Enabled) 6689 case *ComputerZoomConfigParam: 6690 return paramutil.AddrIfPresent(vt.Enabled) 6691 } 6692 return nil 6693 } 6694 6695 // Returns a pointer to the underlying variant's AllowedDomains property, if 6696 // present. 6697 func (u MessageCountTokensToolUnionParam) GetAllowedDomains() []string { 6698 if vt := u.OfWebSearchTool20250305; vt != nil { 6699 return vt.AllowedDomains 6700 } else if vt := u.OfWebFetchTool20250910; vt != nil { 6701 return vt.AllowedDomains 6702 } else if vt := u.OfWebSearchTool20260209; vt != nil { 6703 return vt.AllowedDomains 6704 } else if vt := u.OfWebFetchTool20260209; vt != nil { 6705 return vt.AllowedDomains 6706 } else if vt := u.OfWebFetchTool20260309; vt != nil { 6707 return vt.AllowedDomains 6708 } else if vt := u.OfWebSearchTool20260318; vt != nil { 6709 return vt.AllowedDomains 6710 } else if vt := u.OfWebFetchTool20260318; vt != nil { 6711 return vt.AllowedDomains 6712 } 6713 return nil 6714 } 6715 6716 // Returns a pointer to the underlying variant's BlockedDomains property, if 6717 // present. 6718 func (u MessageCountTokensToolUnionParam) GetBlockedDomains() []string { 6719 if vt := u.OfWebSearchTool20250305; vt != nil { 6720 return vt.BlockedDomains 6721 } else if vt := u.OfWebFetchTool20250910; vt != nil { 6722 return vt.BlockedDomains 6723 } else if vt := u.OfWebSearchTool20260209; vt != nil { 6724 return vt.BlockedDomains 6725 } else if vt := u.OfWebFetchTool20260209; vt != nil { 6726 return vt.BlockedDomains 6727 } else if vt := u.OfWebFetchTool20260309; vt != nil { 6728 return vt.BlockedDomains 6729 } else if vt := u.OfWebSearchTool20260318; vt != nil { 6730 return vt.BlockedDomains 6731 } else if vt := u.OfWebFetchTool20260318; vt != nil { 6732 return vt.BlockedDomains 6733 } 6734 return nil 6735 } 6736 6737 // Returns a pointer to the underlying variant's UserLocation property, if present. 6738 func (u MessageCountTokensToolUnionParam) GetUserLocation() *UserLocationParam { 6739 if vt := u.OfWebSearchTool20250305; vt != nil { 6740 return &vt.UserLocation 6741 } else if vt := u.OfWebSearchTool20260209; vt != nil { 6742 return &vt.UserLocation 6743 } else if vt := u.OfWebSearchTool20260318; vt != nil { 6744 return &vt.UserLocation 6745 } 6746 return nil 6747 } 6748 6749 // Returns a pointer to the underlying variant's Citations property, if present. 6750 func (u MessageCountTokensToolUnionParam) GetCitations() *CitationsConfigParam { 6751 if vt := u.OfWebFetchTool20250910; vt != nil { 6752 return &vt.Citations 6753 } else if vt := u.OfWebFetchTool20260209; vt != nil { 6754 return &vt.Citations 6755 } else if vt := u.OfWebFetchTool20260309; vt != nil { 6756 return &vt.Citations 6757 } else if vt := u.OfWebFetchTool20260318; vt != nil { 6758 return &vt.Citations 6759 } 6760 return nil 6761 } 6762 6763 // Only one field can be non-zero. 6764 // 6765 // Use [param.IsOmitted] to confirm if a field is set. 6766 type MessageCreateParamsContainerUnion struct { 6767 OfContainers *ContainerParams `json:",omitzero,inline"` 6768 OfString param.Opt[string] `json:",omitzero,inline"` 6769 paramUnion 6770 } 6771 6772 func (u MessageCreateParamsContainerUnion) MarshalJSON() ([]byte, error) { 6773 return param.MarshalUnion(u, u.OfContainers, u.OfString) 6774 } 6775 func (u *MessageCreateParamsContainerUnion) UnmarshalJSON(data []byte) error { 6776 return apijson.UnmarshalRoot(data, u) 6777 } 6778 6779 func (u *MessageCreateParamsContainerUnion) asAny() any { 6780 if !param.IsOmitted(u.OfContainers) { 6781 return u.OfContainers 6782 } else if !param.IsOmitted(u.OfString) { 6783 return &u.OfString.Value 6784 } 6785 return nil 6786 } 6787 6788 type MessageDeltaUsage struct { 6789 // The cumulative number of input tokens used to create the cache entry. 6790 CacheCreationInputTokens int64 `json:"cache_creation_input_tokens" api:"required"` 6791 // The cumulative number of input tokens read from the cache. 6792 CacheReadInputTokens int64 `json:"cache_read_input_tokens" api:"required"` 6793 // The cumulative number of input tokens which were used. 6794 InputTokens int64 `json:"input_tokens" api:"required"` 6795 // The cumulative number of output tokens which were used. 6796 OutputTokens int64 `json:"output_tokens" api:"required"` 6797 // Breakdown of output tokens by category. 6798 // 6799 // `output_tokens` remains the inclusive, authoritative total used for billing. 6800 // This object provides a read-only decomposition for observability — for example, 6801 // how many of the billed output tokens were spent on internal reasoning that may 6802 // have been summarized before being returned to you. 6803 OutputTokensDetails OutputTokensDetails `json:"output_tokens_details" api:"required"` 6804 // The number of server tool requests. 6805 ServerToolUse ServerToolUsage `json:"server_tool_use" api:"required"` 6806 // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. 6807 JSON struct { 6808 CacheCreationInputTokens respjson.Field 6809 CacheReadInputTokens respjson.Field 6810 InputTokens respjson.Field 6811 OutputTokens respjson.Field 6812 OutputTokensDetails respjson.Field 6813 ServerToolUse respjson.Field 6814 ExtraFields map[string]respjson.Field 6815 raw string 6816 } `json:"-"` 6817 } 6818 6819 // Returns the unmodified JSON received from the API 6820 func (r MessageDeltaUsage) RawJSON() string { return r.JSON.raw } 6821 func (r *MessageDeltaUsage) UnmarshalJSON(data []byte) error { 6822 return apijson.UnmarshalRoot(data, r) 6823 } 6824 6825 // The properties Content, Role are required. 6826 type MessageParam struct { 6827 Content []ContentBlockParamUnion `json:"content,omitzero" api:"required"` 6828 // Any of "user", "assistant", "system". 6829 Role MessageParamRole `json:"role,omitzero" api:"required"` 6830 paramObj 6831 } 6832 6833 func NewUserMessage(blocks ...ContentBlockParamUnion) MessageParam { 6834 return MessageParam{ 6835 Role: MessageParamRoleUser, 6836 Content: blocks, 6837 } 6838 } 6839 6840 func NewAssistantMessage(blocks ...ContentBlockParamUnion) MessageParam { 6841 return MessageParam{ 6842 Role: MessageParamRoleAssistant, 6843 Content: blocks, 6844 } 6845 } 6846 6847 func (r MessageParam) MarshalJSON() (data []byte, err error) { 6848 type shadow MessageParam 6849 return param.MarshalObject(r, (*shadow)(&r)) 6850 } 6851 func (r *MessageParam) UnmarshalJSON(data []byte) error { 6852 return apijson.UnmarshalRoot(data, r) 6853 } 6854 6855 type MessageParamRole string 6856 6857 const ( 6858 MessageParamRoleUser MessageParamRole = "user" 6859 MessageParamRoleAssistant MessageParamRole = "assistant" 6860 MessageParamRoleSystem MessageParamRole = "system" 6861 ) 6862 6863 type MessageTokensCount struct { 6864 // The total number of tokens across the provided list of messages, system prompt, 6865 // and tools. 6866 InputTokens int64 `json:"input_tokens" api:"required"` 6867 // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. 6868 JSON struct { 6869 InputTokens respjson.Field 6870 ExtraFields map[string]respjson.Field 6871 raw string 6872 } `json:"-"` 6873 } 6874 6875 // Returns the unmodified JSON received from the API 6876 func (r MessageTokensCount) RawJSON() string { return r.JSON.raw } 6877 func (r *MessageTokensCount) UnmarshalJSON(data []byte) error { 6878 return apijson.UnmarshalRoot(data, r) 6879 } 6880 6881 type MetadataParam struct { 6882 // An external identifier for the user who is associated with the request. 6883 // 6884 // This should be a uuid, hash value, or other opaque identifier. Anthropic may use 6885 // this id to help detect abuse. Do not include any identifying information such as 6886 // name, email address, or phone number. 6887 UserID param.Opt[string] `json:"user_id,omitzero"` 6888 paramObj 6889 } 6890 6891 func (r MetadataParam) MarshalJSON() (data []byte, err error) { 6892 type shadow MetadataParam 6893 return param.MarshalObject(r, (*shadow)(&r)) 6894 } 6895 func (r *MetadataParam) UnmarshalJSON(data []byte) error { 6896 return apijson.UnmarshalRoot(data, r) 6897 } 6898 6899 // The model that will complete your prompt. 6900 // 6901 // See [models](https://docs.anthropic.com/en/docs/models-overview) for additional 6902 // details and options. 6903 type Model = string 6904 6905 const ( 6906 ModelClaudeFable5_1 Model = "claude-fable-5-1" 6907 ModelClaudeMythos5_1 Model = "claude-mythos-5-1" 6908 ModelClaudeSonnet5 Model = "claude-sonnet-5" 6909 ModelClaudeFable5 Model = "claude-fable-5" 6910 ModelClaudeMythos5 Model = "claude-mythos-5" 6911 ModelClaudeOpus5 Model = "claude-opus-5" 6912 ModelClaudeOpus4_8 Model = "claude-opus-4-8" 6913 ModelClaudeOpus4_7 Model = "claude-opus-4-7" 6914 // Deprecated: Will reach end-of-life on June 30, 2026. Please migrate to 6915 // claude-mythos-5. Visit 6916 // https://docs.anthropic.com/en/docs/resources/model-deprecations for more 6917 // information. 6918 ModelClaudeMythosPreview Model = "claude-mythos-preview" 6919 ModelClaudeOpus4_6 Model = "claude-opus-4-6" 6920 ModelClaudeSonnet4_6 Model = "claude-sonnet-4-6" 6921 ModelClaudeHaiku4_5 Model = "claude-haiku-4-5" 6922 ModelClaudeHaiku4_5_20251001 Model = "claude-haiku-4-5-20251001" 6923 ModelClaudeOpus4_5 Model = "claude-opus-4-5" 6924 ModelClaudeOpus4_5_20251101 Model = "claude-opus-4-5-20251101" 6925 ModelClaudeSonnet4_5 Model = "claude-sonnet-4-5" 6926 ModelClaudeSonnet4_5_20250929 Model = "claude-sonnet-4-5-20250929" 6927 ) 6928 6929 type OutputConfigParam struct { 6930 // All possible effort levels. 6931 // 6932 // Any of "low", "medium", "high", "xhigh", "max". 6933 Effort OutputConfigEffort `json:"effort,omitzero"` 6934 // A schema to specify Claude's output format in responses. See 6935 // [structured outputs](https://platform.claude.com/docs/en/build-with-claude/structured-outputs) 6936 Format JSONOutputFormatParam `json:"format,omitzero"` 6937 paramObj 6938 } 6939 6940 func (r OutputConfigParam) MarshalJSON() (data []byte, err error) { 6941 type shadow OutputConfigParam 6942 return param.MarshalObject(r, (*shadow)(&r)) 6943 } 6944 func (r *OutputConfigParam) UnmarshalJSON(data []byte) error { 6945 return apijson.UnmarshalRoot(data, r) 6946 } 6947 6948 // All possible effort levels. 6949 type OutputConfigEffort string 6950 6951 const ( 6952 OutputConfigEffortLow OutputConfigEffort = "low" 6953 OutputConfigEffortMedium OutputConfigEffort = "medium" 6954 OutputConfigEffortHigh OutputConfigEffort = "high" 6955 OutputConfigEffortXhigh OutputConfigEffort = "xhigh" 6956 OutputConfigEffortMax OutputConfigEffort = "max" 6957 ) 6958 6959 type OutputTokensDetails struct { 6960 // Number of output tokens the model generated as internal reasoning, including the 6961 // thinking-block delimiter tokens. 6962 // 6963 // Reflects the raw reasoning the model produced, not the (possibly shorter) 6964 // summarized thinking text returned in the response body. Computed by 6965 // re-tokenizing the raw reasoning text, so it may differ from the model's exact 6966 // generation count by a small number of tokens. Always ≤ `output_tokens`; 6967 // `output_tokens - thinking_tokens` approximates the non-reasoning output. 6968 ThinkingTokens int64 `json:"thinking_tokens" api:"required"` 6969 // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. 6970 JSON struct { 6971 ThinkingTokens respjson.Field 6972 ExtraFields map[string]respjson.Field 6973 raw string 6974 } `json:"-"` 6975 } 6976 6977 // Returns the unmodified JSON received from the API 6978 func (r OutputTokensDetails) RawJSON() string { return r.JSON.raw } 6979 func (r *OutputTokensDetails) UnmarshalJSON(data []byte) error { 6980 return apijson.UnmarshalRoot(data, r) 6981 } 6982 6983 type PlainTextSource struct { 6984 Data string `json:"data" api:"required"` 6985 MediaType constant.TextPlain `json:"media_type" default:"text/plain"` 6986 Type constant.Text `json:"type" default:"text"` 6987 // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. 6988 JSON struct { 6989 Data respjson.Field 6990 MediaType respjson.Field 6991 Type respjson.Field 6992 ExtraFields map[string]respjson.Field 6993 raw string 6994 } `json:"-"` 6995 } 6996 6997 // Returns the unmodified JSON received from the API 6998 func (r PlainTextSource) RawJSON() string { return r.JSON.raw } 6999 func (r *PlainTextSource) UnmarshalJSON(data []byte) error { 7000 return apijson.UnmarshalRoot(data, r) 7001 } 7002 7003 // ToParam converts this PlainTextSource to a PlainTextSourceParam. 7004 // 7005 // Warning: the fields of the param type will not be present. ToParam should only 7006 // be used at the last possible moment before sending a request. Test for this with 7007 // PlainTextSourceParam.Overrides() 7008 func (r PlainTextSource) ToParam() PlainTextSourceParam { 7009 return param.Override[PlainTextSourceParam](json.RawMessage(r.RawJSON())) 7010 } 7011 7012 // The properties Data, MediaType, Type are required. 7013 type PlainTextSourceParam struct { 7014 Data string `json:"data" api:"required"` 7015 // This field can be elided, and will marshal its zero value as "text/plain". 7016 MediaType constant.TextPlain `json:"media_type" default:"text/plain"` 7017 // This field can be elided, and will marshal its zero value as "text". 7018 Type constant.Text `json:"type" default:"text"` 7019 paramObj 7020 } 7021 7022 func (r PlainTextSourceParam) MarshalJSON() (data []byte, err error) { 7023 type shadow PlainTextSourceParam 7024 return param.MarshalObject(r, (*shadow)(&r)) 7025 } 7026 func (r *PlainTextSourceParam) UnmarshalJSON(data []byte) error { 7027 return apijson.UnmarshalRoot(data, r) 7028 } 7029 7030 // RawContentBlockDeltaUnion contains all possible properties and values from 7031 // [TextDelta], [InputJSONDelta], [CitationsDelta], [ThinkingDelta], 7032 // [SignatureDelta]. 7033 // 7034 // Use the [RawContentBlockDeltaUnion.AsAny] method to switch on the variant. 7035 // 7036 // Use the methods beginning with 'As' to cast the union to one of its variants. 7037 type RawContentBlockDeltaUnion struct { 7038 // This field is from variant [TextDelta]. 7039 Text string `json:"text"` 7040 // Any of "text_delta", "input_json_delta", "citations_delta", "thinking_delta", 7041 // "signature_delta". 7042 Type string `json:"type"` 7043 // This field is from variant [InputJSONDelta]. 7044 PartialJSON string `json:"partial_json"` 7045 // This field is from variant [CitationsDelta]. 7046 Citation CitationsDeltaCitationUnion `json:"citation"` 7047 // This field is from variant [ThinkingDelta]. 7048 Thinking string `json:"thinking"` 7049 // This field is from variant [SignatureDelta]. 7050 Signature string `json:"signature"` 7051 JSON struct { 7052 Text respjson.Field 7053 Type respjson.Field 7054 PartialJSON respjson.Field 7055 Citation respjson.Field 7056 Thinking respjson.Field 7057 Signature respjson.Field 7058 raw string 7059 } `json:"-"` 7060 } 7061 7062 // anyRawContentBlockDelta is implemented by each variant of 7063 // [RawContentBlockDeltaUnion] to add type safety for the return type of 7064 // [RawContentBlockDeltaUnion.AsAny] 7065 type anyRawContentBlockDelta interface { 7066 implRawContentBlockDeltaUnion() 7067 } 7068 7069 func (TextDelta) implRawContentBlockDeltaUnion() {} 7070 func (InputJSONDelta) implRawContentBlockDeltaUnion() {} 7071 func (CitationsDelta) implRawContentBlockDeltaUnion() {} 7072 func (ThinkingDelta) implRawContentBlockDeltaUnion() {} 7073 func (SignatureDelta) implRawContentBlockDeltaUnion() {} 7074 7075 // Use the following switch statement to find the correct variant 7076 // 7077 // switch variant := RawContentBlockDeltaUnion.AsAny().(type) { 7078 // case anthropic.TextDelta: 7079 // case anthropic.InputJSONDelta: 7080 // case anthropic.CitationsDelta: 7081 // case anthropic.ThinkingDelta: 7082 // case anthropic.SignatureDelta: 7083 // default: 7084 // fmt.Errorf("no variant present") 7085 // } 7086 func (u RawContentBlockDeltaUnion) AsAny() anyRawContentBlockDelta { 7087 switch u.Type { 7088 case "text_delta": 7089 return u.AsTextDelta() 7090 case "input_json_delta": 7091 return u.AsInputJSONDelta() 7092 case "citations_delta": 7093 return u.AsCitationsDelta() 7094 case "thinking_delta": 7095 return u.AsThinkingDelta() 7096 case "signature_delta": 7097 return u.AsSignatureDelta() 7098 } 7099 return nil 7100 } 7101 7102 func (u RawContentBlockDeltaUnion) AsTextDelta() (v TextDelta) { 7103 apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) 7104 return 7105 } 7106 7107 func (u RawContentBlockDeltaUnion) AsInputJSONDelta() (v InputJSONDelta) { 7108 apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) 7109 return 7110 } 7111 7112 func (u RawContentBlockDeltaUnion) AsCitationsDelta() (v CitationsDelta) { 7113 apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) 7114 return 7115 } 7116 7117 func (u RawContentBlockDeltaUnion) AsThinkingDelta() (v ThinkingDelta) { 7118 apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) 7119 return 7120 } 7121 7122 func (u RawContentBlockDeltaUnion) AsSignatureDelta() (v SignatureDelta) { 7123 apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) 7124 return 7125 } 7126 7127 // Returns the unmodified JSON received from the API 7128 func (u RawContentBlockDeltaUnion) RawJSON() string { return u.JSON.raw } 7129 7130 func (r *RawContentBlockDeltaUnion) UnmarshalJSON(data []byte) error { 7131 return apijson.UnmarshalRoot(data, r) 7132 } 7133 7134 type ContentBlockDeltaEvent struct { 7135 Delta RawContentBlockDeltaUnion `json:"delta" api:"required"` 7136 Index int64 `json:"index" api:"required"` 7137 Type constant.ContentBlockDelta `json:"type" default:"content_block_delta"` 7138 // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. 7139 JSON struct { 7140 Delta respjson.Field 7141 Index respjson.Field 7142 Type respjson.Field 7143 ExtraFields map[string]respjson.Field 7144 raw string 7145 } `json:"-"` 7146 } 7147 7148 // Returns the unmodified JSON received from the API 7149 func (r ContentBlockDeltaEvent) RawJSON() string { return r.JSON.raw } 7150 func (r *ContentBlockDeltaEvent) UnmarshalJSON(data []byte) error { 7151 return apijson.UnmarshalRoot(data, r) 7152 } 7153 7154 type ContentBlockStartEvent struct { 7155 // Response model for a file uploaded to the container. 7156 ContentBlock ContentBlockStartEventContentBlockUnion `json:"content_block" api:"required"` 7157 Index int64 `json:"index" api:"required"` 7158 Type constant.ContentBlockStart `json:"type" default:"content_block_start"` 7159 // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. 7160 JSON struct { 7161 ContentBlock respjson.Field 7162 Index respjson.Field 7163 Type respjson.Field 7164 ExtraFields map[string]respjson.Field 7165 raw string 7166 } `json:"-"` 7167 } 7168 7169 // Returns the unmodified JSON received from the API 7170 func (r ContentBlockStartEvent) RawJSON() string { return r.JSON.raw } 7171 func (r *ContentBlockStartEvent) UnmarshalJSON(data []byte) error { 7172 return apijson.UnmarshalRoot(data, r) 7173 } 7174 7175 // ContentBlockStartEventContentBlockUnion contains all possible properties and 7176 // values from [TextBlock], [ThinkingBlock], [RedactedThinkingBlock], 7177 // [ToolUseBlock], [ServerToolUseBlock], [WebSearchToolResultBlock], 7178 // [WebFetchToolResultBlock], [CodeExecutionToolResultBlock], 7179 // [BashCodeExecutionToolResultBlock], [TextEditorCodeExecutionToolResultBlock], 7180 // [ToolSearchToolResultBlock], [ContainerUploadBlock]. 7181 // 7182 // Use the [ContentBlockStartEventContentBlockUnion.AsAny] method to switch on the 7183 // variant. 7184 // 7185 // Use the methods beginning with 'As' to cast the union to one of its variants. 7186 type ContentBlockStartEventContentBlockUnion struct { 7187 // This field is from variant [TextBlock]. 7188 Citations []TextCitationUnion `json:"citations"` 7189 // This field is from variant [TextBlock]. 7190 Text string `json:"text"` 7191 // Any of "text", "thinking", "redacted_thinking", "tool_use", "server_tool_use", 7192 // "web_search_tool_result", "web_fetch_tool_result", "code_execution_tool_result", 7193 // "bash_code_execution_tool_result", "text_editor_code_execution_tool_result", 7194 // "tool_search_tool_result", "container_upload". 7195 Type string `json:"type"` 7196 // This field is from variant [ThinkingBlock]. 7197 Signature string `json:"signature"` 7198 // This field is from variant [ThinkingBlock]. 7199 Thinking string `json:"thinking"` 7200 // This field is from variant [RedactedThinkingBlock]. 7201 Data string `json:"data"` 7202 ID string `json:"id"` 7203 // This field is a union of [ToolUseBlockCallerUnion], 7204 // [ServerToolUseBlockCallerUnion], [WebSearchToolResultBlockCallerUnion], 7205 // [WebFetchToolResultBlockCallerUnion] 7206 Caller ContentBlockStartEventContentBlockUnionCaller `json:"caller"` 7207 Input any `json:"input"` 7208 Name string `json:"name"` 7209 // This field is from variant [ToolUseBlock]. 7210 ToolsetName string `json:"toolset_name"` 7211 // This field is a union of [WebSearchToolResultBlockContentUnion], 7212 // [WebFetchToolResultBlockContentUnion], 7213 // [CodeExecutionToolResultBlockContentUnion], 7214 // [BashCodeExecutionToolResultBlockContentUnion], 7215 // [TextEditorCodeExecutionToolResultBlockContentUnion], 7216 // [ToolSearchToolResultBlockContentUnion] 7217 Content ContentBlockStartEventContentBlockUnionContent `json:"content"` 7218 ToolUseID string `json:"tool_use_id"` 7219 // This field is from variant [ContainerUploadBlock]. 7220 FileID string `json:"file_id"` 7221 JSON struct { 7222 Citations respjson.Field 7223 Text respjson.Field 7224 Type respjson.Field 7225 Signature respjson.Field 7226 Thinking respjson.Field 7227 Data respjson.Field 7228 ID respjson.Field 7229 Caller respjson.Field 7230 Input respjson.Field 7231 Name respjson.Field 7232 ToolsetName respjson.Field 7233 Content respjson.Field 7234 ToolUseID respjson.Field 7235 FileID respjson.Field 7236 raw string 7237 } `json:"-"` 7238 } 7239 7240 // anyContentBlockStartEventContentBlock is implemented by each variant of 7241 // [ContentBlockStartEventContentBlockUnion] to add type safety for the return type 7242 // of [ContentBlockStartEventContentBlockUnion.AsAny] 7243 type anyContentBlockStartEventContentBlock interface { 7244 implContentBlockStartEventContentBlockUnion() 7245 } 7246 7247 func (TextBlock) implContentBlockStartEventContentBlockUnion() {} 7248 func (ThinkingBlock) implContentBlockStartEventContentBlockUnion() {} 7249 func (RedactedThinkingBlock) implContentBlockStartEventContentBlockUnion() {} 7250 func (ToolUseBlock) implContentBlockStartEventContentBlockUnion() {} 7251 func (ServerToolUseBlock) implContentBlockStartEventContentBlockUnion() {} 7252 func (WebSearchToolResultBlock) implContentBlockStartEventContentBlockUnion() {} 7253 func (WebFetchToolResultBlock) implContentBlockStartEventContentBlockUnion() {} 7254 func (CodeExecutionToolResultBlock) implContentBlockStartEventContentBlockUnion() {} 7255 func (BashCodeExecutionToolResultBlock) implContentBlockStartEventContentBlockUnion() {} 7256 func (TextEditorCodeExecutionToolResultBlock) implContentBlockStartEventContentBlockUnion() {} 7257 func (ToolSearchToolResultBlock) implContentBlockStartEventContentBlockUnion() {} 7258 func (ContainerUploadBlock) implContentBlockStartEventContentBlockUnion() {} 7259 7260 // Use the following switch statement to find the correct variant 7261 // 7262 // switch variant := ContentBlockStartEventContentBlockUnion.AsAny().(type) { 7263 // case anthropic.TextBlock: 7264 // case anthropic.ThinkingBlock: 7265 // case anthropic.RedactedThinkingBlock: 7266 // case anthropic.ToolUseBlock: 7267 // case anthropic.ServerToolUseBlock: 7268 // case anthropic.WebSearchToolResultBlock: 7269 // case anthropic.WebFetchToolResultBlock: 7270 // case anthropic.CodeExecutionToolResultBlock: 7271 // case anthropic.BashCodeExecutionToolResultBlock: 7272 // case anthropic.TextEditorCodeExecutionToolResultBlock: 7273 // case anthropic.ToolSearchToolResultBlock: 7274 // case anthropic.ContainerUploadBlock: 7275 // default: 7276 // fmt.Errorf("no variant present") 7277 // } 7278 func (u ContentBlockStartEventContentBlockUnion) AsAny() anyContentBlockStartEventContentBlock { 7279 switch u.Type { 7280 case "text": 7281 return u.AsText() 7282 case "thinking": 7283 return u.AsThinking() 7284 case "redacted_thinking": 7285 return u.AsRedactedThinking() 7286 case "tool_use": 7287 return u.AsToolUse() 7288 case "server_tool_use": 7289 return u.AsServerToolUse() 7290 case "web_search_tool_result": 7291 return u.AsWebSearchToolResult() 7292 case "web_fetch_tool_result": 7293 return u.AsWebFetchToolResult() 7294 case "code_execution_tool_result": 7295 return u.AsCodeExecutionToolResult() 7296 case "bash_code_execution_tool_result": 7297 return u.AsBashCodeExecutionToolResult() 7298 case "text_editor_code_execution_tool_result": 7299 return u.AsTextEditorCodeExecutionToolResult() 7300 case "tool_search_tool_result": 7301 return u.AsToolSearchToolResult() 7302 case "container_upload": 7303 return u.AsContainerUpload() 7304 } 7305 return nil 7306 } 7307 7308 func (u ContentBlockStartEventContentBlockUnion) AsText() (v TextBlock) { 7309 apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) 7310 return 7311 } 7312 7313 func (u ContentBlockStartEventContentBlockUnion) AsThinking() (v ThinkingBlock) { 7314 apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) 7315 return 7316 } 7317 7318 func (u ContentBlockStartEventContentBlockUnion) AsRedactedThinking() (v RedactedThinkingBlock) { 7319 apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) 7320 return 7321 } 7322 7323 func (u ContentBlockStartEventContentBlockUnion) AsToolUse() (v ToolUseBlock) { 7324 apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) 7325 return 7326 } 7327 7328 func (u ContentBlockStartEventContentBlockUnion) AsServerToolUse() (v ServerToolUseBlock) { 7329 apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) 7330 return 7331 } 7332 7333 func (u ContentBlockStartEventContentBlockUnion) AsWebSearchToolResult() (v WebSearchToolResultBlock) { 7334 apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) 7335 return 7336 } 7337 7338 func (u ContentBlockStartEventContentBlockUnion) AsWebFetchToolResult() (v WebFetchToolResultBlock) { 7339 apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) 7340 return 7341 } 7342 7343 func (u ContentBlockStartEventContentBlockUnion) AsCodeExecutionToolResult() (v CodeExecutionToolResultBlock) { 7344 apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) 7345 return 7346 } 7347 7348 func (u ContentBlockStartEventContentBlockUnion) AsBashCodeExecutionToolResult() (v BashCodeExecutionToolResultBlock) { 7349 apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) 7350 return 7351 } 7352 7353 func (u ContentBlockStartEventContentBlockUnion) AsTextEditorCodeExecutionToolResult() (v TextEditorCodeExecutionToolResultBlock) { 7354 apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) 7355 return 7356 } 7357 7358 func (u ContentBlockStartEventContentBlockUnion) AsToolSearchToolResult() (v ToolSearchToolResultBlock) { 7359 apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) 7360 return 7361 } 7362 7363 func (u ContentBlockStartEventContentBlockUnion) AsContainerUpload() (v ContainerUploadBlock) { 7364 apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) 7365 return 7366 } 7367 7368 // Returns the unmodified JSON received from the API 7369 func (u ContentBlockStartEventContentBlockUnion) RawJSON() string { return u.JSON.raw } 7370 7371 func (r *ContentBlockStartEventContentBlockUnion) UnmarshalJSON(data []byte) error { 7372 return apijson.UnmarshalRoot(data, r) 7373 } 7374 7375 // ContentBlockStartEventContentBlockUnionCaller is an implicit subunion of 7376 // [ContentBlockStartEventContentBlockUnion]. 7377 // ContentBlockStartEventContentBlockUnionCaller provides convenient access to the 7378 // sub-properties of the union. 7379 // 7380 // For type safety it is recommended to directly use a variant of the 7381 // [ContentBlockStartEventContentBlockUnion]. 7382 type ContentBlockStartEventContentBlockUnionCaller struct { 7383 Type string `json:"type"` 7384 ToolID string `json:"tool_id"` 7385 JSON struct { 7386 Type respjson.Field 7387 ToolID respjson.Field 7388 raw string 7389 } `json:"-"` 7390 } 7391 7392 func (r *ContentBlockStartEventContentBlockUnionCaller) UnmarshalJSON(data []byte) error { 7393 return apijson.UnmarshalRoot(data, r) 7394 } 7395 7396 // ContentBlockStartEventContentBlockUnionContent is an implicit subunion of 7397 // [ContentBlockStartEventContentBlockUnion]. 7398 // ContentBlockStartEventContentBlockUnionContent provides convenient access to the 7399 // sub-properties of the union. 7400 // 7401 // For type safety it is recommended to directly use a variant of the 7402 // [ContentBlockStartEventContentBlockUnion]. 7403 // 7404 // If the underlying value is not a json object, one of the following properties 7405 // will be valid: OfWebSearchResultBlockArray] 7406 type ContentBlockStartEventContentBlockUnionContent struct { 7407 // This field will be present if the value is a [[]WebSearchResultBlock] instead of 7408 // an object. 7409 OfWebSearchResultBlockArray []WebSearchResultBlock `json:",inline"` 7410 ErrorCode string `json:"error_code"` 7411 Type string `json:"type"` 7412 // This field is a union of [DocumentBlock], [[]CodeExecutionOutputBlock], 7413 // [[]CodeExecutionOutputBlock], [[]BashCodeExecutionOutputBlock], [string] 7414 Content ContentBlockStartEventContentBlockUnionContentContent `json:"content"` 7415 // This field is from variant [WebFetchToolResultBlockContentUnion]. 7416 RetrievedAt string `json:"retrieved_at"` 7417 // This field is from variant [WebFetchToolResultBlockContentUnion]. 7418 URL string `json:"url"` 7419 ReturnCode int64 `json:"return_code"` 7420 Stderr string `json:"stderr"` 7421 Stdout string `json:"stdout"` 7422 // This field is from variant [CodeExecutionToolResultBlockContentUnion]. 7423 EncryptedStdout string `json:"encrypted_stdout"` 7424 ErrorMessage string `json:"error_message"` 7425 // This field is from variant [TextEditorCodeExecutionToolResultBlockContentUnion]. 7426 FileType TextEditorCodeExecutionViewResultBlockFileType `json:"file_type"` 7427 // This field is from variant [TextEditorCodeExecutionToolResultBlockContentUnion]. 7428 NumLines int64 `json:"num_lines"` 7429 // This field is from variant [TextEditorCodeExecutionToolResultBlockContentUnion]. 7430 StartLine int64 `json:"start_line"` 7431 // This field is from variant [TextEditorCodeExecutionToolResultBlockContentUnion]. 7432 TotalLines int64 `json:"total_lines"` 7433 // This field is from variant [TextEditorCodeExecutionToolResultBlockContentUnion]. 7434 IsFileUpdate bool `json:"is_file_update"` 7435 // This field is from variant [TextEditorCodeExecutionToolResultBlockContentUnion]. 7436 Lines []string `json:"lines"` 7437 // This field is from variant [TextEditorCodeExecutionToolResultBlockContentUnion]. 7438 NewLines int64 `json:"new_lines"` 7439 // This field is from variant [TextEditorCodeExecutionToolResultBlockContentUnion]. 7440 NewStart int64 `json:"new_start"` 7441 // This field is from variant [TextEditorCodeExecutionToolResultBlockContentUnion]. 7442 OldLines int64 `json:"old_lines"` 7443 // This field is from variant [TextEditorCodeExecutionToolResultBlockContentUnion]. 7444 OldStart int64 `json:"old_start"` 7445 // This field is from variant [ToolSearchToolResultBlockContentUnion]. 7446 ToolReferences []ToolReferenceBlock `json:"tool_references"` 7447 JSON struct { 7448 OfWebSearchResultBlockArray respjson.Field 7449 ErrorCode respjson.Field 7450 Type respjson.Field 7451 Content respjson.Field 7452 RetrievedAt respjson.Field 7453 URL respjson.Field 7454 ReturnCode respjson.Field 7455 Stderr respjson.Field 7456 Stdout respjson.Field 7457 EncryptedStdout respjson.Field 7458 ErrorMessage respjson.Field 7459 FileType respjson.Field 7460 NumLines respjson.Field 7461 StartLine respjson.Field 7462 TotalLines respjson.Field 7463 IsFileUpdate respjson.Field 7464 Lines respjson.Field 7465 NewLines respjson.Field 7466 NewStart respjson.Field 7467 OldLines respjson.Field 7468 OldStart respjson.Field 7469 ToolReferences respjson.Field 7470 raw string 7471 } `json:"-"` 7472 } 7473 7474 func (r *ContentBlockStartEventContentBlockUnionContent) UnmarshalJSON(data []byte) error { 7475 return apijson.UnmarshalRoot(data, r) 7476 } 7477 7478 // ContentBlockStartEventContentBlockUnionContentContent is an implicit subunion of 7479 // [ContentBlockStartEventContentBlockUnion]. 7480 // ContentBlockStartEventContentBlockUnionContentContent provides convenient access 7481 // to the sub-properties of the union. 7482 // 7483 // For type safety it is recommended to directly use a variant of the 7484 // [ContentBlockStartEventContentBlockUnion]. 7485 // 7486 // If the underlying value is not a json object, one of the following properties 7487 // will be valid: OfContent OfString] 7488 type ContentBlockStartEventContentBlockUnionContentContent struct { 7489 // This field will be present if the value is a [[]CodeExecutionOutputBlock] 7490 // instead of an object. 7491 OfContent []CodeExecutionOutputBlock `json:",inline"` 7492 // This field will be present if the value is a [string] instead of an object. 7493 OfString string `json:",inline"` 7494 // This field is from variant [DocumentBlock]. 7495 Citations CitationsConfig `json:"citations"` 7496 // This field is from variant [DocumentBlock]. 7497 Source DocumentBlockSourceUnion `json:"source"` 7498 // This field is from variant [DocumentBlock]. 7499 Title string `json:"title"` 7500 // This field is from variant [DocumentBlock]. 7501 Type constant.Document `json:"type"` 7502 JSON struct { 7503 OfContent respjson.Field 7504 OfString respjson.Field 7505 Citations respjson.Field 7506 Source respjson.Field 7507 Title respjson.Field 7508 Type respjson.Field 7509 raw string 7510 } `json:"-"` 7511 } 7512 7513 func (r *ContentBlockStartEventContentBlockUnionContentContent) UnmarshalJSON(data []byte) error { 7514 return apijson.UnmarshalRoot(data, r) 7515 } 7516 7517 type ContentBlockStopEvent struct { 7518 Index int64 `json:"index" api:"required"` 7519 Type constant.ContentBlockStop `json:"type" default:"content_block_stop"` 7520 // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. 7521 JSON struct { 7522 Index respjson.Field 7523 Type respjson.Field 7524 ExtraFields map[string]respjson.Field 7525 raw string 7526 } `json:"-"` 7527 } 7528 7529 // Returns the unmodified JSON received from the API 7530 func (r ContentBlockStopEvent) RawJSON() string { return r.JSON.raw } 7531 func (r *ContentBlockStopEvent) UnmarshalJSON(data []byte) error { 7532 return apijson.UnmarshalRoot(data, r) 7533 } 7534 7535 type MessageDeltaEvent struct { 7536 Delta MessageDeltaEventDelta `json:"delta" api:"required"` 7537 Type constant.MessageDelta `json:"type" default:"message_delta"` 7538 // Billing and rate-limit usage. 7539 // 7540 // Anthropic's API bills and rate-limits by token counts, as tokens represent the 7541 // underlying cost to our systems. 7542 // 7543 // Under the hood, the API transforms requests into a format suitable for the 7544 // model. The model's output then goes through a parsing stage before becoming an 7545 // API response. As a result, the token counts in `usage` will not match one-to-one 7546 // with the exact visible content of an API request or response. 7547 // 7548 // For example, `output_tokens` will be non-zero, even for an empty string response 7549 // from Claude. 7550 // 7551 // Total input tokens in a request is the summation of `input_tokens`, 7552 // `cache_creation_input_tokens`, and `cache_read_input_tokens`. 7553 Usage MessageDeltaUsage `json:"usage" api:"required"` 7554 // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. 7555 JSON struct { 7556 Delta respjson.Field 7557 Type respjson.Field 7558 Usage respjson.Field 7559 ExtraFields map[string]respjson.Field 7560 raw string 7561 } `json:"-"` 7562 } 7563 7564 // Returns the unmodified JSON received from the API 7565 func (r MessageDeltaEvent) RawJSON() string { return r.JSON.raw } 7566 func (r *MessageDeltaEvent) UnmarshalJSON(data []byte) error { 7567 return apijson.UnmarshalRoot(data, r) 7568 } 7569 7570 type MessageDeltaEventDelta struct { 7571 // Information about the container used in the request (for the code execution 7572 // tool) 7573 Container Container `json:"container" api:"required"` 7574 // Structured information about a refusal. 7575 StopDetails RefusalStopDetails `json:"stop_details" api:"required"` 7576 // Any of "end_turn", "max_tokens", "stop_sequence", "tool_use", "pause_turn", 7577 // "refusal", "model_context_window_exceeded". 7578 StopReason StopReason `json:"stop_reason" api:"required"` 7579 StopSequence string `json:"stop_sequence" api:"required"` 7580 // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. 7581 JSON struct { 7582 Container respjson.Field 7583 StopDetails respjson.Field 7584 StopReason respjson.Field 7585 StopSequence respjson.Field 7586 ExtraFields map[string]respjson.Field 7587 raw string 7588 } `json:"-"` 7589 } 7590 7591 // Returns the unmodified JSON received from the API 7592 func (r MessageDeltaEventDelta) RawJSON() string { return r.JSON.raw } 7593 func (r *MessageDeltaEventDelta) UnmarshalJSON(data []byte) error { 7594 return apijson.UnmarshalRoot(data, r) 7595 } 7596 7597 type MessageStartEvent struct { 7598 Message Message `json:"message" api:"required"` 7599 Type constant.MessageStart `json:"type" default:"message_start"` 7600 // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. 7601 JSON struct { 7602 Message respjson.Field 7603 Type respjson.Field 7604 ExtraFields map[string]respjson.Field 7605 raw string 7606 } `json:"-"` 7607 } 7608 7609 // Returns the unmodified JSON received from the API 7610 func (r MessageStartEvent) RawJSON() string { return r.JSON.raw } 7611 func (r *MessageStartEvent) UnmarshalJSON(data []byte) error { 7612 return apijson.UnmarshalRoot(data, r) 7613 } 7614 7615 type MessageStopEvent struct { 7616 Type constant.MessageStop `json:"type" default:"message_stop"` 7617 // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. 7618 JSON struct { 7619 Type respjson.Field 7620 ExtraFields map[string]respjson.Field 7621 raw string 7622 } `json:"-"` 7623 } 7624 7625 // Returns the unmodified JSON received from the API 7626 func (r MessageStopEvent) RawJSON() string { return r.JSON.raw } 7627 func (r *MessageStopEvent) UnmarshalJSON(data []byte) error { 7628 return apijson.UnmarshalRoot(data, r) 7629 } 7630 7631 // MessageStreamEventUnion contains all possible properties and values from 7632 // [MessageStartEvent], [MessageDeltaEvent], [MessageStopEvent], 7633 // [ContentBlockStartEvent], [ContentBlockDeltaEvent], [ContentBlockStopEvent]. 7634 // 7635 // Use the [MessageStreamEventUnion.AsAny] method to switch on the variant. 7636 // 7637 // Use the methods beginning with 'As' to cast the union to one of its variants. 7638 type MessageStreamEventUnion struct { 7639 // This field is from variant [MessageStartEvent]. 7640 Message Message `json:"message"` 7641 // Any of "message_start", "message_delta", "message_stop", "content_block_start", 7642 // "content_block_delta", "content_block_stop". 7643 Type string `json:"type"` 7644 // This field is a union of [MessageDeltaEventDelta], [RawContentBlockDeltaUnion] 7645 Delta MessageStreamEventUnionDelta `json:"delta"` 7646 // This field is from variant [MessageDeltaEvent]. 7647 Usage MessageDeltaUsage `json:"usage"` 7648 // This field is from variant [ContentBlockStartEvent]. 7649 ContentBlock ContentBlockStartEventContentBlockUnion `json:"content_block"` 7650 Index int64 `json:"index"` 7651 JSON struct { 7652 Message respjson.Field 7653 Type respjson.Field 7654 Delta respjson.Field 7655 Usage respjson.Field 7656 ContentBlock respjson.Field 7657 Index respjson.Field 7658 raw string 7659 } `json:"-"` 7660 } 7661 7662 // anyMessageStreamEvent is implemented by each variant of 7663 // [MessageStreamEventUnion] to add type safety for the return type of 7664 // [MessageStreamEventUnion.AsAny] 7665 type anyMessageStreamEvent interface { 7666 implMessageStreamEventUnion() 7667 } 7668 7669 func (MessageStartEvent) implMessageStreamEventUnion() {} 7670 func (MessageDeltaEvent) implMessageStreamEventUnion() {} 7671 func (MessageStopEvent) implMessageStreamEventUnion() {} 7672 func (ContentBlockStartEvent) implMessageStreamEventUnion() {} 7673 func (ContentBlockDeltaEvent) implMessageStreamEventUnion() {} 7674 func (ContentBlockStopEvent) implMessageStreamEventUnion() {} 7675 7676 // Use the following switch statement to find the correct variant 7677 // 7678 // switch variant := MessageStreamEventUnion.AsAny().(type) { 7679 // case anthropic.MessageStartEvent: 7680 // case anthropic.MessageDeltaEvent: 7681 // case anthropic.MessageStopEvent: 7682 // case anthropic.ContentBlockStartEvent: 7683 // case anthropic.ContentBlockDeltaEvent: 7684 // case anthropic.ContentBlockStopEvent: 7685 // default: 7686 // fmt.Errorf("no variant present") 7687 // } 7688 func (u MessageStreamEventUnion) AsAny() anyMessageStreamEvent { 7689 switch u.Type { 7690 case "message_start": 7691 return u.AsMessageStart() 7692 case "message_delta": 7693 return u.AsMessageDelta() 7694 case "message_stop": 7695 return u.AsMessageStop() 7696 case "content_block_start": 7697 return u.AsContentBlockStart() 7698 case "content_block_delta": 7699 return u.AsContentBlockDelta() 7700 case "content_block_stop": 7701 return u.AsContentBlockStop() 7702 } 7703 return nil 7704 } 7705 7706 func (u MessageStreamEventUnion) AsMessageStart() (v MessageStartEvent) { 7707 apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) 7708 return 7709 } 7710 7711 func (u MessageStreamEventUnion) AsMessageDelta() (v MessageDeltaEvent) { 7712 apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) 7713 return 7714 } 7715 7716 func (u MessageStreamEventUnion) AsMessageStop() (v MessageStopEvent) { 7717 apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) 7718 return 7719 } 7720 7721 func (u MessageStreamEventUnion) AsContentBlockStart() (v ContentBlockStartEvent) { 7722 apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) 7723 return 7724 } 7725 7726 func (u MessageStreamEventUnion) AsContentBlockDelta() (v ContentBlockDeltaEvent) { 7727 apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) 7728 return 7729 } 7730 7731 func (u MessageStreamEventUnion) AsContentBlockStop() (v ContentBlockStopEvent) { 7732 apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) 7733 return 7734 } 7735 7736 // Returns the unmodified JSON received from the API 7737 func (u MessageStreamEventUnion) RawJSON() string { return u.JSON.raw } 7738 7739 func (r *MessageStreamEventUnion) UnmarshalJSON(data []byte) error { 7740 return apijson.UnmarshalRoot(data, r) 7741 } 7742 7743 // MessageStreamEventUnionDelta is an implicit subunion of 7744 // [MessageStreamEventUnion]. MessageStreamEventUnionDelta provides convenient 7745 // access to the sub-properties of the union. 7746 // 7747 // For type safety it is recommended to directly use a variant of the 7748 // [MessageStreamEventUnion]. 7749 type MessageStreamEventUnionDelta struct { 7750 // This field is from variant [MessageDeltaEventDelta]. 7751 Container Container `json:"container"` 7752 // This field is from variant [MessageDeltaEventDelta]. 7753 StopDetails RefusalStopDetails `json:"stop_details"` 7754 // This field is from variant [MessageDeltaEventDelta]. 7755 StopReason StopReason `json:"stop_reason"` 7756 // This field is from variant [MessageDeltaEventDelta]. 7757 StopSequence string `json:"stop_sequence"` 7758 // This field is from variant [RawContentBlockDeltaUnion]. 7759 Text string `json:"text"` 7760 Type string `json:"type"` 7761 // This field is from variant [RawContentBlockDeltaUnion]. 7762 PartialJSON string `json:"partial_json"` 7763 // This field is from variant [RawContentBlockDeltaUnion]. 7764 Citation CitationsDeltaCitationUnion `json:"citation"` 7765 // This field is from variant [RawContentBlockDeltaUnion]. 7766 Thinking string `json:"thinking"` 7767 // This field is from variant [RawContentBlockDeltaUnion]. 7768 Signature string `json:"signature"` 7769 JSON struct { 7770 Container respjson.Field 7771 StopDetails respjson.Field 7772 StopReason respjson.Field 7773 StopSequence respjson.Field 7774 Text respjson.Field 7775 Type respjson.Field 7776 PartialJSON respjson.Field 7777 Citation respjson.Field 7778 Thinking respjson.Field 7779 Signature respjson.Field 7780 raw string 7781 } `json:"-"` 7782 } 7783 7784 func (r *MessageStreamEventUnionDelta) UnmarshalJSON(data []byte) error { 7785 return apijson.UnmarshalRoot(data, r) 7786 } 7787 7788 type RedactedThinkingBlock struct { 7789 // The contents of this redacted thinking block, returned when portions of the 7790 // model's thinking were safety-redacted. This field is opaque and encrypted, with 7791 // no readable content. 7792 // 7793 // Pass `redacted_thinking` blocks back to the API unchanged when continuing a 7794 // multi-turn conversation. 7795 // 7796 // See 7797 // [extended thinking](https://platform.claude.com/docs/en/build-with-claude/extended-thinking#redacted-thinking-blocks) 7798 // for details. 7799 Data string `json:"data" api:"required"` 7800 Type constant.RedactedThinking `json:"type" default:"redacted_thinking"` 7801 // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. 7802 JSON struct { 7803 Data respjson.Field 7804 Type respjson.Field 7805 ExtraFields map[string]respjson.Field 7806 raw string 7807 } `json:"-"` 7808 } 7809 7810 // Returns the unmodified JSON received from the API 7811 func (r RedactedThinkingBlock) RawJSON() string { return r.JSON.raw } 7812 func (r *RedactedThinkingBlock) UnmarshalJSON(data []byte) error { 7813 return apijson.UnmarshalRoot(data, r) 7814 } 7815 7816 // The properties Data, Type are required. 7817 type RedactedThinkingBlockParam struct { 7818 // The `data` value of this redacted thinking block, exactly as returned by the API 7819 // in a previous response. Opaque and encrypted; pass it back unchanged. 7820 Data string `json:"data" api:"required"` 7821 // This field can be elided, and will marshal its zero value as 7822 // "redacted_thinking". 7823 Type constant.RedactedThinking `json:"type" default:"redacted_thinking"` 7824 paramObj 7825 } 7826 7827 func (r RedactedThinkingBlockParam) MarshalJSON() (data []byte, err error) { 7828 type shadow RedactedThinkingBlockParam 7829 return param.MarshalObject(r, (*shadow)(&r)) 7830 } 7831 func (r *RedactedThinkingBlockParam) UnmarshalJSON(data []byte) error { 7832 return apijson.UnmarshalRoot(data, r) 7833 } 7834 7835 // Structured information about a refusal. 7836 type RefusalStopDetails struct { 7837 // The policy category that triggered a refusal. 7838 // 7839 // Any of "cyber", "bio", "frontier_llm", "reasoning_extraction", "general_harms". 7840 Category RefusalStopDetailsCategory `json:"category" api:"required"` 7841 // Human-readable explanation of the refusal. 7842 // 7843 // This text is not guaranteed to be stable. `null` when no explanation is 7844 // available for the category. 7845 Explanation string `json:"explanation" api:"required"` 7846 Type constant.Refusal `json:"type" default:"refusal"` 7847 // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. 7848 JSON struct { 7849 Category respjson.Field 7850 Explanation respjson.Field 7851 Type respjson.Field 7852 ExtraFields map[string]respjson.Field 7853 raw string 7854 } `json:"-"` 7855 } 7856 7857 // Returns the unmodified JSON received from the API 7858 func (r RefusalStopDetails) RawJSON() string { return r.JSON.raw } 7859 func (r *RefusalStopDetails) UnmarshalJSON(data []byte) error { 7860 return apijson.UnmarshalRoot(data, r) 7861 } 7862 7863 // The policy category that triggered a refusal. 7864 type RefusalStopDetailsCategory string 7865 7866 const ( 7867 RefusalStopDetailsCategoryCyber RefusalStopDetailsCategory = "cyber" 7868 RefusalStopDetailsCategoryBio RefusalStopDetailsCategory = "bio" 7869 RefusalStopDetailsCategoryFrontierLLM RefusalStopDetailsCategory = "frontier_llm" 7870 RefusalStopDetailsCategoryReasoningExtraction RefusalStopDetailsCategory = "reasoning_extraction" 7871 RefusalStopDetailsCategoryGeneralHarms RefusalStopDetailsCategory = "general_harms" 7872 ) 7873 7874 // The properties Content, Source, Title, Type are required. 7875 type SearchResultBlockParam struct { 7876 Content []TextBlockParam `json:"content,omitzero" api:"required"` 7877 Source string `json:"source" api:"required"` 7878 Title string `json:"title" api:"required"` 7879 // Create a cache control breakpoint at this content block. 7880 CacheControl CacheControlEphemeralParam `json:"cache_control,omitzero"` 7881 Citations CitationsConfigParam `json:"citations,omitzero"` 7882 // This field can be elided, and will marshal its zero value as "search_result". 7883 Type constant.SearchResult `json:"type" default:"search_result"` 7884 paramObj 7885 } 7886 7887 func (r SearchResultBlockParam) MarshalJSON() (data []byte, err error) { 7888 type shadow SearchResultBlockParam 7889 return param.MarshalObject(r, (*shadow)(&r)) 7890 } 7891 func (r *SearchResultBlockParam) UnmarshalJSON(data []byte) error { 7892 return apijson.UnmarshalRoot(data, r) 7893 } 7894 7895 // Tool invocation generated by a server-side tool. 7896 type ServerToolCaller struct { 7897 ToolID string `json:"tool_id" api:"required"` 7898 Type constant.CodeExecution20250825 `json:"type" default:"code_execution_20250825"` 7899 // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. 7900 JSON struct { 7901 ToolID respjson.Field 7902 Type respjson.Field 7903 ExtraFields map[string]respjson.Field 7904 raw string 7905 } `json:"-"` 7906 } 7907 7908 // Returns the unmodified JSON received from the API 7909 func (r ServerToolCaller) RawJSON() string { return r.JSON.raw } 7910 func (r *ServerToolCaller) UnmarshalJSON(data []byte) error { 7911 return apijson.UnmarshalRoot(data, r) 7912 } 7913 7914 // ToParam converts this ServerToolCaller to a ServerToolCallerParam. 7915 // 7916 // Warning: the fields of the param type will not be present. ToParam should only 7917 // be used at the last possible moment before sending a request. Test for this with 7918 // ServerToolCallerParam.Overrides() 7919 func (r ServerToolCaller) ToParam() ServerToolCallerParam { 7920 return param.Override[ServerToolCallerParam](json.RawMessage(r.RawJSON())) 7921 } 7922 7923 // Tool invocation generated by a server-side tool. 7924 // 7925 // The properties ToolID, Type are required. 7926 type ServerToolCallerParam struct { 7927 ToolID string `json:"tool_id" api:"required"` 7928 // This field can be elided, and will marshal its zero value as 7929 // "code_execution_20250825". 7930 Type constant.CodeExecution20250825 `json:"type" default:"code_execution_20250825"` 7931 paramObj 7932 } 7933 7934 func (r ServerToolCallerParam) MarshalJSON() (data []byte, err error) { 7935 type shadow ServerToolCallerParam 7936 return param.MarshalObject(r, (*shadow)(&r)) 7937 } 7938 func (r *ServerToolCallerParam) UnmarshalJSON(data []byte) error { 7939 return apijson.UnmarshalRoot(data, r) 7940 } 7941 7942 type ServerToolCaller20260120 struct { 7943 ToolID string `json:"tool_id" api:"required"` 7944 Type constant.CodeExecution20260120 `json:"type" default:"code_execution_20260120"` 7945 // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. 7946 JSON struct { 7947 ToolID respjson.Field 7948 Type respjson.Field 7949 ExtraFields map[string]respjson.Field 7950 raw string 7951 } `json:"-"` 7952 } 7953 7954 // Returns the unmodified JSON received from the API 7955 func (r ServerToolCaller20260120) RawJSON() string { return r.JSON.raw } 7956 func (r *ServerToolCaller20260120) UnmarshalJSON(data []byte) error { 7957 return apijson.UnmarshalRoot(data, r) 7958 } 7959 7960 // ToParam converts this ServerToolCaller20260120 to a 7961 // ServerToolCaller20260120Param. 7962 // 7963 // Warning: the fields of the param type will not be present. ToParam should only 7964 // be used at the last possible moment before sending a request. Test for this with 7965 // ServerToolCaller20260120Param.Overrides() 7966 func (r ServerToolCaller20260120) ToParam() ServerToolCaller20260120Param { 7967 return param.Override[ServerToolCaller20260120Param](json.RawMessage(r.RawJSON())) 7968 } 7969 7970 // The properties ToolID, Type are required. 7971 type ServerToolCaller20260120Param struct { 7972 ToolID string `json:"tool_id" api:"required"` 7973 // This field can be elided, and will marshal its zero value as 7974 // "code_execution_20260120". 7975 Type constant.CodeExecution20260120 `json:"type" default:"code_execution_20260120"` 7976 paramObj 7977 } 7978 7979 func (r ServerToolCaller20260120Param) MarshalJSON() (data []byte, err error) { 7980 type shadow ServerToolCaller20260120Param 7981 return param.MarshalObject(r, (*shadow)(&r)) 7982 } 7983 func (r *ServerToolCaller20260120Param) UnmarshalJSON(data []byte) error { 7984 return apijson.UnmarshalRoot(data, r) 7985 } 7986 7987 type ServerToolUsage struct { 7988 // The number of web fetch tool requests. 7989 WebFetchRequests int64 `json:"web_fetch_requests" api:"required"` 7990 // The number of web search tool requests. 7991 WebSearchRequests int64 `json:"web_search_requests" api:"required"` 7992 // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. 7993 JSON struct { 7994 WebFetchRequests respjson.Field 7995 WebSearchRequests respjson.Field 7996 ExtraFields map[string]respjson.Field 7997 raw string 7998 } `json:"-"` 7999 } 8000 8001 // Returns the unmodified JSON received from the API 8002 func (r ServerToolUsage) RawJSON() string { return r.JSON.raw } 8003 func (r *ServerToolUsage) UnmarshalJSON(data []byte) error { 8004 return apijson.UnmarshalRoot(data, r) 8005 } 8006 8007 type ServerToolUseBlock struct { 8008 ID string `json:"id" api:"required"` 8009 // Tool invocation directly from the model. 8010 Caller ServerToolUseBlockCallerUnion `json:"caller" api:"required"` 8011 Input any `json:"input" api:"required"` 8012 // Any of "web_search", "web_fetch", "code_execution", "bash_code_execution", 8013 // "text_editor_code_execution", "tool_search_tool_regex", "tool_search_tool_bm25". 8014 Name ServerToolUseBlockName `json:"name" api:"required"` 8015 Type constant.ServerToolUse `json:"type" default:"server_tool_use"` 8016 // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. 8017 JSON struct { 8018 ID respjson.Field 8019 Caller respjson.Field 8020 Input respjson.Field 8021 Name respjson.Field 8022 Type respjson.Field 8023 ExtraFields map[string]respjson.Field 8024 raw string 8025 } `json:"-"` 8026 } 8027 8028 // Returns the unmodified JSON received from the API 8029 func (r ServerToolUseBlock) RawJSON() string { return r.JSON.raw } 8030 func (r *ServerToolUseBlock) UnmarshalJSON(data []byte) error { 8031 return apijson.UnmarshalRoot(data, r) 8032 } 8033 8034 // ServerToolUseBlockCallerUnion contains all possible properties and values from 8035 // [DirectCaller], [ServerToolCaller], [ServerToolCaller20260120]. 8036 // 8037 // Use the [ServerToolUseBlockCallerUnion.AsAny] method to switch on the variant. 8038 // 8039 // Use the methods beginning with 'As' to cast the union to one of its variants. 8040 type ServerToolUseBlockCallerUnion struct { 8041 // Any of "direct", "code_execution_20250825", "code_execution_20260120". 8042 Type string `json:"type"` 8043 ToolID string `json:"tool_id"` 8044 JSON struct { 8045 Type respjson.Field 8046 ToolID respjson.Field 8047 raw string 8048 } `json:"-"` 8049 } 8050 8051 // anyServerToolUseBlockCaller is implemented by each variant of 8052 // [ServerToolUseBlockCallerUnion] to add type safety for the return type of 8053 // [ServerToolUseBlockCallerUnion.AsAny] 8054 type anyServerToolUseBlockCaller interface { 8055 implServerToolUseBlockCallerUnion() 8056 } 8057 8058 func (DirectCaller) implServerToolUseBlockCallerUnion() {} 8059 func (ServerToolCaller) implServerToolUseBlockCallerUnion() {} 8060 func (ServerToolCaller20260120) implServerToolUseBlockCallerUnion() {} 8061 8062 // Use the following switch statement to find the correct variant 8063 // 8064 // switch variant := ServerToolUseBlockCallerUnion.AsAny().(type) { 8065 // case anthropic.DirectCaller: 8066 // case anthropic.ServerToolCaller: 8067 // case anthropic.ServerToolCaller20260120: 8068 // default: 8069 // fmt.Errorf("no variant present") 8070 // } 8071 func (u ServerToolUseBlockCallerUnion) AsAny() anyServerToolUseBlockCaller { 8072 switch u.Type { 8073 case "direct": 8074 return u.AsDirect() 8075 case "code_execution_20250825": 8076 return u.AsCodeExecution20250825() 8077 case "code_execution_20260120": 8078 return u.AsCodeExecution20260120() 8079 } 8080 return nil 8081 } 8082 8083 func (u ServerToolUseBlockCallerUnion) AsDirect() (v DirectCaller) { 8084 apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) 8085 return 8086 } 8087 8088 func (u ServerToolUseBlockCallerUnion) AsCodeExecution20250825() (v ServerToolCaller) { 8089 apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) 8090 return 8091 } 8092 8093 func (u ServerToolUseBlockCallerUnion) AsCodeExecution20260120() (v ServerToolCaller20260120) { 8094 apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) 8095 return 8096 } 8097 8098 // Returns the unmodified JSON received from the API 8099 func (u ServerToolUseBlockCallerUnion) RawJSON() string { return u.JSON.raw } 8100 8101 func (r *ServerToolUseBlockCallerUnion) UnmarshalJSON(data []byte) error { 8102 return apijson.UnmarshalRoot(data, r) 8103 } 8104 8105 type ServerToolUseBlockName string 8106 8107 const ( 8108 ServerToolUseBlockNameWebSearch ServerToolUseBlockName = "web_search" 8109 ServerToolUseBlockNameWebFetch ServerToolUseBlockName = "web_fetch" 8110 ServerToolUseBlockNameCodeExecution ServerToolUseBlockName = "code_execution" 8111 ServerToolUseBlockNameBashCodeExecution ServerToolUseBlockName = "bash_code_execution" 8112 ServerToolUseBlockNameTextEditorCodeExecution ServerToolUseBlockName = "text_editor_code_execution" 8113 ServerToolUseBlockNameToolSearchToolRegex ServerToolUseBlockName = "tool_search_tool_regex" 8114 ServerToolUseBlockNameToolSearchToolBm25 ServerToolUseBlockName = "tool_search_tool_bm25" 8115 ) 8116 8117 // The properties ID, Input, Name, Type are required. 8118 type ServerToolUseBlockParam struct { 8119 ID string `json:"id" api:"required"` 8120 Input any `json:"input,omitzero" api:"required"` 8121 // Any of "web_search", "web_fetch", "code_execution", "bash_code_execution", 8122 // "text_editor_code_execution", "tool_search_tool_regex", "tool_search_tool_bm25". 8123 Name ServerToolUseBlockParamName `json:"name,omitzero" api:"required"` 8124 // Create a cache control breakpoint at this content block. 8125 CacheControl CacheControlEphemeralParam `json:"cache_control,omitzero"` 8126 // Tool invocation directly from the model. 8127 Caller ServerToolUseBlockParamCallerUnion `json:"caller,omitzero"` 8128 // This field can be elided, and will marshal its zero value as "server_tool_use". 8129 Type constant.ServerToolUse `json:"type" default:"server_tool_use"` 8130 paramObj 8131 } 8132 8133 func (r ServerToolUseBlockParam) MarshalJSON() (data []byte, err error) { 8134 type shadow ServerToolUseBlockParam 8135 return param.MarshalObject(r, (*shadow)(&r)) 8136 } 8137 func (r *ServerToolUseBlockParam) UnmarshalJSON(data []byte) error { 8138 return apijson.UnmarshalRoot(data, r) 8139 } 8140 8141 type ServerToolUseBlockParamName string 8142 8143 const ( 8144 ServerToolUseBlockParamNameWebSearch ServerToolUseBlockParamName = "web_search" 8145 ServerToolUseBlockParamNameWebFetch ServerToolUseBlockParamName = "web_fetch" 8146 ServerToolUseBlockParamNameCodeExecution ServerToolUseBlockParamName = "code_execution" 8147 ServerToolUseBlockParamNameBashCodeExecution ServerToolUseBlockParamName = "bash_code_execution" 8148 ServerToolUseBlockParamNameTextEditorCodeExecution ServerToolUseBlockParamName = "text_editor_code_execution" 8149 ServerToolUseBlockParamNameToolSearchToolRegex ServerToolUseBlockParamName = "tool_search_tool_regex" 8150 ServerToolUseBlockParamNameToolSearchToolBm25 ServerToolUseBlockParamName = "tool_search_tool_bm25" 8151 ) 8152 8153 // Only one field can be non-zero. 8154 // 8155 // Use [param.IsOmitted] to confirm if a field is set. 8156 type ServerToolUseBlockParamCallerUnion struct { 8157 OfDirect *DirectCallerParam `json:",omitzero,inline"` 8158 OfCodeExecution20250825 *ServerToolCallerParam `json:",omitzero,inline"` 8159 OfCodeExecution20260120 *ServerToolCaller20260120Param `json:",omitzero,inline"` 8160 paramUnion 8161 } 8162 8163 func (u ServerToolUseBlockParamCallerUnion) MarshalJSON() ([]byte, error) { 8164 return param.MarshalUnion(u, u.OfDirect, u.OfCodeExecution20250825, u.OfCodeExecution20260120) 8165 } 8166 func (u *ServerToolUseBlockParamCallerUnion) UnmarshalJSON(data []byte) error { 8167 return apijson.UnmarshalRoot(data, u) 8168 } 8169 8170 func (u *ServerToolUseBlockParamCallerUnion) asAny() any { 8171 if !param.IsOmitted(u.OfDirect) { 8172 return u.OfDirect 8173 } else if !param.IsOmitted(u.OfCodeExecution20250825) { 8174 return u.OfCodeExecution20250825 8175 } else if !param.IsOmitted(u.OfCodeExecution20260120) { 8176 return u.OfCodeExecution20260120 8177 } 8178 return nil 8179 } 8180 8181 // Returns a pointer to the underlying variant's property, if present. 8182 func (u ServerToolUseBlockParamCallerUnion) GetType() *string { 8183 if vt := u.OfDirect; vt != nil { 8184 return (*string)(&vt.Type) 8185 } else if vt := u.OfCodeExecution20250825; vt != nil { 8186 return (*string)(&vt.Type) 8187 } else if vt := u.OfCodeExecution20260120; vt != nil { 8188 return (*string)(&vt.Type) 8189 } 8190 return nil 8191 } 8192 8193 // Returns a pointer to the underlying variant's property, if present. 8194 func (u ServerToolUseBlockParamCallerUnion) GetToolID() *string { 8195 if vt := u.OfCodeExecution20250825; vt != nil { 8196 return (*string)(&vt.ToolID) 8197 } else if vt := u.OfCodeExecution20260120; vt != nil { 8198 return (*string)(&vt.ToolID) 8199 } 8200 return nil 8201 } 8202 8203 func init() { 8204 apijson.RegisterUnion[ServerToolUseBlockParamCallerUnion]( 8205 "type", 8206 apijson.Discriminator[DirectCallerParam]("direct"), 8207 apijson.Discriminator[ServerToolCallerParam]("code_execution_20250825"), 8208 apijson.Discriminator[ServerToolCaller20260120Param]("code_execution_20260120"), 8209 ) 8210 } 8211 8212 type SignatureDelta struct { 8213 // The `signature` for this thinking block: an opaque value used to verify that the 8214 // block was generated by Claude when it is passed back to the API. Delivered in a 8215 // `signature_delta` event just before the block's `content_block_stop` event. 8216 Signature string `json:"signature" api:"required"` 8217 Type constant.SignatureDelta `json:"type" default:"signature_delta"` 8218 // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. 8219 JSON struct { 8220 Signature respjson.Field 8221 Type respjson.Field 8222 ExtraFields map[string]respjson.Field 8223 raw string 8224 } `json:"-"` 8225 } 8226 8227 // Returns the unmodified JSON received from the API 8228 func (r SignatureDelta) RawJSON() string { return r.JSON.raw } 8229 func (r *SignatureDelta) UnmarshalJSON(data []byte) error { 8230 return apijson.UnmarshalRoot(data, r) 8231 } 8232 8233 // Specification for a skill to be loaded in a container (request model). 8234 // 8235 // The properties SkillID, Type are required. 8236 type SkillParams struct { 8237 // Skill ID 8238 SkillID string `json:"skill_id" api:"required"` 8239 // Type of skill - either 'anthropic' (built-in) or 'custom' (user-defined) 8240 // 8241 // Any of "anthropic", "custom". 8242 Type SkillParamsType `json:"type,omitzero" api:"required"` 8243 // Skill version or 'latest' for most recent version 8244 Version param.Opt[string] `json:"version,omitzero"` 8245 paramObj 8246 } 8247 8248 func (r SkillParams) MarshalJSON() (data []byte, err error) { 8249 type shadow SkillParams 8250 return param.MarshalObject(r, (*shadow)(&r)) 8251 } 8252 func (r *SkillParams) UnmarshalJSON(data []byte) error { 8253 return apijson.UnmarshalRoot(data, r) 8254 } 8255 8256 // Type of skill - either 'anthropic' (built-in) or 'custom' (user-defined) 8257 type SkillParamsType string 8258 8259 const ( 8260 SkillParamsTypeAnthropic SkillParamsType = "anthropic" 8261 SkillParamsTypeCustom SkillParamsType = "custom" 8262 ) 8263 8264 type StopReason string 8265 8266 const ( 8267 StopReasonEndTurn StopReason = "end_turn" 8268 StopReasonMaxTokens StopReason = "max_tokens" 8269 StopReasonStopSequence StopReason = "stop_sequence" 8270 StopReasonToolUse StopReason = "tool_use" 8271 StopReasonPauseTurn StopReason = "pause_turn" 8272 StopReasonRefusal StopReason = "refusal" 8273 StopReasonModelContextWindowExceeded StopReason = "model_context_window_exceeded" 8274 ) 8275 8276 type TextBlock struct { 8277 // Citations supporting the text block. 8278 // 8279 // The type of citation returned will depend on the type of document being cited. 8280 // Citing a PDF results in `page_location`, plain text results in `char_location`, 8281 // and content document results in `content_block_location`. 8282 Citations []TextCitationUnion `json:"citations" api:"required"` 8283 Text string `json:"text" api:"required"` 8284 Type constant.Text `json:"type" default:"text"` 8285 // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. 8286 JSON struct { 8287 Citations respjson.Field 8288 Text respjson.Field 8289 Type respjson.Field 8290 ExtraFields map[string]respjson.Field 8291 raw string 8292 } `json:"-"` 8293 } 8294 8295 // Returns the unmodified JSON received from the API 8296 func (r TextBlock) RawJSON() string { return r.JSON.raw } 8297 func (r *TextBlock) UnmarshalJSON(data []byte) error { 8298 return apijson.UnmarshalRoot(data, r) 8299 } 8300 8301 // The properties Text, Type are required. 8302 type TextBlockParam struct { 8303 Text string `json:"text" api:"required"` 8304 Citations []TextCitationParamUnion `json:"citations,omitzero"` 8305 // Create a cache control breakpoint at this content block. 8306 CacheControl CacheControlEphemeralParam `json:"cache_control,omitzero"` 8307 // This field can be elided, and will marshal its zero value as "text". 8308 Type constant.Text `json:"type" default:"text"` 8309 paramObj 8310 } 8311 8312 func (r TextBlockParam) MarshalJSON() (data []byte, err error) { 8313 type shadow TextBlockParam 8314 return param.MarshalObject(r, (*shadow)(&r)) 8315 } 8316 func (r *TextBlockParam) UnmarshalJSON(data []byte) error { 8317 return apijson.UnmarshalRoot(data, r) 8318 } 8319 8320 // TextCitationUnion contains all possible properties and values from 8321 // [CitationCharLocation], [CitationPageLocation], [CitationContentBlockLocation], 8322 // [CitationsWebSearchResultLocation], [CitationsSearchResultLocation]. 8323 // 8324 // Use the [TextCitationUnion.AsAny] method to switch on the variant. 8325 // 8326 // Use the methods beginning with 'As' to cast the union to one of its variants. 8327 type TextCitationUnion struct { 8328 CitedText string `json:"cited_text"` 8329 DocumentIndex int64 `json:"document_index"` 8330 DocumentTitle string `json:"document_title"` 8331 // This field is from variant [CitationCharLocation]. 8332 EndCharIndex int64 `json:"end_char_index"` 8333 FileID string `json:"file_id"` 8334 // This field is from variant [CitationCharLocation]. 8335 StartCharIndex int64 `json:"start_char_index"` 8336 // Any of "char_location", "page_location", "content_block_location", 8337 // "web_search_result_location", "search_result_location". 8338 Type string `json:"type"` 8339 // This field is from variant [CitationPageLocation]. 8340 EndPageNumber int64 `json:"end_page_number"` 8341 // This field is from variant [CitationPageLocation]. 8342 StartPageNumber int64 `json:"start_page_number"` 8343 EndBlockIndex int64 `json:"end_block_index"` 8344 StartBlockIndex int64 `json:"start_block_index"` 8345 // This field is from variant [CitationsWebSearchResultLocation]. 8346 EncryptedIndex string `json:"encrypted_index"` 8347 Title string `json:"title"` 8348 // This field is from variant [CitationsWebSearchResultLocation]. 8349 URL string `json:"url"` 8350 // This field is from variant [CitationsSearchResultLocation]. 8351 SearchResultIndex int64 `json:"search_result_index"` 8352 // This field is from variant [CitationsSearchResultLocation]. 8353 Source string `json:"source"` 8354 JSON struct { 8355 CitedText respjson.Field 8356 DocumentIndex respjson.Field 8357 DocumentTitle respjson.Field 8358 EndCharIndex respjson.Field 8359 FileID respjson.Field 8360 StartCharIndex respjson.Field 8361 Type respjson.Field 8362 EndPageNumber respjson.Field 8363 StartPageNumber respjson.Field 8364 EndBlockIndex respjson.Field 8365 StartBlockIndex respjson.Field 8366 EncryptedIndex respjson.Field 8367 Title respjson.Field 8368 URL respjson.Field 8369 SearchResultIndex respjson.Field 8370 Source respjson.Field 8371 raw string 8372 } `json:"-"` 8373 } 8374 8375 // anyTextCitation is implemented by each variant of [TextCitationUnion] to add 8376 // type safety for the return type of [TextCitationUnion.AsAny] 8377 type anyTextCitation interface { 8378 implTextCitationUnion() 8379 toParamUnion() TextCitationParamUnion 8380 } 8381 8382 func (CitationCharLocation) implTextCitationUnion() {} 8383 func (CitationPageLocation) implTextCitationUnion() {} 8384 func (CitationContentBlockLocation) implTextCitationUnion() {} 8385 func (CitationsWebSearchResultLocation) implTextCitationUnion() {} 8386 func (CitationsSearchResultLocation) implTextCitationUnion() {} 8387 8388 // Use the following switch statement to find the correct variant 8389 // 8390 // switch variant := TextCitationUnion.AsAny().(type) { 8391 // case anthropic.CitationCharLocation: 8392 // case anthropic.CitationPageLocation: 8393 // case anthropic.CitationContentBlockLocation: 8394 // case anthropic.CitationsWebSearchResultLocation: 8395 // case anthropic.CitationsSearchResultLocation: 8396 // default: 8397 // fmt.Errorf("no variant present") 8398 // } 8399 func (u TextCitationUnion) AsAny() anyTextCitation { 8400 switch u.Type { 8401 case "char_location": 8402 return u.AsCharLocation() 8403 case "page_location": 8404 return u.AsPageLocation() 8405 case "content_block_location": 8406 return u.AsContentBlockLocation() 8407 case "web_search_result_location": 8408 return u.AsWebSearchResultLocation() 8409 case "search_result_location": 8410 return u.AsSearchResultLocation() 8411 } 8412 return nil 8413 } 8414 8415 func (u TextCitationUnion) AsCharLocation() (v CitationCharLocation) { 8416 apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) 8417 return 8418 } 8419 8420 func (u TextCitationUnion) AsPageLocation() (v CitationPageLocation) { 8421 apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) 8422 return 8423 } 8424 8425 func (u TextCitationUnion) AsContentBlockLocation() (v CitationContentBlockLocation) { 8426 apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) 8427 return 8428 } 8429 8430 func (u TextCitationUnion) AsWebSearchResultLocation() (v CitationsWebSearchResultLocation) { 8431 apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) 8432 return 8433 } 8434 8435 func (u TextCitationUnion) AsSearchResultLocation() (v CitationsSearchResultLocation) { 8436 apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) 8437 return 8438 } 8439 8440 // Returns the unmodified JSON received from the API 8441 func (u TextCitationUnion) RawJSON() string { return u.JSON.raw } 8442 8443 func (r *TextCitationUnion) UnmarshalJSON(data []byte) error { 8444 return apijson.UnmarshalRoot(data, r) 8445 } 8446 8447 // Only one field can be non-zero. 8448 // 8449 // Use [param.IsOmitted] to confirm if a field is set. 8450 type TextCitationParamUnion struct { 8451 OfCharLocation *CitationCharLocationParam `json:",omitzero,inline"` 8452 OfPageLocation *CitationPageLocationParam `json:",omitzero,inline"` 8453 OfContentBlockLocation *CitationContentBlockLocationParam `json:",omitzero,inline"` 8454 OfWebSearchResultLocation *CitationWebSearchResultLocationParam `json:",omitzero,inline"` 8455 OfSearchResultLocation *CitationSearchResultLocationParam `json:",omitzero,inline"` 8456 paramUnion 8457 } 8458 8459 func (u TextCitationParamUnion) MarshalJSON() ([]byte, error) { 8460 return param.MarshalUnion(u, u.OfCharLocation, 8461 u.OfPageLocation, 8462 u.OfContentBlockLocation, 8463 u.OfWebSearchResultLocation, 8464 u.OfSearchResultLocation) 8465 } 8466 func (u *TextCitationParamUnion) UnmarshalJSON(data []byte) error { 8467 return apijson.UnmarshalRoot(data, u) 8468 } 8469 8470 func (u *TextCitationParamUnion) asAny() any { 8471 if !param.IsOmitted(u.OfCharLocation) { 8472 return u.OfCharLocation 8473 } else if !param.IsOmitted(u.OfPageLocation) { 8474 return u.OfPageLocation 8475 } else if !param.IsOmitted(u.OfContentBlockLocation) { 8476 return u.OfContentBlockLocation 8477 } else if !param.IsOmitted(u.OfWebSearchResultLocation) { 8478 return u.OfWebSearchResultLocation 8479 } else if !param.IsOmitted(u.OfSearchResultLocation) { 8480 return u.OfSearchResultLocation 8481 } 8482 return nil 8483 } 8484 8485 // Returns a pointer to the underlying variant's property, if present. 8486 func (u TextCitationParamUnion) GetEndCharIndex() *int64 { 8487 if vt := u.OfCharLocation; vt != nil { 8488 return &vt.EndCharIndex 8489 } 8490 return nil 8491 } 8492 8493 // Returns a pointer to the underlying variant's property, if present. 8494 func (u TextCitationParamUnion) GetStartCharIndex() *int64 { 8495 if vt := u.OfCharLocation; vt != nil { 8496 return &vt.StartCharIndex 8497 } 8498 return nil 8499 } 8500 8501 // Returns a pointer to the underlying variant's property, if present. 8502 func (u TextCitationParamUnion) GetEndPageNumber() *int64 { 8503 if vt := u.OfPageLocation; vt != nil { 8504 return &vt.EndPageNumber 8505 } 8506 return nil 8507 } 8508 8509 // Returns a pointer to the underlying variant's property, if present. 8510 func (u TextCitationParamUnion) GetStartPageNumber() *int64 { 8511 if vt := u.OfPageLocation; vt != nil { 8512 return &vt.StartPageNumber 8513 } 8514 return nil 8515 } 8516 8517 // Returns a pointer to the underlying variant's property, if present. 8518 func (u TextCitationParamUnion) GetEncryptedIndex() *string { 8519 if vt := u.OfWebSearchResultLocation; vt != nil { 8520 return &vt.EncryptedIndex 8521 } 8522 return nil 8523 } 8524 8525 // Returns a pointer to the underlying variant's property, if present. 8526 func (u TextCitationParamUnion) GetURL() *string { 8527 if vt := u.OfWebSearchResultLocation; vt != nil { 8528 return &vt.URL 8529 } 8530 return nil 8531 } 8532 8533 // Returns a pointer to the underlying variant's property, if present. 8534 func (u TextCitationParamUnion) GetSearchResultIndex() *int64 { 8535 if vt := u.OfSearchResultLocation; vt != nil { 8536 return &vt.SearchResultIndex 8537 } 8538 return nil 8539 } 8540 8541 // Returns a pointer to the underlying variant's property, if present. 8542 func (u TextCitationParamUnion) GetSource() *string { 8543 if vt := u.OfSearchResultLocation; vt != nil { 8544 return &vt.Source 8545 } 8546 return nil 8547 } 8548 8549 // Returns a pointer to the underlying variant's property, if present. 8550 func (u TextCitationParamUnion) GetCitedText() *string { 8551 if vt := u.OfCharLocation; vt != nil { 8552 return (*string)(&vt.CitedText) 8553 } else if vt := u.OfPageLocation; vt != nil { 8554 return (*string)(&vt.CitedText) 8555 } else if vt := u.OfContentBlockLocation; vt != nil { 8556 return (*string)(&vt.CitedText) 8557 } else if vt := u.OfWebSearchResultLocation; vt != nil { 8558 return (*string)(&vt.CitedText) 8559 } else if vt := u.OfSearchResultLocation; vt != nil { 8560 return (*string)(&vt.CitedText) 8561 } 8562 return nil 8563 } 8564 8565 // Returns a pointer to the underlying variant's property, if present. 8566 func (u TextCitationParamUnion) GetDocumentIndex() *int64 { 8567 if vt := u.OfCharLocation; vt != nil { 8568 return (*int64)(&vt.DocumentIndex) 8569 } else if vt := u.OfPageLocation; vt != nil { 8570 return (*int64)(&vt.DocumentIndex) 8571 } else if vt := u.OfContentBlockLocation; vt != nil { 8572 return (*int64)(&vt.DocumentIndex) 8573 } 8574 return nil 8575 } 8576 8577 // Returns a pointer to the underlying variant's property, if present. 8578 func (u TextCitationParamUnion) GetDocumentTitle() *string { 8579 if vt := u.OfCharLocation; vt != nil && vt.DocumentTitle.Valid() { 8580 return &vt.DocumentTitle.Value 8581 } else if vt := u.OfPageLocation; vt != nil && vt.DocumentTitle.Valid() { 8582 return &vt.DocumentTitle.Value 8583 } else if vt := u.OfContentBlockLocation; vt != nil && vt.DocumentTitle.Valid() { 8584 return &vt.DocumentTitle.Value 8585 } 8586 return nil 8587 } 8588 8589 // Returns a pointer to the underlying variant's property, if present. 8590 func (u TextCitationParamUnion) GetType() *string { 8591 if vt := u.OfCharLocation; vt != nil { 8592 return (*string)(&vt.Type) 8593 } else if vt := u.OfPageLocation; vt != nil { 8594 return (*string)(&vt.Type) 8595 } else if vt := u.OfContentBlockLocation; vt != nil { 8596 return (*string)(&vt.Type) 8597 } else if vt := u.OfWebSearchResultLocation; vt != nil { 8598 return (*string)(&vt.Type) 8599 } else if vt := u.OfSearchResultLocation; vt != nil { 8600 return (*string)(&vt.Type) 8601 } 8602 return nil 8603 } 8604 8605 // Returns a pointer to the underlying variant's property, if present. 8606 func (u TextCitationParamUnion) GetEndBlockIndex() *int64 { 8607 if vt := u.OfContentBlockLocation; vt != nil { 8608 return (*int64)(&vt.EndBlockIndex) 8609 } else if vt := u.OfSearchResultLocation; vt != nil { 8610 return (*int64)(&vt.EndBlockIndex) 8611 } 8612 return nil 8613 } 8614 8615 // Returns a pointer to the underlying variant's property, if present. 8616 func (u TextCitationParamUnion) GetStartBlockIndex() *int64 { 8617 if vt := u.OfContentBlockLocation; vt != nil { 8618 return (*int64)(&vt.StartBlockIndex) 8619 } else if vt := u.OfSearchResultLocation; vt != nil { 8620 return (*int64)(&vt.StartBlockIndex) 8621 } 8622 return nil 8623 } 8624 8625 // Returns a pointer to the underlying variant's property, if present. 8626 func (u TextCitationParamUnion) GetTitle() *string { 8627 if vt := u.OfWebSearchResultLocation; vt != nil && vt.Title.Valid() { 8628 return &vt.Title.Value 8629 } else if vt := u.OfSearchResultLocation; vt != nil && vt.Title.Valid() { 8630 return &vt.Title.Value 8631 } 8632 return nil 8633 } 8634 8635 func init() { 8636 apijson.RegisterUnion[TextCitationParamUnion]( 8637 "type", 8638 apijson.Discriminator[CitationCharLocationParam]("char_location"), 8639 apijson.Discriminator[CitationPageLocationParam]("page_location"), 8640 apijson.Discriminator[CitationContentBlockLocationParam]("content_block_location"), 8641 apijson.Discriminator[CitationWebSearchResultLocationParam]("web_search_result_location"), 8642 apijson.Discriminator[CitationSearchResultLocationParam]("search_result_location"), 8643 ) 8644 } 8645 8646 type TextDelta struct { 8647 Text string `json:"text" api:"required"` 8648 Type constant.TextDelta `json:"type" default:"text_delta"` 8649 // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. 8650 JSON struct { 8651 Text respjson.Field 8652 Type respjson.Field 8653 ExtraFields map[string]respjson.Field 8654 raw string 8655 } `json:"-"` 8656 } 8657 8658 // Returns the unmodified JSON received from the API 8659 func (r TextDelta) RawJSON() string { return r.JSON.raw } 8660 func (r *TextDelta) UnmarshalJSON(data []byte) error { 8661 return apijson.UnmarshalRoot(data, r) 8662 } 8663 8664 type TextEditorCodeExecutionCreateResultBlock struct { 8665 IsFileUpdate bool `json:"is_file_update" api:"required"` 8666 Type constant.TextEditorCodeExecutionCreateResult `json:"type" default:"text_editor_code_execution_create_result"` 8667 // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. 8668 JSON struct { 8669 IsFileUpdate respjson.Field 8670 Type respjson.Field 8671 ExtraFields map[string]respjson.Field 8672 raw string 8673 } `json:"-"` 8674 } 8675 8676 // Returns the unmodified JSON received from the API 8677 func (r TextEditorCodeExecutionCreateResultBlock) RawJSON() string { return r.JSON.raw } 8678 func (r *TextEditorCodeExecutionCreateResultBlock) UnmarshalJSON(data []byte) error { 8679 return apijson.UnmarshalRoot(data, r) 8680 } 8681 8682 // The properties IsFileUpdate, Type are required. 8683 type TextEditorCodeExecutionCreateResultBlockParam struct { 8684 IsFileUpdate bool `json:"is_file_update" api:"required"` 8685 // This field can be elided, and will marshal its zero value as 8686 // "text_editor_code_execution_create_result". 8687 Type constant.TextEditorCodeExecutionCreateResult `json:"type" default:"text_editor_code_execution_create_result"` 8688 paramObj 8689 } 8690 8691 func (r TextEditorCodeExecutionCreateResultBlockParam) MarshalJSON() (data []byte, err error) { 8692 type shadow TextEditorCodeExecutionCreateResultBlockParam 8693 return param.MarshalObject(r, (*shadow)(&r)) 8694 } 8695 func (r *TextEditorCodeExecutionCreateResultBlockParam) UnmarshalJSON(data []byte) error { 8696 return apijson.UnmarshalRoot(data, r) 8697 } 8698 8699 type TextEditorCodeExecutionStrReplaceResultBlock struct { 8700 Lines []string `json:"lines" api:"required"` 8701 NewLines int64 `json:"new_lines" api:"required"` 8702 NewStart int64 `json:"new_start" api:"required"` 8703 OldLines int64 `json:"old_lines" api:"required"` 8704 OldStart int64 `json:"old_start" api:"required"` 8705 Type constant.TextEditorCodeExecutionStrReplaceResult `json:"type" default:"text_editor_code_execution_str_replace_result"` 8706 // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. 8707 JSON struct { 8708 Lines respjson.Field 8709 NewLines respjson.Field 8710 NewStart respjson.Field 8711 OldLines respjson.Field 8712 OldStart respjson.Field 8713 Type respjson.Field 8714 ExtraFields map[string]respjson.Field 8715 raw string 8716 } `json:"-"` 8717 } 8718 8719 // Returns the unmodified JSON received from the API 8720 func (r TextEditorCodeExecutionStrReplaceResultBlock) RawJSON() string { return r.JSON.raw } 8721 func (r *TextEditorCodeExecutionStrReplaceResultBlock) UnmarshalJSON(data []byte) error { 8722 return apijson.UnmarshalRoot(data, r) 8723 } 8724 8725 // The property Type is required. 8726 type TextEditorCodeExecutionStrReplaceResultBlockParam struct { 8727 NewLines param.Opt[int64] `json:"new_lines,omitzero"` 8728 NewStart param.Opt[int64] `json:"new_start,omitzero"` 8729 OldLines param.Opt[int64] `json:"old_lines,omitzero"` 8730 OldStart param.Opt[int64] `json:"old_start,omitzero"` 8731 Lines []string `json:"lines,omitzero"` 8732 // This field can be elided, and will marshal its zero value as 8733 // "text_editor_code_execution_str_replace_result". 8734 Type constant.TextEditorCodeExecutionStrReplaceResult `json:"type" default:"text_editor_code_execution_str_replace_result"` 8735 paramObj 8736 } 8737 8738 func (r TextEditorCodeExecutionStrReplaceResultBlockParam) MarshalJSON() (data []byte, err error) { 8739 type shadow TextEditorCodeExecutionStrReplaceResultBlockParam 8740 return param.MarshalObject(r, (*shadow)(&r)) 8741 } 8742 func (r *TextEditorCodeExecutionStrReplaceResultBlockParam) UnmarshalJSON(data []byte) error { 8743 return apijson.UnmarshalRoot(data, r) 8744 } 8745 8746 type TextEditorCodeExecutionToolResultBlock struct { 8747 Content TextEditorCodeExecutionToolResultBlockContentUnion `json:"content" api:"required"` 8748 ToolUseID string `json:"tool_use_id" api:"required"` 8749 Type constant.TextEditorCodeExecutionToolResult `json:"type" default:"text_editor_code_execution_tool_result"` 8750 // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. 8751 JSON struct { 8752 Content respjson.Field 8753 ToolUseID respjson.Field 8754 Type respjson.Field 8755 ExtraFields map[string]respjson.Field 8756 raw string 8757 } `json:"-"` 8758 } 8759 8760 // Returns the unmodified JSON received from the API 8761 func (r TextEditorCodeExecutionToolResultBlock) RawJSON() string { return r.JSON.raw } 8762 func (r *TextEditorCodeExecutionToolResultBlock) UnmarshalJSON(data []byte) error { 8763 return apijson.UnmarshalRoot(data, r) 8764 } 8765 8766 // TextEditorCodeExecutionToolResultBlockContentUnion contains all possible 8767 // properties and values from [TextEditorCodeExecutionToolResultError], 8768 // [TextEditorCodeExecutionViewResultBlock], 8769 // [TextEditorCodeExecutionCreateResultBlock], 8770 // [TextEditorCodeExecutionStrReplaceResultBlock]. 8771 // 8772 // Use the methods beginning with 'As' to cast the union to one of its variants. 8773 type TextEditorCodeExecutionToolResultBlockContentUnion struct { 8774 // This field is from variant [TextEditorCodeExecutionToolResultError]. 8775 ErrorCode TextEditorCodeExecutionToolResultErrorCode `json:"error_code"` 8776 // This field is from variant [TextEditorCodeExecutionToolResultError]. 8777 ErrorMessage string `json:"error_message"` 8778 Type string `json:"type"` 8779 // This field is from variant [TextEditorCodeExecutionViewResultBlock]. 8780 Content string `json:"content"` 8781 // This field is from variant [TextEditorCodeExecutionViewResultBlock]. 8782 FileType TextEditorCodeExecutionViewResultBlockFileType `json:"file_type"` 8783 // This field is from variant [TextEditorCodeExecutionViewResultBlock]. 8784 NumLines int64 `json:"num_lines"` 8785 // This field is from variant [TextEditorCodeExecutionViewResultBlock]. 8786 StartLine int64 `json:"start_line"` 8787 // This field is from variant [TextEditorCodeExecutionViewResultBlock]. 8788 TotalLines int64 `json:"total_lines"` 8789 // This field is from variant [TextEditorCodeExecutionCreateResultBlock]. 8790 IsFileUpdate bool `json:"is_file_update"` 8791 // This field is from variant [TextEditorCodeExecutionStrReplaceResultBlock]. 8792 Lines []string `json:"lines"` 8793 // This field is from variant [TextEditorCodeExecutionStrReplaceResultBlock]. 8794 NewLines int64 `json:"new_lines"` 8795 // This field is from variant [TextEditorCodeExecutionStrReplaceResultBlock]. 8796 NewStart int64 `json:"new_start"` 8797 // This field is from variant [TextEditorCodeExecutionStrReplaceResultBlock]. 8798 OldLines int64 `json:"old_lines"` 8799 // This field is from variant [TextEditorCodeExecutionStrReplaceResultBlock]. 8800 OldStart int64 `json:"old_start"` 8801 JSON struct { 8802 ErrorCode respjson.Field 8803 ErrorMessage respjson.Field 8804 Type respjson.Field 8805 Content respjson.Field 8806 FileType respjson.Field 8807 NumLines respjson.Field 8808 StartLine respjson.Field 8809 TotalLines respjson.Field 8810 IsFileUpdate respjson.Field 8811 Lines respjson.Field 8812 NewLines respjson.Field 8813 NewStart respjson.Field 8814 OldLines respjson.Field 8815 OldStart respjson.Field 8816 raw string 8817 } `json:"-"` 8818 } 8819 8820 func (u TextEditorCodeExecutionToolResultBlockContentUnion) AsResponseTextEditorCodeExecutionToolResultError() (v TextEditorCodeExecutionToolResultError) { 8821 apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) 8822 return 8823 } 8824 8825 func (u TextEditorCodeExecutionToolResultBlockContentUnion) AsResponseTextEditorCodeExecutionViewResultBlock() (v TextEditorCodeExecutionViewResultBlock) { 8826 apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) 8827 return 8828 } 8829 8830 func (u TextEditorCodeExecutionToolResultBlockContentUnion) AsResponseTextEditorCodeExecutionCreateResultBlock() (v TextEditorCodeExecutionCreateResultBlock) { 8831 apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) 8832 return 8833 } 8834 8835 func (u TextEditorCodeExecutionToolResultBlockContentUnion) AsResponseTextEditorCodeExecutionStrReplaceResultBlock() (v TextEditorCodeExecutionStrReplaceResultBlock) { 8836 apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) 8837 return 8838 } 8839 8840 // Returns the unmodified JSON received from the API 8841 func (u TextEditorCodeExecutionToolResultBlockContentUnion) RawJSON() string { return u.JSON.raw } 8842 8843 func (r *TextEditorCodeExecutionToolResultBlockContentUnion) UnmarshalJSON(data []byte) error { 8844 return apijson.UnmarshalRoot(data, r) 8845 } 8846 8847 // The properties Content, ToolUseID, Type are required. 8848 type TextEditorCodeExecutionToolResultBlockParam struct { 8849 Content TextEditorCodeExecutionToolResultBlockParamContentUnion `json:"content,omitzero" api:"required"` 8850 ToolUseID string `json:"tool_use_id" api:"required"` 8851 // Create a cache control breakpoint at this content block. 8852 CacheControl CacheControlEphemeralParam `json:"cache_control,omitzero"` 8853 // This field can be elided, and will marshal its zero value as 8854 // "text_editor_code_execution_tool_result". 8855 Type constant.TextEditorCodeExecutionToolResult `json:"type" default:"text_editor_code_execution_tool_result"` 8856 paramObj 8857 } 8858 8859 func (r TextEditorCodeExecutionToolResultBlockParam) MarshalJSON() (data []byte, err error) { 8860 type shadow TextEditorCodeExecutionToolResultBlockParam 8861 return param.MarshalObject(r, (*shadow)(&r)) 8862 } 8863 func (r *TextEditorCodeExecutionToolResultBlockParam) UnmarshalJSON(data []byte) error { 8864 return apijson.UnmarshalRoot(data, r) 8865 } 8866 8867 // Only one field can be non-zero. 8868 // 8869 // Use [param.IsOmitted] to confirm if a field is set. 8870 type TextEditorCodeExecutionToolResultBlockParamContentUnion struct { 8871 OfRequestTextEditorCodeExecutionToolResultError *TextEditorCodeExecutionToolResultErrorParam `json:",omitzero,inline"` 8872 OfRequestTextEditorCodeExecutionViewResultBlock *TextEditorCodeExecutionViewResultBlockParam `json:",omitzero,inline"` 8873 OfRequestTextEditorCodeExecutionCreateResultBlock *TextEditorCodeExecutionCreateResultBlockParam `json:",omitzero,inline"` 8874 OfRequestTextEditorCodeExecutionStrReplaceResultBlock *TextEditorCodeExecutionStrReplaceResultBlockParam `json:",omitzero,inline"` 8875 paramUnion 8876 } 8877 8878 func (u TextEditorCodeExecutionToolResultBlockParamContentUnion) MarshalJSON() ([]byte, error) { 8879 return param.MarshalUnion(u, u.OfRequestTextEditorCodeExecutionToolResultError, u.OfRequestTextEditorCodeExecutionViewResultBlock, u.OfRequestTextEditorCodeExecutionCreateResultBlock, u.OfRequestTextEditorCodeExecutionStrReplaceResultBlock) 8880 } 8881 func (u *TextEditorCodeExecutionToolResultBlockParamContentUnion) UnmarshalJSON(data []byte) error { 8882 return apijson.UnmarshalRoot(data, u) 8883 } 8884 8885 func (u *TextEditorCodeExecutionToolResultBlockParamContentUnion) asAny() any { 8886 if !param.IsOmitted(u.OfRequestTextEditorCodeExecutionToolResultError) { 8887 return u.OfRequestTextEditorCodeExecutionToolResultError 8888 } else if !param.IsOmitted(u.OfRequestTextEditorCodeExecutionViewResultBlock) { 8889 return u.OfRequestTextEditorCodeExecutionViewResultBlock 8890 } else if !param.IsOmitted(u.OfRequestTextEditorCodeExecutionCreateResultBlock) { 8891 return u.OfRequestTextEditorCodeExecutionCreateResultBlock 8892 } else if !param.IsOmitted(u.OfRequestTextEditorCodeExecutionStrReplaceResultBlock) { 8893 return u.OfRequestTextEditorCodeExecutionStrReplaceResultBlock 8894 } 8895 return nil 8896 } 8897 8898 // Returns a pointer to the underlying variant's property, if present. 8899 func (u TextEditorCodeExecutionToolResultBlockParamContentUnion) GetErrorCode() *string { 8900 if vt := u.OfRequestTextEditorCodeExecutionToolResultError; vt != nil { 8901 return (*string)(&vt.ErrorCode) 8902 } 8903 return nil 8904 } 8905 8906 // Returns a pointer to the underlying variant's property, if present. 8907 func (u TextEditorCodeExecutionToolResultBlockParamContentUnion) GetErrorMessage() *string { 8908 if vt := u.OfRequestTextEditorCodeExecutionToolResultError; vt != nil && vt.ErrorMessage.Valid() { 8909 return &vt.ErrorMessage.Value 8910 } 8911 return nil 8912 } 8913 8914 // Returns a pointer to the underlying variant's property, if present. 8915 func (u TextEditorCodeExecutionToolResultBlockParamContentUnion) GetContent() *string { 8916 if vt := u.OfRequestTextEditorCodeExecutionViewResultBlock; vt != nil { 8917 return &vt.Content 8918 } 8919 return nil 8920 } 8921 8922 // Returns a pointer to the underlying variant's property, if present. 8923 func (u TextEditorCodeExecutionToolResultBlockParamContentUnion) GetFileType() *string { 8924 if vt := u.OfRequestTextEditorCodeExecutionViewResultBlock; vt != nil { 8925 return (*string)(&vt.FileType) 8926 } 8927 return nil 8928 } 8929 8930 // Returns a pointer to the underlying variant's property, if present. 8931 func (u TextEditorCodeExecutionToolResultBlockParamContentUnion) GetNumLines() *int64 { 8932 if vt := u.OfRequestTextEditorCodeExecutionViewResultBlock; vt != nil && vt.NumLines.Valid() { 8933 return &vt.NumLines.Value 8934 } 8935 return nil 8936 } 8937 8938 // Returns a pointer to the underlying variant's property, if present. 8939 func (u TextEditorCodeExecutionToolResultBlockParamContentUnion) GetStartLine() *int64 { 8940 if vt := u.OfRequestTextEditorCodeExecutionViewResultBlock; vt != nil && vt.StartLine.Valid() { 8941 return &vt.StartLine.Value 8942 } 8943 return nil 8944 } 8945 8946 // Returns a pointer to the underlying variant's property, if present. 8947 func (u TextEditorCodeExecutionToolResultBlockParamContentUnion) GetTotalLines() *int64 { 8948 if vt := u.OfRequestTextEditorCodeExecutionViewResultBlock; vt != nil && vt.TotalLines.Valid() { 8949 return &vt.TotalLines.Value 8950 } 8951 return nil 8952 } 8953 8954 // Returns a pointer to the underlying variant's property, if present. 8955 func (u TextEditorCodeExecutionToolResultBlockParamContentUnion) GetIsFileUpdate() *bool { 8956 if vt := u.OfRequestTextEditorCodeExecutionCreateResultBlock; vt != nil { 8957 return &vt.IsFileUpdate 8958 } 8959 return nil 8960 } 8961 8962 // Returns a pointer to the underlying variant's property, if present. 8963 func (u TextEditorCodeExecutionToolResultBlockParamContentUnion) GetLines() []string { 8964 if vt := u.OfRequestTextEditorCodeExecutionStrReplaceResultBlock; vt != nil { 8965 return vt.Lines 8966 } 8967 return nil 8968 } 8969 8970 // Returns a pointer to the underlying variant's property, if present. 8971 func (u TextEditorCodeExecutionToolResultBlockParamContentUnion) GetNewLines() *int64 { 8972 if vt := u.OfRequestTextEditorCodeExecutionStrReplaceResultBlock; vt != nil && vt.NewLines.Valid() { 8973 return &vt.NewLines.Value 8974 } 8975 return nil 8976 } 8977 8978 // Returns a pointer to the underlying variant's property, if present. 8979 func (u TextEditorCodeExecutionToolResultBlockParamContentUnion) GetNewStart() *int64 { 8980 if vt := u.OfRequestTextEditorCodeExecutionStrReplaceResultBlock; vt != nil && vt.NewStart.Valid() { 8981 return &vt.NewStart.Value 8982 } 8983 return nil 8984 } 8985 8986 // Returns a pointer to the underlying variant's property, if present. 8987 func (u TextEditorCodeExecutionToolResultBlockParamContentUnion) GetOldLines() *int64 { 8988 if vt := u.OfRequestTextEditorCodeExecutionStrReplaceResultBlock; vt != nil && vt.OldLines.Valid() { 8989 return &vt.OldLines.Value 8990 } 8991 return nil 8992 } 8993 8994 // Returns a pointer to the underlying variant's property, if present. 8995 func (u TextEditorCodeExecutionToolResultBlockParamContentUnion) GetOldStart() *int64 { 8996 if vt := u.OfRequestTextEditorCodeExecutionStrReplaceResultBlock; vt != nil && vt.OldStart.Valid() { 8997 return &vt.OldStart.Value 8998 } 8999 return nil 9000 } 9001 9002 // Returns a pointer to the underlying variant's property, if present. 9003 func (u TextEditorCodeExecutionToolResultBlockParamContentUnion) GetType() *string { 9004 if vt := u.OfRequestTextEditorCodeExecutionToolResultError; vt != nil { 9005 return (*string)(&vt.Type) 9006 } else if vt := u.OfRequestTextEditorCodeExecutionViewResultBlock; vt != nil { 9007 return (*string)(&vt.Type) 9008 } else if vt := u.OfRequestTextEditorCodeExecutionCreateResultBlock; vt != nil { 9009 return (*string)(&vt.Type) 9010 } else if vt := u.OfRequestTextEditorCodeExecutionStrReplaceResultBlock; vt != nil { 9011 return (*string)(&vt.Type) 9012 } 9013 return nil 9014 } 9015 9016 type TextEditorCodeExecutionToolResultError struct { 9017 // Any of "invalid_tool_input", "unavailable", "too_many_requests", 9018 // "execution_time_exceeded", "file_not_found". 9019 ErrorCode TextEditorCodeExecutionToolResultErrorCode `json:"error_code" api:"required"` 9020 ErrorMessage string `json:"error_message" api:"required"` 9021 Type constant.TextEditorCodeExecutionToolResultError `json:"type" default:"text_editor_code_execution_tool_result_error"` 9022 // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. 9023 JSON struct { 9024 ErrorCode respjson.Field 9025 ErrorMessage respjson.Field 9026 Type respjson.Field 9027 ExtraFields map[string]respjson.Field 9028 raw string 9029 } `json:"-"` 9030 } 9031 9032 // Returns the unmodified JSON received from the API 9033 func (r TextEditorCodeExecutionToolResultError) RawJSON() string { return r.JSON.raw } 9034 func (r *TextEditorCodeExecutionToolResultError) UnmarshalJSON(data []byte) error { 9035 return apijson.UnmarshalRoot(data, r) 9036 } 9037 9038 type TextEditorCodeExecutionToolResultErrorCode string 9039 9040 const ( 9041 TextEditorCodeExecutionToolResultErrorCodeInvalidToolInput TextEditorCodeExecutionToolResultErrorCode = "invalid_tool_input" 9042 TextEditorCodeExecutionToolResultErrorCodeUnavailable TextEditorCodeExecutionToolResultErrorCode = "unavailable" 9043 TextEditorCodeExecutionToolResultErrorCodeTooManyRequests TextEditorCodeExecutionToolResultErrorCode = "too_many_requests" 9044 TextEditorCodeExecutionToolResultErrorCodeExecutionTimeExceeded TextEditorCodeExecutionToolResultErrorCode = "execution_time_exceeded" 9045 TextEditorCodeExecutionToolResultErrorCodeFileNotFound TextEditorCodeExecutionToolResultErrorCode = "file_not_found" 9046 ) 9047 9048 // The properties ErrorCode, Type are required. 9049 type TextEditorCodeExecutionToolResultErrorParam struct { 9050 // Any of "invalid_tool_input", "unavailable", "too_many_requests", 9051 // "execution_time_exceeded", "file_not_found". 9052 ErrorCode TextEditorCodeExecutionToolResultErrorCode `json:"error_code,omitzero" api:"required"` 9053 ErrorMessage param.Opt[string] `json:"error_message,omitzero"` 9054 // This field can be elided, and will marshal its zero value as 9055 // "text_editor_code_execution_tool_result_error". 9056 Type constant.TextEditorCodeExecutionToolResultError `json:"type" default:"text_editor_code_execution_tool_result_error"` 9057 paramObj 9058 } 9059 9060 func (r TextEditorCodeExecutionToolResultErrorParam) MarshalJSON() (data []byte, err error) { 9061 type shadow TextEditorCodeExecutionToolResultErrorParam 9062 return param.MarshalObject(r, (*shadow)(&r)) 9063 } 9064 func (r *TextEditorCodeExecutionToolResultErrorParam) UnmarshalJSON(data []byte) error { 9065 return apijson.UnmarshalRoot(data, r) 9066 } 9067 9068 type TextEditorCodeExecutionViewResultBlock struct { 9069 Content string `json:"content" api:"required"` 9070 // Any of "text", "image", "pdf". 9071 FileType TextEditorCodeExecutionViewResultBlockFileType `json:"file_type" api:"required"` 9072 NumLines int64 `json:"num_lines" api:"required"` 9073 StartLine int64 `json:"start_line" api:"required"` 9074 TotalLines int64 `json:"total_lines" api:"required"` 9075 Type constant.TextEditorCodeExecutionViewResult `json:"type" default:"text_editor_code_execution_view_result"` 9076 // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. 9077 JSON struct { 9078 Content respjson.Field 9079 FileType respjson.Field 9080 NumLines respjson.Field 9081 StartLine respjson.Field 9082 TotalLines respjson.Field 9083 Type respjson.Field 9084 ExtraFields map[string]respjson.Field 9085 raw string 9086 } `json:"-"` 9087 } 9088 9089 // Returns the unmodified JSON received from the API 9090 func (r TextEditorCodeExecutionViewResultBlock) RawJSON() string { return r.JSON.raw } 9091 func (r *TextEditorCodeExecutionViewResultBlock) UnmarshalJSON(data []byte) error { 9092 return apijson.UnmarshalRoot(data, r) 9093 } 9094 9095 type TextEditorCodeExecutionViewResultBlockFileType string 9096 9097 const ( 9098 TextEditorCodeExecutionViewResultBlockFileTypeText TextEditorCodeExecutionViewResultBlockFileType = "text" 9099 TextEditorCodeExecutionViewResultBlockFileTypeImage TextEditorCodeExecutionViewResultBlockFileType = "image" 9100 TextEditorCodeExecutionViewResultBlockFileTypePDF TextEditorCodeExecutionViewResultBlockFileType = "pdf" 9101 ) 9102 9103 // The properties Content, FileType, Type are required. 9104 type TextEditorCodeExecutionViewResultBlockParam struct { 9105 Content string `json:"content" api:"required"` 9106 // Any of "text", "image", "pdf". 9107 FileType TextEditorCodeExecutionViewResultBlockParamFileType `json:"file_type,omitzero" api:"required"` 9108 NumLines param.Opt[int64] `json:"num_lines,omitzero"` 9109 StartLine param.Opt[int64] `json:"start_line,omitzero"` 9110 TotalLines param.Opt[int64] `json:"total_lines,omitzero"` 9111 // This field can be elided, and will marshal its zero value as 9112 // "text_editor_code_execution_view_result". 9113 Type constant.TextEditorCodeExecutionViewResult `json:"type" default:"text_editor_code_execution_view_result"` 9114 paramObj 9115 } 9116 9117 func (r TextEditorCodeExecutionViewResultBlockParam) MarshalJSON() (data []byte, err error) { 9118 type shadow TextEditorCodeExecutionViewResultBlockParam 9119 return param.MarshalObject(r, (*shadow)(&r)) 9120 } 9121 func (r *TextEditorCodeExecutionViewResultBlockParam) UnmarshalJSON(data []byte) error { 9122 return apijson.UnmarshalRoot(data, r) 9123 } 9124 9125 type TextEditorCodeExecutionViewResultBlockParamFileType string 9126 9127 const ( 9128 TextEditorCodeExecutionViewResultBlockParamFileTypeText TextEditorCodeExecutionViewResultBlockParamFileType = "text" 9129 TextEditorCodeExecutionViewResultBlockParamFileTypeImage TextEditorCodeExecutionViewResultBlockParamFileType = "image" 9130 TextEditorCodeExecutionViewResultBlockParamFileTypePDF TextEditorCodeExecutionViewResultBlockParamFileType = "pdf" 9131 ) 9132 9133 type ThinkingBlock struct { 9134 // A value used to verify that this thinking block was generated by Claude when it 9135 // is passed back to the API. 9136 // 9137 // This is an opaque field and should not be interpreted or parsed. When passing 9138 // thinking blocks back to the API (required when using tools with extended 9139 // thinking), pass them back exactly as received, with this field intact. 9140 // 9141 // See 9142 // [extended thinking](https://platform.claude.com/docs/en/build-with-claude/extended-thinking) 9143 // for details. 9144 Signature string `json:"signature" api:"required"` 9145 // The text of Claude's thinking process for this block. 9146 Thinking string `json:"thinking" api:"required"` 9147 Type constant.Thinking `json:"type" default:"thinking"` 9148 // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. 9149 JSON struct { 9150 Signature respjson.Field 9151 Thinking respjson.Field 9152 Type respjson.Field 9153 ExtraFields map[string]respjson.Field 9154 raw string 9155 } `json:"-"` 9156 } 9157 9158 // Returns the unmodified JSON received from the API 9159 func (r ThinkingBlock) RawJSON() string { return r.JSON.raw } 9160 func (r *ThinkingBlock) UnmarshalJSON(data []byte) error { 9161 return apijson.UnmarshalRoot(data, r) 9162 } 9163 9164 // The properties Signature, Thinking, Type are required. 9165 type ThinkingBlockParam struct { 9166 // The `signature` value of this thinking block, exactly as returned by the API in 9167 // a previous response. Used to verify that the block was generated by Claude. 9168 // 9169 // Thinking blocks must be passed back unmodified and in their original order; a 9170 // modified block results in a 400 `invalid_request_error`. 9171 Signature string `json:"signature" api:"required"` 9172 // The `thinking` text of this block as returned by the API. 9173 Thinking string `json:"thinking" api:"required"` 9174 // This field can be elided, and will marshal its zero value as "thinking". 9175 Type constant.Thinking `json:"type" default:"thinking"` 9176 paramObj 9177 } 9178 9179 func (r ThinkingBlockParam) MarshalJSON() (data []byte, err error) { 9180 type shadow ThinkingBlockParam 9181 return param.MarshalObject(r, (*shadow)(&r)) 9182 } 9183 func (r *ThinkingBlockParam) UnmarshalJSON(data []byte) error { 9184 return apijson.UnmarshalRoot(data, r) 9185 } 9186 9187 // The property Type is required. 9188 type ThinkingConfigAdaptiveParam struct { 9189 // Controls how thinking content appears in the response. When set to `summarized`, 9190 // thinking is returned normally. When set to `omitted`, thinking content is 9191 // redacted but a signature is returned for multi-turn continuity. Defaults to 9192 // `summarized`. 9193 // 9194 // Any of "summarized", "omitted". 9195 Display ThinkingConfigAdaptiveDisplay `json:"display,omitzero"` 9196 // This field can be elided, and will marshal its zero value as "adaptive". 9197 Type constant.Adaptive `json:"type" default:"adaptive"` 9198 paramObj 9199 } 9200 9201 func (r ThinkingConfigAdaptiveParam) MarshalJSON() (data []byte, err error) { 9202 type shadow ThinkingConfigAdaptiveParam 9203 return param.MarshalObject(r, (*shadow)(&r)) 9204 } 9205 func (r *ThinkingConfigAdaptiveParam) UnmarshalJSON(data []byte) error { 9206 return apijson.UnmarshalRoot(data, r) 9207 } 9208 9209 // Controls how thinking content appears in the response. When set to `summarized`, 9210 // thinking is returned normally. When set to `omitted`, thinking content is 9211 // redacted but a signature is returned for multi-turn continuity. Defaults to 9212 // `summarized`. 9213 type ThinkingConfigAdaptiveDisplay string 9214 9215 const ( 9216 ThinkingConfigAdaptiveDisplaySummarized ThinkingConfigAdaptiveDisplay = "summarized" 9217 ThinkingConfigAdaptiveDisplayOmitted ThinkingConfigAdaptiveDisplay = "omitted" 9218 ) 9219 9220 func NewThinkingConfigDisabledParam() ThinkingConfigDisabledParam { 9221 return ThinkingConfigDisabledParam{ 9222 Type: "disabled", 9223 } 9224 } 9225 9226 // This struct has a constant value, construct it with 9227 // [NewThinkingConfigDisabledParam]. 9228 type ThinkingConfigDisabledParam struct { 9229 Type constant.Disabled `json:"type" default:"disabled"` 9230 paramObj 9231 } 9232 9233 func (r ThinkingConfigDisabledParam) MarshalJSON() (data []byte, err error) { 9234 type shadow ThinkingConfigDisabledParam 9235 return param.MarshalObject(r, (*shadow)(&r)) 9236 } 9237 func (r *ThinkingConfigDisabledParam) UnmarshalJSON(data []byte) error { 9238 return apijson.UnmarshalRoot(data, r) 9239 } 9240 9241 // The properties BudgetTokens, Type are required. 9242 type ThinkingConfigEnabledParam struct { 9243 // Determines how many tokens Claude can use for its internal reasoning process. 9244 // Larger budgets can enable more thorough analysis for complex problems, improving 9245 // response quality. 9246 // 9247 // Must be ≥1024 and less than `max_tokens`. 9248 // 9249 // See 9250 // [extended thinking](https://platform.claude.com/docs/en/build-with-claude/extended-thinking) 9251 // for details. 9252 BudgetTokens int64 `json:"budget_tokens" api:"required"` 9253 // Controls how thinking content appears in the response. When set to `summarized`, 9254 // thinking is returned normally. When set to `omitted`, thinking content is 9255 // redacted but a signature is returned for multi-turn continuity. Defaults to 9256 // `summarized`. 9257 // 9258 // Any of "summarized", "omitted". 9259 Display ThinkingConfigEnabledDisplay `json:"display,omitzero"` 9260 // This field can be elided, and will marshal its zero value as "enabled". 9261 Type constant.Enabled `json:"type" default:"enabled"` 9262 paramObj 9263 } 9264 9265 func (r ThinkingConfigEnabledParam) MarshalJSON() (data []byte, err error) { 9266 type shadow ThinkingConfigEnabledParam 9267 return param.MarshalObject(r, (*shadow)(&r)) 9268 } 9269 func (r *ThinkingConfigEnabledParam) UnmarshalJSON(data []byte) error { 9270 return apijson.UnmarshalRoot(data, r) 9271 } 9272 9273 // Controls how thinking content appears in the response. When set to `summarized`, 9274 // thinking is returned normally. When set to `omitted`, thinking content is 9275 // redacted but a signature is returned for multi-turn continuity. Defaults to 9276 // `summarized`. 9277 type ThinkingConfigEnabledDisplay string 9278 9279 const ( 9280 ThinkingConfigEnabledDisplaySummarized ThinkingConfigEnabledDisplay = "summarized" 9281 ThinkingConfigEnabledDisplayOmitted ThinkingConfigEnabledDisplay = "omitted" 9282 ) 9283 9284 func ThinkingConfigParamOfEnabled(budgetTokens int64) ThinkingConfigParamUnion { 9285 var enabled ThinkingConfigEnabledParam 9286 enabled.BudgetTokens = budgetTokens 9287 return ThinkingConfigParamUnion{OfEnabled: &enabled} 9288 } 9289 9290 // Only one field can be non-zero. 9291 // 9292 // Use [param.IsOmitted] to confirm if a field is set. 9293 type ThinkingConfigParamUnion struct { 9294 OfEnabled *ThinkingConfigEnabledParam `json:",omitzero,inline"` 9295 OfDisabled *ThinkingConfigDisabledParam `json:",omitzero,inline"` 9296 OfAdaptive *ThinkingConfigAdaptiveParam `json:",omitzero,inline"` 9297 paramUnion 9298 } 9299 9300 func (u ThinkingConfigParamUnion) MarshalJSON() ([]byte, error) { 9301 return param.MarshalUnion(u, u.OfEnabled, u.OfDisabled, u.OfAdaptive) 9302 } 9303 func (u *ThinkingConfigParamUnion) UnmarshalJSON(data []byte) error { 9304 return apijson.UnmarshalRoot(data, u) 9305 } 9306 9307 func (u *ThinkingConfigParamUnion) asAny() any { 9308 if !param.IsOmitted(u.OfEnabled) { 9309 return u.OfEnabled 9310 } else if !param.IsOmitted(u.OfDisabled) { 9311 return u.OfDisabled 9312 } else if !param.IsOmitted(u.OfAdaptive) { 9313 return u.OfAdaptive 9314 } 9315 return nil 9316 } 9317 9318 // Returns a pointer to the underlying variant's property, if present. 9319 func (u ThinkingConfigParamUnion) GetBudgetTokens() *int64 { 9320 if vt := u.OfEnabled; vt != nil { 9321 return &vt.BudgetTokens 9322 } 9323 return nil 9324 } 9325 9326 // Returns a pointer to the underlying variant's property, if present. 9327 func (u ThinkingConfigParamUnion) GetType() *string { 9328 if vt := u.OfEnabled; vt != nil { 9329 return (*string)(&vt.Type) 9330 } else if vt := u.OfDisabled; vt != nil { 9331 return (*string)(&vt.Type) 9332 } else if vt := u.OfAdaptive; vt != nil { 9333 return (*string)(&vt.Type) 9334 } 9335 return nil 9336 } 9337 9338 // Returns a pointer to the underlying variant's property, if present. 9339 func (u ThinkingConfigParamUnion) GetDisplay() *string { 9340 if vt := u.OfEnabled; vt != nil { 9341 return (*string)(&vt.Display) 9342 } else if vt := u.OfAdaptive; vt != nil { 9343 return (*string)(&vt.Display) 9344 } 9345 return nil 9346 } 9347 9348 func init() { 9349 apijson.RegisterUnion[ThinkingConfigParamUnion]( 9350 "type", 9351 apijson.Discriminator[ThinkingConfigEnabledParam]("enabled"), 9352 apijson.Discriminator[ThinkingConfigDisabledParam]("disabled"), 9353 apijson.Discriminator[ThinkingConfigAdaptiveParam]("adaptive"), 9354 ) 9355 } 9356 9357 type ThinkingDelta struct { 9358 // The incremental `thinking` text for this content block. Concatenate the 9359 // `thinking` values of successive `thinking_delta` events to assemble the block's 9360 // full `thinking` value. 9361 Thinking string `json:"thinking" api:"required"` 9362 Type constant.ThinkingDelta `json:"type" default:"thinking_delta"` 9363 // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. 9364 JSON struct { 9365 Thinking respjson.Field 9366 Type respjson.Field 9367 ExtraFields map[string]respjson.Field 9368 raw string 9369 } `json:"-"` 9370 } 9371 9372 // Returns the unmodified JSON received from the API 9373 func (r ThinkingDelta) RawJSON() string { return r.JSON.raw } 9374 func (r *ThinkingDelta) UnmarshalJSON(data []byte) error { 9375 return apijson.UnmarshalRoot(data, r) 9376 } 9377 9378 // The properties InputSchema, Name are required. 9379 type ToolParam struct { 9380 // [JSON schema](https://json-schema.org/draft/2020-12) for this tool's input. 9381 // 9382 // This defines the shape of the `input` that your tool accepts and that the model 9383 // will produce. 9384 InputSchema ToolInputSchemaParam `json:"input_schema,omitzero" api:"required"` 9385 // Name of the tool. 9386 // 9387 // This is how the tool will be called by the model and in `tool_use` blocks. 9388 Name string `json:"name" api:"required"` 9389 // Enable eager input streaming for this tool. When true, tool input parameters 9390 // will be streamed incrementally as they are generated, and types will be inferred 9391 // on-the-fly rather than buffering the full JSON output. When false, streaming is 9392 // disabled for this tool even if the fine-grained-tool-streaming beta is active. 9393 // When null (default), uses the default behavior based on beta headers. 9394 EagerInputStreaming param.Opt[bool] `json:"eager_input_streaming,omitzero"` 9395 // If true, tool will not be included in initial system prompt. Only loaded when 9396 // returned via tool_reference from tool search. 9397 DeferLoading param.Opt[bool] `json:"defer_loading,omitzero"` 9398 // Description of what this tool does. 9399 // 9400 // Tool descriptions should be as detailed as possible. The more information that 9401 // the model has about what the tool is and how to use it, the better it will 9402 // perform. You can use natural language descriptions to reinforce important 9403 // aspects of the tool input JSON schema. 9404 Description param.Opt[string] `json:"description,omitzero"` 9405 // When true, guarantees schema validation on tool names and inputs 9406 Strict param.Opt[bool] `json:"strict,omitzero"` 9407 // Any of "custom". 9408 Type ToolType `json:"type,omitzero"` 9409 // Any of "direct", "code_execution_20250825", "code_execution_20260120", 9410 // "code_execution_20260521". 9411 AllowedCallers []string `json:"allowed_callers,omitzero"` 9412 // Create a cache control breakpoint at this content block. 9413 CacheControl CacheControlEphemeralParam `json:"cache_control,omitzero"` 9414 InputExamples []map[string]any `json:"input_examples,omitzero"` 9415 paramObj 9416 } 9417 9418 func (r ToolParam) MarshalJSON() (data []byte, err error) { 9419 type shadow ToolParam 9420 return param.MarshalObject(r, (*shadow)(&r)) 9421 } 9422 func (r *ToolParam) UnmarshalJSON(data []byte) error { 9423 return apijson.UnmarshalRoot(data, r) 9424 } 9425 9426 // [JSON schema](https://json-schema.org/draft/2020-12) for this tool's input. 9427 // 9428 // This defines the shape of the `input` that your tool accepts and that the model 9429 // will produce. 9430 // 9431 // The property Type is required. 9432 type ToolInputSchemaParam struct { 9433 Properties any `json:"properties,omitzero"` 9434 Required []string `json:"required,omitzero"` 9435 // This field can be elided, and will marshal its zero value as "object". 9436 Type constant.Object `json:"type" default:"object"` 9437 ExtraFields map[string]any `json:"-"` 9438 paramObj 9439 } 9440 9441 func (r ToolInputSchemaParam) MarshalJSON() (data []byte, err error) { 9442 type shadow ToolInputSchemaParam 9443 return param.MarshalWithExtras(r, (*shadow)(&r), r.ExtraFields) 9444 } 9445 func (r *ToolInputSchemaParam) UnmarshalJSON(data []byte) error { 9446 return apijson.UnmarshalRoot(data, r) 9447 } 9448 9449 type ToolType string 9450 9451 const ( 9452 ToolTypeCustom ToolType = "custom" 9453 ) 9454 9455 // The properties Name, Type are required. 9456 type ToolBash20250124Param struct { 9457 // If true, tool will not be included in initial system prompt. Only loaded when 9458 // returned via tool_reference from tool search. 9459 DeferLoading param.Opt[bool] `json:"defer_loading,omitzero"` 9460 // When true, guarantees schema validation on tool names and inputs 9461 Strict param.Opt[bool] `json:"strict,omitzero"` 9462 // Any of "direct", "code_execution_20250825", "code_execution_20260120", 9463 // "code_execution_20260521". 9464 AllowedCallers []string `json:"allowed_callers,omitzero"` 9465 // Create a cache control breakpoint at this content block. 9466 CacheControl CacheControlEphemeralParam `json:"cache_control,omitzero"` 9467 InputExamples []map[string]any `json:"input_examples,omitzero"` 9468 // Name of the tool. 9469 // 9470 // This is how the tool will be called by the model and in `tool_use` blocks. 9471 // 9472 // This field can be elided, and will marshal its zero value as "bash". 9473 Name constant.Bash `json:"name" default:"bash"` 9474 // This field can be elided, and will marshal its zero value as "bash_20250124". 9475 Type constant.Bash20250124 `json:"type" default:"bash_20250124"` 9476 paramObj 9477 } 9478 9479 func (r ToolBash20250124Param) MarshalJSON() (data []byte, err error) { 9480 type shadow ToolBash20250124Param 9481 return param.MarshalObject(r, (*shadow)(&r)) 9482 } 9483 func (r *ToolBash20250124Param) UnmarshalJSON(data []byte) error { 9484 return apijson.UnmarshalRoot(data, r) 9485 } 9486 9487 func ToolChoiceParamOfTool(name string) ToolChoiceUnionParam { 9488 var tool ToolChoiceToolParam 9489 tool.Name = name 9490 return ToolChoiceUnionParam{OfTool: &tool} 9491 } 9492 9493 // Only one field can be non-zero. 9494 // 9495 // Use [param.IsOmitted] to confirm if a field is set. 9496 type ToolChoiceUnionParam struct { 9497 OfAuto *ToolChoiceAutoParam `json:",omitzero,inline"` 9498 OfAny *ToolChoiceAnyParam `json:",omitzero,inline"` 9499 OfTool *ToolChoiceToolParam `json:",omitzero,inline"` 9500 OfNone *ToolChoiceNoneParam `json:",omitzero,inline"` 9501 paramUnion 9502 } 9503 9504 func (u ToolChoiceUnionParam) MarshalJSON() ([]byte, error) { 9505 return param.MarshalUnion(u, u.OfAuto, u.OfAny, u.OfTool, u.OfNone) 9506 } 9507 func (u *ToolChoiceUnionParam) UnmarshalJSON(data []byte) error { 9508 return apijson.UnmarshalRoot(data, u) 9509 } 9510 9511 func (u *ToolChoiceUnionParam) asAny() any { 9512 if !param.IsOmitted(u.OfAuto) { 9513 return u.OfAuto 9514 } else if !param.IsOmitted(u.OfAny) { 9515 return u.OfAny 9516 } else if !param.IsOmitted(u.OfTool) { 9517 return u.OfTool 9518 } else if !param.IsOmitted(u.OfNone) { 9519 return u.OfNone 9520 } 9521 return nil 9522 } 9523 9524 // Returns a pointer to the underlying variant's property, if present. 9525 func (u ToolChoiceUnionParam) GetName() *string { 9526 if vt := u.OfTool; vt != nil { 9527 return &vt.Name 9528 } 9529 return nil 9530 } 9531 9532 // Returns a pointer to the underlying variant's property, if present. 9533 func (u ToolChoiceUnionParam) GetType() *string { 9534 if vt := u.OfAuto; vt != nil { 9535 return (*string)(&vt.Type) 9536 } else if vt := u.OfAny; vt != nil { 9537 return (*string)(&vt.Type) 9538 } else if vt := u.OfTool; vt != nil { 9539 return (*string)(&vt.Type) 9540 } else if vt := u.OfNone; vt != nil { 9541 return (*string)(&vt.Type) 9542 } 9543 return nil 9544 } 9545 9546 // Returns a pointer to the underlying variant's property, if present. 9547 func (u ToolChoiceUnionParam) GetDisableParallelToolUse() *bool { 9548 if vt := u.OfAuto; vt != nil && vt.DisableParallelToolUse.Valid() { 9549 return &vt.DisableParallelToolUse.Value 9550 } else if vt := u.OfAny; vt != nil && vt.DisableParallelToolUse.Valid() { 9551 return &vt.DisableParallelToolUse.Value 9552 } else if vt := u.OfTool; vt != nil && vt.DisableParallelToolUse.Valid() { 9553 return &vt.DisableParallelToolUse.Value 9554 } 9555 return nil 9556 } 9557 9558 func init() { 9559 apijson.RegisterUnion[ToolChoiceUnionParam]( 9560 "type", 9561 apijson.Discriminator[ToolChoiceAutoParam]("auto"), 9562 apijson.Discriminator[ToolChoiceAnyParam]("any"), 9563 apijson.Discriminator[ToolChoiceToolParam]("tool"), 9564 apijson.Discriminator[ToolChoiceNoneParam]("none"), 9565 ) 9566 } 9567 9568 // The model will use any available tools. 9569 // 9570 // The property Type is required. 9571 type ToolChoiceAnyParam struct { 9572 // Whether to disable parallel tool use. 9573 // 9574 // Defaults to `false`. If set to `true`, the model will output exactly one tool 9575 // use. 9576 DisableParallelToolUse param.Opt[bool] `json:"disable_parallel_tool_use,omitzero"` 9577 // This field can be elided, and will marshal its zero value as "any". 9578 Type constant.Any `json:"type" default:"any"` 9579 paramObj 9580 } 9581 9582 func (r ToolChoiceAnyParam) MarshalJSON() (data []byte, err error) { 9583 type shadow ToolChoiceAnyParam 9584 return param.MarshalObject(r, (*shadow)(&r)) 9585 } 9586 func (r *ToolChoiceAnyParam) UnmarshalJSON(data []byte) error { 9587 return apijson.UnmarshalRoot(data, r) 9588 } 9589 9590 // The model will automatically decide whether to use tools. 9591 // 9592 // The property Type is required. 9593 type ToolChoiceAutoParam struct { 9594 // Whether to disable parallel tool use. 9595 // 9596 // Defaults to `false`. If set to `true`, the model will output at most one tool 9597 // use. 9598 DisableParallelToolUse param.Opt[bool] `json:"disable_parallel_tool_use,omitzero"` 9599 // This field can be elided, and will marshal its zero value as "auto". 9600 Type constant.Auto `json:"type" default:"auto"` 9601 paramObj 9602 } 9603 9604 func (r ToolChoiceAutoParam) MarshalJSON() (data []byte, err error) { 9605 type shadow ToolChoiceAutoParam 9606 return param.MarshalObject(r, (*shadow)(&r)) 9607 } 9608 func (r *ToolChoiceAutoParam) UnmarshalJSON(data []byte) error { 9609 return apijson.UnmarshalRoot(data, r) 9610 } 9611 9612 func NewToolChoiceNoneParam() ToolChoiceNoneParam { 9613 return ToolChoiceNoneParam{ 9614 Type: "none", 9615 } 9616 } 9617 9618 // The model will not be allowed to use tools. 9619 // 9620 // This struct has a constant value, construct it with [NewToolChoiceNoneParam]. 9621 type ToolChoiceNoneParam struct { 9622 Type constant.None `json:"type" default:"none"` 9623 paramObj 9624 } 9625 9626 func (r ToolChoiceNoneParam) MarshalJSON() (data []byte, err error) { 9627 type shadow ToolChoiceNoneParam 9628 return param.MarshalObject(r, (*shadow)(&r)) 9629 } 9630 func (r *ToolChoiceNoneParam) UnmarshalJSON(data []byte) error { 9631 return apijson.UnmarshalRoot(data, r) 9632 } 9633 9634 // The model will use the specified tool with `tool_choice.name`. 9635 // 9636 // The properties Name, Type are required. 9637 type ToolChoiceToolParam struct { 9638 // The name of the tool to use. 9639 Name string `json:"name" api:"required"` 9640 // Whether to disable parallel tool use. 9641 // 9642 // Defaults to `false`. If set to `true`, the model will output exactly one tool 9643 // use. 9644 DisableParallelToolUse param.Opt[bool] `json:"disable_parallel_tool_use,omitzero"` 9645 // This field can be elided, and will marshal its zero value as "tool". 9646 Type constant.Tool `json:"type" default:"tool"` 9647 paramObj 9648 } 9649 9650 func (r ToolChoiceToolParam) MarshalJSON() (data []byte, err error) { 9651 type shadow ToolChoiceToolParam 9652 return param.MarshalObject(r, (*shadow)(&r)) 9653 } 9654 func (r *ToolChoiceToolParam) UnmarshalJSON(data []byte) error { 9655 return apijson.UnmarshalRoot(data, r) 9656 } 9657 9658 type ToolReferenceBlock struct { 9659 ToolName string `json:"tool_name" api:"required"` 9660 Type constant.ToolReference `json:"type" default:"tool_reference"` 9661 // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. 9662 JSON struct { 9663 ToolName respjson.Field 9664 Type respjson.Field 9665 ExtraFields map[string]respjson.Field 9666 raw string 9667 } `json:"-"` 9668 } 9669 9670 // Returns the unmodified JSON received from the API 9671 func (r ToolReferenceBlock) RawJSON() string { return r.JSON.raw } 9672 func (r *ToolReferenceBlock) UnmarshalJSON(data []byte) error { 9673 return apijson.UnmarshalRoot(data, r) 9674 } 9675 9676 // Tool reference block that can be included in tool_result content. 9677 // 9678 // The properties ToolName, Type are required. 9679 type ToolReferenceBlockParam struct { 9680 ToolName string `json:"tool_name" api:"required"` 9681 // Create a cache control breakpoint at this content block. 9682 CacheControl CacheControlEphemeralParam `json:"cache_control,omitzero"` 9683 // This field can be elided, and will marshal its zero value as "tool_reference". 9684 Type constant.ToolReference `json:"type" default:"tool_reference"` 9685 paramObj 9686 } 9687 9688 func (r ToolReferenceBlockParam) MarshalJSON() (data []byte, err error) { 9689 type shadow ToolReferenceBlockParam 9690 return param.MarshalObject(r, (*shadow)(&r)) 9691 } 9692 func (r *ToolReferenceBlockParam) UnmarshalJSON(data []byte) error { 9693 return apijson.UnmarshalRoot(data, r) 9694 } 9695 9696 // The properties ToolUseID, Type are required. 9697 type ToolResultBlockParam struct { 9698 ToolUseID string `json:"tool_use_id" api:"required"` 9699 // For a toolset member tool_result, the toolset family of the paired tool_use. 9700 ToolsetName param.Opt[string] `json:"toolset_name,omitzero"` 9701 IsError param.Opt[bool] `json:"is_error,omitzero"` 9702 // Create a cache control breakpoint at this content block. 9703 CacheControl CacheControlEphemeralParam `json:"cache_control,omitzero"` 9704 Content []ToolResultBlockParamContentUnion `json:"content,omitzero"` 9705 // This field can be elided, and will marshal its zero value as "tool_result". 9706 Type constant.ToolResult `json:"type" default:"tool_result"` 9707 paramObj 9708 } 9709 9710 func (r ToolResultBlockParam) MarshalJSON() (data []byte, err error) { 9711 type shadow ToolResultBlockParam 9712 return param.MarshalObject(r, (*shadow)(&r)) 9713 } 9714 func (r *ToolResultBlockParam) UnmarshalJSON(data []byte) error { 9715 return apijson.UnmarshalRoot(data, r) 9716 } 9717 9718 // Only one field can be non-zero. 9719 // 9720 // Use [param.IsOmitted] to confirm if a field is set. 9721 type ToolResultBlockParamContentUnion struct { 9722 OfText *TextBlockParam `json:",omitzero,inline"` 9723 OfImage *ImageBlockParam `json:",omitzero,inline"` 9724 OfSearchResult *SearchResultBlockParam `json:",omitzero,inline"` 9725 OfDocument *DocumentBlockParam `json:",omitzero,inline"` 9726 OfToolReference *ToolReferenceBlockParam `json:",omitzero,inline"` 9727 OfBrowserState *BrowserStateBlockParam `json:",omitzero,inline"` 9728 paramUnion 9729 } 9730 9731 func (u ToolResultBlockParamContentUnion) MarshalJSON() ([]byte, error) { 9732 return param.MarshalUnion(u, u.OfText, 9733 u.OfImage, 9734 u.OfSearchResult, 9735 u.OfDocument, 9736 u.OfToolReference, 9737 u.OfBrowserState) 9738 } 9739 func (u *ToolResultBlockParamContentUnion) UnmarshalJSON(data []byte) error { 9740 return apijson.UnmarshalRoot(data, u) 9741 } 9742 9743 func (u *ToolResultBlockParamContentUnion) asAny() any { 9744 if !param.IsOmitted(u.OfText) { 9745 return u.OfText 9746 } else if !param.IsOmitted(u.OfImage) { 9747 return u.OfImage 9748 } else if !param.IsOmitted(u.OfSearchResult) { 9749 return u.OfSearchResult 9750 } else if !param.IsOmitted(u.OfDocument) { 9751 return u.OfDocument 9752 } else if !param.IsOmitted(u.OfToolReference) { 9753 return u.OfToolReference 9754 } else if !param.IsOmitted(u.OfBrowserState) { 9755 return u.OfBrowserState 9756 } 9757 return nil 9758 } 9759 9760 // Returns a pointer to the underlying variant's property, if present. 9761 func (u ToolResultBlockParamContentUnion) GetText() *string { 9762 if vt := u.OfText; vt != nil { 9763 return &vt.Text 9764 } 9765 return nil 9766 } 9767 9768 // Returns a pointer to the underlying variant's property, if present. 9769 func (u ToolResultBlockParamContentUnion) GetTransformations() *ImageTransformationsParam { 9770 if vt := u.OfImage; vt != nil { 9771 return &vt.Transformations 9772 } 9773 return nil 9774 } 9775 9776 // Returns a pointer to the underlying variant's property, if present. 9777 func (u ToolResultBlockParamContentUnion) GetContent() []TextBlockParam { 9778 if vt := u.OfSearchResult; vt != nil { 9779 return vt.Content 9780 } 9781 return nil 9782 } 9783 9784 // Returns a pointer to the underlying variant's property, if present. 9785 func (u ToolResultBlockParamContentUnion) GetContext() *string { 9786 if vt := u.OfDocument; vt != nil && vt.Context.Valid() { 9787 return &vt.Context.Value 9788 } 9789 return nil 9790 } 9791 9792 // Returns a pointer to the underlying variant's property, if present. 9793 func (u ToolResultBlockParamContentUnion) GetToolName() *string { 9794 if vt := u.OfToolReference; vt != nil { 9795 return &vt.ToolName 9796 } 9797 return nil 9798 } 9799 9800 // Returns a pointer to the underlying variant's property, if present. 9801 func (u ToolResultBlockParamContentUnion) GetTabs() []BrowserStateTabEntryParam { 9802 if vt := u.OfBrowserState; vt != nil { 9803 return vt.Tabs 9804 } 9805 return nil 9806 } 9807 9808 // Returns a pointer to the underlying variant's property, if present. 9809 func (u ToolResultBlockParamContentUnion) GetStateChanges() []BrowserStateChangeUnionParam { 9810 if vt := u.OfBrowserState; vt != nil { 9811 return vt.StateChanges 9812 } 9813 return nil 9814 } 9815 9816 // Returns a pointer to the underlying variant's property, if present. 9817 func (u ToolResultBlockParamContentUnion) GetType() *string { 9818 if vt := u.OfText; vt != nil { 9819 return (*string)(&vt.Type) 9820 } else if vt := u.OfImage; vt != nil { 9821 return (*string)(&vt.Type) 9822 } else if vt := u.OfSearchResult; vt != nil { 9823 return (*string)(&vt.Type) 9824 } else if vt := u.OfDocument; vt != nil { 9825 return (*string)(&vt.Type) 9826 } else if vt := u.OfToolReference; vt != nil { 9827 return (*string)(&vt.Type) 9828 } else if vt := u.OfBrowserState; vt != nil { 9829 return (*string)(&vt.Type) 9830 } 9831 return nil 9832 } 9833 9834 // Returns a pointer to the underlying variant's property, if present. 9835 func (u ToolResultBlockParamContentUnion) GetTitle() *string { 9836 if vt := u.OfSearchResult; vt != nil { 9837 return (*string)(&vt.Title) 9838 } else if vt := u.OfDocument; vt != nil && vt.Title.Valid() { 9839 return &vt.Title.Value 9840 } 9841 return nil 9842 } 9843 9844 // Returns a pointer to the underlying variant's CacheControl property, if present. 9845 func (u ToolResultBlockParamContentUnion) GetCacheControl() *CacheControlEphemeralParam { 9846 if vt := u.OfText; vt != nil { 9847 return &vt.CacheControl 9848 } else if vt := u.OfImage; vt != nil { 9849 return &vt.CacheControl 9850 } else if vt := u.OfSearchResult; vt != nil { 9851 return &vt.CacheControl 9852 } else if vt := u.OfDocument; vt != nil { 9853 return &vt.CacheControl 9854 } else if vt := u.OfToolReference; vt != nil { 9855 return &vt.CacheControl 9856 } else if vt := u.OfBrowserState; vt != nil { 9857 return &vt.CacheControl 9858 } 9859 return nil 9860 } 9861 9862 // Returns a subunion which exports methods to access subproperties 9863 // 9864 // Or use AsAny() to get the underlying value 9865 func (u ToolResultBlockParamContentUnion) GetCitations() (res toolResultBlockParamContentUnionCitations) { 9866 if vt := u.OfText; vt != nil { 9867 res.any = &vt.Citations 9868 } else if vt := u.OfSearchResult; vt != nil { 9869 res.any = &vt.Citations 9870 } else if vt := u.OfDocument; vt != nil { 9871 res.any = &vt.Citations 9872 } 9873 return 9874 } 9875 9876 // Can have the runtime types [*[]TextCitationParamUnion], [*CitationsConfigParam] 9877 type toolResultBlockParamContentUnionCitations struct{ any } 9878 9879 // Use the following switch statement to get the type of the union: 9880 // 9881 // switch u.AsAny().(type) { 9882 // case *[]anthropic.TextCitationParamUnion: 9883 // case *anthropic.CitationsConfigParam: 9884 // default: 9885 // fmt.Errorf("not present") 9886 // } 9887 func (u toolResultBlockParamContentUnionCitations) AsAny() any { return u.any } 9888 9889 // Returns a pointer to the underlying variant's property, if present. 9890 func (u toolResultBlockParamContentUnionCitations) GetEnabled() *bool { 9891 switch vt := u.any.(type) { 9892 case *CitationsConfigParam: 9893 return paramutil.AddrIfPresent(vt.Enabled) 9894 } 9895 return nil 9896 } 9897 9898 // Returns a subunion which exports methods to access subproperties 9899 // 9900 // Or use AsAny() to get the underlying value 9901 func (u ToolResultBlockParamContentUnion) GetSource() (res toolResultBlockParamContentUnionSource) { 9902 if vt := u.OfImage; vt != nil { 9903 res.any = vt.Source.asAny() 9904 } else if vt := u.OfSearchResult; vt != nil { 9905 res.any = &vt.Source 9906 } else if vt := u.OfDocument; vt != nil { 9907 res.any = vt.Source.asAny() 9908 } 9909 return 9910 } 9911 9912 // Can have the runtime types [*Base64ImageSourceParam], [*URLImageSourceParam], 9913 // [*FileImageSourceParam], [*string], [*Base64PDFSourceParam], 9914 // [*PlainTextSourceParam], [*ContentBlockSourceParam], [*URLPDFSourceParam], 9915 // [*FileDocumentSourceParam] 9916 type toolResultBlockParamContentUnionSource struct{ any } 9917 9918 // Use the following switch statement to get the type of the union: 9919 // 9920 // switch u.AsAny().(type) { 9921 // case *anthropic.Base64ImageSourceParam: 9922 // case *anthropic.URLImageSourceParam: 9923 // case *anthropic.FileImageSourceParam: 9924 // case *string: 9925 // case *anthropic.Base64PDFSourceParam: 9926 // case *anthropic.PlainTextSourceParam: 9927 // case *anthropic.ContentBlockSourceParam: 9928 // case *anthropic.URLPDFSourceParam: 9929 // case *anthropic.FileDocumentSourceParam: 9930 // default: 9931 // fmt.Errorf("not present") 9932 // } 9933 func (u toolResultBlockParamContentUnionSource) AsAny() any { return u.any } 9934 9935 // Returns a pointer to the underlying variant's property, if present. 9936 func (u toolResultBlockParamContentUnionSource) GetContent() *ContentBlockSourceContentUnionParam { 9937 switch vt := u.any.(type) { 9938 case *DocumentBlockParamSourceUnion: 9939 return vt.GetContent() 9940 } 9941 return nil 9942 } 9943 9944 // Returns a pointer to the underlying variant's property, if present. 9945 func (u toolResultBlockParamContentUnionSource) GetData() *string { 9946 switch vt := u.any.(type) { 9947 case *ImageBlockParamSourceUnion: 9948 return vt.GetData() 9949 case *DocumentBlockParamSourceUnion: 9950 return vt.GetData() 9951 } 9952 return nil 9953 } 9954 9955 // Returns a pointer to the underlying variant's property, if present. 9956 func (u toolResultBlockParamContentUnionSource) GetMediaType() *string { 9957 switch vt := u.any.(type) { 9958 case *ImageBlockParamSourceUnion: 9959 return vt.GetMediaType() 9960 case *DocumentBlockParamSourceUnion: 9961 return vt.GetMediaType() 9962 } 9963 return nil 9964 } 9965 9966 // Returns a pointer to the underlying variant's property, if present. 9967 func (u toolResultBlockParamContentUnionSource) GetType() *string { 9968 switch vt := u.any.(type) { 9969 case *ImageBlockParamSourceUnion: 9970 return vt.GetType() 9971 case *DocumentBlockParamSourceUnion: 9972 return vt.GetType() 9973 } 9974 return nil 9975 } 9976 9977 // Returns a pointer to the underlying variant's property, if present. 9978 func (u toolResultBlockParamContentUnionSource) GetURL() *string { 9979 switch vt := u.any.(type) { 9980 case *ImageBlockParamSourceUnion: 9981 return vt.GetURL() 9982 case *DocumentBlockParamSourceUnion: 9983 return vt.GetURL() 9984 } 9985 return nil 9986 } 9987 9988 // Returns a pointer to the underlying variant's property, if present. 9989 func (u toolResultBlockParamContentUnionSource) GetFileID() *string { 9990 switch vt := u.any.(type) { 9991 case *ImageBlockParamSourceUnion: 9992 return vt.GetFileID() 9993 case *DocumentBlockParamSourceUnion: 9994 return vt.GetFileID() 9995 } 9996 return nil 9997 } 9998 9999 func init() { 10000 apijson.RegisterUnion[ToolResultBlockParamContentUnion]( 10001 "type", 10002 apijson.Discriminator[TextBlockParam]("text"), 10003 apijson.Discriminator[ImageBlockParam]("image"), 10004 apijson.Discriminator[SearchResultBlockParam]("search_result"), 10005 apijson.Discriminator[DocumentBlockParam]("document"), 10006 apijson.Discriminator[ToolReferenceBlockParam]("tool_reference"), 10007 apijson.Discriminator[BrowserStateBlockParam]("browser_state"), 10008 ) 10009 } 10010 10011 // The properties Name, Type are required. 10012 type ToolSearchToolBm25_20251119Param struct { 10013 // Any of "tool_search_tool_bm25_20251119", "tool_search_tool_bm25". 10014 Type ToolSearchToolBm25_20251119Type `json:"type,omitzero" api:"required"` 10015 // If true, tool will not be included in initial system prompt. Only loaded when 10016 // returned via tool_reference from tool search. 10017 DeferLoading param.Opt[bool] `json:"defer_loading,omitzero"` 10018 // When true, guarantees schema validation on tool names and inputs 10019 Strict param.Opt[bool] `json:"strict,omitzero"` 10020 // Any of "direct", "code_execution_20250825", "code_execution_20260120", 10021 // "code_execution_20260521". 10022 AllowedCallers []string `json:"allowed_callers,omitzero"` 10023 // Create a cache control breakpoint at this content block. 10024 CacheControl CacheControlEphemeralParam `json:"cache_control,omitzero"` 10025 // Name of the tool. 10026 // 10027 // This is how the tool will be called by the model and in `tool_use` blocks. 10028 // 10029 // This field can be elided, and will marshal its zero value as 10030 // "tool_search_tool_bm25". 10031 Name constant.ToolSearchToolBm25 `json:"name" default:"tool_search_tool_bm25"` 10032 paramObj 10033 } 10034 10035 func (r ToolSearchToolBm25_20251119Param) MarshalJSON() (data []byte, err error) { 10036 type shadow ToolSearchToolBm25_20251119Param 10037 return param.MarshalObject(r, (*shadow)(&r)) 10038 } 10039 func (r *ToolSearchToolBm25_20251119Param) UnmarshalJSON(data []byte) error { 10040 return apijson.UnmarshalRoot(data, r) 10041 } 10042 10043 type ToolSearchToolBm25_20251119Type string 10044 10045 const ( 10046 ToolSearchToolBm25_20251119TypeToolSearchToolBm25_20251119 ToolSearchToolBm25_20251119Type = "tool_search_tool_bm25_20251119" 10047 ToolSearchToolBm25_20251119TypeToolSearchToolBm25 ToolSearchToolBm25_20251119Type = "tool_search_tool_bm25" 10048 ) 10049 10050 // The properties Name, Type are required. 10051 type ToolSearchToolRegex20251119Param struct { 10052 // Any of "tool_search_tool_regex_20251119", "tool_search_tool_regex". 10053 Type ToolSearchToolRegex20251119Type `json:"type,omitzero" api:"required"` 10054 // If true, tool will not be included in initial system prompt. Only loaded when 10055 // returned via tool_reference from tool search. 10056 DeferLoading param.Opt[bool] `json:"defer_loading,omitzero"` 10057 // When true, guarantees schema validation on tool names and inputs 10058 Strict param.Opt[bool] `json:"strict,omitzero"` 10059 // Any of "direct", "code_execution_20250825", "code_execution_20260120", 10060 // "code_execution_20260521". 10061 AllowedCallers []string `json:"allowed_callers,omitzero"` 10062 // Create a cache control breakpoint at this content block. 10063 CacheControl CacheControlEphemeralParam `json:"cache_control,omitzero"` 10064 // Name of the tool. 10065 // 10066 // This is how the tool will be called by the model and in `tool_use` blocks. 10067 // 10068 // This field can be elided, and will marshal its zero value as 10069 // "tool_search_tool_regex". 10070 Name constant.ToolSearchToolRegex `json:"name" default:"tool_search_tool_regex"` 10071 paramObj 10072 } 10073 10074 func (r ToolSearchToolRegex20251119Param) MarshalJSON() (data []byte, err error) { 10075 type shadow ToolSearchToolRegex20251119Param 10076 return param.MarshalObject(r, (*shadow)(&r)) 10077 } 10078 func (r *ToolSearchToolRegex20251119Param) UnmarshalJSON(data []byte) error { 10079 return apijson.UnmarshalRoot(data, r) 10080 } 10081 10082 type ToolSearchToolRegex20251119Type string 10083 10084 const ( 10085 ToolSearchToolRegex20251119TypeToolSearchToolRegex20251119 ToolSearchToolRegex20251119Type = "tool_search_tool_regex_20251119" 10086 ToolSearchToolRegex20251119TypeToolSearchToolRegex ToolSearchToolRegex20251119Type = "tool_search_tool_regex" 10087 ) 10088 10089 type ToolSearchToolResultBlock struct { 10090 Content ToolSearchToolResultBlockContentUnion `json:"content" api:"required"` 10091 ToolUseID string `json:"tool_use_id" api:"required"` 10092 Type constant.ToolSearchToolResult `json:"type" default:"tool_search_tool_result"` 10093 // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. 10094 JSON struct { 10095 Content respjson.Field 10096 ToolUseID respjson.Field 10097 Type respjson.Field 10098 ExtraFields map[string]respjson.Field 10099 raw string 10100 } `json:"-"` 10101 } 10102 10103 // Returns the unmodified JSON received from the API 10104 func (r ToolSearchToolResultBlock) RawJSON() string { return r.JSON.raw } 10105 func (r *ToolSearchToolResultBlock) UnmarshalJSON(data []byte) error { 10106 return apijson.UnmarshalRoot(data, r) 10107 } 10108 10109 // ToolSearchToolResultBlockContentUnion contains all possible properties and 10110 // values from [ToolSearchToolResultError], [ToolSearchToolSearchResultBlock]. 10111 // 10112 // Use the methods beginning with 'As' to cast the union to one of its variants. 10113 type ToolSearchToolResultBlockContentUnion struct { 10114 // This field is from variant [ToolSearchToolResultError]. 10115 ErrorCode ToolSearchToolResultErrorCode `json:"error_code"` 10116 // This field is from variant [ToolSearchToolResultError]. 10117 ErrorMessage string `json:"error_message"` 10118 Type string `json:"type"` 10119 // This field is from variant [ToolSearchToolSearchResultBlock]. 10120 ToolReferences []ToolReferenceBlock `json:"tool_references"` 10121 JSON struct { 10122 ErrorCode respjson.Field 10123 ErrorMessage respjson.Field 10124 Type respjson.Field 10125 ToolReferences respjson.Field 10126 raw string 10127 } `json:"-"` 10128 } 10129 10130 func (u ToolSearchToolResultBlockContentUnion) AsResponseToolSearchToolResultError() (v ToolSearchToolResultError) { 10131 apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) 10132 return 10133 } 10134 10135 func (u ToolSearchToolResultBlockContentUnion) AsResponseToolSearchToolSearchResultBlock() (v ToolSearchToolSearchResultBlock) { 10136 apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) 10137 return 10138 } 10139 10140 // Returns the unmodified JSON received from the API 10141 func (u ToolSearchToolResultBlockContentUnion) RawJSON() string { return u.JSON.raw } 10142 10143 func (r *ToolSearchToolResultBlockContentUnion) UnmarshalJSON(data []byte) error { 10144 return apijson.UnmarshalRoot(data, r) 10145 } 10146 10147 // The properties Content, ToolUseID, Type are required. 10148 type ToolSearchToolResultBlockParam struct { 10149 Content ToolSearchToolResultBlockParamContentUnion `json:"content,omitzero" api:"required"` 10150 ToolUseID string `json:"tool_use_id" api:"required"` 10151 // Create a cache control breakpoint at this content block. 10152 CacheControl CacheControlEphemeralParam `json:"cache_control,omitzero"` 10153 // This field can be elided, and will marshal its zero value as 10154 // "tool_search_tool_result". 10155 Type constant.ToolSearchToolResult `json:"type" default:"tool_search_tool_result"` 10156 paramObj 10157 } 10158 10159 func (r ToolSearchToolResultBlockParam) MarshalJSON() (data []byte, err error) { 10160 type shadow ToolSearchToolResultBlockParam 10161 return param.MarshalObject(r, (*shadow)(&r)) 10162 } 10163 func (r *ToolSearchToolResultBlockParam) UnmarshalJSON(data []byte) error { 10164 return apijson.UnmarshalRoot(data, r) 10165 } 10166 10167 // Only one field can be non-zero. 10168 // 10169 // Use [param.IsOmitted] to confirm if a field is set. 10170 type ToolSearchToolResultBlockParamContentUnion struct { 10171 OfRequestToolSearchToolResultError *ToolSearchToolResultErrorParam `json:",omitzero,inline"` 10172 OfRequestToolSearchToolSearchResultBlock *ToolSearchToolSearchResultBlockParam `json:",omitzero,inline"` 10173 paramUnion 10174 } 10175 10176 func (u ToolSearchToolResultBlockParamContentUnion) MarshalJSON() ([]byte, error) { 10177 return param.MarshalUnion(u, u.OfRequestToolSearchToolResultError, u.OfRequestToolSearchToolSearchResultBlock) 10178 } 10179 func (u *ToolSearchToolResultBlockParamContentUnion) UnmarshalJSON(data []byte) error { 10180 return apijson.UnmarshalRoot(data, u) 10181 } 10182 10183 func (u *ToolSearchToolResultBlockParamContentUnion) asAny() any { 10184 if !param.IsOmitted(u.OfRequestToolSearchToolResultError) { 10185 return u.OfRequestToolSearchToolResultError 10186 } else if !param.IsOmitted(u.OfRequestToolSearchToolSearchResultBlock) { 10187 return u.OfRequestToolSearchToolSearchResultBlock 10188 } 10189 return nil 10190 } 10191 10192 // Returns a pointer to the underlying variant's property, if present. 10193 func (u ToolSearchToolResultBlockParamContentUnion) GetErrorCode() *string { 10194 if vt := u.OfRequestToolSearchToolResultError; vt != nil { 10195 return (*string)(&vt.ErrorCode) 10196 } 10197 return nil 10198 } 10199 10200 // Returns a pointer to the underlying variant's property, if present. 10201 func (u ToolSearchToolResultBlockParamContentUnion) GetErrorMessage() *string { 10202 if vt := u.OfRequestToolSearchToolResultError; vt != nil && vt.ErrorMessage.Valid() { 10203 return &vt.ErrorMessage.Value 10204 } 10205 return nil 10206 } 10207 10208 // Returns a pointer to the underlying variant's property, if present. 10209 func (u ToolSearchToolResultBlockParamContentUnion) GetToolReferences() []ToolReferenceBlockParam { 10210 if vt := u.OfRequestToolSearchToolSearchResultBlock; vt != nil { 10211 return vt.ToolReferences 10212 } 10213 return nil 10214 } 10215 10216 // Returns a pointer to the underlying variant's property, if present. 10217 func (u ToolSearchToolResultBlockParamContentUnion) GetType() *string { 10218 if vt := u.OfRequestToolSearchToolResultError; vt != nil { 10219 return (*string)(&vt.Type) 10220 } else if vt := u.OfRequestToolSearchToolSearchResultBlock; vt != nil { 10221 return (*string)(&vt.Type) 10222 } 10223 return nil 10224 } 10225 10226 type ToolSearchToolResultError struct { 10227 // Any of "invalid_tool_input", "unavailable", "too_many_requests", 10228 // "execution_time_exceeded". 10229 ErrorCode ToolSearchToolResultErrorCode `json:"error_code" api:"required"` 10230 ErrorMessage string `json:"error_message" api:"required"` 10231 Type constant.ToolSearchToolResultError `json:"type" default:"tool_search_tool_result_error"` 10232 // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. 10233 JSON struct { 10234 ErrorCode respjson.Field 10235 ErrorMessage respjson.Field 10236 Type respjson.Field 10237 ExtraFields map[string]respjson.Field 10238 raw string 10239 } `json:"-"` 10240 } 10241 10242 // Returns the unmodified JSON received from the API 10243 func (r ToolSearchToolResultError) RawJSON() string { return r.JSON.raw } 10244 func (r *ToolSearchToolResultError) UnmarshalJSON(data []byte) error { 10245 return apijson.UnmarshalRoot(data, r) 10246 } 10247 10248 type ToolSearchToolResultErrorCode string 10249 10250 const ( 10251 ToolSearchToolResultErrorCodeInvalidToolInput ToolSearchToolResultErrorCode = "invalid_tool_input" 10252 ToolSearchToolResultErrorCodeUnavailable ToolSearchToolResultErrorCode = "unavailable" 10253 ToolSearchToolResultErrorCodeTooManyRequests ToolSearchToolResultErrorCode = "too_many_requests" 10254 ToolSearchToolResultErrorCodeExecutionTimeExceeded ToolSearchToolResultErrorCode = "execution_time_exceeded" 10255 ) 10256 10257 // The properties ErrorCode, Type are required. 10258 type ToolSearchToolResultErrorParam struct { 10259 // Any of "invalid_tool_input", "unavailable", "too_many_requests", 10260 // "execution_time_exceeded". 10261 ErrorCode ToolSearchToolResultErrorCode `json:"error_code,omitzero" api:"required"` 10262 ErrorMessage param.Opt[string] `json:"error_message,omitzero"` 10263 // This field can be elided, and will marshal its zero value as 10264 // "tool_search_tool_result_error". 10265 Type constant.ToolSearchToolResultError `json:"type" default:"tool_search_tool_result_error"` 10266 paramObj 10267 } 10268 10269 func (r ToolSearchToolResultErrorParam) MarshalJSON() (data []byte, err error) { 10270 type shadow ToolSearchToolResultErrorParam 10271 return param.MarshalObject(r, (*shadow)(&r)) 10272 } 10273 func (r *ToolSearchToolResultErrorParam) UnmarshalJSON(data []byte) error { 10274 return apijson.UnmarshalRoot(data, r) 10275 } 10276 10277 type ToolSearchToolSearchResultBlock struct { 10278 ToolReferences []ToolReferenceBlock `json:"tool_references" api:"required"` 10279 Type constant.ToolSearchToolSearchResult `json:"type" default:"tool_search_tool_search_result"` 10280 // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. 10281 JSON struct { 10282 ToolReferences respjson.Field 10283 Type respjson.Field 10284 ExtraFields map[string]respjson.Field 10285 raw string 10286 } `json:"-"` 10287 } 10288 10289 // Returns the unmodified JSON received from the API 10290 func (r ToolSearchToolSearchResultBlock) RawJSON() string { return r.JSON.raw } 10291 func (r *ToolSearchToolSearchResultBlock) UnmarshalJSON(data []byte) error { 10292 return apijson.UnmarshalRoot(data, r) 10293 } 10294 10295 // The properties ToolReferences, Type are required. 10296 type ToolSearchToolSearchResultBlockParam struct { 10297 ToolReferences []ToolReferenceBlockParam `json:"tool_references,omitzero" api:"required"` 10298 // This field can be elided, and will marshal its zero value as 10299 // "tool_search_tool_search_result". 10300 Type constant.ToolSearchToolSearchResult `json:"type" default:"tool_search_tool_search_result"` 10301 paramObj 10302 } 10303 10304 func (r ToolSearchToolSearchResultBlockParam) MarshalJSON() (data []byte, err error) { 10305 type shadow ToolSearchToolSearchResultBlockParam 10306 return param.MarshalObject(r, (*shadow)(&r)) 10307 } 10308 func (r *ToolSearchToolSearchResultBlockParam) UnmarshalJSON(data []byte) error { 10309 return apijson.UnmarshalRoot(data, r) 10310 } 10311 10312 // The properties Name, Type are required. 10313 type ToolTextEditor20250124Param struct { 10314 // If true, tool will not be included in initial system prompt. Only loaded when 10315 // returned via tool_reference from tool search. 10316 DeferLoading param.Opt[bool] `json:"defer_loading,omitzero"` 10317 // When true, guarantees schema validation on tool names and inputs 10318 Strict param.Opt[bool] `json:"strict,omitzero"` 10319 // Any of "direct", "code_execution_20250825", "code_execution_20260120", 10320 // "code_execution_20260521". 10321 AllowedCallers []string `json:"allowed_callers,omitzero"` 10322 // Create a cache control breakpoint at this content block. 10323 CacheControl CacheControlEphemeralParam `json:"cache_control,omitzero"` 10324 InputExamples []map[string]any `json:"input_examples,omitzero"` 10325 // Name of the tool. 10326 // 10327 // This is how the tool will be called by the model and in `tool_use` blocks. 10328 // 10329 // This field can be elided, and will marshal its zero value as 10330 // "str_replace_editor". 10331 Name constant.StrReplaceEditor `json:"name" default:"str_replace_editor"` 10332 // This field can be elided, and will marshal its zero value as 10333 // "text_editor_20250124". 10334 Type constant.TextEditor20250124 `json:"type" default:"text_editor_20250124"` 10335 paramObj 10336 } 10337 10338 func (r ToolTextEditor20250124Param) MarshalJSON() (data []byte, err error) { 10339 type shadow ToolTextEditor20250124Param 10340 return param.MarshalObject(r, (*shadow)(&r)) 10341 } 10342 func (r *ToolTextEditor20250124Param) UnmarshalJSON(data []byte) error { 10343 return apijson.UnmarshalRoot(data, r) 10344 } 10345 10346 // The properties Name, Type are required. 10347 type ToolTextEditor20250429Param struct { 10348 // If true, tool will not be included in initial system prompt. Only loaded when 10349 // returned via tool_reference from tool search. 10350 DeferLoading param.Opt[bool] `json:"defer_loading,omitzero"` 10351 // When true, guarantees schema validation on tool names and inputs 10352 Strict param.Opt[bool] `json:"strict,omitzero"` 10353 // Any of "direct", "code_execution_20250825", "code_execution_20260120", 10354 // "code_execution_20260521". 10355 AllowedCallers []string `json:"allowed_callers,omitzero"` 10356 // Create a cache control breakpoint at this content block. 10357 CacheControl CacheControlEphemeralParam `json:"cache_control,omitzero"` 10358 InputExamples []map[string]any `json:"input_examples,omitzero"` 10359 // Name of the tool. 10360 // 10361 // This is how the tool will be called by the model and in `tool_use` blocks. 10362 // 10363 // This field can be elided, and will marshal its zero value as 10364 // "str_replace_based_edit_tool". 10365 Name constant.StrReplaceBasedEditTool `json:"name" default:"str_replace_based_edit_tool"` 10366 // This field can be elided, and will marshal its zero value as 10367 // "text_editor_20250429". 10368 Type constant.TextEditor20250429 `json:"type" default:"text_editor_20250429"` 10369 paramObj 10370 } 10371 10372 func (r ToolTextEditor20250429Param) MarshalJSON() (data []byte, err error) { 10373 type shadow ToolTextEditor20250429Param 10374 return param.MarshalObject(r, (*shadow)(&r)) 10375 } 10376 func (r *ToolTextEditor20250429Param) UnmarshalJSON(data []byte) error { 10377 return apijson.UnmarshalRoot(data, r) 10378 } 10379 10380 // The properties Name, Type are required. 10381 type ToolTextEditor20250728Param struct { 10382 // Maximum number of characters to display when viewing a file. If not specified, 10383 // defaults to displaying the full file. 10384 MaxCharacters param.Opt[int64] `json:"max_characters,omitzero"` 10385 // If true, tool will not be included in initial system prompt. Only loaded when 10386 // returned via tool_reference from tool search. 10387 DeferLoading param.Opt[bool] `json:"defer_loading,omitzero"` 10388 // When true, guarantees schema validation on tool names and inputs 10389 Strict param.Opt[bool] `json:"strict,omitzero"` 10390 // Any of "direct", "code_execution_20250825", "code_execution_20260120", 10391 // "code_execution_20260521". 10392 AllowedCallers []string `json:"allowed_callers,omitzero"` 10393 // Create a cache control breakpoint at this content block. 10394 CacheControl CacheControlEphemeralParam `json:"cache_control,omitzero"` 10395 InputExamples []map[string]any `json:"input_examples,omitzero"` 10396 // Name of the tool. 10397 // 10398 // This is how the tool will be called by the model and in `tool_use` blocks. 10399 // 10400 // This field can be elided, and will marshal its zero value as 10401 // "str_replace_based_edit_tool". 10402 Name constant.StrReplaceBasedEditTool `json:"name" default:"str_replace_based_edit_tool"` 10403 // This field can be elided, and will marshal its zero value as 10404 // "text_editor_20250728". 10405 Type constant.TextEditor20250728 `json:"type" default:"text_editor_20250728"` 10406 paramObj 10407 } 10408 10409 func (r ToolTextEditor20250728Param) MarshalJSON() (data []byte, err error) { 10410 type shadow ToolTextEditor20250728Param 10411 return param.MarshalObject(r, (*shadow)(&r)) 10412 } 10413 func (r *ToolTextEditor20250728Param) UnmarshalJSON(data []byte) error { 10414 return apijson.UnmarshalRoot(data, r) 10415 } 10416 10417 func ToolUnionParamOfTool(inputSchema ToolInputSchemaParam, name string) ToolUnionParam { 10418 var variant ToolParam 10419 variant.InputSchema = inputSchema 10420 variant.Name = name 10421 return ToolUnionParam{OfTool: &variant} 10422 } 10423 10424 func ToolUnionParamOfToolSearchToolBm25_20251119(type_ ToolSearchToolBm25_20251119Type) ToolUnionParam { 10425 var variant ToolSearchToolBm25_20251119Param 10426 variant.Type = type_ 10427 return ToolUnionParam{OfToolSearchToolBm25_20251119: &variant} 10428 } 10429 10430 func ToolUnionParamOfToolSearchToolRegex20251119(type_ ToolSearchToolRegex20251119Type) ToolUnionParam { 10431 var variant ToolSearchToolRegex20251119Param 10432 variant.Type = type_ 10433 return ToolUnionParam{OfToolSearchToolRegex20251119: &variant} 10434 } 10435 10436 // Only one field can be non-zero. 10437 // 10438 // Use [param.IsOmitted] to confirm if a field is set. 10439 type ToolUnionParam struct { 10440 OfTool *ToolParam `json:",omitzero,inline"` 10441 OfBashTool20250124 *ToolBash20250124Param `json:",omitzero,inline"` 10442 OfCodeExecutionTool20250522 *CodeExecutionTool20250522Param `json:",omitzero,inline"` 10443 OfCodeExecutionTool20250825 *CodeExecutionTool20250825Param `json:",omitzero,inline"` 10444 OfCodeExecutionTool20260120 *CodeExecutionTool20260120Param `json:",omitzero,inline"` 10445 OfCodeExecutionTool20260521 *CodeExecutionTool20260521Param `json:",omitzero,inline"` 10446 OfBrowserToolset20260801 *BrowserToolset20260801Param `json:",omitzero,inline"` 10447 OfMemoryTool20250818 *MemoryTool20250818Param `json:",omitzero,inline"` 10448 OfComputerToolset20260801 *ComputerToolset20260801Param `json:",omitzero,inline"` 10449 OfTextEditor20250124 *ToolTextEditor20250124Param `json:",omitzero,inline"` 10450 OfTextEditor20250429 *ToolTextEditor20250429Param `json:",omitzero,inline"` 10451 OfTextEditor20250728 *ToolTextEditor20250728Param `json:",omitzero,inline"` 10452 OfWebSearchTool20250305 *WebSearchTool20250305Param `json:",omitzero,inline"` 10453 OfWebFetchTool20250910 *WebFetchTool20250910Param `json:",omitzero,inline"` 10454 OfWebSearchTool20260209 *WebSearchTool20260209Param `json:",omitzero,inline"` 10455 OfWebFetchTool20260209 *WebFetchTool20260209Param `json:",omitzero,inline"` 10456 OfWebFetchTool20260309 *WebFetchTool20260309Param `json:",omitzero,inline"` 10457 OfWebSearchTool20260318 *WebSearchTool20260318Param `json:",omitzero,inline"` 10458 OfWebFetchTool20260318 *WebFetchTool20260318Param `json:",omitzero,inline"` 10459 OfToolSearchToolBm25_20251119 *ToolSearchToolBm25_20251119Param `json:",omitzero,inline"` 10460 OfToolSearchToolRegex20251119 *ToolSearchToolRegex20251119Param `json:",omitzero,inline"` 10461 paramUnion 10462 } 10463 10464 func (u ToolUnionParam) MarshalJSON() ([]byte, error) { 10465 return param.MarshalUnion(u, u.OfTool, 10466 u.OfBashTool20250124, 10467 u.OfCodeExecutionTool20250522, 10468 u.OfCodeExecutionTool20250825, 10469 u.OfCodeExecutionTool20260120, 10470 u.OfCodeExecutionTool20260521, 10471 u.OfBrowserToolset20260801, 10472 u.OfMemoryTool20250818, 10473 u.OfComputerToolset20260801, 10474 u.OfTextEditor20250124, 10475 u.OfTextEditor20250429, 10476 u.OfTextEditor20250728, 10477 u.OfWebSearchTool20250305, 10478 u.OfWebFetchTool20250910, 10479 u.OfWebSearchTool20260209, 10480 u.OfWebFetchTool20260209, 10481 u.OfWebFetchTool20260309, 10482 u.OfWebSearchTool20260318, 10483 u.OfWebFetchTool20260318, 10484 u.OfToolSearchToolBm25_20251119, 10485 u.OfToolSearchToolRegex20251119) 10486 } 10487 func (u *ToolUnionParam) UnmarshalJSON(data []byte) error { 10488 return apijson.UnmarshalRoot(data, u) 10489 } 10490 10491 func (u *ToolUnionParam) asAny() any { 10492 if !param.IsOmitted(u.OfTool) { 10493 return u.OfTool 10494 } else if !param.IsOmitted(u.OfBashTool20250124) { 10495 return u.OfBashTool20250124 10496 } else if !param.IsOmitted(u.OfCodeExecutionTool20250522) { 10497 return u.OfCodeExecutionTool20250522 10498 } else if !param.IsOmitted(u.OfCodeExecutionTool20250825) { 10499 return u.OfCodeExecutionTool20250825 10500 } else if !param.IsOmitted(u.OfCodeExecutionTool20260120) { 10501 return u.OfCodeExecutionTool20260120 10502 } else if !param.IsOmitted(u.OfCodeExecutionTool20260521) { 10503 return u.OfCodeExecutionTool20260521 10504 } else if !param.IsOmitted(u.OfBrowserToolset20260801) { 10505 return u.OfBrowserToolset20260801 10506 } else if !param.IsOmitted(u.OfMemoryTool20250818) { 10507 return u.OfMemoryTool20250818 10508 } else if !param.IsOmitted(u.OfComputerToolset20260801) { 10509 return u.OfComputerToolset20260801 10510 } else if !param.IsOmitted(u.OfTextEditor20250124) { 10511 return u.OfTextEditor20250124 10512 } else if !param.IsOmitted(u.OfTextEditor20250429) { 10513 return u.OfTextEditor20250429 10514 } else if !param.IsOmitted(u.OfTextEditor20250728) { 10515 return u.OfTextEditor20250728 10516 } else if !param.IsOmitted(u.OfWebSearchTool20250305) { 10517 return u.OfWebSearchTool20250305 10518 } else if !param.IsOmitted(u.OfWebFetchTool20250910) { 10519 return u.OfWebFetchTool20250910 10520 } else if !param.IsOmitted(u.OfWebSearchTool20260209) { 10521 return u.OfWebSearchTool20260209 10522 } else if !param.IsOmitted(u.OfWebFetchTool20260209) { 10523 return u.OfWebFetchTool20260209 10524 } else if !param.IsOmitted(u.OfWebFetchTool20260309) { 10525 return u.OfWebFetchTool20260309 10526 } else if !param.IsOmitted(u.OfWebSearchTool20260318) { 10527 return u.OfWebSearchTool20260318 10528 } else if !param.IsOmitted(u.OfWebFetchTool20260318) { 10529 return u.OfWebFetchTool20260318 10530 } else if !param.IsOmitted(u.OfToolSearchToolBm25_20251119) { 10531 return u.OfToolSearchToolBm25_20251119 10532 } else if !param.IsOmitted(u.OfToolSearchToolRegex20251119) { 10533 return u.OfToolSearchToolRegex20251119 10534 } 10535 return nil 10536 } 10537 10538 // Returns a pointer to the underlying variant's property, if present. 10539 func (u ToolUnionParam) GetInputSchema() *ToolInputSchemaParam { 10540 if vt := u.OfTool; vt != nil { 10541 return &vt.InputSchema 10542 } 10543 return nil 10544 } 10545 10546 // Returns a pointer to the underlying variant's property, if present. 10547 func (u ToolUnionParam) GetDescription() *string { 10548 if vt := u.OfTool; vt != nil && vt.Description.Valid() { 10549 return &vt.Description.Value 10550 } 10551 return nil 10552 } 10553 10554 // Returns a pointer to the underlying variant's property, if present. 10555 func (u ToolUnionParam) GetEagerInputStreaming() *bool { 10556 if vt := u.OfTool; vt != nil && vt.EagerInputStreaming.Valid() { 10557 return &vt.EagerInputStreaming.Value 10558 } 10559 return nil 10560 } 10561 10562 // Returns a pointer to the underlying variant's property, if present. 10563 func (u ToolUnionParam) GetMaxCharacters() *int64 { 10564 if vt := u.OfTextEditor20250728; vt != nil && vt.MaxCharacters.Valid() { 10565 return &vt.MaxCharacters.Value 10566 } 10567 return nil 10568 } 10569 10570 // Returns a pointer to the underlying variant's property, if present. 10571 func (u ToolUnionParam) GetName() *string { 10572 if vt := u.OfTool; vt != nil { 10573 return (*string)(&vt.Name) 10574 } else if vt := u.OfBashTool20250124; vt != nil { 10575 return (*string)(&vt.Name) 10576 } else if vt := u.OfCodeExecutionTool20250522; vt != nil { 10577 return (*string)(&vt.Name) 10578 } else if vt := u.OfCodeExecutionTool20250825; vt != nil { 10579 return (*string)(&vt.Name) 10580 } else if vt := u.OfCodeExecutionTool20260120; vt != nil { 10581 return (*string)(&vt.Name) 10582 } else if vt := u.OfCodeExecutionTool20260521; vt != nil { 10583 return (*string)(&vt.Name) 10584 } else if vt := u.OfMemoryTool20250818; vt != nil { 10585 return (*string)(&vt.Name) 10586 } else if vt := u.OfTextEditor20250124; vt != nil { 10587 return (*string)(&vt.Name) 10588 } else if vt := u.OfTextEditor20250429; vt != nil { 10589 return (*string)(&vt.Name) 10590 } else if vt := u.OfTextEditor20250728; vt != nil { 10591 return (*string)(&vt.Name) 10592 } else if vt := u.OfWebSearchTool20250305; vt != nil { 10593 return (*string)(&vt.Name) 10594 } else if vt := u.OfWebFetchTool20250910; vt != nil { 10595 return (*string)(&vt.Name) 10596 } else if vt := u.OfWebSearchTool20260209; vt != nil { 10597 return (*string)(&vt.Name) 10598 } else if vt := u.OfWebFetchTool20260209; vt != nil { 10599 return (*string)(&vt.Name) 10600 } else if vt := u.OfWebFetchTool20260309; vt != nil { 10601 return (*string)(&vt.Name) 10602 } else if vt := u.OfWebSearchTool20260318; vt != nil { 10603 return (*string)(&vt.Name) 10604 } else if vt := u.OfWebFetchTool20260318; vt != nil { 10605 return (*string)(&vt.Name) 10606 } else if vt := u.OfToolSearchToolBm25_20251119; vt != nil { 10607 return (*string)(&vt.Name) 10608 } else if vt := u.OfToolSearchToolRegex20251119; vt != nil { 10609 return (*string)(&vt.Name) 10610 } 10611 return nil 10612 } 10613 10614 // Returns a pointer to the underlying variant's property, if present. 10615 func (u ToolUnionParam) GetDeferLoading() *bool { 10616 if vt := u.OfTool; vt != nil && vt.DeferLoading.Valid() { 10617 return &vt.DeferLoading.Value 10618 } else if vt := u.OfBashTool20250124; vt != nil && vt.DeferLoading.Valid() { 10619 return &vt.DeferLoading.Value 10620 } else if vt := u.OfCodeExecutionTool20250522; vt != nil && vt.DeferLoading.Valid() { 10621 return &vt.DeferLoading.Value 10622 } else if vt := u.OfCodeExecutionTool20250825; vt != nil && vt.DeferLoading.Valid() { 10623 return &vt.DeferLoading.Value 10624 } else if vt := u.OfCodeExecutionTool20260120; vt != nil && vt.DeferLoading.Valid() { 10625 return &vt.DeferLoading.Value 10626 } else if vt := u.OfCodeExecutionTool20260521; vt != nil && vt.DeferLoading.Valid() { 10627 return &vt.DeferLoading.Value 10628 } else if vt := u.OfMemoryTool20250818; vt != nil && vt.DeferLoading.Valid() { 10629 return &vt.DeferLoading.Value 10630 } else if vt := u.OfTextEditor20250124; vt != nil && vt.DeferLoading.Valid() { 10631 return &vt.DeferLoading.Value 10632 } else if vt := u.OfTextEditor20250429; vt != nil && vt.DeferLoading.Valid() { 10633 return &vt.DeferLoading.Value 10634 } else if vt := u.OfTextEditor20250728; vt != nil && vt.DeferLoading.Valid() { 10635 return &vt.DeferLoading.Value 10636 } else if vt := u.OfWebSearchTool20250305; vt != nil && vt.DeferLoading.Valid() { 10637 return &vt.DeferLoading.Value 10638 } else if vt := u.OfWebFetchTool20250910; vt != nil && vt.DeferLoading.Valid() { 10639 return &vt.DeferLoading.Value 10640 } else if vt := u.OfWebSearchTool20260209; vt != nil && vt.DeferLoading.Valid() { 10641 return &vt.DeferLoading.Value 10642 } else if vt := u.OfWebFetchTool20260209; vt != nil && vt.DeferLoading.Valid() { 10643 return &vt.DeferLoading.Value 10644 } else if vt := u.OfWebFetchTool20260309; vt != nil && vt.DeferLoading.Valid() { 10645 return &vt.DeferLoading.Value 10646 } else if vt := u.OfWebSearchTool20260318; vt != nil && vt.DeferLoading.Valid() { 10647 return &vt.DeferLoading.Value 10648 } else if vt := u.OfWebFetchTool20260318; vt != nil && vt.DeferLoading.Valid() { 10649 return &vt.DeferLoading.Value 10650 } else if vt := u.OfToolSearchToolBm25_20251119; vt != nil && vt.DeferLoading.Valid() { 10651 return &vt.DeferLoading.Value 10652 } else if vt := u.OfToolSearchToolRegex20251119; vt != nil && vt.DeferLoading.Valid() { 10653 return &vt.DeferLoading.Value 10654 } 10655 return nil 10656 } 10657 10658 // Returns a pointer to the underlying variant's property, if present. 10659 func (u ToolUnionParam) GetStrict() *bool { 10660 if vt := u.OfTool; vt != nil && vt.Strict.Valid() { 10661 return &vt.Strict.Value 10662 } else if vt := u.OfBashTool20250124; vt != nil && vt.Strict.Valid() { 10663 return &vt.Strict.Value 10664 } else if vt := u.OfCodeExecutionTool20250522; vt != nil && vt.Strict.Valid() { 10665 return &vt.Strict.Value 10666 } else if vt := u.OfCodeExecutionTool20250825; vt != nil && vt.Strict.Valid() { 10667 return &vt.Strict.Value 10668 } else if vt := u.OfCodeExecutionTool20260120; vt != nil && vt.Strict.Valid() { 10669 return &vt.Strict.Value 10670 } else if vt := u.OfCodeExecutionTool20260521; vt != nil && vt.Strict.Valid() { 10671 return &vt.Strict.Value 10672 } else if vt := u.OfMemoryTool20250818; vt != nil && vt.Strict.Valid() { 10673 return &vt.Strict.Value 10674 } else if vt := u.OfTextEditor20250124; vt != nil && vt.Strict.Valid() { 10675 return &vt.Strict.Value 10676 } else if vt := u.OfTextEditor20250429; vt != nil && vt.Strict.Valid() { 10677 return &vt.Strict.Value 10678 } else if vt := u.OfTextEditor20250728; vt != nil && vt.Strict.Valid() { 10679 return &vt.Strict.Value 10680 } else if vt := u.OfWebSearchTool20250305; vt != nil && vt.Strict.Valid() { 10681 return &vt.Strict.Value 10682 } else if vt := u.OfWebFetchTool20250910; vt != nil && vt.Strict.Valid() { 10683 return &vt.Strict.Value 10684 } else if vt := u.OfWebSearchTool20260209; vt != nil && vt.Strict.Valid() { 10685 return &vt.Strict.Value 10686 } else if vt := u.OfWebFetchTool20260209; vt != nil && vt.Strict.Valid() { 10687 return &vt.Strict.Value 10688 } else if vt := u.OfWebFetchTool20260309; vt != nil && vt.Strict.Valid() { 10689 return &vt.Strict.Value 10690 } else if vt := u.OfWebSearchTool20260318; vt != nil && vt.Strict.Valid() { 10691 return &vt.Strict.Value 10692 } else if vt := u.OfWebFetchTool20260318; vt != nil && vt.Strict.Valid() { 10693 return &vt.Strict.Value 10694 } else if vt := u.OfToolSearchToolBm25_20251119; vt != nil && vt.Strict.Valid() { 10695 return &vt.Strict.Value 10696 } else if vt := u.OfToolSearchToolRegex20251119; vt != nil && vt.Strict.Valid() { 10697 return &vt.Strict.Value 10698 } 10699 return nil 10700 } 10701 10702 // Returns a pointer to the underlying variant's property, if present. 10703 func (u ToolUnionParam) GetType() *string { 10704 if vt := u.OfTool; vt != nil { 10705 return (*string)(&vt.Type) 10706 } else if vt := u.OfBashTool20250124; vt != nil { 10707 return (*string)(&vt.Type) 10708 } else if vt := u.OfCodeExecutionTool20250522; vt != nil { 10709 return (*string)(&vt.Type) 10710 } else if vt := u.OfCodeExecutionTool20250825; vt != nil { 10711 return (*string)(&vt.Type) 10712 } else if vt := u.OfCodeExecutionTool20260120; vt != nil { 10713 return (*string)(&vt.Type) 10714 } else if vt := u.OfCodeExecutionTool20260521; vt != nil { 10715 return (*string)(&vt.Type) 10716 } else if vt := u.OfBrowserToolset20260801; vt != nil { 10717 return (*string)(&vt.Type) 10718 } else if vt := u.OfMemoryTool20250818; vt != nil { 10719 return (*string)(&vt.Type) 10720 } else if vt := u.OfComputerToolset20260801; vt != nil { 10721 return (*string)(&vt.Type) 10722 } else if vt := u.OfTextEditor20250124; vt != nil { 10723 return (*string)(&vt.Type) 10724 } else if vt := u.OfTextEditor20250429; vt != nil { 10725 return (*string)(&vt.Type) 10726 } else if vt := u.OfTextEditor20250728; vt != nil { 10727 return (*string)(&vt.Type) 10728 } else if vt := u.OfWebSearchTool20250305; vt != nil { 10729 return (*string)(&vt.Type) 10730 } else if vt := u.OfWebFetchTool20250910; vt != nil { 10731 return (*string)(&vt.Type) 10732 } else if vt := u.OfWebSearchTool20260209; vt != nil { 10733 return (*string)(&vt.Type) 10734 } else if vt := u.OfWebFetchTool20260209; vt != nil { 10735 return (*string)(&vt.Type) 10736 } else if vt := u.OfWebFetchTool20260309; vt != nil { 10737 return (*string)(&vt.Type) 10738 } else if vt := u.OfWebSearchTool20260318; vt != nil { 10739 return (*string)(&vt.Type) 10740 } else if vt := u.OfWebFetchTool20260318; vt != nil { 10741 return (*string)(&vt.Type) 10742 } else if vt := u.OfToolSearchToolBm25_20251119; vt != nil { 10743 return (*string)(&vt.Type) 10744 } else if vt := u.OfToolSearchToolRegex20251119; vt != nil { 10745 return (*string)(&vt.Type) 10746 } 10747 return nil 10748 } 10749 10750 // Returns a pointer to the underlying variant's property, if present. 10751 func (u ToolUnionParam) GetMaxUses() *int64 { 10752 if vt := u.OfWebSearchTool20250305; vt != nil && vt.MaxUses.Valid() { 10753 return &vt.MaxUses.Value 10754 } else if vt := u.OfWebFetchTool20250910; vt != nil && vt.MaxUses.Valid() { 10755 return &vt.MaxUses.Value 10756 } else if vt := u.OfWebSearchTool20260209; vt != nil && vt.MaxUses.Valid() { 10757 return &vt.MaxUses.Value 10758 } else if vt := u.OfWebFetchTool20260209; vt != nil && vt.MaxUses.Valid() { 10759 return &vt.MaxUses.Value 10760 } else if vt := u.OfWebFetchTool20260309; vt != nil && vt.MaxUses.Valid() { 10761 return &vt.MaxUses.Value 10762 } else if vt := u.OfWebSearchTool20260318; vt != nil && vt.MaxUses.Valid() { 10763 return &vt.MaxUses.Value 10764 } else if vt := u.OfWebFetchTool20260318; vt != nil && vt.MaxUses.Valid() { 10765 return &vt.MaxUses.Value 10766 } 10767 return nil 10768 } 10769 10770 // Returns a pointer to the underlying variant's property, if present. 10771 func (u ToolUnionParam) GetMaxContentTokens() *int64 { 10772 if vt := u.OfWebFetchTool20250910; vt != nil && vt.MaxContentTokens.Valid() { 10773 return &vt.MaxContentTokens.Value 10774 } else if vt := u.OfWebFetchTool20260209; vt != nil && vt.MaxContentTokens.Valid() { 10775 return &vt.MaxContentTokens.Value 10776 } else if vt := u.OfWebFetchTool20260309; vt != nil && vt.MaxContentTokens.Valid() { 10777 return &vt.MaxContentTokens.Value 10778 } else if vt := u.OfWebFetchTool20260318; vt != nil && vt.MaxContentTokens.Valid() { 10779 return &vt.MaxContentTokens.Value 10780 } 10781 return nil 10782 } 10783 10784 // Returns a pointer to the underlying variant's property, if present. 10785 func (u ToolUnionParam) GetUseCache() *bool { 10786 if vt := u.OfWebFetchTool20260309; vt != nil && vt.UseCache.Valid() { 10787 return &vt.UseCache.Value 10788 } else if vt := u.OfWebFetchTool20260318; vt != nil && vt.UseCache.Valid() { 10789 return &vt.UseCache.Value 10790 } 10791 return nil 10792 } 10793 10794 // Returns a pointer to the underlying variant's property, if present. 10795 func (u ToolUnionParam) GetResponseInclusion() *string { 10796 if vt := u.OfWebSearchTool20260318; vt != nil { 10797 return (*string)(&vt.ResponseInclusion) 10798 } else if vt := u.OfWebFetchTool20260318; vt != nil { 10799 return (*string)(&vt.ResponseInclusion) 10800 } 10801 return nil 10802 } 10803 10804 // Returns a pointer to the underlying variant's AllowedCallers property, if 10805 // present. 10806 func (u ToolUnionParam) GetAllowedCallers() []string { 10807 if vt := u.OfTool; vt != nil { 10808 return vt.AllowedCallers 10809 } else if vt := u.OfBashTool20250124; vt != nil { 10810 return vt.AllowedCallers 10811 } else if vt := u.OfCodeExecutionTool20250522; vt != nil { 10812 return vt.AllowedCallers 10813 } else if vt := u.OfCodeExecutionTool20250825; vt != nil { 10814 return vt.AllowedCallers 10815 } else if vt := u.OfCodeExecutionTool20260120; vt != nil { 10816 return vt.AllowedCallers 10817 } else if vt := u.OfCodeExecutionTool20260521; vt != nil { 10818 return vt.AllowedCallers 10819 } else if vt := u.OfMemoryTool20250818; vt != nil { 10820 return vt.AllowedCallers 10821 } else if vt := u.OfTextEditor20250124; vt != nil { 10822 return vt.AllowedCallers 10823 } else if vt := u.OfTextEditor20250429; vt != nil { 10824 return vt.AllowedCallers 10825 } else if vt := u.OfTextEditor20250728; vt != nil { 10826 return vt.AllowedCallers 10827 } else if vt := u.OfWebSearchTool20250305; vt != nil { 10828 return vt.AllowedCallers 10829 } else if vt := u.OfWebFetchTool20250910; vt != nil { 10830 return vt.AllowedCallers 10831 } else if vt := u.OfWebSearchTool20260209; vt != nil { 10832 return vt.AllowedCallers 10833 } else if vt := u.OfWebFetchTool20260209; vt != nil { 10834 return vt.AllowedCallers 10835 } else if vt := u.OfWebFetchTool20260309; vt != nil { 10836 return vt.AllowedCallers 10837 } else if vt := u.OfWebSearchTool20260318; vt != nil { 10838 return vt.AllowedCallers 10839 } else if vt := u.OfWebFetchTool20260318; vt != nil { 10840 return vt.AllowedCallers 10841 } else if vt := u.OfToolSearchToolBm25_20251119; vt != nil { 10842 return vt.AllowedCallers 10843 } else if vt := u.OfToolSearchToolRegex20251119; vt != nil { 10844 return vt.AllowedCallers 10845 } 10846 return nil 10847 } 10848 10849 // Returns a pointer to the underlying variant's CacheControl property, if present. 10850 func (u ToolUnionParam) GetCacheControl() *CacheControlEphemeralParam { 10851 if vt := u.OfTool; vt != nil { 10852 return &vt.CacheControl 10853 } else if vt := u.OfBashTool20250124; vt != nil { 10854 return &vt.CacheControl 10855 } else if vt := u.OfCodeExecutionTool20250522; vt != nil { 10856 return &vt.CacheControl 10857 } else if vt := u.OfCodeExecutionTool20250825; vt != nil { 10858 return &vt.CacheControl 10859 } else if vt := u.OfCodeExecutionTool20260120; vt != nil { 10860 return &vt.CacheControl 10861 } else if vt := u.OfCodeExecutionTool20260521; vt != nil { 10862 return &vt.CacheControl 10863 } else if vt := u.OfBrowserToolset20260801; vt != nil { 10864 return &vt.CacheControl 10865 } else if vt := u.OfMemoryTool20250818; vt != nil { 10866 return &vt.CacheControl 10867 } else if vt := u.OfComputerToolset20260801; vt != nil { 10868 return &vt.CacheControl 10869 } else if vt := u.OfTextEditor20250124; vt != nil { 10870 return &vt.CacheControl 10871 } else if vt := u.OfTextEditor20250429; vt != nil { 10872 return &vt.CacheControl 10873 } else if vt := u.OfTextEditor20250728; vt != nil { 10874 return &vt.CacheControl 10875 } else if vt := u.OfWebSearchTool20250305; vt != nil { 10876 return &vt.CacheControl 10877 } else if vt := u.OfWebFetchTool20250910; vt != nil { 10878 return &vt.CacheControl 10879 } else if vt := u.OfWebSearchTool20260209; vt != nil { 10880 return &vt.CacheControl 10881 } else if vt := u.OfWebFetchTool20260209; vt != nil { 10882 return &vt.CacheControl 10883 } else if vt := u.OfWebFetchTool20260309; vt != nil { 10884 return &vt.CacheControl 10885 } else if vt := u.OfWebSearchTool20260318; vt != nil { 10886 return &vt.CacheControl 10887 } else if vt := u.OfWebFetchTool20260318; vt != nil { 10888 return &vt.CacheControl 10889 } else if vt := u.OfToolSearchToolBm25_20251119; vt != nil { 10890 return &vt.CacheControl 10891 } else if vt := u.OfToolSearchToolRegex20251119; vt != nil { 10892 return &vt.CacheControl 10893 } 10894 return nil 10895 } 10896 10897 // Returns a pointer to the underlying variant's InputExamples property, if 10898 // present. 10899 func (u ToolUnionParam) GetInputExamples() []map[string]any { 10900 if vt := u.OfTool; vt != nil { 10901 return vt.InputExamples 10902 } else if vt := u.OfBashTool20250124; vt != nil { 10903 return vt.InputExamples 10904 } else if vt := u.OfMemoryTool20250818; vt != nil { 10905 return vt.InputExamples 10906 } else if vt := u.OfTextEditor20250124; vt != nil { 10907 return vt.InputExamples 10908 } else if vt := u.OfTextEditor20250429; vt != nil { 10909 return vt.InputExamples 10910 } else if vt := u.OfTextEditor20250728; vt != nil { 10911 return vt.InputExamples 10912 } 10913 return nil 10914 } 10915 10916 // Returns a subunion which exports methods to access subproperties 10917 // 10918 // Or use AsAny() to get the underlying value 10919 func (u ToolUnionParam) GetConfigs() (res toolUnionParamConfigs) { 10920 if vt := u.OfBrowserToolset20260801; vt != nil { 10921 res.any = &vt.Configs 10922 } else if vt := u.OfComputerToolset20260801; vt != nil { 10923 res.any = &vt.Configs 10924 } 10925 return 10926 } 10927 10928 // Can have the runtime types [*BrowserToolsetConfigsParam], 10929 // [*ComputerToolsetConfigsParam] 10930 type toolUnionParamConfigs struct{ any } 10931 10932 // Use the following switch statement to get the type of the union: 10933 // 10934 // switch u.AsAny().(type) { 10935 // case *anthropic.BrowserToolsetConfigsParam: 10936 // case *anthropic.ComputerToolsetConfigsParam: 10937 // default: 10938 // fmt.Errorf("not present") 10939 // } 10940 func (u toolUnionParamConfigs) AsAny() any { return u.any } 10941 10942 // Returns a pointer to the underlying variant's property, if present. 10943 func (u toolUnionParamConfigs) GetCloseTab() *BrowserCloseTabConfigParam { 10944 switch vt := u.any.(type) { 10945 case *BrowserToolsetConfigsParam: 10946 return &vt.CloseTab 10947 } 10948 return nil 10949 } 10950 10951 // Returns a pointer to the underlying variant's property, if present. 10952 func (u toolUnionParamConfigs) GetFileUpload() *BrowserFileUploadConfigParam { 10953 switch vt := u.any.(type) { 10954 case *BrowserToolsetConfigsParam: 10955 return &vt.FileUpload 10956 } 10957 return nil 10958 } 10959 10960 // Returns a pointer to the underlying variant's property, if present. 10961 func (u toolUnionParamConfigs) GetFind() *BrowserFindConfigParam { 10962 switch vt := u.any.(type) { 10963 case *BrowserToolsetConfigsParam: 10964 return &vt.Find 10965 } 10966 return nil 10967 } 10968 10969 // Returns a pointer to the underlying variant's property, if present. 10970 func (u toolUnionParamConfigs) GetFormInput() *BrowserFormInputConfigParam { 10971 switch vt := u.any.(type) { 10972 case *BrowserToolsetConfigsParam: 10973 return &vt.FormInput 10974 } 10975 return nil 10976 } 10977 10978 // Returns a pointer to the underlying variant's property, if present. 10979 func (u toolUnionParamConfigs) GetGetPageText() *BrowserGetPageTextConfigParam { 10980 switch vt := u.any.(type) { 10981 case *BrowserToolsetConfigsParam: 10982 return &vt.GetPageText 10983 } 10984 return nil 10985 } 10986 10987 // Returns a pointer to the underlying variant's property, if present. 10988 func (u toolUnionParamConfigs) GetHover() *BrowserHoverConfigParam { 10989 switch vt := u.any.(type) { 10990 case *BrowserToolsetConfigsParam: 10991 return &vt.Hover 10992 } 10993 return nil 10994 } 10995 10996 // Returns a pointer to the underlying variant's property, if present. 10997 func (u toolUnionParamConfigs) GetJavascriptExec() *BrowserJavascriptExecConfigParam { 10998 switch vt := u.any.(type) { 10999 case *BrowserToolsetConfigsParam: 11000 return &vt.JavascriptExec 11001 } 11002 return nil 11003 } 11004 11005 // Returns a pointer to the underlying variant's property, if present. 11006 func (u toolUnionParamConfigs) GetListTabs() *BrowserListTabsConfigParam { 11007 switch vt := u.any.(type) { 11008 case *BrowserToolsetConfigsParam: 11009 return &vt.ListTabs 11010 } 11011 return nil 11012 } 11013 11014 // Returns a pointer to the underlying variant's property, if present. 11015 func (u toolUnionParamConfigs) GetNavigate() *BrowserNavigateConfigParam { 11016 switch vt := u.any.(type) { 11017 case *BrowserToolsetConfigsParam: 11018 return &vt.Navigate 11019 } 11020 return nil 11021 } 11022 11023 // Returns a pointer to the underlying variant's property, if present. 11024 func (u toolUnionParamConfigs) GetNewTab() *BrowserNewTabConfigParam { 11025 switch vt := u.any.(type) { 11026 case *BrowserToolsetConfigsParam: 11027 return &vt.NewTab 11028 } 11029 return nil 11030 } 11031 11032 // Returns a pointer to the underlying variant's property, if present. 11033 func (u toolUnionParamConfigs) GetReadConsole() *BrowserReadConsoleConfigParam { 11034 switch vt := u.any.(type) { 11035 case *BrowserToolsetConfigsParam: 11036 return &vt.ReadConsole 11037 } 11038 return nil 11039 } 11040 11041 // Returns a pointer to the underlying variant's property, if present. 11042 func (u toolUnionParamConfigs) GetReadNetwork() *BrowserReadNetworkConfigParam { 11043 switch vt := u.any.(type) { 11044 case *BrowserToolsetConfigsParam: 11045 return &vt.ReadNetwork 11046 } 11047 return nil 11048 } 11049 11050 // Returns a pointer to the underlying variant's property, if present. 11051 func (u toolUnionParamConfigs) GetReadPage() *BrowserReadPageConfigParam { 11052 switch vt := u.any.(type) { 11053 case *BrowserToolsetConfigsParam: 11054 return &vt.ReadPage 11055 } 11056 return nil 11057 } 11058 11059 // Returns a pointer to the underlying variant's property, if present. 11060 func (u toolUnionParamConfigs) GetScrollTo() *BrowserScrollToConfigParam { 11061 switch vt := u.any.(type) { 11062 case *BrowserToolsetConfigsParam: 11063 return &vt.ScrollTo 11064 } 11065 return nil 11066 } 11067 11068 // Returns a pointer to the underlying variant's property, if present. 11069 func (u toolUnionParamConfigs) GetSwitchTab() *BrowserSwitchTabConfigParam { 11070 switch vt := u.any.(type) { 11071 case *BrowserToolsetConfigsParam: 11072 return &vt.SwitchTab 11073 } 11074 return nil 11075 } 11076 11077 // Returns a pointer to the underlying variant's property, if present. 11078 func (u toolUnionParamConfigs) GetCursorPosition() *ComputerCursorPositionConfigParam { 11079 switch vt := u.any.(type) { 11080 case *ComputerToolsetConfigsParam: 11081 return &vt.CursorPosition 11082 } 11083 return nil 11084 } 11085 11086 // Returns a subunion which exports methods to access subproperties 11087 // 11088 // Or use AsAny() to get the underlying value 11089 func (u toolUnionParamConfigs) GetDoubleClick() (res toolUnionParamConfigsDoubleClick) { 11090 switch vt := u.any.(type) { 11091 case *BrowserToolsetConfigsParam: 11092 res.any = &vt.DoubleClick 11093 case *ComputerToolsetConfigsParam: 11094 res.any = &vt.DoubleClick 11095 } 11096 return res 11097 } 11098 11099 // Can have the runtime types [*BrowserDoubleClickConfigParam], 11100 // [*ComputerDoubleClickConfigParam] 11101 type toolUnionParamConfigsDoubleClick struct{ any } 11102 11103 // Use the following switch statement to get the type of the union: 11104 // 11105 // switch u.AsAny().(type) { 11106 // case *anthropic.BrowserDoubleClickConfigParam: 11107 // case *anthropic.ComputerDoubleClickConfigParam: 11108 // default: 11109 // fmt.Errorf("not present") 11110 // } 11111 func (u toolUnionParamConfigsDoubleClick) AsAny() any { return u.any } 11112 11113 // Returns a pointer to the underlying variant's property, if present. 11114 func (u toolUnionParamConfigsDoubleClick) GetDeferLoading() *bool { 11115 switch vt := u.any.(type) { 11116 case *BrowserDoubleClickConfigParam: 11117 return paramutil.AddrIfPresent(vt.DeferLoading) 11118 case *ComputerDoubleClickConfigParam: 11119 return paramutil.AddrIfPresent(vt.DeferLoading) 11120 } 11121 return nil 11122 } 11123 11124 // Returns a pointer to the underlying variant's property, if present. 11125 func (u toolUnionParamConfigsDoubleClick) GetEnabled() *bool { 11126 switch vt := u.any.(type) { 11127 case *BrowserDoubleClickConfigParam: 11128 return paramutil.AddrIfPresent(vt.Enabled) 11129 case *ComputerDoubleClickConfigParam: 11130 return paramutil.AddrIfPresent(vt.Enabled) 11131 } 11132 return nil 11133 } 11134 11135 // Returns a subunion which exports methods to access subproperties 11136 // 11137 // Or use AsAny() to get the underlying value 11138 func (u toolUnionParamConfigs) GetHoldKey() (res toolUnionParamConfigsHoldKey) { 11139 switch vt := u.any.(type) { 11140 case *BrowserToolsetConfigsParam: 11141 res.any = &vt.HoldKey 11142 case *ComputerToolsetConfigsParam: 11143 res.any = &vt.HoldKey 11144 } 11145 return res 11146 } 11147 11148 // Can have the runtime types [*BrowserHoldKeyConfigParam], 11149 // [*ComputerHoldKeyConfigParam] 11150 type toolUnionParamConfigsHoldKey struct{ any } 11151 11152 // Use the following switch statement to get the type of the union: 11153 // 11154 // switch u.AsAny().(type) { 11155 // case *anthropic.BrowserHoldKeyConfigParam: 11156 // case *anthropic.ComputerHoldKeyConfigParam: 11157 // default: 11158 // fmt.Errorf("not present") 11159 // } 11160 func (u toolUnionParamConfigsHoldKey) AsAny() any { return u.any } 11161 11162 // Returns a pointer to the underlying variant's property, if present. 11163 func (u toolUnionParamConfigsHoldKey) GetDeferLoading() *bool { 11164 switch vt := u.any.(type) { 11165 case *BrowserHoldKeyConfigParam: 11166 return paramutil.AddrIfPresent(vt.DeferLoading) 11167 case *ComputerHoldKeyConfigParam: 11168 return paramutil.AddrIfPresent(vt.DeferLoading) 11169 } 11170 return nil 11171 } 11172 11173 // Returns a pointer to the underlying variant's property, if present. 11174 func (u toolUnionParamConfigsHoldKey) GetEnabled() *bool { 11175 switch vt := u.any.(type) { 11176 case *BrowserHoldKeyConfigParam: 11177 return paramutil.AddrIfPresent(vt.Enabled) 11178 case *ComputerHoldKeyConfigParam: 11179 return paramutil.AddrIfPresent(vt.Enabled) 11180 } 11181 return nil 11182 } 11183 11184 // Returns a subunion which exports methods to access subproperties 11185 // 11186 // Or use AsAny() to get the underlying value 11187 func (u toolUnionParamConfigs) GetKey() (res toolUnionParamConfigsKey) { 11188 switch vt := u.any.(type) { 11189 case *BrowserToolsetConfigsParam: 11190 res.any = &vt.Key 11191 case *ComputerToolsetConfigsParam: 11192 res.any = &vt.Key 11193 } 11194 return res 11195 } 11196 11197 // Can have the runtime types [*BrowserKeyConfigParam], [*ComputerKeyConfigParam] 11198 type toolUnionParamConfigsKey struct{ any } 11199 11200 // Use the following switch statement to get the type of the union: 11201 // 11202 // switch u.AsAny().(type) { 11203 // case *anthropic.BrowserKeyConfigParam: 11204 // case *anthropic.ComputerKeyConfigParam: 11205 // default: 11206 // fmt.Errorf("not present") 11207 // } 11208 func (u toolUnionParamConfigsKey) AsAny() any { return u.any } 11209 11210 // Returns a pointer to the underlying variant's property, if present. 11211 func (u toolUnionParamConfigsKey) GetDeferLoading() *bool { 11212 switch vt := u.any.(type) { 11213 case *BrowserKeyConfigParam: 11214 return paramutil.AddrIfPresent(vt.DeferLoading) 11215 case *ComputerKeyConfigParam: 11216 return paramutil.AddrIfPresent(vt.DeferLoading) 11217 } 11218 return nil 11219 } 11220 11221 // Returns a pointer to the underlying variant's property, if present. 11222 func (u toolUnionParamConfigsKey) GetEnabled() *bool { 11223 switch vt := u.any.(type) { 11224 case *BrowserKeyConfigParam: 11225 return paramutil.AddrIfPresent(vt.Enabled) 11226 case *ComputerKeyConfigParam: 11227 return paramutil.AddrIfPresent(vt.Enabled) 11228 } 11229 return nil 11230 } 11231 11232 // Returns a subunion which exports methods to access subproperties 11233 // 11234 // Or use AsAny() to get the underlying value 11235 func (u toolUnionParamConfigs) GetLeftClick() (res toolUnionParamConfigsLeftClick) { 11236 switch vt := u.any.(type) { 11237 case *BrowserToolsetConfigsParam: 11238 res.any = &vt.LeftClick 11239 case *ComputerToolsetConfigsParam: 11240 res.any = &vt.LeftClick 11241 } 11242 return res 11243 } 11244 11245 // Can have the runtime types [*BrowserLeftClickConfigParam], 11246 // [*ComputerLeftClickConfigParam] 11247 type toolUnionParamConfigsLeftClick struct{ any } 11248 11249 // Use the following switch statement to get the type of the union: 11250 // 11251 // switch u.AsAny().(type) { 11252 // case *anthropic.BrowserLeftClickConfigParam: 11253 // case *anthropic.ComputerLeftClickConfigParam: 11254 // default: 11255 // fmt.Errorf("not present") 11256 // } 11257 func (u toolUnionParamConfigsLeftClick) AsAny() any { return u.any } 11258 11259 // Returns a pointer to the underlying variant's property, if present. 11260 func (u toolUnionParamConfigsLeftClick) GetDeferLoading() *bool { 11261 switch vt := u.any.(type) { 11262 case *BrowserLeftClickConfigParam: 11263 return paramutil.AddrIfPresent(vt.DeferLoading) 11264 case *ComputerLeftClickConfigParam: 11265 return paramutil.AddrIfPresent(vt.DeferLoading) 11266 } 11267 return nil 11268 } 11269 11270 // Returns a pointer to the underlying variant's property, if present. 11271 func (u toolUnionParamConfigsLeftClick) GetEnabled() *bool { 11272 switch vt := u.any.(type) { 11273 case *BrowserLeftClickConfigParam: 11274 return paramutil.AddrIfPresent(vt.Enabled) 11275 case *ComputerLeftClickConfigParam: 11276 return paramutil.AddrIfPresent(vt.Enabled) 11277 } 11278 return nil 11279 } 11280 11281 // Returns a subunion which exports methods to access subproperties 11282 // 11283 // Or use AsAny() to get the underlying value 11284 func (u toolUnionParamConfigs) GetLeftClickDrag() (res toolUnionParamConfigsLeftClickDrag) { 11285 switch vt := u.any.(type) { 11286 case *BrowserToolsetConfigsParam: 11287 res.any = &vt.LeftClickDrag 11288 case *ComputerToolsetConfigsParam: 11289 res.any = &vt.LeftClickDrag 11290 } 11291 return res 11292 } 11293 11294 // Can have the runtime types [*BrowserLeftClickDragConfigParam], 11295 // [*ComputerLeftClickDragConfigParam] 11296 type toolUnionParamConfigsLeftClickDrag struct{ any } 11297 11298 // Use the following switch statement to get the type of the union: 11299 // 11300 // switch u.AsAny().(type) { 11301 // case *anthropic.BrowserLeftClickDragConfigParam: 11302 // case *anthropic.ComputerLeftClickDragConfigParam: 11303 // default: 11304 // fmt.Errorf("not present") 11305 // } 11306 func (u toolUnionParamConfigsLeftClickDrag) AsAny() any { return u.any } 11307 11308 // Returns a pointer to the underlying variant's property, if present. 11309 func (u toolUnionParamConfigsLeftClickDrag) GetDeferLoading() *bool { 11310 switch vt := u.any.(type) { 11311 case *BrowserLeftClickDragConfigParam: 11312 return paramutil.AddrIfPresent(vt.DeferLoading) 11313 case *ComputerLeftClickDragConfigParam: 11314 return paramutil.AddrIfPresent(vt.DeferLoading) 11315 } 11316 return nil 11317 } 11318 11319 // Returns a pointer to the underlying variant's property, if present. 11320 func (u toolUnionParamConfigsLeftClickDrag) GetEnabled() *bool { 11321 switch vt := u.any.(type) { 11322 case *BrowserLeftClickDragConfigParam: 11323 return paramutil.AddrIfPresent(vt.Enabled) 11324 case *ComputerLeftClickDragConfigParam: 11325 return paramutil.AddrIfPresent(vt.Enabled) 11326 } 11327 return nil 11328 } 11329 11330 // Returns a subunion which exports methods to access subproperties 11331 // 11332 // Or use AsAny() to get the underlying value 11333 func (u toolUnionParamConfigs) GetLeftMouseDown() (res toolUnionParamConfigsLeftMouseDown) { 11334 switch vt := u.any.(type) { 11335 case *BrowserToolsetConfigsParam: 11336 res.any = &vt.LeftMouseDown 11337 case *ComputerToolsetConfigsParam: 11338 res.any = &vt.LeftMouseDown 11339 } 11340 return res 11341 } 11342 11343 // Can have the runtime types [*BrowserLeftMouseDownConfigParam], 11344 // [*ComputerLeftMouseDownConfigParam] 11345 type toolUnionParamConfigsLeftMouseDown struct{ any } 11346 11347 // Use the following switch statement to get the type of the union: 11348 // 11349 // switch u.AsAny().(type) { 11350 // case *anthropic.BrowserLeftMouseDownConfigParam: 11351 // case *anthropic.ComputerLeftMouseDownConfigParam: 11352 // default: 11353 // fmt.Errorf("not present") 11354 // } 11355 func (u toolUnionParamConfigsLeftMouseDown) AsAny() any { return u.any } 11356 11357 // Returns a pointer to the underlying variant's property, if present. 11358 func (u toolUnionParamConfigsLeftMouseDown) GetDeferLoading() *bool { 11359 switch vt := u.any.(type) { 11360 case *BrowserLeftMouseDownConfigParam: 11361 return paramutil.AddrIfPresent(vt.DeferLoading) 11362 case *ComputerLeftMouseDownConfigParam: 11363 return paramutil.AddrIfPresent(vt.DeferLoading) 11364 } 11365 return nil 11366 } 11367 11368 // Returns a pointer to the underlying variant's property, if present. 11369 func (u toolUnionParamConfigsLeftMouseDown) GetEnabled() *bool { 11370 switch vt := u.any.(type) { 11371 case *BrowserLeftMouseDownConfigParam: 11372 return paramutil.AddrIfPresent(vt.Enabled) 11373 case *ComputerLeftMouseDownConfigParam: 11374 return paramutil.AddrIfPresent(vt.Enabled) 11375 } 11376 return nil 11377 } 11378 11379 // Returns a subunion which exports methods to access subproperties 11380 // 11381 // Or use AsAny() to get the underlying value 11382 func (u toolUnionParamConfigs) GetLeftMouseUp() (res toolUnionParamConfigsLeftMouseUp) { 11383 switch vt := u.any.(type) { 11384 case *BrowserToolsetConfigsParam: 11385 res.any = &vt.LeftMouseUp 11386 case *ComputerToolsetConfigsParam: 11387 res.any = &vt.LeftMouseUp 11388 } 11389 return res 11390 } 11391 11392 // Can have the runtime types [*BrowserLeftMouseUpConfigParam], 11393 // [*ComputerLeftMouseUpConfigParam] 11394 type toolUnionParamConfigsLeftMouseUp struct{ any } 11395 11396 // Use the following switch statement to get the type of the union: 11397 // 11398 // switch u.AsAny().(type) { 11399 // case *anthropic.BrowserLeftMouseUpConfigParam: 11400 // case *anthropic.ComputerLeftMouseUpConfigParam: 11401 // default: 11402 // fmt.Errorf("not present") 11403 // } 11404 func (u toolUnionParamConfigsLeftMouseUp) AsAny() any { return u.any } 11405 11406 // Returns a pointer to the underlying variant's property, if present. 11407 func (u toolUnionParamConfigsLeftMouseUp) GetDeferLoading() *bool { 11408 switch vt := u.any.(type) { 11409 case *BrowserLeftMouseUpConfigParam: 11410 return paramutil.AddrIfPresent(vt.DeferLoading) 11411 case *ComputerLeftMouseUpConfigParam: 11412 return paramutil.AddrIfPresent(vt.DeferLoading) 11413 } 11414 return nil 11415 } 11416 11417 // Returns a pointer to the underlying variant's property, if present. 11418 func (u toolUnionParamConfigsLeftMouseUp) GetEnabled() *bool { 11419 switch vt := u.any.(type) { 11420 case *BrowserLeftMouseUpConfigParam: 11421 return paramutil.AddrIfPresent(vt.Enabled) 11422 case *ComputerLeftMouseUpConfigParam: 11423 return paramutil.AddrIfPresent(vt.Enabled) 11424 } 11425 return nil 11426 } 11427 11428 // Returns a subunion which exports methods to access subproperties 11429 // 11430 // Or use AsAny() to get the underlying value 11431 func (u toolUnionParamConfigs) GetMiddleClick() (res toolUnionParamConfigsMiddleClick) { 11432 switch vt := u.any.(type) { 11433 case *BrowserToolsetConfigsParam: 11434 res.any = &vt.MiddleClick 11435 case *ComputerToolsetConfigsParam: 11436 res.any = &vt.MiddleClick 11437 } 11438 return res 11439 } 11440 11441 // Can have the runtime types [*BrowserMiddleClickConfigParam], 11442 // [*ComputerMiddleClickConfigParam] 11443 type toolUnionParamConfigsMiddleClick struct{ any } 11444 11445 // Use the following switch statement to get the type of the union: 11446 // 11447 // switch u.AsAny().(type) { 11448 // case *anthropic.BrowserMiddleClickConfigParam: 11449 // case *anthropic.ComputerMiddleClickConfigParam: 11450 // default: 11451 // fmt.Errorf("not present") 11452 // } 11453 func (u toolUnionParamConfigsMiddleClick) AsAny() any { return u.any } 11454 11455 // Returns a pointer to the underlying variant's property, if present. 11456 func (u toolUnionParamConfigsMiddleClick) GetDeferLoading() *bool { 11457 switch vt := u.any.(type) { 11458 case *BrowserMiddleClickConfigParam: 11459 return paramutil.AddrIfPresent(vt.DeferLoading) 11460 case *ComputerMiddleClickConfigParam: 11461 return paramutil.AddrIfPresent(vt.DeferLoading) 11462 } 11463 return nil 11464 } 11465 11466 // Returns a pointer to the underlying variant's property, if present. 11467 func (u toolUnionParamConfigsMiddleClick) GetEnabled() *bool { 11468 switch vt := u.any.(type) { 11469 case *BrowserMiddleClickConfigParam: 11470 return paramutil.AddrIfPresent(vt.Enabled) 11471 case *ComputerMiddleClickConfigParam: 11472 return paramutil.AddrIfPresent(vt.Enabled) 11473 } 11474 return nil 11475 } 11476 11477 // Returns a subunion which exports methods to access subproperties 11478 // 11479 // Or use AsAny() to get the underlying value 11480 func (u toolUnionParamConfigs) GetMouseMove() (res toolUnionParamConfigsMouseMove) { 11481 switch vt := u.any.(type) { 11482 case *BrowserToolsetConfigsParam: 11483 res.any = &vt.MouseMove 11484 case *ComputerToolsetConfigsParam: 11485 res.any = &vt.MouseMove 11486 } 11487 return res 11488 } 11489 11490 // Can have the runtime types [*BrowserMouseMoveConfigParam], 11491 // [*ComputerMouseMoveConfigParam] 11492 type toolUnionParamConfigsMouseMove struct{ any } 11493 11494 // Use the following switch statement to get the type of the union: 11495 // 11496 // switch u.AsAny().(type) { 11497 // case *anthropic.BrowserMouseMoveConfigParam: 11498 // case *anthropic.ComputerMouseMoveConfigParam: 11499 // default: 11500 // fmt.Errorf("not present") 11501 // } 11502 func (u toolUnionParamConfigsMouseMove) AsAny() any { return u.any } 11503 11504 // Returns a pointer to the underlying variant's property, if present. 11505 func (u toolUnionParamConfigsMouseMove) GetDeferLoading() *bool { 11506 switch vt := u.any.(type) { 11507 case *BrowserMouseMoveConfigParam: 11508 return paramutil.AddrIfPresent(vt.DeferLoading) 11509 case *ComputerMouseMoveConfigParam: 11510 return paramutil.AddrIfPresent(vt.DeferLoading) 11511 } 11512 return nil 11513 } 11514 11515 // Returns a pointer to the underlying variant's property, if present. 11516 func (u toolUnionParamConfigsMouseMove) GetEnabled() *bool { 11517 switch vt := u.any.(type) { 11518 case *BrowserMouseMoveConfigParam: 11519 return paramutil.AddrIfPresent(vt.Enabled) 11520 case *ComputerMouseMoveConfigParam: 11521 return paramutil.AddrIfPresent(vt.Enabled) 11522 } 11523 return nil 11524 } 11525 11526 // Returns a subunion which exports methods to access subproperties 11527 // 11528 // Or use AsAny() to get the underlying value 11529 func (u toolUnionParamConfigs) GetRightClick() (res toolUnionParamConfigsRightClick) { 11530 switch vt := u.any.(type) { 11531 case *BrowserToolsetConfigsParam: 11532 res.any = &vt.RightClick 11533 case *ComputerToolsetConfigsParam: 11534 res.any = &vt.RightClick 11535 } 11536 return res 11537 } 11538 11539 // Can have the runtime types [*BrowserRightClickConfigParam], 11540 // [*ComputerRightClickConfigParam] 11541 type toolUnionParamConfigsRightClick struct{ any } 11542 11543 // Use the following switch statement to get the type of the union: 11544 // 11545 // switch u.AsAny().(type) { 11546 // case *anthropic.BrowserRightClickConfigParam: 11547 // case *anthropic.ComputerRightClickConfigParam: 11548 // default: 11549 // fmt.Errorf("not present") 11550 // } 11551 func (u toolUnionParamConfigsRightClick) AsAny() any { return u.any } 11552 11553 // Returns a pointer to the underlying variant's property, if present. 11554 func (u toolUnionParamConfigsRightClick) GetDeferLoading() *bool { 11555 switch vt := u.any.(type) { 11556 case *BrowserRightClickConfigParam: 11557 return paramutil.AddrIfPresent(vt.DeferLoading) 11558 case *ComputerRightClickConfigParam: 11559 return paramutil.AddrIfPresent(vt.DeferLoading) 11560 } 11561 return nil 11562 } 11563 11564 // Returns a pointer to the underlying variant's property, if present. 11565 func (u toolUnionParamConfigsRightClick) GetEnabled() *bool { 11566 switch vt := u.any.(type) { 11567 case *BrowserRightClickConfigParam: 11568 return paramutil.AddrIfPresent(vt.Enabled) 11569 case *ComputerRightClickConfigParam: 11570 return paramutil.AddrIfPresent(vt.Enabled) 11571 } 11572 return nil 11573 } 11574 11575 // Returns a subunion which exports methods to access subproperties 11576 // 11577 // Or use AsAny() to get the underlying value 11578 func (u toolUnionParamConfigs) GetScreenshot() (res toolUnionParamConfigsScreenshot) { 11579 switch vt := u.any.(type) { 11580 case *BrowserToolsetConfigsParam: 11581 res.any = &vt.Screenshot 11582 case *ComputerToolsetConfigsParam: 11583 res.any = &vt.Screenshot 11584 } 11585 return res 11586 } 11587 11588 // Can have the runtime types [*BrowserScreenshotConfigParam], 11589 // [*ComputerScreenshotConfigParam] 11590 type toolUnionParamConfigsScreenshot struct{ any } 11591 11592 // Use the following switch statement to get the type of the union: 11593 // 11594 // switch u.AsAny().(type) { 11595 // case *anthropic.BrowserScreenshotConfigParam: 11596 // case *anthropic.ComputerScreenshotConfigParam: 11597 // default: 11598 // fmt.Errorf("not present") 11599 // } 11600 func (u toolUnionParamConfigsScreenshot) AsAny() any { return u.any } 11601 11602 // Returns a pointer to the underlying variant's property, if present. 11603 func (u toolUnionParamConfigsScreenshot) GetDeferLoading() *bool { 11604 switch vt := u.any.(type) { 11605 case *BrowserScreenshotConfigParam: 11606 return paramutil.AddrIfPresent(vt.DeferLoading) 11607 case *ComputerScreenshotConfigParam: 11608 return paramutil.AddrIfPresent(vt.DeferLoading) 11609 } 11610 return nil 11611 } 11612 11613 // Returns a pointer to the underlying variant's property, if present. 11614 func (u toolUnionParamConfigsScreenshot) GetEnabled() *bool { 11615 switch vt := u.any.(type) { 11616 case *BrowserScreenshotConfigParam: 11617 return paramutil.AddrIfPresent(vt.Enabled) 11618 case *ComputerScreenshotConfigParam: 11619 return paramutil.AddrIfPresent(vt.Enabled) 11620 } 11621 return nil 11622 } 11623 11624 // Returns a subunion which exports methods to access subproperties 11625 // 11626 // Or use AsAny() to get the underlying value 11627 func (u toolUnionParamConfigs) GetScroll() (res toolUnionParamConfigsScroll) { 11628 switch vt := u.any.(type) { 11629 case *BrowserToolsetConfigsParam: 11630 res.any = &vt.Scroll 11631 case *ComputerToolsetConfigsParam: 11632 res.any = &vt.Scroll 11633 } 11634 return res 11635 } 11636 11637 // Can have the runtime types [*BrowserScrollConfigParam], 11638 // [*ComputerScrollConfigParam] 11639 type toolUnionParamConfigsScroll struct{ any } 11640 11641 // Use the following switch statement to get the type of the union: 11642 // 11643 // switch u.AsAny().(type) { 11644 // case *anthropic.BrowserScrollConfigParam: 11645 // case *anthropic.ComputerScrollConfigParam: 11646 // default: 11647 // fmt.Errorf("not present") 11648 // } 11649 func (u toolUnionParamConfigsScroll) AsAny() any { return u.any } 11650 11651 // Returns a pointer to the underlying variant's property, if present. 11652 func (u toolUnionParamConfigsScroll) GetDeferLoading() *bool { 11653 switch vt := u.any.(type) { 11654 case *BrowserScrollConfigParam: 11655 return paramutil.AddrIfPresent(vt.DeferLoading) 11656 case *ComputerScrollConfigParam: 11657 return paramutil.AddrIfPresent(vt.DeferLoading) 11658 } 11659 return nil 11660 } 11661 11662 // Returns a pointer to the underlying variant's property, if present. 11663 func (u toolUnionParamConfigsScroll) GetEnabled() *bool { 11664 switch vt := u.any.(type) { 11665 case *BrowserScrollConfigParam: 11666 return paramutil.AddrIfPresent(vt.Enabled) 11667 case *ComputerScrollConfigParam: 11668 return paramutil.AddrIfPresent(vt.Enabled) 11669 } 11670 return nil 11671 } 11672 11673 // Returns a subunion which exports methods to access subproperties 11674 // 11675 // Or use AsAny() to get the underlying value 11676 func (u toolUnionParamConfigs) GetTripleClick() (res toolUnionParamConfigsTripleClick) { 11677 switch vt := u.any.(type) { 11678 case *BrowserToolsetConfigsParam: 11679 res.any = &vt.TripleClick 11680 case *ComputerToolsetConfigsParam: 11681 res.any = &vt.TripleClick 11682 } 11683 return res 11684 } 11685 11686 // Can have the runtime types [*BrowserTripleClickConfigParam], 11687 // [*ComputerTripleClickConfigParam] 11688 type toolUnionParamConfigsTripleClick struct{ any } 11689 11690 // Use the following switch statement to get the type of the union: 11691 // 11692 // switch u.AsAny().(type) { 11693 // case *anthropic.BrowserTripleClickConfigParam: 11694 // case *anthropic.ComputerTripleClickConfigParam: 11695 // default: 11696 // fmt.Errorf("not present") 11697 // } 11698 func (u toolUnionParamConfigsTripleClick) AsAny() any { return u.any } 11699 11700 // Returns a pointer to the underlying variant's property, if present. 11701 func (u toolUnionParamConfigsTripleClick) GetDeferLoading() *bool { 11702 switch vt := u.any.(type) { 11703 case *BrowserTripleClickConfigParam: 11704 return paramutil.AddrIfPresent(vt.DeferLoading) 11705 case *ComputerTripleClickConfigParam: 11706 return paramutil.AddrIfPresent(vt.DeferLoading) 11707 } 11708 return nil 11709 } 11710 11711 // Returns a pointer to the underlying variant's property, if present. 11712 func (u toolUnionParamConfigsTripleClick) GetEnabled() *bool { 11713 switch vt := u.any.(type) { 11714 case *BrowserTripleClickConfigParam: 11715 return paramutil.AddrIfPresent(vt.Enabled) 11716 case *ComputerTripleClickConfigParam: 11717 return paramutil.AddrIfPresent(vt.Enabled) 11718 } 11719 return nil 11720 } 11721 11722 // Returns a subunion which exports methods to access subproperties 11723 // 11724 // Or use AsAny() to get the underlying value 11725 func (u toolUnionParamConfigs) GetType() (res toolUnionParamConfigsType) { 11726 switch vt := u.any.(type) { 11727 case *BrowserToolsetConfigsParam: 11728 res.any = &vt.Type 11729 case *ComputerToolsetConfigsParam: 11730 res.any = &vt.Type 11731 } 11732 return res 11733 } 11734 11735 // Can have the runtime types [*BrowserTypeConfigParam], [*ComputerTypeConfigParam] 11736 type toolUnionParamConfigsType struct{ any } 11737 11738 // Use the following switch statement to get the type of the union: 11739 // 11740 // switch u.AsAny().(type) { 11741 // case *anthropic.BrowserTypeConfigParam: 11742 // case *anthropic.ComputerTypeConfigParam: 11743 // default: 11744 // fmt.Errorf("not present") 11745 // } 11746 func (u toolUnionParamConfigsType) AsAny() any { return u.any } 11747 11748 // Returns a pointer to the underlying variant's property, if present. 11749 func (u toolUnionParamConfigsType) GetDeferLoading() *bool { 11750 switch vt := u.any.(type) { 11751 case *BrowserTypeConfigParam: 11752 return paramutil.AddrIfPresent(vt.DeferLoading) 11753 case *ComputerTypeConfigParam: 11754 return paramutil.AddrIfPresent(vt.DeferLoading) 11755 } 11756 return nil 11757 } 11758 11759 // Returns a pointer to the underlying variant's property, if present. 11760 func (u toolUnionParamConfigsType) GetEnabled() *bool { 11761 switch vt := u.any.(type) { 11762 case *BrowserTypeConfigParam: 11763 return paramutil.AddrIfPresent(vt.Enabled) 11764 case *ComputerTypeConfigParam: 11765 return paramutil.AddrIfPresent(vt.Enabled) 11766 } 11767 return nil 11768 } 11769 11770 // Returns a subunion which exports methods to access subproperties 11771 // 11772 // Or use AsAny() to get the underlying value 11773 func (u toolUnionParamConfigs) GetWait() (res toolUnionParamConfigsWait) { 11774 switch vt := u.any.(type) { 11775 case *BrowserToolsetConfigsParam: 11776 res.any = &vt.Wait 11777 case *ComputerToolsetConfigsParam: 11778 res.any = &vt.Wait 11779 } 11780 return res 11781 } 11782 11783 // Can have the runtime types [*BrowserWaitConfigParam], [*ComputerWaitConfigParam] 11784 type toolUnionParamConfigsWait struct{ any } 11785 11786 // Use the following switch statement to get the type of the union: 11787 // 11788 // switch u.AsAny().(type) { 11789 // case *anthropic.BrowserWaitConfigParam: 11790 // case *anthropic.ComputerWaitConfigParam: 11791 // default: 11792 // fmt.Errorf("not present") 11793 // } 11794 func (u toolUnionParamConfigsWait) AsAny() any { return u.any } 11795 11796 // Returns a pointer to the underlying variant's property, if present. 11797 func (u toolUnionParamConfigsWait) GetDeferLoading() *bool { 11798 switch vt := u.any.(type) { 11799 case *BrowserWaitConfigParam: 11800 return paramutil.AddrIfPresent(vt.DeferLoading) 11801 case *ComputerWaitConfigParam: 11802 return paramutil.AddrIfPresent(vt.DeferLoading) 11803 } 11804 return nil 11805 } 11806 11807 // Returns a pointer to the underlying variant's property, if present. 11808 func (u toolUnionParamConfigsWait) GetEnabled() *bool { 11809 switch vt := u.any.(type) { 11810 case *BrowserWaitConfigParam: 11811 return paramutil.AddrIfPresent(vt.Enabled) 11812 case *ComputerWaitConfigParam: 11813 return paramutil.AddrIfPresent(vt.Enabled) 11814 } 11815 return nil 11816 } 11817 11818 // Returns a subunion which exports methods to access subproperties 11819 // 11820 // Or use AsAny() to get the underlying value 11821 func (u toolUnionParamConfigs) GetZoom() (res toolUnionParamConfigsZoom) { 11822 switch vt := u.any.(type) { 11823 case *BrowserToolsetConfigsParam: 11824 res.any = &vt.Zoom 11825 case *ComputerToolsetConfigsParam: 11826 res.any = &vt.Zoom 11827 } 11828 return res 11829 } 11830 11831 // Can have the runtime types [*BrowserZoomConfigParam], [*ComputerZoomConfigParam] 11832 type toolUnionParamConfigsZoom struct{ any } 11833 11834 // Use the following switch statement to get the type of the union: 11835 // 11836 // switch u.AsAny().(type) { 11837 // case *anthropic.BrowserZoomConfigParam: 11838 // case *anthropic.ComputerZoomConfigParam: 11839 // default: 11840 // fmt.Errorf("not present") 11841 // } 11842 func (u toolUnionParamConfigsZoom) AsAny() any { return u.any } 11843 11844 // Returns a pointer to the underlying variant's property, if present. 11845 func (u toolUnionParamConfigsZoom) GetDeferLoading() *bool { 11846 switch vt := u.any.(type) { 11847 case *BrowserZoomConfigParam: 11848 return paramutil.AddrIfPresent(vt.DeferLoading) 11849 case *ComputerZoomConfigParam: 11850 return paramutil.AddrIfPresent(vt.DeferLoading) 11851 } 11852 return nil 11853 } 11854 11855 // Returns a pointer to the underlying variant's property, if present. 11856 func (u toolUnionParamConfigsZoom) GetEnabled() *bool { 11857 switch vt := u.any.(type) { 11858 case *BrowserZoomConfigParam: 11859 return paramutil.AddrIfPresent(vt.Enabled) 11860 case *ComputerZoomConfigParam: 11861 return paramutil.AddrIfPresent(vt.Enabled) 11862 } 11863 return nil 11864 } 11865 11866 // Returns a pointer to the underlying variant's AllowedDomains property, if 11867 // present. 11868 func (u ToolUnionParam) GetAllowedDomains() []string { 11869 if vt := u.OfWebSearchTool20250305; vt != nil { 11870 return vt.AllowedDomains 11871 } else if vt := u.OfWebFetchTool20250910; vt != nil { 11872 return vt.AllowedDomains 11873 } else if vt := u.OfWebSearchTool20260209; vt != nil { 11874 return vt.AllowedDomains 11875 } else if vt := u.OfWebFetchTool20260209; vt != nil { 11876 return vt.AllowedDomains 11877 } else if vt := u.OfWebFetchTool20260309; vt != nil { 11878 return vt.AllowedDomains 11879 } else if vt := u.OfWebSearchTool20260318; vt != nil { 11880 return vt.AllowedDomains 11881 } else if vt := u.OfWebFetchTool20260318; vt != nil { 11882 return vt.AllowedDomains 11883 } 11884 return nil 11885 } 11886 11887 // Returns a pointer to the underlying variant's BlockedDomains property, if 11888 // present. 11889 func (u ToolUnionParam) GetBlockedDomains() []string { 11890 if vt := u.OfWebSearchTool20250305; vt != nil { 11891 return vt.BlockedDomains 11892 } else if vt := u.OfWebFetchTool20250910; vt != nil { 11893 return vt.BlockedDomains 11894 } else if vt := u.OfWebSearchTool20260209; vt != nil { 11895 return vt.BlockedDomains 11896 } else if vt := u.OfWebFetchTool20260209; vt != nil { 11897 return vt.BlockedDomains 11898 } else if vt := u.OfWebFetchTool20260309; vt != nil { 11899 return vt.BlockedDomains 11900 } else if vt := u.OfWebSearchTool20260318; vt != nil { 11901 return vt.BlockedDomains 11902 } else if vt := u.OfWebFetchTool20260318; vt != nil { 11903 return vt.BlockedDomains 11904 } 11905 return nil 11906 } 11907 11908 // Returns a pointer to the underlying variant's UserLocation property, if present. 11909 func (u ToolUnionParam) GetUserLocation() *UserLocationParam { 11910 if vt := u.OfWebSearchTool20250305; vt != nil { 11911 return &vt.UserLocation 11912 } else if vt := u.OfWebSearchTool20260209; vt != nil { 11913 return &vt.UserLocation 11914 } else if vt := u.OfWebSearchTool20260318; vt != nil { 11915 return &vt.UserLocation 11916 } 11917 return nil 11918 } 11919 11920 // Returns a pointer to the underlying variant's Citations property, if present. 11921 func (u ToolUnionParam) GetCitations() *CitationsConfigParam { 11922 if vt := u.OfWebFetchTool20250910; vt != nil { 11923 return &vt.Citations 11924 } else if vt := u.OfWebFetchTool20260209; vt != nil { 11925 return &vt.Citations 11926 } else if vt := u.OfWebFetchTool20260309; vt != nil { 11927 return &vt.Citations 11928 } else if vt := u.OfWebFetchTool20260318; vt != nil { 11929 return &vt.Citations 11930 } 11931 return nil 11932 } 11933 11934 type ToolUseBlock struct { 11935 ID string `json:"id" api:"required"` 11936 // Tool invocation directly from the model. 11937 Caller ToolUseBlockCallerUnion `json:"caller" api:"required"` 11938 // necessary custom code modification 11939 Input json.RawMessage `json:"input,required"` 11940 Name string `json:"name" api:"required"` 11941 Type constant.ToolUse `json:"type" default:"tool_use"` 11942 // For a toolset member tool_use, the toolset family. 11943 ToolsetName string `json:"toolset_name" api:"nullable"` 11944 // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. 11945 JSON struct { 11946 ID respjson.Field 11947 Caller respjson.Field 11948 Input respjson.Field 11949 Name respjson.Field 11950 Type respjson.Field 11951 ToolsetName respjson.Field 11952 ExtraFields map[string]respjson.Field 11953 raw string 11954 } `json:"-"` 11955 } 11956 11957 // Returns the unmodified JSON received from the API 11958 func (r ToolUseBlock) RawJSON() string { return r.JSON.raw } 11959 func (r *ToolUseBlock) UnmarshalJSON(data []byte) error { 11960 return apijson.UnmarshalRoot(data, r) 11961 } 11962 11963 // ToolUseBlockCallerUnion contains all possible properties and values from 11964 // [DirectCaller], [ServerToolCaller], [ServerToolCaller20260120]. 11965 // 11966 // Use the [ToolUseBlockCallerUnion.AsAny] method to switch on the variant. 11967 // 11968 // Use the methods beginning with 'As' to cast the union to one of its variants. 11969 type ToolUseBlockCallerUnion struct { 11970 // Any of "direct", "code_execution_20250825", "code_execution_20260120". 11971 Type string `json:"type"` 11972 ToolID string `json:"tool_id"` 11973 JSON struct { 11974 Type respjson.Field 11975 ToolID respjson.Field 11976 raw string 11977 } `json:"-"` 11978 } 11979 11980 // anyToolUseBlockCaller is implemented by each variant of 11981 // [ToolUseBlockCallerUnion] to add type safety for the return type of 11982 // [ToolUseBlockCallerUnion.AsAny] 11983 type anyToolUseBlockCaller interface { 11984 implToolUseBlockCallerUnion() 11985 } 11986 11987 func (DirectCaller) implToolUseBlockCallerUnion() {} 11988 func (ServerToolCaller) implToolUseBlockCallerUnion() {} 11989 func (ServerToolCaller20260120) implToolUseBlockCallerUnion() {} 11990 11991 // Use the following switch statement to find the correct variant 11992 // 11993 // switch variant := ToolUseBlockCallerUnion.AsAny().(type) { 11994 // case anthropic.DirectCaller: 11995 // case anthropic.ServerToolCaller: 11996 // case anthropic.ServerToolCaller20260120: 11997 // default: 11998 // fmt.Errorf("no variant present") 11999 // } 12000 func (u ToolUseBlockCallerUnion) AsAny() anyToolUseBlockCaller { 12001 switch u.Type { 12002 case "direct": 12003 return u.AsDirect() 12004 case "code_execution_20250825": 12005 return u.AsCodeExecution20250825() 12006 case "code_execution_20260120": 12007 return u.AsCodeExecution20260120() 12008 } 12009 return nil 12010 } 12011 12012 func (u ToolUseBlockCallerUnion) AsDirect() (v DirectCaller) { 12013 apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) 12014 return 12015 } 12016 12017 func (u ToolUseBlockCallerUnion) AsCodeExecution20250825() (v ServerToolCaller) { 12018 apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) 12019 return 12020 } 12021 12022 func (u ToolUseBlockCallerUnion) AsCodeExecution20260120() (v ServerToolCaller20260120) { 12023 apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) 12024 return 12025 } 12026 12027 // Returns the unmodified JSON received from the API 12028 func (u ToolUseBlockCallerUnion) RawJSON() string { return u.JSON.raw } 12029 12030 func (r *ToolUseBlockCallerUnion) UnmarshalJSON(data []byte) error { 12031 return apijson.UnmarshalRoot(data, r) 12032 } 12033 12034 // The properties ID, Input, Name, Type are required. 12035 type ToolUseBlockParam struct { 12036 ID string `json:"id" api:"required"` 12037 Input any `json:"input,omitzero" api:"required"` 12038 Name string `json:"name" api:"required"` 12039 // For a toolset member tool_use, the toolset family this member belongs to. 12040 ToolsetName param.Opt[string] `json:"toolset_name,omitzero"` 12041 // Create a cache control breakpoint at this content block. 12042 CacheControl CacheControlEphemeralParam `json:"cache_control,omitzero"` 12043 // Tool invocation directly from the model. 12044 Caller ToolUseBlockParamCallerUnion `json:"caller,omitzero"` 12045 // This field can be elided, and will marshal its zero value as "tool_use". 12046 Type constant.ToolUse `json:"type" default:"tool_use"` 12047 paramObj 12048 } 12049 12050 func (r ToolUseBlockParam) MarshalJSON() (data []byte, err error) { 12051 type shadow ToolUseBlockParam 12052 return param.MarshalObject(r, (*shadow)(&r)) 12053 } 12054 func (r *ToolUseBlockParam) UnmarshalJSON(data []byte) error { 12055 return apijson.UnmarshalRoot(data, r) 12056 } 12057 12058 // Only one field can be non-zero. 12059 // 12060 // Use [param.IsOmitted] to confirm if a field is set. 12061 type ToolUseBlockParamCallerUnion struct { 12062 OfDirect *DirectCallerParam `json:",omitzero,inline"` 12063 OfCodeExecution20250825 *ServerToolCallerParam `json:",omitzero,inline"` 12064 OfCodeExecution20260120 *ServerToolCaller20260120Param `json:",omitzero,inline"` 12065 paramUnion 12066 } 12067 12068 func (u ToolUseBlockParamCallerUnion) MarshalJSON() ([]byte, error) { 12069 return param.MarshalUnion(u, u.OfDirect, u.OfCodeExecution20250825, u.OfCodeExecution20260120) 12070 } 12071 func (u *ToolUseBlockParamCallerUnion) UnmarshalJSON(data []byte) error { 12072 return apijson.UnmarshalRoot(data, u) 12073 } 12074 12075 func (u *ToolUseBlockParamCallerUnion) asAny() any { 12076 if !param.IsOmitted(u.OfDirect) { 12077 return u.OfDirect 12078 } else if !param.IsOmitted(u.OfCodeExecution20250825) { 12079 return u.OfCodeExecution20250825 12080 } else if !param.IsOmitted(u.OfCodeExecution20260120) { 12081 return u.OfCodeExecution20260120 12082 } 12083 return nil 12084 } 12085 12086 // Returns a pointer to the underlying variant's property, if present. 12087 func (u ToolUseBlockParamCallerUnion) GetType() *string { 12088 if vt := u.OfDirect; vt != nil { 12089 return (*string)(&vt.Type) 12090 } else if vt := u.OfCodeExecution20250825; vt != nil { 12091 return (*string)(&vt.Type) 12092 } else if vt := u.OfCodeExecution20260120; vt != nil { 12093 return (*string)(&vt.Type) 12094 } 12095 return nil 12096 } 12097 12098 // Returns a pointer to the underlying variant's property, if present. 12099 func (u ToolUseBlockParamCallerUnion) GetToolID() *string { 12100 if vt := u.OfCodeExecution20250825; vt != nil { 12101 return (*string)(&vt.ToolID) 12102 } else if vt := u.OfCodeExecution20260120; vt != nil { 12103 return (*string)(&vt.ToolID) 12104 } 12105 return nil 12106 } 12107 12108 func init() { 12109 apijson.RegisterUnion[ToolUseBlockParamCallerUnion]( 12110 "type", 12111 apijson.Discriminator[DirectCallerParam]("direct"), 12112 apijson.Discriminator[ServerToolCallerParam]("code_execution_20250825"), 12113 apijson.Discriminator[ServerToolCaller20260120Param]("code_execution_20260120"), 12114 ) 12115 } 12116 12117 // The properties Type, URL are required. 12118 type URLImageSourceParam struct { 12119 URL string `json:"url" api:"required"` 12120 // This field can be elided, and will marshal its zero value as "url". 12121 Type constant.URL `json:"type" default:"url"` 12122 paramObj 12123 } 12124 12125 func (r URLImageSourceParam) MarshalJSON() (data []byte, err error) { 12126 type shadow URLImageSourceParam 12127 return param.MarshalObject(r, (*shadow)(&r)) 12128 } 12129 func (r *URLImageSourceParam) UnmarshalJSON(data []byte) error { 12130 return apijson.UnmarshalRoot(data, r) 12131 } 12132 12133 // The properties Type, URL are required. 12134 type URLPDFSourceParam struct { 12135 URL string `json:"url" api:"required"` 12136 // This field can be elided, and will marshal its zero value as "url". 12137 Type constant.URL `json:"type" default:"url"` 12138 paramObj 12139 } 12140 12141 func (r URLPDFSourceParam) MarshalJSON() (data []byte, err error) { 12142 type shadow URLPDFSourceParam 12143 return param.MarshalObject(r, (*shadow)(&r)) 12144 } 12145 func (r *URLPDFSourceParam) UnmarshalJSON(data []byte) error { 12146 return apijson.UnmarshalRoot(data, r) 12147 } 12148 12149 type Usage struct { 12150 // Breakdown of cached tokens by TTL 12151 CacheCreation CacheCreation `json:"cache_creation" api:"required"` 12152 // The number of input tokens used to create the cache entry. 12153 CacheCreationInputTokens int64 `json:"cache_creation_input_tokens" api:"required"` 12154 // The number of input tokens read from the cache. 12155 CacheReadInputTokens int64 `json:"cache_read_input_tokens" api:"required"` 12156 // The geographic region where inference was performed for this request. 12157 InferenceGeo string `json:"inference_geo" api:"required"` 12158 // The number of input tokens which were used. 12159 InputTokens int64 `json:"input_tokens" api:"required"` 12160 // The number of output tokens which were used. 12161 OutputTokens int64 `json:"output_tokens" api:"required"` 12162 // Breakdown of output tokens by category. 12163 // 12164 // `output_tokens` remains the inclusive, authoritative total used for billing. 12165 // This object provides a read-only decomposition for observability — for example, 12166 // how many of the billed output tokens were spent on internal reasoning that may 12167 // have been summarized before being returned to you. 12168 OutputTokensDetails OutputTokensDetails `json:"output_tokens_details" api:"required"` 12169 // The number of server tool requests. 12170 ServerToolUse ServerToolUsage `json:"server_tool_use" api:"required"` 12171 // If the request used the priority, standard, or batch tier. 12172 // 12173 // Any of "standard", "priority", "batch". 12174 ServiceTier UsageServiceTier `json:"service_tier" api:"required"` 12175 // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. 12176 JSON struct { 12177 CacheCreation respjson.Field 12178 CacheCreationInputTokens respjson.Field 12179 CacheReadInputTokens respjson.Field 12180 InferenceGeo respjson.Field 12181 InputTokens respjson.Field 12182 OutputTokens respjson.Field 12183 OutputTokensDetails respjson.Field 12184 ServerToolUse respjson.Field 12185 ServiceTier respjson.Field 12186 ExtraFields map[string]respjson.Field 12187 raw string 12188 } `json:"-"` 12189 } 12190 12191 // Returns the unmodified JSON received from the API 12192 func (r Usage) RawJSON() string { return r.JSON.raw } 12193 func (r *Usage) UnmarshalJSON(data []byte) error { 12194 return apijson.UnmarshalRoot(data, r) 12195 } 12196 12197 // If the request used the priority, standard, or batch tier. 12198 type UsageServiceTier string 12199 12200 const ( 12201 UsageServiceTierStandard UsageServiceTier = "standard" 12202 UsageServiceTierPriority UsageServiceTier = "priority" 12203 UsageServiceTierBatch UsageServiceTier = "batch" 12204 ) 12205 12206 // The property Type is required. 12207 type UserLocationParam struct { 12208 // The city of the user. 12209 City param.Opt[string] `json:"city,omitzero"` 12210 // The two letter 12211 // [ISO country code](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2) of the 12212 // user. 12213 Country param.Opt[string] `json:"country,omitzero"` 12214 // The region of the user. 12215 Region param.Opt[string] `json:"region,omitzero"` 12216 // The [IANA timezone](https://nodatime.org/TimeZones) of the user. 12217 Timezone param.Opt[string] `json:"timezone,omitzero"` 12218 // This field can be elided, and will marshal its zero value as "approximate". 12219 Type constant.Approximate `json:"type" default:"approximate"` 12220 paramObj 12221 } 12222 12223 func (r UserLocationParam) MarshalJSON() (data []byte, err error) { 12224 type shadow UserLocationParam 12225 return param.MarshalObject(r, (*shadow)(&r)) 12226 } 12227 func (r *UserLocationParam) UnmarshalJSON(data []byte) error { 12228 return apijson.UnmarshalRoot(data, r) 12229 } 12230 12231 type WebFetchBlock struct { 12232 Content DocumentBlock `json:"content" api:"required"` 12233 // ISO 8601 timestamp when the content was retrieved 12234 RetrievedAt string `json:"retrieved_at" api:"required"` 12235 Type constant.WebFetchResult `json:"type" default:"web_fetch_result"` 12236 // Fetched content URL 12237 URL string `json:"url" api:"required"` 12238 // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. 12239 JSON struct { 12240 Content respjson.Field 12241 RetrievedAt respjson.Field 12242 Type respjson.Field 12243 URL respjson.Field 12244 ExtraFields map[string]respjson.Field 12245 raw string 12246 } `json:"-"` 12247 } 12248 12249 // Returns the unmodified JSON received from the API 12250 func (r WebFetchBlock) RawJSON() string { return r.JSON.raw } 12251 func (r *WebFetchBlock) UnmarshalJSON(data []byte) error { 12252 return apijson.UnmarshalRoot(data, r) 12253 } 12254 12255 // The properties Content, Type, URL are required. 12256 type WebFetchBlockParam struct { 12257 Content DocumentBlockParam `json:"content,omitzero" api:"required"` 12258 // Fetched content URL 12259 URL string `json:"url" api:"required"` 12260 // ISO 8601 timestamp when the content was retrieved 12261 RetrievedAt param.Opt[string] `json:"retrieved_at,omitzero"` 12262 // This field can be elided, and will marshal its zero value as "web_fetch_result". 12263 Type constant.WebFetchResult `json:"type" default:"web_fetch_result"` 12264 paramObj 12265 } 12266 12267 func (r WebFetchBlockParam) MarshalJSON() (data []byte, err error) { 12268 type shadow WebFetchBlockParam 12269 return param.MarshalObject(r, (*shadow)(&r)) 12270 } 12271 func (r *WebFetchBlockParam) UnmarshalJSON(data []byte) error { 12272 return apijson.UnmarshalRoot(data, r) 12273 } 12274 12275 // The properties Name, Type are required. 12276 type WebFetchTool20250910Param struct { 12277 // Maximum number of tokens used by including web page text content in the context. 12278 // The limit is approximate and does not apply to binary content such as PDFs. 12279 MaxContentTokens param.Opt[int64] `json:"max_content_tokens,omitzero"` 12280 // Maximum number of times the tool can be used in the API request. 12281 MaxUses param.Opt[int64] `json:"max_uses,omitzero"` 12282 // If true, tool will not be included in initial system prompt. Only loaded when 12283 // returned via tool_reference from tool search. 12284 DeferLoading param.Opt[bool] `json:"defer_loading,omitzero"` 12285 // When true, guarantees schema validation on tool names and inputs 12286 Strict param.Opt[bool] `json:"strict,omitzero"` 12287 // List of domains to allow fetching from 12288 AllowedDomains []string `json:"allowed_domains,omitzero"` 12289 // List of domains to block fetching from 12290 BlockedDomains []string `json:"blocked_domains,omitzero"` 12291 // Any of "direct", "code_execution_20250825", "code_execution_20260120", 12292 // "code_execution_20260521". 12293 AllowedCallers []string `json:"allowed_callers,omitzero"` 12294 // Create a cache control breakpoint at this content block. 12295 CacheControl CacheControlEphemeralParam `json:"cache_control,omitzero"` 12296 // Citations configuration for fetched documents. Citations are disabled by 12297 // default. 12298 Citations CitationsConfigParam `json:"citations,omitzero"` 12299 // Name of the tool. 12300 // 12301 // This is how the tool will be called by the model and in `tool_use` blocks. 12302 // 12303 // This field can be elided, and will marshal its zero value as "web_fetch". 12304 Name constant.WebFetch `json:"name" default:"web_fetch"` 12305 // This field can be elided, and will marshal its zero value as 12306 // "web_fetch_20250910". 12307 Type constant.WebFetch20250910 `json:"type" default:"web_fetch_20250910"` 12308 paramObj 12309 } 12310 12311 func (r WebFetchTool20250910Param) MarshalJSON() (data []byte, err error) { 12312 type shadow WebFetchTool20250910Param 12313 return param.MarshalObject(r, (*shadow)(&r)) 12314 } 12315 func (r *WebFetchTool20250910Param) UnmarshalJSON(data []byte) error { 12316 return apijson.UnmarshalRoot(data, r) 12317 } 12318 12319 // The properties Name, Type are required. 12320 type WebFetchTool20260209Param struct { 12321 // Maximum number of tokens used by including web page text content in the context. 12322 // The limit is approximate and does not apply to binary content such as PDFs. 12323 MaxContentTokens param.Opt[int64] `json:"max_content_tokens,omitzero"` 12324 // Maximum number of times the tool can be used in the API request. 12325 MaxUses param.Opt[int64] `json:"max_uses,omitzero"` 12326 // If true, tool will not be included in initial system prompt. Only loaded when 12327 // returned via tool_reference from tool search. 12328 DeferLoading param.Opt[bool] `json:"defer_loading,omitzero"` 12329 // When true, guarantees schema validation on tool names and inputs 12330 Strict param.Opt[bool] `json:"strict,omitzero"` 12331 // List of domains to allow fetching from 12332 AllowedDomains []string `json:"allowed_domains,omitzero"` 12333 // List of domains to block fetching from 12334 BlockedDomains []string `json:"blocked_domains,omitzero"` 12335 // Any of "direct", "code_execution_20250825", "code_execution_20260120", 12336 // "code_execution_20260521". 12337 AllowedCallers []string `json:"allowed_callers,omitzero"` 12338 // Create a cache control breakpoint at this content block. 12339 CacheControl CacheControlEphemeralParam `json:"cache_control,omitzero"` 12340 // Citations configuration for fetched documents. Citations are disabled by 12341 // default. 12342 Citations CitationsConfigParam `json:"citations,omitzero"` 12343 // Name of the tool. 12344 // 12345 // This is how the tool will be called by the model and in `tool_use` blocks. 12346 // 12347 // This field can be elided, and will marshal its zero value as "web_fetch". 12348 Name constant.WebFetch `json:"name" default:"web_fetch"` 12349 // This field can be elided, and will marshal its zero value as 12350 // "web_fetch_20260209". 12351 Type constant.WebFetch20260209 `json:"type" default:"web_fetch_20260209"` 12352 paramObj 12353 } 12354 12355 func (r WebFetchTool20260209Param) MarshalJSON() (data []byte, err error) { 12356 type shadow WebFetchTool20260209Param 12357 return param.MarshalObject(r, (*shadow)(&r)) 12358 } 12359 func (r *WebFetchTool20260209Param) UnmarshalJSON(data []byte) error { 12360 return apijson.UnmarshalRoot(data, r) 12361 } 12362 12363 // Web fetch tool with use_cache parameter for bypassing cached content. 12364 // 12365 // The properties Name, Type are required. 12366 type WebFetchTool20260309Param struct { 12367 // Maximum number of tokens used by including web page text content in the context. 12368 // The limit is approximate and does not apply to binary content such as PDFs. 12369 MaxContentTokens param.Opt[int64] `json:"max_content_tokens,omitzero"` 12370 // Maximum number of times the tool can be used in the API request. 12371 MaxUses param.Opt[int64] `json:"max_uses,omitzero"` 12372 // If true, tool will not be included in initial system prompt. Only loaded when 12373 // returned via tool_reference from tool search. 12374 DeferLoading param.Opt[bool] `json:"defer_loading,omitzero"` 12375 // When true, guarantees schema validation on tool names and inputs 12376 Strict param.Opt[bool] `json:"strict,omitzero"` 12377 // Whether to use cached content. Set to false to bypass the cache and fetch fresh 12378 // content. Only set to false when the user explicitly requests fresh content or 12379 // when fetching rapidly-changing sources. 12380 UseCache param.Opt[bool] `json:"use_cache,omitzero"` 12381 // List of domains to allow fetching from 12382 AllowedDomains []string `json:"allowed_domains,omitzero"` 12383 // List of domains to block fetching from 12384 BlockedDomains []string `json:"blocked_domains,omitzero"` 12385 // Any of "direct", "code_execution_20250825", "code_execution_20260120", 12386 // "code_execution_20260521". 12387 AllowedCallers []string `json:"allowed_callers,omitzero"` 12388 // Create a cache control breakpoint at this content block. 12389 CacheControl CacheControlEphemeralParam `json:"cache_control,omitzero"` 12390 // Citations configuration for fetched documents. Citations are disabled by 12391 // default. 12392 Citations CitationsConfigParam `json:"citations,omitzero"` 12393 // Name of the tool. 12394 // 12395 // This is how the tool will be called by the model and in `tool_use` blocks. 12396 // 12397 // This field can be elided, and will marshal its zero value as "web_fetch". 12398 Name constant.WebFetch `json:"name" default:"web_fetch"` 12399 // This field can be elided, and will marshal its zero value as 12400 // "web_fetch_20260309". 12401 Type constant.WebFetch20260309 `json:"type" default:"web_fetch_20260309"` 12402 paramObj 12403 } 12404 12405 func (r WebFetchTool20260309Param) MarshalJSON() (data []byte, err error) { 12406 type shadow WebFetchTool20260309Param 12407 return param.MarshalObject(r, (*shadow)(&r)) 12408 } 12409 func (r *WebFetchTool20260309Param) UnmarshalJSON(data []byte) error { 12410 return apijson.UnmarshalRoot(data, r) 12411 } 12412 12413 // The properties Name, Type are required. 12414 type WebFetchTool20260318Param struct { 12415 // Maximum number of tokens used by including web page text content in the context. 12416 // The limit is approximate and does not apply to binary content such as PDFs. 12417 MaxContentTokens param.Opt[int64] `json:"max_content_tokens,omitzero"` 12418 // Maximum number of times the tool can be used in the API request. 12419 MaxUses param.Opt[int64] `json:"max_uses,omitzero"` 12420 // If true, tool will not be included in initial system prompt. Only loaded when 12421 // returned via tool_reference from tool search. 12422 DeferLoading param.Opt[bool] `json:"defer_loading,omitzero"` 12423 // When true, guarantees schema validation on tool names and inputs 12424 Strict param.Opt[bool] `json:"strict,omitzero"` 12425 // Whether to use cached content. Set to false to bypass the cache and fetch fresh 12426 // content. Only set to false when the user explicitly requests fresh content or 12427 // when fetching rapidly-changing sources. 12428 UseCache param.Opt[bool] `json:"use_cache,omitzero"` 12429 // List of domains to allow fetching from 12430 AllowedDomains []string `json:"allowed_domains,omitzero"` 12431 // List of domains to block fetching from 12432 BlockedDomains []string `json:"blocked_domains,omitzero"` 12433 // Any of "direct", "code_execution_20250825", "code_execution_20260120", 12434 // "code_execution_20260521". 12435 AllowedCallers []string `json:"allowed_callers,omitzero"` 12436 // Create a cache control breakpoint at this content block. 12437 CacheControl CacheControlEphemeralParam `json:"cache_control,omitzero"` 12438 // Citations configuration for fetched documents. Citations are disabled by 12439 // default. 12440 Citations CitationsConfigParam `json:"citations,omitzero"` 12441 // How this tool's result blocks appear in the API response when the result was 12442 // consumed by a completed code_execution call in the same turn. 'full' returns the 12443 // complete content (default). 'excluded' drops the nested server_tool_use and 12444 // result block pair entirely. Results from direct calls, or from code_execution 12445 // calls that paused before completing, are always returned in full so they can be 12446 // sent back on the next turn. 12447 // 12448 // Any of "full", "excluded". 12449 ResponseInclusion WebFetchTool20260318ResponseInclusion `json:"response_inclusion,omitzero"` 12450 // Name of the tool. 12451 // 12452 // This is how the tool will be called by the model and in `tool_use` blocks. 12453 // 12454 // This field can be elided, and will marshal its zero value as "web_fetch". 12455 Name constant.WebFetch `json:"name" default:"web_fetch"` 12456 // This field can be elided, and will marshal its zero value as 12457 // "web_fetch_20260318". 12458 Type constant.WebFetch20260318 `json:"type" default:"web_fetch_20260318"` 12459 paramObj 12460 } 12461 12462 func (r WebFetchTool20260318Param) MarshalJSON() (data []byte, err error) { 12463 type shadow WebFetchTool20260318Param 12464 return param.MarshalObject(r, (*shadow)(&r)) 12465 } 12466 func (r *WebFetchTool20260318Param) UnmarshalJSON(data []byte) error { 12467 return apijson.UnmarshalRoot(data, r) 12468 } 12469 12470 // How this tool's result blocks appear in the API response when the result was 12471 // consumed by a completed code_execution call in the same turn. 'full' returns the 12472 // complete content (default). 'excluded' drops the nested server_tool_use and 12473 // result block pair entirely. Results from direct calls, or from code_execution 12474 // calls that paused before completing, are always returned in full so they can be 12475 // sent back on the next turn. 12476 type WebFetchTool20260318ResponseInclusion string 12477 12478 const ( 12479 WebFetchTool20260318ResponseInclusionFull WebFetchTool20260318ResponseInclusion = "full" 12480 WebFetchTool20260318ResponseInclusionExcluded WebFetchTool20260318ResponseInclusion = "excluded" 12481 ) 12482 12483 type WebFetchToolResultBlock struct { 12484 // Tool invocation directly from the model. 12485 Caller WebFetchToolResultBlockCallerUnion `json:"caller" api:"required"` 12486 Content WebFetchToolResultBlockContentUnion `json:"content" api:"required"` 12487 ToolUseID string `json:"tool_use_id" api:"required"` 12488 Type constant.WebFetchToolResult `json:"type" default:"web_fetch_tool_result"` 12489 // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. 12490 JSON struct { 12491 Caller respjson.Field 12492 Content respjson.Field 12493 ToolUseID respjson.Field 12494 Type respjson.Field 12495 ExtraFields map[string]respjson.Field 12496 raw string 12497 } `json:"-"` 12498 } 12499 12500 // Returns the unmodified JSON received from the API 12501 func (r WebFetchToolResultBlock) RawJSON() string { return r.JSON.raw } 12502 func (r *WebFetchToolResultBlock) UnmarshalJSON(data []byte) error { 12503 return apijson.UnmarshalRoot(data, r) 12504 } 12505 12506 // WebFetchToolResultBlockCallerUnion contains all possible properties and values 12507 // from [DirectCaller], [ServerToolCaller], [ServerToolCaller20260120]. 12508 // 12509 // Use the [WebFetchToolResultBlockCallerUnion.AsAny] method to switch on the 12510 // variant. 12511 // 12512 // Use the methods beginning with 'As' to cast the union to one of its variants. 12513 type WebFetchToolResultBlockCallerUnion struct { 12514 // Any of "direct", "code_execution_20250825", "code_execution_20260120". 12515 Type string `json:"type"` 12516 ToolID string `json:"tool_id"` 12517 JSON struct { 12518 Type respjson.Field 12519 ToolID respjson.Field 12520 raw string 12521 } `json:"-"` 12522 } 12523 12524 // anyWebFetchToolResultBlockCaller is implemented by each variant of 12525 // [WebFetchToolResultBlockCallerUnion] to add type safety for the return type of 12526 // [WebFetchToolResultBlockCallerUnion.AsAny] 12527 type anyWebFetchToolResultBlockCaller interface { 12528 implWebFetchToolResultBlockCallerUnion() 12529 } 12530 12531 func (DirectCaller) implWebFetchToolResultBlockCallerUnion() {} 12532 func (ServerToolCaller) implWebFetchToolResultBlockCallerUnion() {} 12533 func (ServerToolCaller20260120) implWebFetchToolResultBlockCallerUnion() {} 12534 12535 // Use the following switch statement to find the correct variant 12536 // 12537 // switch variant := WebFetchToolResultBlockCallerUnion.AsAny().(type) { 12538 // case anthropic.DirectCaller: 12539 // case anthropic.ServerToolCaller: 12540 // case anthropic.ServerToolCaller20260120: 12541 // default: 12542 // fmt.Errorf("no variant present") 12543 // } 12544 func (u WebFetchToolResultBlockCallerUnion) AsAny() anyWebFetchToolResultBlockCaller { 12545 switch u.Type { 12546 case "direct": 12547 return u.AsDirect() 12548 case "code_execution_20250825": 12549 return u.AsCodeExecution20250825() 12550 case "code_execution_20260120": 12551 return u.AsCodeExecution20260120() 12552 } 12553 return nil 12554 } 12555 12556 func (u WebFetchToolResultBlockCallerUnion) AsDirect() (v DirectCaller) { 12557 apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) 12558 return 12559 } 12560 12561 func (u WebFetchToolResultBlockCallerUnion) AsCodeExecution20250825() (v ServerToolCaller) { 12562 apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) 12563 return 12564 } 12565 12566 func (u WebFetchToolResultBlockCallerUnion) AsCodeExecution20260120() (v ServerToolCaller20260120) { 12567 apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) 12568 return 12569 } 12570 12571 // Returns the unmodified JSON received from the API 12572 func (u WebFetchToolResultBlockCallerUnion) RawJSON() string { return u.JSON.raw } 12573 12574 func (r *WebFetchToolResultBlockCallerUnion) UnmarshalJSON(data []byte) error { 12575 return apijson.UnmarshalRoot(data, r) 12576 } 12577 12578 // WebFetchToolResultBlockContentUnion contains all possible properties and values 12579 // from [WebFetchToolResultErrorBlock], [WebFetchBlock]. 12580 // 12581 // Use the methods beginning with 'As' to cast the union to one of its variants. 12582 type WebFetchToolResultBlockContentUnion struct { 12583 // This field is from variant [WebFetchToolResultErrorBlock]. 12584 ErrorCode WebFetchToolResultErrorCode `json:"error_code"` 12585 Type string `json:"type"` 12586 // This field is from variant [WebFetchBlock]. 12587 Content DocumentBlock `json:"content"` 12588 // This field is from variant [WebFetchBlock]. 12589 RetrievedAt string `json:"retrieved_at"` 12590 // This field is from variant [WebFetchBlock]. 12591 URL string `json:"url"` 12592 JSON struct { 12593 ErrorCode respjson.Field 12594 Type respjson.Field 12595 Content respjson.Field 12596 RetrievedAt respjson.Field 12597 URL respjson.Field 12598 raw string 12599 } `json:"-"` 12600 } 12601 12602 func (u WebFetchToolResultBlockContentUnion) AsResponseWebFetchToolResultError() (v WebFetchToolResultErrorBlock) { 12603 apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) 12604 return 12605 } 12606 12607 func (u WebFetchToolResultBlockContentUnion) AsResponseWebFetchResultBlock() (v WebFetchBlock) { 12608 apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) 12609 return 12610 } 12611 12612 // Returns the unmodified JSON received from the API 12613 func (u WebFetchToolResultBlockContentUnion) RawJSON() string { return u.JSON.raw } 12614 12615 func (r *WebFetchToolResultBlockContentUnion) UnmarshalJSON(data []byte) error { 12616 return apijson.UnmarshalRoot(data, r) 12617 } 12618 12619 // The properties Content, ToolUseID, Type are required. 12620 type WebFetchToolResultBlockParam struct { 12621 Content WebFetchToolResultBlockParamContentUnion `json:"content,omitzero" api:"required"` 12622 ToolUseID string `json:"tool_use_id" api:"required"` 12623 // Create a cache control breakpoint at this content block. 12624 CacheControl CacheControlEphemeralParam `json:"cache_control,omitzero"` 12625 // Tool invocation directly from the model. 12626 Caller WebFetchToolResultBlockParamCallerUnion `json:"caller,omitzero"` 12627 // This field can be elided, and will marshal its zero value as 12628 // "web_fetch_tool_result". 12629 Type constant.WebFetchToolResult `json:"type" default:"web_fetch_tool_result"` 12630 paramObj 12631 } 12632 12633 func (r WebFetchToolResultBlockParam) MarshalJSON() (data []byte, err error) { 12634 type shadow WebFetchToolResultBlockParam 12635 return param.MarshalObject(r, (*shadow)(&r)) 12636 } 12637 func (r *WebFetchToolResultBlockParam) UnmarshalJSON(data []byte) error { 12638 return apijson.UnmarshalRoot(data, r) 12639 } 12640 12641 // Only one field can be non-zero. 12642 // 12643 // Use [param.IsOmitted] to confirm if a field is set. 12644 type WebFetchToolResultBlockParamContentUnion struct { 12645 OfRequestWebFetchToolResultError *WebFetchToolResultErrorBlockParam `json:",omitzero,inline"` 12646 OfRequestWebFetchResultBlock *WebFetchBlockParam `json:",omitzero,inline"` 12647 paramUnion 12648 } 12649 12650 func (u WebFetchToolResultBlockParamContentUnion) MarshalJSON() ([]byte, error) { 12651 return param.MarshalUnion(u, u.OfRequestWebFetchToolResultError, u.OfRequestWebFetchResultBlock) 12652 } 12653 func (u *WebFetchToolResultBlockParamContentUnion) UnmarshalJSON(data []byte) error { 12654 return apijson.UnmarshalRoot(data, u) 12655 } 12656 12657 func (u *WebFetchToolResultBlockParamContentUnion) asAny() any { 12658 if !param.IsOmitted(u.OfRequestWebFetchToolResultError) { 12659 return u.OfRequestWebFetchToolResultError 12660 } else if !param.IsOmitted(u.OfRequestWebFetchResultBlock) { 12661 return u.OfRequestWebFetchResultBlock 12662 } 12663 return nil 12664 } 12665 12666 // Returns a pointer to the underlying variant's property, if present. 12667 func (u WebFetchToolResultBlockParamContentUnion) GetErrorCode() *string { 12668 if vt := u.OfRequestWebFetchToolResultError; vt != nil { 12669 return (*string)(&vt.ErrorCode) 12670 } 12671 return nil 12672 } 12673 12674 // Returns a pointer to the underlying variant's property, if present. 12675 func (u WebFetchToolResultBlockParamContentUnion) GetContent() *DocumentBlockParam { 12676 if vt := u.OfRequestWebFetchResultBlock; vt != nil { 12677 return &vt.Content 12678 } 12679 return nil 12680 } 12681 12682 // Returns a pointer to the underlying variant's property, if present. 12683 func (u WebFetchToolResultBlockParamContentUnion) GetURL() *string { 12684 if vt := u.OfRequestWebFetchResultBlock; vt != nil { 12685 return &vt.URL 12686 } 12687 return nil 12688 } 12689 12690 // Returns a pointer to the underlying variant's property, if present. 12691 func (u WebFetchToolResultBlockParamContentUnion) GetRetrievedAt() *string { 12692 if vt := u.OfRequestWebFetchResultBlock; vt != nil && vt.RetrievedAt.Valid() { 12693 return &vt.RetrievedAt.Value 12694 } 12695 return nil 12696 } 12697 12698 // Returns a pointer to the underlying variant's property, if present. 12699 func (u WebFetchToolResultBlockParamContentUnion) GetType() *string { 12700 if vt := u.OfRequestWebFetchToolResultError; vt != nil { 12701 return (*string)(&vt.Type) 12702 } else if vt := u.OfRequestWebFetchResultBlock; vt != nil { 12703 return (*string)(&vt.Type) 12704 } 12705 return nil 12706 } 12707 12708 // Only one field can be non-zero. 12709 // 12710 // Use [param.IsOmitted] to confirm if a field is set. 12711 type WebFetchToolResultBlockParamCallerUnion struct { 12712 OfDirect *DirectCallerParam `json:",omitzero,inline"` 12713 OfCodeExecution20250825 *ServerToolCallerParam `json:",omitzero,inline"` 12714 OfCodeExecution20260120 *ServerToolCaller20260120Param `json:",omitzero,inline"` 12715 paramUnion 12716 } 12717 12718 func (u WebFetchToolResultBlockParamCallerUnion) MarshalJSON() ([]byte, error) { 12719 return param.MarshalUnion(u, u.OfDirect, u.OfCodeExecution20250825, u.OfCodeExecution20260120) 12720 } 12721 func (u *WebFetchToolResultBlockParamCallerUnion) UnmarshalJSON(data []byte) error { 12722 return apijson.UnmarshalRoot(data, u) 12723 } 12724 12725 func (u *WebFetchToolResultBlockParamCallerUnion) asAny() any { 12726 if !param.IsOmitted(u.OfDirect) { 12727 return u.OfDirect 12728 } else if !param.IsOmitted(u.OfCodeExecution20250825) { 12729 return u.OfCodeExecution20250825 12730 } else if !param.IsOmitted(u.OfCodeExecution20260120) { 12731 return u.OfCodeExecution20260120 12732 } 12733 return nil 12734 } 12735 12736 // Returns a pointer to the underlying variant's property, if present. 12737 func (u WebFetchToolResultBlockParamCallerUnion) GetType() *string { 12738 if vt := u.OfDirect; vt != nil { 12739 return (*string)(&vt.Type) 12740 } else if vt := u.OfCodeExecution20250825; vt != nil { 12741 return (*string)(&vt.Type) 12742 } else if vt := u.OfCodeExecution20260120; vt != nil { 12743 return (*string)(&vt.Type) 12744 } 12745 return nil 12746 } 12747 12748 // Returns a pointer to the underlying variant's property, if present. 12749 func (u WebFetchToolResultBlockParamCallerUnion) GetToolID() *string { 12750 if vt := u.OfCodeExecution20250825; vt != nil { 12751 return (*string)(&vt.ToolID) 12752 } else if vt := u.OfCodeExecution20260120; vt != nil { 12753 return (*string)(&vt.ToolID) 12754 } 12755 return nil 12756 } 12757 12758 func init() { 12759 apijson.RegisterUnion[WebFetchToolResultBlockParamCallerUnion]( 12760 "type", 12761 apijson.Discriminator[DirectCallerParam]("direct"), 12762 apijson.Discriminator[ServerToolCallerParam]("code_execution_20250825"), 12763 apijson.Discriminator[ServerToolCaller20260120Param]("code_execution_20260120"), 12764 ) 12765 } 12766 12767 type WebFetchToolResultErrorBlock struct { 12768 // Any of "invalid_tool_input", "url_too_long", "url_not_allowed", 12769 // "url_not_in_prior_context", "url_not_accessible", "unsupported_content_type", 12770 // "too_many_requests", "max_uses_exceeded", "unavailable". 12771 ErrorCode WebFetchToolResultErrorCode `json:"error_code" api:"required"` 12772 Type constant.WebFetchToolResultError `json:"type" default:"web_fetch_tool_result_error"` 12773 // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. 12774 JSON struct { 12775 ErrorCode respjson.Field 12776 Type respjson.Field 12777 ExtraFields map[string]respjson.Field 12778 raw string 12779 } `json:"-"` 12780 } 12781 12782 // Returns the unmodified JSON received from the API 12783 func (r WebFetchToolResultErrorBlock) RawJSON() string { return r.JSON.raw } 12784 func (r *WebFetchToolResultErrorBlock) UnmarshalJSON(data []byte) error { 12785 return apijson.UnmarshalRoot(data, r) 12786 } 12787 12788 // The properties ErrorCode, Type are required. 12789 type WebFetchToolResultErrorBlockParam struct { 12790 // Any of "invalid_tool_input", "url_too_long", "url_not_allowed", 12791 // "url_not_in_prior_context", "url_not_accessible", "unsupported_content_type", 12792 // "too_many_requests", "max_uses_exceeded", "unavailable". 12793 ErrorCode WebFetchToolResultErrorCode `json:"error_code,omitzero" api:"required"` 12794 // This field can be elided, and will marshal its zero value as 12795 // "web_fetch_tool_result_error". 12796 Type constant.WebFetchToolResultError `json:"type" default:"web_fetch_tool_result_error"` 12797 paramObj 12798 } 12799 12800 func (r WebFetchToolResultErrorBlockParam) MarshalJSON() (data []byte, err error) { 12801 type shadow WebFetchToolResultErrorBlockParam 12802 return param.MarshalObject(r, (*shadow)(&r)) 12803 } 12804 func (r *WebFetchToolResultErrorBlockParam) UnmarshalJSON(data []byte) error { 12805 return apijson.UnmarshalRoot(data, r) 12806 } 12807 12808 type WebFetchToolResultErrorCode string 12809 12810 const ( 12811 WebFetchToolResultErrorCodeInvalidToolInput WebFetchToolResultErrorCode = "invalid_tool_input" 12812 WebFetchToolResultErrorCodeURLTooLong WebFetchToolResultErrorCode = "url_too_long" 12813 WebFetchToolResultErrorCodeURLNotAllowed WebFetchToolResultErrorCode = "url_not_allowed" 12814 WebFetchToolResultErrorCodeURLNotInPriorContext WebFetchToolResultErrorCode = "url_not_in_prior_context" 12815 WebFetchToolResultErrorCodeURLNotAccessible WebFetchToolResultErrorCode = "url_not_accessible" 12816 WebFetchToolResultErrorCodeUnsupportedContentType WebFetchToolResultErrorCode = "unsupported_content_type" 12817 WebFetchToolResultErrorCodeTooManyRequests WebFetchToolResultErrorCode = "too_many_requests" 12818 WebFetchToolResultErrorCodeMaxUsesExceeded WebFetchToolResultErrorCode = "max_uses_exceeded" 12819 WebFetchToolResultErrorCodeUnavailable WebFetchToolResultErrorCode = "unavailable" 12820 ) 12821 12822 type WebSearchResultBlock struct { 12823 EncryptedContent string `json:"encrypted_content" api:"required"` 12824 PageAge string `json:"page_age" api:"required"` 12825 Title string `json:"title" api:"required"` 12826 Type constant.WebSearchResult `json:"type" default:"web_search_result"` 12827 URL string `json:"url" api:"required"` 12828 // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. 12829 JSON struct { 12830 EncryptedContent respjson.Field 12831 PageAge respjson.Field 12832 Title respjson.Field 12833 Type respjson.Field 12834 URL respjson.Field 12835 ExtraFields map[string]respjson.Field 12836 raw string 12837 } `json:"-"` 12838 } 12839 12840 // Returns the unmodified JSON received from the API 12841 func (r WebSearchResultBlock) RawJSON() string { return r.JSON.raw } 12842 func (r *WebSearchResultBlock) UnmarshalJSON(data []byte) error { 12843 return apijson.UnmarshalRoot(data, r) 12844 } 12845 12846 // The properties EncryptedContent, Title, Type, URL are required. 12847 type WebSearchResultBlockParam struct { 12848 EncryptedContent string `json:"encrypted_content" api:"required"` 12849 Title string `json:"title" api:"required"` 12850 URL string `json:"url" api:"required"` 12851 PageAge param.Opt[string] `json:"page_age,omitzero"` 12852 // This field can be elided, and will marshal its zero value as 12853 // "web_search_result". 12854 Type constant.WebSearchResult `json:"type" default:"web_search_result"` 12855 paramObj 12856 } 12857 12858 func (r WebSearchResultBlockParam) MarshalJSON() (data []byte, err error) { 12859 type shadow WebSearchResultBlockParam 12860 return param.MarshalObject(r, (*shadow)(&r)) 12861 } 12862 func (r *WebSearchResultBlockParam) UnmarshalJSON(data []byte) error { 12863 return apijson.UnmarshalRoot(data, r) 12864 } 12865 12866 // The properties Name, Type are required. 12867 type WebSearchTool20250305Param struct { 12868 // Maximum number of times the tool can be used in the API request. 12869 MaxUses param.Opt[int64] `json:"max_uses,omitzero"` 12870 // If true, tool will not be included in initial system prompt. Only loaded when 12871 // returned via tool_reference from tool search. 12872 DeferLoading param.Opt[bool] `json:"defer_loading,omitzero"` 12873 // When true, guarantees schema validation on tool names and inputs 12874 Strict param.Opt[bool] `json:"strict,omitzero"` 12875 // If provided, only these domains will be included in results. Cannot be used 12876 // alongside `blocked_domains`. 12877 AllowedDomains []string `json:"allowed_domains,omitzero"` 12878 // If provided, these domains will never appear in results. Cannot be used 12879 // alongside `allowed_domains`. 12880 BlockedDomains []string `json:"blocked_domains,omitzero"` 12881 // Any of "direct", "code_execution_20250825", "code_execution_20260120", 12882 // "code_execution_20260521". 12883 AllowedCallers []string `json:"allowed_callers,omitzero"` 12884 // Create a cache control breakpoint at this content block. 12885 CacheControl CacheControlEphemeralParam `json:"cache_control,omitzero"` 12886 // Parameters for the user's location. Used to provide more relevant search 12887 // results. 12888 UserLocation UserLocationParam `json:"user_location,omitzero"` 12889 // Name of the tool. 12890 // 12891 // This is how the tool will be called by the model and in `tool_use` blocks. 12892 // 12893 // This field can be elided, and will marshal its zero value as "web_search". 12894 Name constant.WebSearch `json:"name" default:"web_search"` 12895 // This field can be elided, and will marshal its zero value as 12896 // "web_search_20250305". 12897 Type constant.WebSearch20250305 `json:"type" default:"web_search_20250305"` 12898 paramObj 12899 } 12900 12901 func (r WebSearchTool20250305Param) MarshalJSON() (data []byte, err error) { 12902 type shadow WebSearchTool20250305Param 12903 return param.MarshalObject(r, (*shadow)(&r)) 12904 } 12905 func (r *WebSearchTool20250305Param) UnmarshalJSON(data []byte) error { 12906 return apijson.UnmarshalRoot(data, r) 12907 } 12908 12909 // The properties Name, Type are required. 12910 type WebSearchTool20260209Param struct { 12911 // Maximum number of times the tool can be used in the API request. 12912 MaxUses param.Opt[int64] `json:"max_uses,omitzero"` 12913 // If true, tool will not be included in initial system prompt. Only loaded when 12914 // returned via tool_reference from tool search. 12915 DeferLoading param.Opt[bool] `json:"defer_loading,omitzero"` 12916 // When true, guarantees schema validation on tool names and inputs 12917 Strict param.Opt[bool] `json:"strict,omitzero"` 12918 // If provided, only these domains will be included in results. Cannot be used 12919 // alongside `blocked_domains`. 12920 AllowedDomains []string `json:"allowed_domains,omitzero"` 12921 // If provided, these domains will never appear in results. Cannot be used 12922 // alongside `allowed_domains`. 12923 BlockedDomains []string `json:"blocked_domains,omitzero"` 12924 // Any of "direct", "code_execution_20250825", "code_execution_20260120", 12925 // "code_execution_20260521". 12926 AllowedCallers []string `json:"allowed_callers,omitzero"` 12927 // Create a cache control breakpoint at this content block. 12928 CacheControl CacheControlEphemeralParam `json:"cache_control,omitzero"` 12929 // Parameters for the user's location. Used to provide more relevant search 12930 // results. 12931 UserLocation UserLocationParam `json:"user_location,omitzero"` 12932 // Name of the tool. 12933 // 12934 // This is how the tool will be called by the model and in `tool_use` blocks. 12935 // 12936 // This field can be elided, and will marshal its zero value as "web_search". 12937 Name constant.WebSearch `json:"name" default:"web_search"` 12938 // This field can be elided, and will marshal its zero value as 12939 // "web_search_20260209". 12940 Type constant.WebSearch20260209 `json:"type" default:"web_search_20260209"` 12941 paramObj 12942 } 12943 12944 func (r WebSearchTool20260209Param) MarshalJSON() (data []byte, err error) { 12945 type shadow WebSearchTool20260209Param 12946 return param.MarshalObject(r, (*shadow)(&r)) 12947 } 12948 func (r *WebSearchTool20260209Param) UnmarshalJSON(data []byte) error { 12949 return apijson.UnmarshalRoot(data, r) 12950 } 12951 12952 // The properties Name, Type are required. 12953 type WebSearchTool20260318Param struct { 12954 // Maximum number of times the tool can be used in the API request. 12955 MaxUses param.Opt[int64] `json:"max_uses,omitzero"` 12956 // If true, tool will not be included in initial system prompt. Only loaded when 12957 // returned via tool_reference from tool search. 12958 DeferLoading param.Opt[bool] `json:"defer_loading,omitzero"` 12959 // When true, guarantees schema validation on tool names and inputs 12960 Strict param.Opt[bool] `json:"strict,omitzero"` 12961 // If provided, only these domains will be included in results. Cannot be used 12962 // alongside `blocked_domains`. 12963 AllowedDomains []string `json:"allowed_domains,omitzero"` 12964 // If provided, these domains will never appear in results. Cannot be used 12965 // alongside `allowed_domains`. 12966 BlockedDomains []string `json:"blocked_domains,omitzero"` 12967 // Any of "direct", "code_execution_20250825", "code_execution_20260120", 12968 // "code_execution_20260521". 12969 AllowedCallers []string `json:"allowed_callers,omitzero"` 12970 // Create a cache control breakpoint at this content block. 12971 CacheControl CacheControlEphemeralParam `json:"cache_control,omitzero"` 12972 // How this tool's result blocks appear in the API response when the result was 12973 // consumed by a completed code_execution call in the same turn. 'full' returns the 12974 // complete content (default). 'excluded' drops the nested server_tool_use and 12975 // result block pair entirely. Results from direct calls, or from code_execution 12976 // calls that paused before completing, are always returned in full so they can be 12977 // sent back on the next turn. 12978 // 12979 // Any of "full", "excluded". 12980 ResponseInclusion WebSearchTool20260318ResponseInclusion `json:"response_inclusion,omitzero"` 12981 // Parameters for the user's location. Used to provide more relevant search 12982 // results. 12983 UserLocation UserLocationParam `json:"user_location,omitzero"` 12984 // Name of the tool. 12985 // 12986 // This is how the tool will be called by the model and in `tool_use` blocks. 12987 // 12988 // This field can be elided, and will marshal its zero value as "web_search". 12989 Name constant.WebSearch `json:"name" default:"web_search"` 12990 // This field can be elided, and will marshal its zero value as 12991 // "web_search_20260318". 12992 Type constant.WebSearch20260318 `json:"type" default:"web_search_20260318"` 12993 paramObj 12994 } 12995 12996 func (r WebSearchTool20260318Param) MarshalJSON() (data []byte, err error) { 12997 type shadow WebSearchTool20260318Param 12998 return param.MarshalObject(r, (*shadow)(&r)) 12999 } 13000 func (r *WebSearchTool20260318Param) UnmarshalJSON(data []byte) error { 13001 return apijson.UnmarshalRoot(data, r) 13002 } 13003 13004 // How this tool's result blocks appear in the API response when the result was 13005 // consumed by a completed code_execution call in the same turn. 'full' returns the 13006 // complete content (default). 'excluded' drops the nested server_tool_use and 13007 // result block pair entirely. Results from direct calls, or from code_execution 13008 // calls that paused before completing, are always returned in full so they can be 13009 // sent back on the next turn. 13010 type WebSearchTool20260318ResponseInclusion string 13011 13012 const ( 13013 WebSearchTool20260318ResponseInclusionFull WebSearchTool20260318ResponseInclusion = "full" 13014 WebSearchTool20260318ResponseInclusionExcluded WebSearchTool20260318ResponseInclusion = "excluded" 13015 ) 13016 13017 // The properties ErrorCode, Type are required. 13018 type WebSearchToolRequestErrorParam struct { 13019 // Any of "invalid_tool_input", "unavailable", "max_uses_exceeded", 13020 // "too_many_requests", "query_too_long", "request_too_large". 13021 ErrorCode WebSearchToolResultErrorCode `json:"error_code,omitzero" api:"required"` 13022 // This field can be elided, and will marshal its zero value as 13023 // "web_search_tool_result_error". 13024 Type constant.WebSearchToolResultError `json:"type" default:"web_search_tool_result_error"` 13025 paramObj 13026 } 13027 13028 func (r WebSearchToolRequestErrorParam) MarshalJSON() (data []byte, err error) { 13029 type shadow WebSearchToolRequestErrorParam 13030 return param.MarshalObject(r, (*shadow)(&r)) 13031 } 13032 func (r *WebSearchToolRequestErrorParam) UnmarshalJSON(data []byte) error { 13033 return apijson.UnmarshalRoot(data, r) 13034 } 13035 13036 type WebSearchToolResultBlock struct { 13037 // Tool invocation directly from the model. 13038 Caller WebSearchToolResultBlockCallerUnion `json:"caller" api:"required"` 13039 Content WebSearchToolResultBlockContentUnion `json:"content" api:"required"` 13040 ToolUseID string `json:"tool_use_id" api:"required"` 13041 Type constant.WebSearchToolResult `json:"type" default:"web_search_tool_result"` 13042 // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. 13043 JSON struct { 13044 Caller respjson.Field 13045 Content respjson.Field 13046 ToolUseID respjson.Field 13047 Type respjson.Field 13048 ExtraFields map[string]respjson.Field 13049 raw string 13050 } `json:"-"` 13051 } 13052 13053 // Returns the unmodified JSON received from the API 13054 func (r WebSearchToolResultBlock) RawJSON() string { return r.JSON.raw } 13055 func (r *WebSearchToolResultBlock) UnmarshalJSON(data []byte) error { 13056 return apijson.UnmarshalRoot(data, r) 13057 } 13058 13059 // WebSearchToolResultBlockCallerUnion contains all possible properties and values 13060 // from [DirectCaller], [ServerToolCaller], [ServerToolCaller20260120]. 13061 // 13062 // Use the [WebSearchToolResultBlockCallerUnion.AsAny] method to switch on the 13063 // variant. 13064 // 13065 // Use the methods beginning with 'As' to cast the union to one of its variants. 13066 type WebSearchToolResultBlockCallerUnion struct { 13067 // Any of "direct", "code_execution_20250825", "code_execution_20260120". 13068 Type string `json:"type"` 13069 ToolID string `json:"tool_id"` 13070 JSON struct { 13071 Type respjson.Field 13072 ToolID respjson.Field 13073 raw string 13074 } `json:"-"` 13075 } 13076 13077 // anyWebSearchToolResultBlockCaller is implemented by each variant of 13078 // [WebSearchToolResultBlockCallerUnion] to add type safety for the return type of 13079 // [WebSearchToolResultBlockCallerUnion.AsAny] 13080 type anyWebSearchToolResultBlockCaller interface { 13081 implWebSearchToolResultBlockCallerUnion() 13082 } 13083 13084 func (DirectCaller) implWebSearchToolResultBlockCallerUnion() {} 13085 func (ServerToolCaller) implWebSearchToolResultBlockCallerUnion() {} 13086 func (ServerToolCaller20260120) implWebSearchToolResultBlockCallerUnion() {} 13087 13088 // Use the following switch statement to find the correct variant 13089 // 13090 // switch variant := WebSearchToolResultBlockCallerUnion.AsAny().(type) { 13091 // case anthropic.DirectCaller: 13092 // case anthropic.ServerToolCaller: 13093 // case anthropic.ServerToolCaller20260120: 13094 // default: 13095 // fmt.Errorf("no variant present") 13096 // } 13097 func (u WebSearchToolResultBlockCallerUnion) AsAny() anyWebSearchToolResultBlockCaller { 13098 switch u.Type { 13099 case "direct": 13100 return u.AsDirect() 13101 case "code_execution_20250825": 13102 return u.AsCodeExecution20250825() 13103 case "code_execution_20260120": 13104 return u.AsCodeExecution20260120() 13105 } 13106 return nil 13107 } 13108 13109 func (u WebSearchToolResultBlockCallerUnion) AsDirect() (v DirectCaller) { 13110 apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) 13111 return 13112 } 13113 13114 func (u WebSearchToolResultBlockCallerUnion) AsCodeExecution20250825() (v ServerToolCaller) { 13115 apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) 13116 return 13117 } 13118 13119 func (u WebSearchToolResultBlockCallerUnion) AsCodeExecution20260120() (v ServerToolCaller20260120) { 13120 apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) 13121 return 13122 } 13123 13124 // Returns the unmodified JSON received from the API 13125 func (u WebSearchToolResultBlockCallerUnion) RawJSON() string { return u.JSON.raw } 13126 13127 func (r *WebSearchToolResultBlockCallerUnion) UnmarshalJSON(data []byte) error { 13128 return apijson.UnmarshalRoot(data, r) 13129 } 13130 13131 // WebSearchToolResultBlockContentUnion contains all possible properties and values 13132 // from [WebSearchToolResultError], [[]WebSearchResultBlock]. 13133 // 13134 // Use the methods beginning with 'As' to cast the union to one of its variants. 13135 // 13136 // If the underlying value is not a json object, one of the following properties 13137 // will be valid: OfWebSearchResultBlockArray] 13138 type WebSearchToolResultBlockContentUnion struct { 13139 // This field will be present if the value is a [[]WebSearchResultBlock] instead of 13140 // an object. 13141 OfWebSearchResultBlockArray []WebSearchResultBlock `json:",inline"` 13142 // This field is from variant [WebSearchToolResultError]. 13143 ErrorCode WebSearchToolResultErrorCode `json:"error_code"` 13144 // This field is from variant [WebSearchToolResultError]. 13145 Type constant.WebSearchToolResultError `json:"type"` 13146 JSON struct { 13147 OfWebSearchResultBlockArray respjson.Field 13148 ErrorCode respjson.Field 13149 Type respjson.Field 13150 raw string 13151 } `json:"-"` 13152 } 13153 13154 func (u WebSearchToolResultBlockContentUnion) AsResponseWebSearchToolResultError() (v WebSearchToolResultError) { 13155 apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) 13156 return 13157 } 13158 13159 func (u WebSearchToolResultBlockContentUnion) AsWebSearchResultBlockArray() (v []WebSearchResultBlock) { 13160 apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) 13161 return 13162 } 13163 13164 // Returns the unmodified JSON received from the API 13165 func (u WebSearchToolResultBlockContentUnion) RawJSON() string { return u.JSON.raw } 13166 13167 func (r *WebSearchToolResultBlockContentUnion) UnmarshalJSON(data []byte) error { 13168 return apijson.UnmarshalRoot(data, r) 13169 } 13170 13171 // The properties Content, ToolUseID, Type are required. 13172 type WebSearchToolResultBlockParam struct { 13173 Content WebSearchToolResultBlockParamContentUnion `json:"content,omitzero" api:"required"` 13174 ToolUseID string `json:"tool_use_id" api:"required"` 13175 // Create a cache control breakpoint at this content block. 13176 CacheControl CacheControlEphemeralParam `json:"cache_control,omitzero"` 13177 // Tool invocation directly from the model. 13178 Caller WebSearchToolResultBlockParamCallerUnion `json:"caller,omitzero"` 13179 // This field can be elided, and will marshal its zero value as 13180 // "web_search_tool_result". 13181 Type constant.WebSearchToolResult `json:"type" default:"web_search_tool_result"` 13182 paramObj 13183 } 13184 13185 func (r WebSearchToolResultBlockParam) MarshalJSON() (data []byte, err error) { 13186 type shadow WebSearchToolResultBlockParam 13187 return param.MarshalObject(r, (*shadow)(&r)) 13188 } 13189 func (r *WebSearchToolResultBlockParam) UnmarshalJSON(data []byte) error { 13190 return apijson.UnmarshalRoot(data, r) 13191 } 13192 13193 // Only one field can be non-zero. 13194 // 13195 // Use [param.IsOmitted] to confirm if a field is set. 13196 type WebSearchToolResultBlockParamCallerUnion struct { 13197 OfDirect *DirectCallerParam `json:",omitzero,inline"` 13198 OfCodeExecution20250825 *ServerToolCallerParam `json:",omitzero,inline"` 13199 OfCodeExecution20260120 *ServerToolCaller20260120Param `json:",omitzero,inline"` 13200 paramUnion 13201 } 13202 13203 func (u WebSearchToolResultBlockParamCallerUnion) MarshalJSON() ([]byte, error) { 13204 return param.MarshalUnion(u, u.OfDirect, u.OfCodeExecution20250825, u.OfCodeExecution20260120) 13205 } 13206 func (u *WebSearchToolResultBlockParamCallerUnion) UnmarshalJSON(data []byte) error { 13207 return apijson.UnmarshalRoot(data, u) 13208 } 13209 13210 func (u *WebSearchToolResultBlockParamCallerUnion) asAny() any { 13211 if !param.IsOmitted(u.OfDirect) { 13212 return u.OfDirect 13213 } else if !param.IsOmitted(u.OfCodeExecution20250825) { 13214 return u.OfCodeExecution20250825 13215 } else if !param.IsOmitted(u.OfCodeExecution20260120) { 13216 return u.OfCodeExecution20260120 13217 } 13218 return nil 13219 } 13220 13221 // Returns a pointer to the underlying variant's property, if present. 13222 func (u WebSearchToolResultBlockParamCallerUnion) GetType() *string { 13223 if vt := u.OfDirect; vt != nil { 13224 return (*string)(&vt.Type) 13225 } else if vt := u.OfCodeExecution20250825; vt != nil { 13226 return (*string)(&vt.Type) 13227 } else if vt := u.OfCodeExecution20260120; vt != nil { 13228 return (*string)(&vt.Type) 13229 } 13230 return nil 13231 } 13232 13233 // Returns a pointer to the underlying variant's property, if present. 13234 func (u WebSearchToolResultBlockParamCallerUnion) GetToolID() *string { 13235 if vt := u.OfCodeExecution20250825; vt != nil { 13236 return (*string)(&vt.ToolID) 13237 } else if vt := u.OfCodeExecution20260120; vt != nil { 13238 return (*string)(&vt.ToolID) 13239 } 13240 return nil 13241 } 13242 13243 func init() { 13244 apijson.RegisterUnion[WebSearchToolResultBlockParamCallerUnion]( 13245 "type", 13246 apijson.Discriminator[DirectCallerParam]("direct"), 13247 apijson.Discriminator[ServerToolCallerParam]("code_execution_20250825"), 13248 apijson.Discriminator[ServerToolCaller20260120Param]("code_execution_20260120"), 13249 ) 13250 } 13251 13252 func NewWebSearchToolRequestError(errorCode WebSearchToolResultErrorCode) WebSearchToolResultBlockParamContentUnion { 13253 var variant WebSearchToolRequestErrorParam 13254 variant.ErrorCode = errorCode 13255 return WebSearchToolResultBlockParamContentUnion{OfRequestWebSearchToolResultError: &variant} 13256 } 13257 13258 // Only one field can be non-zero. 13259 // 13260 // Use [param.IsOmitted] to confirm if a field is set. 13261 type WebSearchToolResultBlockParamContentUnion struct { 13262 OfWebSearchToolResultBlockItem []WebSearchResultBlockParam `json:",omitzero,inline"` 13263 OfRequestWebSearchToolResultError *WebSearchToolRequestErrorParam `json:",omitzero,inline"` 13264 paramUnion 13265 } 13266 13267 func (u WebSearchToolResultBlockParamContentUnion) MarshalJSON() ([]byte, error) { 13268 return param.MarshalUnion(u, u.OfWebSearchToolResultBlockItem, u.OfRequestWebSearchToolResultError) 13269 } 13270 func (u *WebSearchToolResultBlockParamContentUnion) UnmarshalJSON(data []byte) error { 13271 return apijson.UnmarshalRoot(data, u) 13272 } 13273 13274 func (u *WebSearchToolResultBlockParamContentUnion) asAny() any { 13275 if !param.IsOmitted(u.OfWebSearchToolResultBlockItem) { 13276 return &u.OfWebSearchToolResultBlockItem 13277 } else if !param.IsOmitted(u.OfRequestWebSearchToolResultError) { 13278 return u.OfRequestWebSearchToolResultError 13279 } 13280 return nil 13281 } 13282 13283 type WebSearchToolResultError struct { 13284 // Any of "invalid_tool_input", "unavailable", "max_uses_exceeded", 13285 // "too_many_requests", "query_too_long", "request_too_large". 13286 ErrorCode WebSearchToolResultErrorCode `json:"error_code" api:"required"` 13287 Type constant.WebSearchToolResultError `json:"type" default:"web_search_tool_result_error"` 13288 // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. 13289 JSON struct { 13290 ErrorCode respjson.Field 13291 Type respjson.Field 13292 ExtraFields map[string]respjson.Field 13293 raw string 13294 } `json:"-"` 13295 } 13296 13297 // Returns the unmodified JSON received from the API 13298 func (r WebSearchToolResultError) RawJSON() string { return r.JSON.raw } 13299 func (r *WebSearchToolResultError) UnmarshalJSON(data []byte) error { 13300 return apijson.UnmarshalRoot(data, r) 13301 } 13302 13303 type WebSearchToolResultErrorCode string 13304 13305 const ( 13306 WebSearchToolResultErrorCodeInvalidToolInput WebSearchToolResultErrorCode = "invalid_tool_input" 13307 WebSearchToolResultErrorCodeUnavailable WebSearchToolResultErrorCode = "unavailable" 13308 WebSearchToolResultErrorCodeMaxUsesExceeded WebSearchToolResultErrorCode = "max_uses_exceeded" 13309 WebSearchToolResultErrorCodeTooManyRequests WebSearchToolResultErrorCode = "too_many_requests" 13310 WebSearchToolResultErrorCodeQueryTooLong WebSearchToolResultErrorCode = "query_too_long" 13311 WebSearchToolResultErrorCodeRequestTooLarge WebSearchToolResultErrorCode = "request_too_large" 13312 ) 13313 13314 type MessageNewParams struct { 13315 // The maximum number of tokens to generate before stopping. 13316 // 13317 // Note that our models may stop _before_ reaching this maximum. This parameter 13318 // only specifies the absolute maximum number of tokens to generate. 13319 // 13320 // Set to `0` to populate the 13321 // [prompt cache](https://platform.claude.com/docs/en/build-with-claude/prompt-caching#pre-warming-the-cache) 13322 // without generating a response. 13323 // 13324 // Different models have different maximum values for this parameter. See 13325 // [models](https://platform.claude.com/docs/en/about-claude/models/overview) for 13326 // details. 13327 MaxTokens int64 `json:"max_tokens" api:"required"` 13328 // Input messages. 13329 // 13330 // Our models are trained to operate on alternating `user` and `assistant` 13331 // conversational turns. When creating a new `Message`, you specify the prior 13332 // conversational turns with the `messages` parameter, and the model then generates 13333 // the next `Message` in the conversation. Consecutive `user` or `assistant` turns 13334 // in your request will be combined into a single turn. 13335 // 13336 // Each input message must be an object with a `role` and `content`. You can 13337 // specify a single `user`-role message, or you can include multiple `user` and 13338 // `assistant` messages. 13339 // 13340 // If the final message uses the `assistant` role, the response content will 13341 // continue immediately from the content in that message. This can be used to 13342 // constrain part of the model's response. 13343 // 13344 // Example with a single `user` message: 13345 // 13346 // ```json 13347 // [{ "role": "user", "content": "Hello, Claude" }] 13348 // ``` 13349 // 13350 // Example with multiple conversational turns: 13351 // 13352 // ```json 13353 // [ 13354 // 13355 // { "role": "user", "content": "Hello there." }, 13356 // { "role": "assistant", "content": "Hi, I'm Claude. How can I help you?" }, 13357 // { "role": "user", "content": "Can you explain LLMs in plain English?" } 13358 // 13359 // ] 13360 // ``` 13361 // 13362 // Example with a partially-filled response from Claude: 13363 // 13364 // ```json 13365 // [ 13366 // 13367 // { 13368 // "role": "user", 13369 // "content": "What's the Greek name for Sun? (A) Sol (B) Helios (C) Sun" 13370 // }, 13371 // { "role": "assistant", "content": "The best answer is (" } 13372 // 13373 // ] 13374 // ``` 13375 // 13376 // Each input message `content` may be either a single `string` or an array of 13377 // content blocks, where each block has a specific `type`. Using a `string` for 13378 // `content` is shorthand for an array of one content block of type `"text"`. The 13379 // following input messages are equivalent: 13380 // 13381 // ```json 13382 // { "role": "user", "content": "Hello, Claude" } 13383 // ``` 13384 // 13385 // ```json 13386 // { "role": "user", "content": [{ "type": "text", "text": "Hello, Claude" }] } 13387 // ``` 13388 // 13389 // See 13390 // [input examples](https://platform.claude.com/docs/en/build-with-claude/working-with-messages). 13391 // 13392 // Note that if you want to include a 13393 // [system prompt](https://platform.claude.com/docs/en/build-with-claude/prompt-engineering/claude-prompting-best-practices#give-claude-a-role), 13394 // you can use the top-level `system` parameter — there is no `"system"` role for 13395 // input messages in the Messages API. 13396 // 13397 // There is a limit of 100,000 messages in a single request. 13398 Messages []MessageParam `json:"messages,omitzero" api:"required"` 13399 // The model that will complete your prompt. 13400 // 13401 // See [models](https://docs.anthropic.com/en/docs/models-overview) for additional 13402 // details and options. 13403 Model Model `json:"model,omitzero" api:"required"` 13404 // Specifies the geographic region for inference processing. If not specified, the 13405 // workspace's `default_inference_geo` is used. 13406 InferenceGeo param.Opt[string] `json:"inference_geo,omitzero"` 13407 // Amount of randomness injected into the response. 13408 // 13409 // Defaults to `1.0`. Ranges from `0.0` to `1.0`. Use `temperature` closer to `0.0` 13410 // for analytical / multiple choice, and closer to `1.0` for creative and 13411 // generative tasks. 13412 // 13413 // Note that even with `temperature` of `0.0`, the results will not be fully 13414 // deterministic. 13415 Temperature param.Opt[float64] `json:"temperature,omitzero"` 13416 // Only sample from the top K options for each subsequent token. 13417 // 13418 // Used to remove "long tail" low probability responses. 13419 // [Learn more technical details here](https://towardsdatascience.com/how-to-sample-from-language-models-682bceb97277). 13420 // 13421 // Recommended for advanced use cases only. 13422 TopK param.Opt[int64] `json:"top_k,omitzero"` 13423 // Use nucleus sampling. 13424 // 13425 // In nucleus sampling, we compute the cumulative distribution over all the options 13426 // for each subsequent token in decreasing probability order and cut it off once it 13427 // reaches a particular probability specified by `top_p`. 13428 // 13429 // Recommended for advanced use cases only. 13430 TopP param.Opt[float64] `json:"top_p,omitzero"` 13431 // The user profile ID to attribute this request to. Use when acting on behalf of a 13432 // party other than your organization. Requires the `user-profiles` beta header. 13433 UserProfileID param.Opt[string] `header:"anthropic-user-profile-id,omitzero" json:"-"` 13434 WorkspaceID param.Opt[string] `header:"anthropic-workspace-id,omitzero" json:"-"` 13435 // Container identifier for reuse across requests. 13436 Container MessageCreateParamsContainerUnion `json:"container,omitzero"` 13437 // Top-level cache control automatically applies a cache_control marker to the last 13438 // cacheable block in the request. 13439 CacheControl CacheControlEphemeralParam `json:"cache_control,omitzero"` 13440 // An object describing metadata about the request. 13441 Metadata MetadataParam `json:"metadata,omitzero"` 13442 // Configuration options for the model's output, such as the output format. 13443 OutputConfig OutputConfigParam `json:"output_config,omitzero"` 13444 // Determines whether to use priority capacity (if available) or standard capacity 13445 // for this request. 13446 // 13447 // Anthropic offers different levels of service for your API requests. See 13448 // [service-tiers](https://platform.claude.com/docs/en/api/service-tiers) for 13449 // details. 13450 // 13451 // Any of "auto", "standard_only". 13452 ServiceTier MessageNewParamsServiceTier `json:"service_tier,omitzero"` 13453 // Custom text sequences that will cause the model to stop generating. 13454 // 13455 // Our models will normally stop when they have naturally completed their turn, 13456 // which will result in a response `stop_reason` of `"end_turn"`. 13457 // 13458 // If you want the model to stop generating when it encounters custom strings of 13459 // text, you can use the `stop_sequences` parameter. If the model encounters one of 13460 // the custom sequences, the response `stop_reason` value will be `"stop_sequence"` 13461 // and the response `stop_sequence` value will contain the matched stop sequence. 13462 StopSequences []string `json:"stop_sequences,omitzero"` 13463 // System prompt. 13464 // 13465 // A system prompt is a way of providing context and instructions to Claude, such 13466 // as specifying a particular goal or role. See our 13467 // [guide to system prompts](https://platform.claude.com/docs/en/build-with-claude/prompt-engineering/claude-prompting-best-practices#give-claude-a-role). 13468 System []TextBlockParam `json:"system,omitzero"` 13469 // Configuration for enabling Claude's extended thinking. 13470 // 13471 // When enabled, responses include `thinking` content blocks showing Claude's 13472 // thinking process before the final answer. Requires a minimum budget of 1,024 13473 // tokens and counts towards your `max_tokens` limit. 13474 // 13475 // See 13476 // [extended thinking](https://platform.claude.com/docs/en/build-with-claude/extended-thinking) 13477 // for details. 13478 Thinking ThinkingConfigParamUnion `json:"thinking,omitzero"` 13479 // How the model should use the provided tools. The model can use a specific tool, 13480 // any available tool, decide by itself, or not use tools at all. 13481 ToolChoice ToolChoiceUnionParam `json:"tool_choice,omitzero"` 13482 // Definitions of tools that the model may use. 13483 // 13484 // If you include `tools` in your API request, the model may return `tool_use` 13485 // content blocks that represent the model's use of those tools. You can then run 13486 // those tools using the tool input generated by the model and then optionally 13487 // return results back to the model using `tool_result` content blocks. 13488 // 13489 // There are two types of tools: **client tools** and **server tools**. The 13490 // behavior described below applies to client tools. For 13491 // [server tools](https://platform.claude.com/docs/en/agents-and-tools/tool-use/server-tools), 13492 // see their individual documentation as each has its own behavior (e.g., the 13493 // [web search tool](https://platform.claude.com/docs/en/agents-and-tools/tool-use/web-search-tool)). 13494 // 13495 // Each tool definition includes: 13496 // 13497 // - `name`: Name of the tool. 13498 // - `description`: Optional, but strongly-recommended description of the tool. 13499 // - `input_schema`: [JSON schema](https://json-schema.org/draft/2020-12) for the 13500 // tool `input` shape that the model will produce in `tool_use` output content 13501 // blocks. 13502 // 13503 // For example, if you defined `tools` as: 13504 // 13505 // ```json 13506 // [ 13507 // 13508 // { 13509 // "name": "get_stock_price", 13510 // "description": "Get the current stock price for a given ticker symbol.", 13511 // "input_schema": { 13512 // "type": "object", 13513 // "properties": { 13514 // "ticker": { 13515 // "type": "string", 13516 // "description": "The stock ticker symbol, e.g. AAPL for Apple Inc." 13517 // } 13518 // }, 13519 // "required": ["ticker"] 13520 // } 13521 // } 13522 // 13523 // ] 13524 // ``` 13525 // 13526 // And then asked the model "What's the S&P 500 at today?", the model might produce 13527 // `tool_use` content blocks in the response like this: 13528 // 13529 // ```json 13530 // [ 13531 // 13532 // { 13533 // "type": "tool_use", 13534 // "id": "toolu_01D7FLrfh4GYq7yT1ULFeyMV", 13535 // "name": "get_stock_price", 13536 // "input": { "ticker": "^GSPC" } 13537 // } 13538 // 13539 // ] 13540 // ``` 13541 // 13542 // You might then run your `get_stock_price` tool with `{"ticker": "^GSPC"}` as an 13543 // input, and return the following back to the model in a subsequent `user` 13544 // message: 13545 // 13546 // ```json 13547 // [ 13548 // 13549 // { 13550 // "type": "tool_result", 13551 // "tool_use_id": "toolu_01D7FLrfh4GYq7yT1ULFeyMV", 13552 // "content": "259.75 USD" 13553 // } 13554 // 13555 // ] 13556 // ``` 13557 // 13558 // Tools can be used for workflows that include running client-side tools and 13559 // functions, or more generally whenever you want the model to produce a particular 13560 // JSON structure of output. 13561 // 13562 // See our 13563 // [guide](https://platform.claude.com/docs/en/agents-and-tools/tool-use/overview) 13564 // for more details. 13565 Tools []ToolUnionParam `json:"tools,omitzero"` 13566 paramObj 13567 } 13568 13569 func (r MessageNewParams) MarshalJSON() (data []byte, err error) { 13570 type shadow MessageNewParams 13571 return param.MarshalObject(r, (*shadow)(&r)) 13572 } 13573 func (r *MessageNewParams) UnmarshalJSON(data []byte) error { 13574 return apijson.UnmarshalRoot(data, r) 13575 } 13576 13577 // Determines whether to use priority capacity (if available) or standard capacity 13578 // for this request. 13579 // 13580 // Anthropic offers different levels of service for your API requests. See 13581 // [service-tiers](https://platform.claude.com/docs/en/api/service-tiers) for 13582 // details. 13583 type MessageNewParamsServiceTier string 13584 13585 const ( 13586 MessageNewParamsServiceTierAuto MessageNewParamsServiceTier = "auto" 13587 MessageNewParamsServiceTierStandardOnly MessageNewParamsServiceTier = "standard_only" 13588 ) 13589 13590 type MessageCountTokensParams struct { 13591 // Input messages. 13592 // 13593 // Our models are trained to operate on alternating `user` and `assistant` 13594 // conversational turns. When creating a new `Message`, you specify the prior 13595 // conversational turns with the `messages` parameter, and the model then generates 13596 // the next `Message` in the conversation. Consecutive `user` or `assistant` turns 13597 // in your request will be combined into a single turn. 13598 // 13599 // Each input message must be an object with a `role` and `content`. You can 13600 // specify a single `user`-role message, or you can include multiple `user` and 13601 // `assistant` messages. 13602 // 13603 // If the final message uses the `assistant` role, the response content will 13604 // continue immediately from the content in that message. This can be used to 13605 // constrain part of the model's response. 13606 // 13607 // Example with a single `user` message: 13608 // 13609 // ```json 13610 // [{ "role": "user", "content": "Hello, Claude" }] 13611 // ``` 13612 // 13613 // Example with multiple conversational turns: 13614 // 13615 // ```json 13616 // [ 13617 // 13618 // { "role": "user", "content": "Hello there." }, 13619 // { "role": "assistant", "content": "Hi, I'm Claude. How can I help you?" }, 13620 // { "role": "user", "content": "Can you explain LLMs in plain English?" } 13621 // 13622 // ] 13623 // ``` 13624 // 13625 // Example with a partially-filled response from Claude: 13626 // 13627 // ```json 13628 // [ 13629 // 13630 // { 13631 // "role": "user", 13632 // "content": "What's the Greek name for Sun? (A) Sol (B) Helios (C) Sun" 13633 // }, 13634 // { "role": "assistant", "content": "The best answer is (" } 13635 // 13636 // ] 13637 // ``` 13638 // 13639 // Each input message `content` may be either a single `string` or an array of 13640 // content blocks, where each block has a specific `type`. Using a `string` for 13641 // `content` is shorthand for an array of one content block of type `"text"`. The 13642 // following input messages are equivalent: 13643 // 13644 // ```json 13645 // { "role": "user", "content": "Hello, Claude" } 13646 // ``` 13647 // 13648 // ```json 13649 // { "role": "user", "content": [{ "type": "text", "text": "Hello, Claude" }] } 13650 // ``` 13651 // 13652 // See 13653 // [input examples](https://platform.claude.com/docs/en/build-with-claude/working-with-messages). 13654 // 13655 // Note that if you want to include a 13656 // [system prompt](https://platform.claude.com/docs/en/build-with-claude/prompt-engineering/claude-prompting-best-practices#give-claude-a-role), 13657 // you can use the top-level `system` parameter — there is no `"system"` role for 13658 // input messages in the Messages API. 13659 // 13660 // There is a limit of 100,000 messages in a single request. 13661 Messages []MessageParam `json:"messages,omitzero" api:"required"` 13662 // The model that will complete your prompt. 13663 // 13664 // See [models](https://docs.anthropic.com/en/docs/models-overview) for additional 13665 // details and options. 13666 Model Model `json:"model,omitzero" api:"required"` 13667 // The user profile ID to attribute this request to. Use when acting on behalf of a 13668 // party other than your organization. Requires the `user-profiles` beta header. 13669 UserProfileID param.Opt[string] `header:"anthropic-user-profile-id,omitzero" json:"-"` 13670 WorkspaceID param.Opt[string] `header:"anthropic-workspace-id,omitzero" json:"-"` 13671 // Top-level cache control automatically applies a cache_control marker to the last 13672 // cacheable block in the request. 13673 CacheControl CacheControlEphemeralParam `json:"cache_control,omitzero"` 13674 // Configuration options for the model's output, such as the output format. 13675 OutputConfig OutputConfigParam `json:"output_config,omitzero"` 13676 // System prompt. 13677 // 13678 // A system prompt is a way of providing context and instructions to Claude, such 13679 // as specifying a particular goal or role. See our 13680 // [guide to system prompts](https://platform.claude.com/docs/en/build-with-claude/prompt-engineering/claude-prompting-best-practices#give-claude-a-role). 13681 System MessageCountTokensParamsSystemUnion `json:"system,omitzero"` 13682 // Configuration for enabling Claude's extended thinking. 13683 // 13684 // When enabled, responses include `thinking` content blocks showing Claude's 13685 // thinking process before the final answer. Requires a minimum budget of 1,024 13686 // tokens and counts towards your `max_tokens` limit. 13687 // 13688 // See 13689 // [extended thinking](https://platform.claude.com/docs/en/build-with-claude/extended-thinking) 13690 // for details. 13691 Thinking ThinkingConfigParamUnion `json:"thinking,omitzero"` 13692 // How the model should use the provided tools. The model can use a specific tool, 13693 // any available tool, decide by itself, or not use tools at all. 13694 ToolChoice ToolChoiceUnionParam `json:"tool_choice,omitzero"` 13695 // Definitions of tools that the model may use. 13696 // 13697 // If you include `tools` in your API request, the model may return `tool_use` 13698 // content blocks that represent the model's use of those tools. You can then run 13699 // those tools using the tool input generated by the model and then optionally 13700 // return results back to the model using `tool_result` content blocks. 13701 // 13702 // There are two types of tools: **client tools** and **server tools**. The 13703 // behavior described below applies to client tools. For 13704 // [server tools](https://platform.claude.com/docs/en/agents-and-tools/tool-use/server-tools), 13705 // see their individual documentation as each has its own behavior (e.g., the 13706 // [web search tool](https://platform.claude.com/docs/en/agents-and-tools/tool-use/web-search-tool)). 13707 // 13708 // Each tool definition includes: 13709 // 13710 // - `name`: Name of the tool. 13711 // - `description`: Optional, but strongly-recommended description of the tool. 13712 // - `input_schema`: [JSON schema](https://json-schema.org/draft/2020-12) for the 13713 // tool `input` shape that the model will produce in `tool_use` output content 13714 // blocks. 13715 // 13716 // For example, if you defined `tools` as: 13717 // 13718 // ```json 13719 // [ 13720 // 13721 // { 13722 // "name": "get_stock_price", 13723 // "description": "Get the current stock price for a given ticker symbol.", 13724 // "input_schema": { 13725 // "type": "object", 13726 // "properties": { 13727 // "ticker": { 13728 // "type": "string", 13729 // "description": "The stock ticker symbol, e.g. AAPL for Apple Inc." 13730 // } 13731 // }, 13732 // "required": ["ticker"] 13733 // } 13734 // } 13735 // 13736 // ] 13737 // ``` 13738 // 13739 // And then asked the model "What's the S&P 500 at today?", the model might produce 13740 // `tool_use` content blocks in the response like this: 13741 // 13742 // ```json 13743 // [ 13744 // 13745 // { 13746 // "type": "tool_use", 13747 // "id": "toolu_01D7FLrfh4GYq7yT1ULFeyMV", 13748 // "name": "get_stock_price", 13749 // "input": { "ticker": "^GSPC" } 13750 // } 13751 // 13752 // ] 13753 // ``` 13754 // 13755 // You might then run your `get_stock_price` tool with `{"ticker": "^GSPC"}` as an 13756 // input, and return the following back to the model in a subsequent `user` 13757 // message: 13758 // 13759 // ```json 13760 // [ 13761 // 13762 // { 13763 // "type": "tool_result", 13764 // "tool_use_id": "toolu_01D7FLrfh4GYq7yT1ULFeyMV", 13765 // "content": "259.75 USD" 13766 // } 13767 // 13768 // ] 13769 // ``` 13770 // 13771 // Tools can be used for workflows that include running client-side tools and 13772 // functions, or more generally whenever you want the model to produce a particular 13773 // JSON structure of output. 13774 // 13775 // See our 13776 // [guide](https://platform.claude.com/docs/en/agents-and-tools/tool-use/overview) 13777 // for more details. 13778 Tools []MessageCountTokensToolUnionParam `json:"tools,omitzero"` 13779 paramObj 13780 } 13781 13782 func (r MessageCountTokensParams) MarshalJSON() (data []byte, err error) { 13783 type shadow MessageCountTokensParams 13784 return param.MarshalObject(r, (*shadow)(&r)) 13785 } 13786 func (r *MessageCountTokensParams) UnmarshalJSON(data []byte) error { 13787 return apijson.UnmarshalRoot(data, r) 13788 } 13789 13790 // Only one field can be non-zero. 13791 // 13792 // Use [param.IsOmitted] to confirm if a field is set. 13793 type MessageCountTokensParamsSystemUnion struct { 13794 OfString param.Opt[string] `json:",omitzero,inline"` 13795 OfTextBlockArray []TextBlockParam `json:",omitzero,inline"` 13796 paramUnion 13797 } 13798 13799 func (u MessageCountTokensParamsSystemUnion) MarshalJSON() ([]byte, error) { 13800 return param.MarshalUnion(u, u.OfString, u.OfTextBlockArray) 13801 } 13802 func (u *MessageCountTokensParamsSystemUnion) UnmarshalJSON(data []byte) error { 13803 return apijson.UnmarshalRoot(data, u) 13804 } 13805 13806 func (u *MessageCountTokensParamsSystemUnion) asAny() any { 13807 if !param.IsOmitted(u.OfString) { 13808 return &u.OfString.Value 13809 } else if !param.IsOmitted(u.OfTextBlockArray) { 13810 return &u.OfTextBlockArray 13811 } 13812 return nil 13813 }