| 1 | # yaml-language-server: $schema=../../tools/ai-codegen/codegen.schema.json |
| 2 | spec: |
| 3 | type: stainless-stats |
| 4 | statsUrl: https://raw.githubusercontent.com/anthropics/anthropic-sdk-typescript/main/.stats.yml |
| 5 | output: src/Generated.ts |
| 6 | name: AnthropicClient |
| 7 | patches: |
| 8 | # Allow system messages in conversation history. |
| 9 | - '[{"op":"replace","path":"/components/schemas/BetaInputMessage/properties/role/enum","value":["user","assistant","system"]},{"op":"replace","path":"/components/schemas/InputMessage/properties/role/enum","value":["user","assistant","system"]}]' |
| 10 | # Make iterations and speed optional in BetaUsage, iterations optional in BetaMessageDeltaUsage (API may omit these fields) |
| 11 | - '[{"op":"remove","path":"/components/schemas/BetaUsage/required/9"},{"op":"remove","path":"/components/schemas/BetaUsage/required/5"},{"op":"remove","path":"/components/schemas/BetaMessageDeltaUsage/required/3"}]' |
| 12 | header: | |
| 13 | /** |
| 14 | * @stability unstable |
| 15 | * @since 1.0.0 |
| 16 | */ |
| 17 | excludeAnnotations: |
| 18 | - examples |
| 19 | disableAdditionalProperties: true |
| 20 | replacements: |
| 21 | # Schema.Unknown doesn't work with Schema.toCodecJson (used by HttpClientResponse.schemaBodyJson) |
| 22 | # Replace with Schema.Json which properly handles arbitrary JSON values |
| 23 | - from: "Schema.Record(Schema.String, Schema.Unknown)" |
| 24 | to: "Schema.Record(Schema.String, Schema.Json)" |
| 25 | - from: "{ readonly [x: string]: unknown }" |
| 26 | to: "{ readonly [x: string]: Schema.Json }" |
| 27 | # Index signature in struct rest pattern |
| 28 | - from: "readonly [x: string]: unknown" |
| 29 | to: "readonly [x: string]: Schema.Json" |
| 30 | # Make citations optional in ResponseTextBlock (API may omit this field) |
| 31 | - from: 'export type ResponseTextBlock = { readonly "citations":' |
| 32 | to: 'export type ResponseTextBlock = { readonly "citations"?:' |
| 33 | - from: "export const ResponseTextBlock = Schema.Struct({ \"citations\": Schema.Union([Schema.Array(Schema.Union([ResponseCharLocationCitation, ResponsePageLocationCitation, ResponseContentBlockLocationCitation, ResponseWebSearchResultLocationCitation, ResponseSearchResultLocationCitation], { mode: \"oneOf\" })), Schema.Null]).annotate({ \"title\": \"Citations\", \"description\": \"Citations supporting the text block.\\n\\nThe type of citation returned will depend on the type of document being cited. Citing a PDF results in `page_location`, plain text results in `char_location`, and content document results in `content_block_location`.\", \"default\": null }), \"text\":" |
| 34 | to: "export const ResponseTextBlock = Schema.Struct({ \"citations\": Schema.optionalKey(Schema.Union([Schema.Array(Schema.Union([ResponseCharLocationCitation, ResponsePageLocationCitation, ResponseContentBlockLocationCitation, ResponseWebSearchResultLocationCitation, ResponseSearchResultLocationCitation], { mode: \"oneOf\" })), Schema.Null]).annotate({ \"title\": \"Citations\", \"description\": \"Citations supporting the text block.\\n\\nThe type of citation returned will depend on the type of document being cited. Citing a PDF results in `page_location`, plain text results in `char_location`, and content document results in `content_block_location`.\", \"default\": null })), \"text\":" |
| 35 | # Make citations optional in BetaResponseTextBlock (API may omit this field) |
| 36 | - from: 'export type BetaResponseTextBlock = { readonly "citations":' |
| 37 | to: 'export type BetaResponseTextBlock = { readonly "citations"?:' |
| 38 | - from: "export const BetaResponseTextBlock = Schema.Struct({ \"citations\": Schema.Union([Schema.Array(Schema.Union([BetaResponseCharLocationCitation, BetaResponsePageLocationCitation, BetaResponseContentBlockLocationCitation, BetaResponseWebSearchResultLocationCitation, BetaResponseSearchResultLocationCitation], { mode: \"oneOf\" })), Schema.Null]).annotate({ \"title\": \"Citations\", \"description\": \"Citations supporting the text block.\\n\\nThe type of citation returned will depend on the type of document being cited. Citing a PDF results in `page_location`, plain text results in `char_location`, and content document results in `content_block_location`.\", \"default\": null }), \"text\":" |
| 39 | to: "export const BetaResponseTextBlock = Schema.Struct({ \"citations\": Schema.optionalKey(Schema.Union([Schema.Array(Schema.Union([BetaResponseCharLocationCitation, BetaResponsePageLocationCitation, BetaResponseContentBlockLocationCitation, BetaResponseWebSearchResultLocationCitation, BetaResponseSearchResultLocationCitation], { mode: \"oneOf\" })), Schema.Null]).annotate({ \"title\": \"Citations\", \"description\": \"Citations supporting the text block.\\n\\nThe type of citation returned will depend on the type of document being cited. Citing a PDF results in `page_location`, plain text results in `char_location`, and content document results in `content_block_location`.\", \"default\": null })), \"text\":" |
| 40 | # Make server_tool_use optional in usage (API may omit this field) |
| 41 | - from: 'readonly "server_tool_use": ServerToolUsage | null' |
| 42 | to: 'readonly "server_tool_use"?: ServerToolUsage | null' |
| 43 | - from: 'readonly "server_tool_use": BetaServerToolUsage | null' |
| 44 | to: 'readonly "server_tool_use"?: BetaServerToolUsage | null' |
| 45 | - from: '"server_tool_use": Schema.Union([ServerToolUsage, Schema.Null]).annotate({ "description": "The number of server tool requests.", "default": null }),' |
| 46 | to: '"server_tool_use": Schema.optionalKey(Schema.Union([ServerToolUsage, Schema.Null]).annotate({ "description": "The number of server tool requests.", "default": null })),' |
| 47 | - from: '"server_tool_use": Schema.Union([BetaServerToolUsage, Schema.Null]).annotate({ "description": "The number of server tool requests.", "default": null }),' |
| 48 | to: '"server_tool_use": Schema.optionalKey(Schema.Union([BetaServerToolUsage, Schema.Null]).annotate({ "description": "The number of server tool requests.", "default": null })),' |
| 49 | # Without trailing comma (for last field in struct) |
| 50 | - from: '"server_tool_use": Schema.Union([BetaServerToolUsage, Schema.Null]).annotate({ "description": "The number of server tool requests.", "default": null }) })' |
| 51 | to: '"server_tool_use": Schema.optionalKey(Schema.Union([BetaServerToolUsage, Schema.Null]).annotate({ "description": "The number of server tool requests.", "default": null })) })' |
| 52 | - from: '"server_tool_use": Schema.Union([ServerToolUsage, Schema.Null]).annotate({ "description": "The number of server tool requests.", "default": null }) })' |
| 53 | to: '"server_tool_use": Schema.optionalKey(Schema.Union([ServerToolUsage, Schema.Null]).annotate({ "description": "The number of server tool requests.", "default": null })) })' |
| 54 | # Anthropic-compatible gateways may omit inference_geo in response usage (#8464) |
| 55 | - from: 'readonly "inference_geo": string | null' |
| 56 | to: 'readonly "inference_geo"?: string | null' |
| 57 | - from: '"inference_geo": Schema.Union([Schema.String, Schema.Null]).annotate({ "title": "Inference Geo", "description": "The geographic region where inference was performed for this request.", "default": null }),' |
| 58 | to: '"inference_geo": Schema.optionalKey(Schema.Union([Schema.String, Schema.Null]).annotate({ "title": "Inference Geo", "description": "The geographic region where inference was performed for this request.", "default": null })),' |
| 59 | # Make context_management and container optional in BetaMessage (API may omit these fields) |
| 60 | - from: 'readonly "context_management": BetaResponseContextManagement | null' |
| 61 | to: 'readonly "context_management"?: BetaResponseContextManagement | null' |
| 62 | - from: 'readonly "container": BetaContainer | null' |
| 63 | to: 'readonly "container"?: BetaContainer | null' |
| 64 | - from: "\"context_management\": Schema.Union([BetaResponseContextManagement, Schema.Null]).annotate({ \"description\": \"Context management response.\\n\\nInformation about context management strategies applied during the request.\", \"default\": null })," |
| 65 | to: "\"context_management\": Schema.optionalKey(Schema.Union([BetaResponseContextManagement, Schema.Null]).annotate({ \"description\": \"Context management response.\\n\\nInformation about context management strategies applied during the request.\", \"default\": null }))," |
| 66 | - from: "\"container\": Schema.Union([BetaContainer, Schema.Null]).annotate({ \"description\": \"Information about the container used in this request.\\n\\nThis will be non-null if a container tool (e.g. code execution) was used.\", \"default\": null })" |
| 67 | to: "\"container\": Schema.optionalKey(Schema.Union([BetaContainer, Schema.Null]).annotate({ \"description\": \"Information about the container used in this request.\\n\\nThis will be non-null if a container tool (e.g. code execution) was used.\", \"default\": null }))" |
| 68 | # Make context_management optional in BetaMessageDeltaEvent (API may omit this field) |
| 69 | - from: '"context_management": Schema.Union([BetaResponseContextManagement, Schema.Null]).annotate({ "description": "Information about context management strategies applied during the request", "default": null }),' |
| 70 | to: '"context_management": Schema.optionalKey(Schema.Union([BetaResponseContextManagement, Schema.Null]).annotate({ "description": "Information about context management strategies applied during the request", "default": null })),' |