@langchain/anthropic 1.3.14 → 1.3.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +14 -0
- package/dist/chat_models.cjs +29 -9
- package/dist/chat_models.cjs.map +1 -1
- package/dist/chat_models.d.cts +45 -3
- package/dist/chat_models.d.cts.map +1 -1
- package/dist/chat_models.d.ts +45 -3
- package/dist/chat_models.d.ts.map +1 -1
- package/dist/chat_models.js +29 -9
- package/dist/chat_models.js.map +1 -1
- package/dist/tools/computer.d.cts +101 -101
- package/dist/tools/computer.d.cts.map +1 -1
- package/dist/tools/textEditor.d.cts +21 -21
- package/dist/tools/textEditor.d.cts.map +1 -1
- package/dist/types.d.cts +5 -3
- package/dist/types.d.cts.map +1 -1
- package/dist/types.d.ts +5 -3
- package/dist/types.d.ts.map +1 -1
- package/dist/utils/content.cjs +4 -0
- package/dist/utils/content.cjs.map +1 -1
- package/dist/utils/content.js +4 -1
- package/dist/utils/content.js.map +1 -1
- package/dist/utils/message_inputs.cjs +7 -0
- package/dist/utils/message_inputs.cjs.map +1 -1
- package/dist/utils/message_inputs.js +8 -1
- package/dist/utils/message_inputs.js.map +1 -1
- package/dist/utils/message_outputs.cjs +16 -1
- package/dist/utils/message_outputs.cjs.map +1 -1
- package/dist/utils/message_outputs.js +16 -1
- package/dist/utils/message_outputs.js.map +1 -1
- package/package.json +2 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chat_models.d.cts","names":["Anthropic","ClientOptions","Stream","CallbackManagerForLLMRun","AIMessageChunk","BaseMessage","ChatGenerationChunk","ChatResult","BaseChatModel","BaseChatModelCallOptions","LangSmithParams","BaseChatModelParams","StructuredOutputMethodOptions","BaseLanguageModelInput","ModelProfile","Runnable","InteropZodType","AnthropicContextManagementConfigParam","AnthropicInvocationParams","AnthropicMessageCreateParams","AnthropicMessageStreamEvent","AnthropicRequestOptions","AnthropicStreamingMessageCreateParams","AnthropicThinkingConfigParam","AnthropicToolChoice","ChatAnthropicOutputFormat","ChatAnthropicToolType","AnthropicMCPServerURLDefinition","Kwargs","AnthropicBeta","AnthropicCacheControl","ChatAnthropicCallOptions","AnthropicInput","Record","Pick","AnthropicMessagesModelId","Model","NonNullable","ChatAnthropicInput","ChatAnthropicMessages","RunOutput","CallOptions","Messages","ToolUnion","Partial","Metadata","TextBlockParam","ThinkingConfigParam","ToolChoice","AsyncGenerator","MessageCreateParamsNonStreaming","MessageCreateParamsStreaming","Omit","_langchain_core_outputs0","ChatGeneration","StopReason","Usage","Promise","Message","ChatAnthropic"],"sources":["../src/chat_models.d.ts"],"sourcesContent":["import { Anthropic, type ClientOptions } from \"@anthropic-ai/sdk\";\nimport type { Stream } from \"@anthropic-ai/sdk/streaming\";\nimport { CallbackManagerForLLMRun } from \"@langchain/core/callbacks/manager\";\nimport { AIMessageChunk, type BaseMessage } from \"@langchain/core/messages\";\nimport { ChatGenerationChunk, type ChatResult } from \"@langchain/core/outputs\";\nimport { BaseChatModel, BaseChatModelCallOptions, LangSmithParams, type BaseChatModelParams } from \"@langchain/core/language_models/chat_models\";\nimport { type StructuredOutputMethodOptions, type BaseLanguageModelInput } from \"@langchain/core/language_models/base\";\nimport { ModelProfile } from \"@langchain/core/language_models/profile\";\nimport { Runnable } from \"@langchain/core/runnables\";\nimport { InteropZodType } from \"@langchain/core/utils/types\";\nimport { AnthropicContextManagementConfigParam, AnthropicInvocationParams, AnthropicMessageCreateParams, AnthropicMessageStreamEvent, AnthropicRequestOptions, AnthropicStreamingMessageCreateParams, AnthropicThinkingConfigParam, AnthropicToolChoice, ChatAnthropicOutputFormat, ChatAnthropicToolType, AnthropicMCPServerURLDefinition, Kwargs } from \"./types.js\";\nimport { AnthropicBeta } from \"@anthropic-ai/sdk/resources\";\n/**\n * Cache control configuration for Anthropic prompt caching.\n * @see https://docs.anthropic.com/en/docs/build-with-claude/prompt-caching\n */\nexport interface AnthropicCacheControl {\n type: \"ephemeral\";\n ttl?: \"5m\" | \"1h\";\n}\nexport interface ChatAnthropicCallOptions extends BaseChatModelCallOptions, Pick<AnthropicInput, \"streamUsage\"> {\n tools?: ChatAnthropicToolType[];\n /**\n * Whether or not to specify what tool the model should use\n * @default \"auto\"\n */\n tool_choice?: AnthropicToolChoice;\n /**\n * Custom headers to pass to the Anthropic API\n * when making a request.\n */\n headers?: Record<string, string>;\n /**\n * Container ID for file persistence across turns with code execution.\n * Used with the code_execution_20250825 tool.\n */\n container?: string;\n /**\n * Output format to use for the response.\n */\n output_format?: ChatAnthropicOutputFormat;\n /**\n * Optional array of beta features to enable for the Anthropic API.\n * Beta features are experimental capabilities that may change or be removed.\n * See https://docs.anthropic.com/en/api/versioning for available beta features.\n */\n betas?: AnthropicBeta[];\n /**\n * Array of MCP server URLs to use for the request.\n */\n mcp_servers?: AnthropicMCPServerURLDefinition[];\n /**\n * Cache control configuration for prompt caching.\n * When provided, applies cache_control to the last content block of the\n * last message, enabling Anthropic's prompt caching feature.\n *\n * This is the recommended way to enable prompt caching as it applies\n * cache_control at the final message formatting layer, avoiding issues\n * with message content block manipulation during earlier processing stages.\n *\n * @see https://docs.anthropic.com/en/docs/build-with-claude/prompt-caching\n */\n cache_control?: AnthropicCacheControl;\n}\n/**\n * @see https://docs.anthropic.com/claude/docs/models-overview\n */\nexport type AnthropicMessagesModelId = Anthropic.Model | (string & NonNullable<unknown>);\n/**\n * Input to AnthropicChat class.\n */\nexport interface AnthropicInput {\n /**\n * Amount of randomness injected into the response. Ranges\n * from 0 to 1. Use temperature closer to 0 for analytical /\n * multiple choice, and temperature closer to 1 for creative\n * and generative tasks.\n */\n temperature?: number;\n /**\n * Only sample from the top K options for each subsequent\n * token. Used to remove \"long tail\" low probability\n * responses.\n */\n topK?: number;\n /**\n * Does nucleus sampling, in which we compute the\n * cumulative distribution over all the options for each\n * subsequent token in decreasing probability order and\n * cut it off once it reaches a particular probability\n * specified by top_p. Note that you should either alter\n * temperature or top_p, but not both.\n */\n topP?: number | null;\n /** A maximum number of tokens to generate before stopping. */\n maxTokens?: number;\n /**\n * A list of strings upon which to stop generating.\n * You probably want `[\"\\n\\nHuman:\"]`, as that's the cue for\n * the next turn in the dialog agent.\n */\n stopSequences?: string[];\n /** Whether to stream the results or not */\n streaming?: boolean;\n /** Anthropic API key */\n anthropicApiKey?: string;\n /** Anthropic API key */\n apiKey?: string;\n /** Anthropic API URL */\n anthropicApiUrl?: string;\n /** @deprecated Use \"model\" instead */\n modelName?: AnthropicMessagesModelId;\n /** Model name to use */\n model?: AnthropicMessagesModelId;\n /** Overridable Anthropic ClientOptions */\n clientOptions?: ClientOptions;\n /** Holds any additional parameters that are valid to pass to {@link\n * https://console.anthropic.com/docs/api/reference |\n * `anthropic.messages`} that are not explicitly specified on this class.\n */\n invocationKwargs?: Kwargs;\n /**\n * Whether or not to include token usage data in streamed chunks.\n * @default true\n */\n streamUsage?: boolean;\n /**\n * Optional method that returns an initialized underlying Anthropic client.\n * Useful for accessing Anthropic models hosted on other cloud services\n * such as Google Vertex.\n */\n createClient?: (options: ClientOptions) => any;\n /**\n * Options for extended thinking.\n */\n thinking?: AnthropicThinkingConfigParam;\n /**\n * Configuration for context management. See https://docs.claude.com/en/docs/build-with-claude/context-editing\n */\n contextManagement?: AnthropicContextManagementConfigParam;\n /**\n * Optional array of beta features to enable for the Anthropic API.\n * Beta features are experimental capabilities that may change or be removed.\n * See https://docs.claude.com/en/api/beta-headers for available beta features.\n */\n betas?: AnthropicBeta[];\n}\n/**\n * Input to ChatAnthropic class.\n */\nexport type ChatAnthropicInput = AnthropicInput & BaseChatModelParams;\n/**\n * Anthropic chat model integration.\n *\n * Setup:\n * Install `@langchain/anthropic` and set an environment variable named `ANTHROPIC_API_KEY`.\n *\n * ```bash\n * npm install @langchain/anthropic\n * export ANTHROPIC_API_KEY=\"your-api-key\"\n * ```\n *\n * ## [Constructor args](https://api.js.langchain.com/classes/langchain_anthropic.ChatAnthropic.html#constructor)\n *\n * ## [Runtime args](https://api.js.langchain.com/interfaces/langchain_anthropic.ChatAnthropicCallOptions.html)\n *\n * Runtime args can be passed as the second argument to any of the base runnable methods `.invoke`. `.stream`, `.batch`, etc.\n * They can also be passed via `.bind`, or the second arg in `.bindTools`, like shown in the examples below:\n *\n * ```typescript\n * // When calling `.bind`, call options should be passed via the first argument\n * const llmWithArgsBound = llm.bindTools([...]).withConfig({\n * stop: [\"\\n\"],\n * });\n *\n * // When calling `.bindTools`, call options should be passed via the second argument\n * const llmWithTools = llm.bindTools(\n * [...],\n * {\n * tool_choice: \"auto\",\n * }\n * );\n * ```\n *\n * ## Examples\n *\n * <details open>\n * <summary><strong>Instantiate</strong></summary>\n *\n * ```typescript\n * import { ChatAnthropic } from '@langchain/anthropic';\n *\n * const llm = new ChatAnthropic({\n * model: \"claude-sonnet-4-5-20250929\",\n * temperature: 0,\n * maxTokens: undefined,\n * maxRetries: 2,\n * // apiKey: \"...\",\n * // baseUrl: \"...\",\n * // other params...\n * });\n * ```\n * </details>\n *\n * <br />\n *\n * <details>\n * <summary><strong>Invoking</strong></summary>\n *\n * ```typescript\n * const input = `Translate \"I love programming\" into French.`;\n *\n * // Models also accept a list of chat messages or a formatted prompt\n * const result = await llm.invoke(input);\n * console.log(result);\n * ```\n *\n * ```txt\n * AIMessage {\n * \"id\": \"msg_01QDpd78JUHpRP6bRRNyzbW3\",\n * \"content\": \"Here's the translation to French:\\n\\nJ'adore la programmation.\",\n * \"response_metadata\": {\n * \"id\": \"msg_01QDpd78JUHpRP6bRRNyzbW3\",\n * \"model\": \"claude-sonnet-4-5-20250929\",\n * \"stop_reason\": \"end_turn\",\n * \"stop_sequence\": null,\n * \"usage\": {\n * \"input_tokens\": 25,\n * \"output_tokens\": 19\n * },\n * \"type\": \"message\",\n * \"role\": \"assistant\"\n * },\n * \"usage_metadata\": {\n * \"input_tokens\": 25,\n * \"output_tokens\": 19,\n * \"total_tokens\": 44\n * }\n * }\n * ```\n * </details>\n *\n * <br />\n *\n * <details>\n * <summary><strong>Streaming Chunks</strong></summary>\n *\n * ```typescript\n * for await (const chunk of await llm.stream(input)) {\n * console.log(chunk);\n * }\n * ```\n *\n * ```txt\n * AIMessageChunk {\n * \"id\": \"msg_01N8MwoYxiKo9w4chE4gXUs4\",\n * \"content\": \"\",\n * \"additional_kwargs\": {\n * \"id\": \"msg_01N8MwoYxiKo9w4chE4gXUs4\",\n * \"type\": \"message\",\n * \"role\": \"assistant\",\n * \"model\": \"claude-sonnet-4-5-20250929\"\n * },\n * \"usage_metadata\": {\n * \"input_tokens\": 25,\n * \"output_tokens\": 1,\n * \"total_tokens\": 26\n * }\n * }\n * AIMessageChunk {\n * \"content\": \"\",\n * }\n * AIMessageChunk {\n * \"content\": \"Here\",\n * }\n * AIMessageChunk {\n * \"content\": \"'s\",\n * }\n * AIMessageChunk {\n * \"content\": \" the translation to\",\n * }\n * AIMessageChunk {\n * \"content\": \" French:\\n\\nJ\",\n * }\n * AIMessageChunk {\n * \"content\": \"'adore la programmation\",\n * }\n * AIMessageChunk {\n * \"content\": \".\",\n * }\n * AIMessageChunk {\n * \"content\": \"\",\n * \"additional_kwargs\": {\n * \"stop_reason\": \"end_turn\",\n * \"stop_sequence\": null\n * },\n * \"usage_metadata\": {\n * \"input_tokens\": 0,\n * \"output_tokens\": 19,\n * \"total_tokens\": 19\n * }\n * }\n * ```\n * </details>\n *\n * <br />\n *\n * <details>\n * <summary><strong>Aggregate Streamed Chunks</strong></summary>\n *\n * ```typescript\n * import { AIMessageChunk } from '@langchain/core/messages';\n * import { concat } from '@langchain/core/utils/stream';\n *\n * const stream = await llm.stream(input);\n * let full: AIMessageChunk | undefined;\n * for await (const chunk of stream) {\n * full = !full ? chunk : concat(full, chunk);\n * }\n * console.log(full);\n * ```\n *\n * ```txt\n * AIMessageChunk {\n * \"id\": \"msg_01SBTb5zSGXfjUc7yQ8EKEEA\",\n * \"content\": \"Here's the translation to French:\\n\\nJ'adore la programmation.\",\n * \"additional_kwargs\": {\n * \"id\": \"msg_01SBTb5zSGXfjUc7yQ8EKEEA\",\n * \"type\": \"message\",\n * \"role\": \"assistant\",\n * \"model\": \"claude-sonnet-4-5-20250929\",\n * \"stop_reason\": \"end_turn\",\n * \"stop_sequence\": null\n * },\n * \"usage_metadata\": {\n * \"input_tokens\": 25,\n * \"output_tokens\": 20,\n * \"total_tokens\": 45\n * }\n * }\n * ```\n * </details>\n *\n * <br />\n *\n * <details>\n * <summary><strong>Bind tools</strong></summary>\n *\n * ```typescript\n * import { z } from 'zod';\n *\n * const GetWeather = {\n * name: \"GetWeather\",\n * description: \"Get the current weather in a given location\",\n * schema: z.object({\n * location: z.string().describe(\"The city and state, e.g. San Francisco, CA\")\n * }),\n * }\n *\n * const GetPopulation = {\n * name: \"GetPopulation\",\n * description: \"Get the current population in a given location\",\n * schema: z.object({\n * location: z.string().describe(\"The city and state, e.g. San Francisco, CA\")\n * }),\n * }\n *\n * const llmWithTools = llm.bindTools([GetWeather, GetPopulation]);\n * const aiMsg = await llmWithTools.invoke(\n * \"Which city is hotter today and which is bigger: LA or NY?\"\n * );\n * console.log(aiMsg.tool_calls);\n * ```\n *\n * ```txt\n * [\n * {\n * name: 'GetWeather',\n * args: { location: 'Los Angeles, CA' },\n * id: 'toolu_01WjW3Dann6BPJVtLhovdBD5',\n * type: 'tool_call'\n * },\n * {\n * name: 'GetWeather',\n * args: { location: 'New York, NY' },\n * id: 'toolu_01G6wfJgqi5zRmJomsmkyZXe',\n * type: 'tool_call'\n * },\n * {\n * name: 'GetPopulation',\n * args: { location: 'Los Angeles, CA' },\n * id: 'toolu_0165qYWBA2VFyUst5RA18zew',\n * type: 'tool_call'\n * },\n * {\n * name: 'GetPopulation',\n * args: { location: 'New York, NY' },\n * id: 'toolu_01PGNyP33vxr13tGqr7i3rDo',\n * type: 'tool_call'\n * }\n * ]\n * ```\n * </details>\n *\n * <br />\n *\n * <details>\n * <summary><strong>Tool Search</strong></summary>\n *\n * Tool search enables Claude to dynamically discover and load tools on-demand\n * instead of loading all tool definitions upfront. This is useful when you have\n * many tools but want to avoid the overhead of sending all definitions with every request.\n *\n * ```typescript\n * import { ChatAnthropic } from \"@langchain/anthropic\";\n *\n * const model = new ChatAnthropic({\n * model: \"claude-sonnet-4-5-20250929\",\n * });\n *\n * const tools = [\n * // Tool search server tool\n * {\n * type: \"tool_search_tool_regex_20251119\",\n * name: \"tool_search_tool_regex\",\n * },\n * // Tools with defer_loading are loaded on-demand\n * {\n * name: \"get_weather\",\n * description: \"Get the current weather for a location\",\n * input_schema: {\n * type: \"object\",\n * properties: {\n * location: { type: \"string\", description: \"City name\" },\n * unit: {\n * type: \"string\",\n * enum: [\"celsius\", \"fahrenheit\"],\n * },\n * },\n * required: [\"location\"],\n * },\n * defer_loading: true, // Tool is loaded on-demand\n * },\n * {\n * name: \"search_files\",\n * description: \"Search through files in the workspace\",\n * input_schema: {\n * type: \"object\",\n * properties: {\n * query: { type: \"string\" },\n * },\n * required: [\"query\"],\n * },\n * defer_loading: true, // Tool is loaded on-demand\n * },\n * ];\n *\n * const modelWithTools = model.bindTools(tools);\n * const response = await modelWithTools.invoke(\"What's the weather in San Francisco?\");\n * ```\n *\n * You can also use the `tool()` helper with the `extras` field:\n *\n * ```typescript\n * import { tool } from \"@langchain/core/tools\";\n * import { z } from \"zod\";\n *\n * const getWeather = tool(\n * async (input) => `Weather in ${input.location}`,\n * {\n * name: \"get_weather\",\n * description: \"Get weather for a location\",\n * schema: z.object({ location: z.string() }),\n * extras: { defer_loading: true },\n * }\n * );\n * ```\n *\n * **Note:** The required `advanced-tool-use-2025-11-20` beta header is automatically\n * appended to the request when using tool search tools.\n *\n * **Best practices:**\n * - Tools with `defer_loading: true` are only loaded when Claude discovers them via search\n * - Keep your 3-5 most frequently used tools as non-deferred for optimal performance\n * - Both regex and bm25 variants search tool names, descriptions, and argument info\n *\n * See the {@link https://platform.claude.com/docs/en/agents-and-tools/tool-use/tool-search-tool | Claude docs}\n * for more information.\n * </details>\n *\n * <br />\n *\n * <details>\n * <summary><strong>Structured Output</strong></summary>\n *\n * ChatAnthropic supports structured output through two main approaches:\n *\n * 1. **Function Calling with `withStructuredOutput()`**: Uses Anthropic's tool calling\n * under the hood to constrain outputs to a specific schema.\n * 2. **JSON Schema Mode**: Uses Anthropic's native JSON schema support for direct\n * structured output without tool calling overhead.\n *\n * **Using withStructuredOutput (Function Calling)**\n *\n * This method leverages Anthropic's tool calling capabilities to ensure the model\n * returns data matching your schema:\n *\n * ```typescript\n * import { z } from 'zod';\n *\n * const Joke = z.object({\n * setup: z.string().describe(\"The setup of the joke\"),\n * punchline: z.string().describe(\"The punchline to the joke\"),\n * rating: z.number().optional().describe(\"How funny the joke is, from 1 to 10\")\n * }).describe('Joke to tell user.');\n *\n * const structuredLlm = llm.withStructuredOutput(Joke, { name: \"Joke\" });\n * const jokeResult = await structuredLlm.invoke(\"Tell me a joke about cats\");\n * console.log(jokeResult);\n * ```\n *\n * ```txt\n * {\n * setup: \"Why don't cats play poker in the jungle?\",\n * punchline: 'Too many cheetahs!',\n * rating: 7\n * }\n * ```\n *\n * **Using JSON Schema Mode**\n *\n * For more direct control, you can use Anthropic's native JSON schema support by\n * passing `method: \"jsonSchema\"`:\n *\n * ```typescript\n * import { z } from 'zod';\n *\n * const RecipeSchema = z.object({\n * recipeName: z.string().describe(\"Name of the recipe\"),\n * ingredients: z.array(z.string()).describe(\"List of ingredients needed\"),\n * steps: z.array(z.string()).describe(\"Cooking steps in order\"),\n * prepTime: z.number().describe(\"Preparation time in minutes\")\n * });\n *\n * const structuredLlm = llm.withStructuredOutput(RecipeSchema, {\n * method: \"jsonSchema\"\n * });\n *\n * const recipe = await structuredLlm.invoke(\n * \"Give me a simple recipe for chocolate chip cookies\"\n * );\n * console.log(recipe);\n * ```\n *\n * ```txt\n * {\n * recipeName: 'Classic Chocolate Chip Cookies',\n * ingredients: [\n * '2 1/4 cups all-purpose flour',\n * '1 cup butter, softened',\n * ...\n * ],\n * steps: [\n * 'Preheat oven to 375°F',\n * 'Mix butter and sugars until creamy',\n * ...\n * ],\n * prepTime: 15\n * }\n * ```\n * </details>\n *\n * <br />\n *\n * <details>\n * <summary><strong>Multimodal</strong></summary>\n *\n * ```typescript\n * import { HumanMessage } from '@langchain/core/messages';\n *\n * const imageUrl = \"https://example.com/image.jpg\";\n * const imageData = await fetch(imageUrl).then(res => res.arrayBuffer());\n * const base64Image = Buffer.from(imageData).toString('base64');\n *\n * const message = new HumanMessage({\n * content: [\n * { type: \"text\", text: \"describe the weather in this image\" },\n * {\n * type: \"image_url\",\n * image_url: { url: `data:image/jpeg;base64,${base64Image}` },\n * },\n * ]\n * });\n *\n * const imageDescriptionAiMsg = await llm.invoke([message]);\n * console.log(imageDescriptionAiMsg.content);\n * ```\n *\n * ```txt\n * The weather in this image appears to be beautiful and clear. The sky is a vibrant blue with scattered white clouds, suggesting a sunny and pleasant day. The clouds are wispy and light, indicating calm conditions without any signs of storms or heavy weather. The bright green grass on the rolling hills looks lush and well-watered, which could mean recent rainfall or good growing conditions. Overall, the scene depicts a perfect spring or early summer day with mild temperatures, plenty of sunshine, and gentle breezes - ideal weather for enjoying the outdoors or for plant growth.\n * ```\n * </details>\n *\n * <br />\n *\n * <details>\n * <summary><strong>Usage Metadata</strong></summary>\n *\n * ```typescript\n * const aiMsgForMetadata = await llm.invoke(input);\n * console.log(aiMsgForMetadata.usage_metadata);\n * ```\n *\n * ```txt\n * { input_tokens: 25, output_tokens: 19, total_tokens: 44 }\n * ```\n * </details>\n *\n * <br />\n *\n * <details>\n * <summary><strong>Stream Usage Metadata</strong></summary>\n *\n * ```typescript\n * const streamForMetadata = await llm.stream(\n * input,\n * {\n * streamUsage: true\n * }\n * );\n * let fullForMetadata: AIMessageChunk | undefined;\n * for await (const chunk of streamForMetadata) {\n * fullForMetadata = !fullForMetadata ? chunk : concat(fullForMetadata, chunk);\n * }\n * console.log(fullForMetadata?.usage_metadata);\n * ```\n *\n * ```txt\n * { input_tokens: 25, output_tokens: 20, total_tokens: 45 }\n * ```\n * </details>\n *\n * <br />\n *\n * <details>\n * <summary><strong>Response Metadata</strong></summary>\n *\n * ```typescript\n * const aiMsgForResponseMetadata = await llm.invoke(input);\n * console.log(aiMsgForResponseMetadata.response_metadata);\n * ```\n *\n * ```txt\n * {\n * id: 'msg_01STxeQxJmp4sCSpioD6vK3L',\n * model: 'claude-sonnet-4-5-20250929',\n * stop_reason: 'end_turn',\n * stop_sequence: null,\n * usage: { input_tokens: 25, output_tokens: 19 },\n * type: 'message',\n * role: 'assistant'\n * }\n * ```\n * </details>\n *\n * <br />\n */\nexport declare class ChatAnthropicMessages<CallOptions extends ChatAnthropicCallOptions = ChatAnthropicCallOptions> extends BaseChatModel<CallOptions, AIMessageChunk> implements AnthropicInput {\n static lc_name(): string;\n get lc_secrets(): {\n [key: string]: string;\n } | undefined;\n get lc_aliases(): Record<string, string>;\n lc_serializable: boolean;\n anthropicApiKey?: string;\n apiKey?: string;\n apiUrl?: string;\n temperature?: number;\n topK?: number;\n topP?: number;\n maxTokens: number;\n modelName: string;\n model: string;\n invocationKwargs?: Kwargs;\n stopSequences?: string[];\n streaming: boolean;\n clientOptions: ClientOptions;\n thinking: AnthropicThinkingConfigParam;\n contextManagement?: AnthropicContextManagementConfigParam;\n protected batchClient: Anthropic;\n protected streamingClient: Anthropic;\n streamUsage: boolean;\n betas?: AnthropicBeta[];\n /**\n * Optional method that returns an initialized underlying Anthropic client.\n * Useful for accessing Anthropic models hosted on other cloud services\n * such as Google Vertex.\n */\n createClient: (options: ClientOptions) => Anthropic;\n constructor(fields?: ChatAnthropicInput);\n getLsParams(options: this[\"ParsedCallOptions\"]): LangSmithParams;\n /**\n * Formats LangChain StructuredTools to AnthropicTools.\n *\n * @param {ChatAnthropicCallOptions[\"tools\"]} tools The tools to format\n * @returns {AnthropicTool[] | undefined} The formatted tools, or undefined if none are passed.\n */\n formatStructuredToolToAnthropic(tools: ChatAnthropicCallOptions[\"tools\"]): Anthropic.Messages.ToolUnion[] | undefined;\n bindTools(tools: ChatAnthropicToolType[], kwargs?: Partial<CallOptions>): Runnable<BaseLanguageModelInput, AIMessageChunk, CallOptions>;\n /**\n * Get the parameters used to invoke the model\n */\n invocationParams(options?: this[\"ParsedCallOptions\"]): AnthropicInvocationParams;\n /** @ignore */\n _identifyingParams(): {\n max_tokens: number;\n model: Anthropic.Model;\n metadata?: Anthropic.Metadata | undefined;\n service_tier?: \"auto\" | \"standard_only\" | undefined;\n stop_sequences?: string[] | undefined;\n system?: string | Anthropic.TextBlockParam[] | undefined;\n temperature?: number | undefined;\n thinking?: Anthropic.ThinkingConfigParam | undefined;\n tool_choice?: Anthropic.ToolChoice | undefined;\n tools?: Anthropic.ToolUnion[] | undefined;\n top_k?: number | undefined;\n top_p?: number | undefined;\n stream?: boolean | undefined;\n model_name: string;\n };\n /**\n * Get the identifying parameters for the model\n */\n identifyingParams(): {\n max_tokens: number;\n model: Anthropic.Model;\n metadata?: Anthropic.Metadata | undefined;\n service_tier?: \"auto\" | \"standard_only\" | undefined;\n stop_sequences?: string[] | undefined;\n system?: string | Anthropic.TextBlockParam[] | undefined;\n temperature?: number | undefined;\n thinking?: Anthropic.ThinkingConfigParam | undefined;\n tool_choice?: Anthropic.ToolChoice | undefined;\n tools?: Anthropic.ToolUnion[] | undefined;\n top_k?: number | undefined;\n top_p?: number | undefined;\n stream?: boolean | undefined;\n model_name: string;\n };\n _streamResponseChunks(messages: BaseMessage[], options: this[\"ParsedCallOptions\"], runManager?: CallbackManagerForLLMRun): AsyncGenerator<ChatGenerationChunk>;\n /** @ignore */\n _generateNonStreaming(messages: BaseMessage[], params: Omit<Anthropic.Messages.MessageCreateParamsNonStreaming | Anthropic.Messages.MessageCreateParamsStreaming, \"messages\"> & Kwargs, requestOptions: AnthropicRequestOptions, cacheControl?: {\n type: \"ephemeral\";\n ttl?: \"5m\" | \"1h\";\n }): Promise<{\n generations: import(\"@langchain/core/outputs\").ChatGeneration[];\n llmOutput: {\n id: string;\n model: Anthropic.Model;\n stop_reason: Anthropic.StopReason | null;\n stop_sequence: string | null;\n usage: Anthropic.Usage;\n };\n }>;\n /** @ignore */\n _generate(messages: BaseMessage[], options: this[\"ParsedCallOptions\"], runManager?: CallbackManagerForLLMRun): Promise<ChatResult>;\n /**\n * Creates a streaming request with retry.\n * @param request The parameters for creating a completion.\n * @param options\n * @returns A streaming request.\n */\n protected createStreamWithRetry(request: AnthropicStreamingMessageCreateParams & Kwargs, options?: AnthropicRequestOptions): Promise<Stream<AnthropicMessageStreamEvent>>;\n /** @ignore */\n protected completionWithRetry(request: AnthropicMessageCreateParams & Kwargs, options: AnthropicRequestOptions): Promise<Anthropic.Message>;\n _llmType(): string;\n /**\n * Return profiling information for the model.\n *\n * Provides information about the model's capabilities and constraints,\n * including token limits, multimodal support, and advanced features like\n * tool calling and structured output.\n *\n * @returns {ModelProfile} An object describing the model's capabilities and constraints\n *\n * @example\n * ```typescript\n * const model = new ChatAnthropic({ model: \"claude-opus-4-0\" });\n * const profile = model.profile;\n * console.log(profile.maxInputTokens); // 200000\n * console.log(profile.imageInputs); // true\n * ```\n */\n get profile(): ModelProfile;\n withStructuredOutput<RunOutput extends Record<string, any> = Record<string, any>>(outputSchema: InteropZodType<RunOutput> | Record<string, any>, config?: StructuredOutputMethodOptions<false>): Runnable<BaseLanguageModelInput, RunOutput>;\n withStructuredOutput<RunOutput extends Record<string, any> = Record<string, any>>(outputSchema: InteropZodType<RunOutput> | Record<string, any>, config?: StructuredOutputMethodOptions<true>): Runnable<BaseLanguageModelInput, {\n raw: BaseMessage;\n parsed: RunOutput;\n }>;\n}\nexport declare class ChatAnthropic extends ChatAnthropicMessages {\n}\n//# sourceMappingURL=chat_models.d.ts.map"],"mappings":";;;;;;;;;;;;;;;;;;;AAgBA;AAIiB+B,UAJAD,qBAAAA,CAIwB;EAAwCE,IAAAA,EAAAA,WAAAA;EACrEN,GAAAA,CAAAA,EAAAA,IAAAA,GAAAA,IAAAA;;AAUEO,UAXGF,wBAAAA,SAAiCtB,wBAWpCwB,EAX8DC,IAW9DD,CAXmED,cA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IMessageChunk","BaseMessage","ChatGenerationChunk","ChatResult","BaseChatModel","BaseChatModelCallOptions","LangSmithParams","BaseChatModelParams","StructuredOutputMethodOptions","BaseLanguageModelInput","ModelProfile","Runnable","InteropZodType","AnthropicContextManagementConfigParam","AnthropicInvocationParams","AnthropicMessageCreateParams","AnthropicMessageStreamEvent","AnthropicRequestOptions","AnthropicStreamingMessageCreateParams","AnthropicThinkingConfigParam","AnthropicToolChoice","AnthropicOutputConfig","ChatAnthropicOutputFormat","ChatAnthropicToolType","AnthropicMCPServerURLDefinition","Kwargs","AnthropicBeta","AnthropicCacheControl","ChatAnthropicCallOptions","AnthropicInput","Record","Pick","AnthropicMessagesModelId","Model","NonNullable","ChatAnthropicInput","ChatAnthropicMessages","RunOutput","CallOptions","Messages","ToolUnion","Partial","Metadata","OutputConfig","TextBlockParam","ThinkingConfigParam","ToolChoice","AsyncGenerator","MessageCreateParamsNonStreaming","MessageCreateParamsStreaming","Omit","_langchain_core_outputs0","ChatGeneration","StopReason","Usage","Promise","Message","ChatAnthropic"],"sources":["../src/chat_models.d.ts"],"sourcesContent":["import { Anthropic, type ClientOptions } from \"@anthropic-ai/sdk\";\nimport type { Stream } from \"@anthropic-ai/sdk/streaming\";\nimport { CallbackManagerForLLMRun } from \"@langchain/core/callbacks/manager\";\nimport { AIMessageChunk, type BaseMessage } from \"@langchain/core/messages\";\nimport { ChatGenerationChunk, type ChatResult } from \"@langchain/core/outputs\";\nimport { BaseChatModel, BaseChatModelCallOptions, LangSmithParams, type BaseChatModelParams } from \"@langchain/core/language_models/chat_models\";\nimport { type StructuredOutputMethodOptions, type BaseLanguageModelInput } from \"@langchain/core/language_models/base\";\nimport { ModelProfile } from \"@langchain/core/language_models/profile\";\nimport { Runnable } from \"@langchain/core/runnables\";\nimport { InteropZodType } from \"@langchain/core/utils/types\";\nimport { AnthropicContextManagementConfigParam, AnthropicInvocationParams, AnthropicMessageCreateParams, AnthropicMessageStreamEvent, AnthropicRequestOptions, AnthropicStreamingMessageCreateParams, AnthropicThinkingConfigParam, AnthropicToolChoice, AnthropicOutputConfig, ChatAnthropicOutputFormat, ChatAnthropicToolType, AnthropicMCPServerURLDefinition, Kwargs } from \"./types.js\";\nimport { AnthropicBeta } from \"@anthropic-ai/sdk/resources\";\n/**\n * Cache control configuration for Anthropic prompt caching.\n * @see https://docs.anthropic.com/en/docs/build-with-claude/prompt-caching\n */\nexport interface AnthropicCacheControl {\n type: \"ephemeral\";\n ttl?: \"5m\" | \"1h\";\n}\nexport interface ChatAnthropicCallOptions extends BaseChatModelCallOptions, Pick<AnthropicInput, \"streamUsage\"> {\n tools?: ChatAnthropicToolType[];\n /**\n * Whether or not to specify what tool the model should use\n * @default \"auto\"\n */\n tool_choice?: AnthropicToolChoice;\n /**\n * Custom headers to pass to the Anthropic API\n * when making a request.\n */\n headers?: Record<string, string>;\n /**\n * Container ID for file persistence across turns with code execution.\n * Used with the code_execution_20250825 tool.\n */\n container?: string;\n /**\n * @deprecated Use `outputConfig.format` instead. This parameter will be\n * removed in a future release.\n */\n outputFormat?: ChatAnthropicOutputFormat;\n /**\n * Configuration options for the model's output, such as effort level\n * and output format.\n */\n outputConfig?: AnthropicOutputConfig;\n /**\n * Optional array of beta features to enable for the Anthropic API.\n * Beta features are experimental capabilities that may change or be removed.\n * See https://docs.anthropic.com/en/api/versioning for available beta features.\n */\n betas?: AnthropicBeta[];\n /**\n * Array of MCP server URLs to use for the request.\n */\n mcp_servers?: AnthropicMCPServerURLDefinition[];\n /**\n * Specifies the geographic region for inference processing.\n * US-only inference is available at 1.1x pricing for models\n * released after February 1, 2026.\n */\n inferenceGeo?: string;\n /**\n * Cache control configuration for prompt caching.\n * When provided, applies cache_control to the last content block of the\n * last message, enabling Anthropic's prompt caching feature.\n *\n * This is the recommended way to enable prompt caching as it applies\n * cache_control at the final message formatting layer, avoiding issues\n * with message content block manipulation during earlier processing stages.\n *\n * @see https://docs.anthropic.com/en/docs/build-with-claude/prompt-caching\n */\n cache_control?: AnthropicCacheControl;\n}\n/**\n * @see https://docs.anthropic.com/claude/docs/models-overview\n */\nexport type AnthropicMessagesModelId = Anthropic.Model | (string & NonNullable<unknown>);\n/**\n * Input to AnthropicChat class.\n */\nexport interface AnthropicInput {\n /**\n * Amount of randomness injected into the response. Ranges\n * from 0 to 1. Use temperature closer to 0 for analytical /\n * multiple choice, and temperature closer to 1 for creative\n * and generative tasks.\n */\n temperature?: number;\n /**\n * Only sample from the top K options for each subsequent\n * token. Used to remove \"long tail\" low probability\n * responses.\n */\n topK?: number;\n /**\n * Does nucleus sampling, in which we compute the\n * cumulative distribution over all the options for each\n * subsequent token in decreasing probability order and\n * cut it off once it reaches a particular probability\n * specified by top_p. Note that you should either alter\n * temperature or top_p, but not both.\n */\n topP?: number | null;\n /** A maximum number of tokens to generate before stopping. */\n maxTokens?: number;\n /**\n * A list of strings upon which to stop generating.\n * You probably want `[\"\\n\\nHuman:\"]`, as that's the cue for\n * the next turn in the dialog agent.\n */\n stopSequences?: string[];\n /** Whether to stream the results or not */\n streaming?: boolean;\n /** Anthropic API key */\n anthropicApiKey?: string;\n /** Anthropic API key */\n apiKey?: string;\n /** Anthropic API URL */\n anthropicApiUrl?: string;\n /** @deprecated Use \"model\" instead */\n modelName?: AnthropicMessagesModelId;\n /** Model name to use */\n model?: AnthropicMessagesModelId;\n /** Overridable Anthropic ClientOptions */\n clientOptions?: ClientOptions;\n /** Holds any additional parameters that are valid to pass to {@link\n * https://console.anthropic.com/docs/api/reference |\n * `anthropic.messages`} that are not explicitly specified on this class.\n */\n invocationKwargs?: Kwargs;\n /**\n * Whether or not to include token usage data in streamed chunks.\n * @default true\n */\n streamUsage?: boolean;\n /**\n * Optional method that returns an initialized underlying Anthropic client.\n * Useful for accessing Anthropic models hosted on other cloud services\n * such as Google Vertex.\n */\n createClient?: (options: ClientOptions) => any;\n /**\n * Options for extended thinking.\n */\n thinking?: AnthropicThinkingConfigParam;\n /**\n * Configuration for context management. See https://docs.claude.com/en/docs/build-with-claude/context-editing\n */\n contextManagement?: AnthropicContextManagementConfigParam;\n /**\n * Configuration options for the model's output, such as effort level\n * and output format. The effort parameter controls how many tokens Claude\n * uses when responding, trading off between response thoroughness and\n * token efficiency.\n *\n * Effort levels: \"low\", \"medium\", \"high\" (default), \"max\" (Opus 4.6 only).\n *\n * @example\n * ```typescript\n * const model = new ChatAnthropic({\n * model: \"claude-opus-4-6\",\n * thinking: { type: \"adaptive\" },\n * outputConfig: { effort: \"medium\" },\n * });\n * ```\n */\n outputConfig?: AnthropicOutputConfig;\n /**\n * Specifies the geographic region for inference processing.\n * US-only inference is available at 1.1x pricing for models\n * released after February 1, 2026.\n */\n inferenceGeo?: string;\n /**\n * Optional array of beta features to enable for the Anthropic API.\n * Beta features are experimental capabilities that may change or be removed.\n * See https://docs.claude.com/en/api/beta-headers for available beta features.\n */\n betas?: AnthropicBeta[];\n}\n/**\n * Input to ChatAnthropic class.\n */\nexport type ChatAnthropicInput = AnthropicInput & BaseChatModelParams;\n/**\n * Anthropic chat model integration.\n *\n * Setup:\n * Install `@langchain/anthropic` and set an environment variable named `ANTHROPIC_API_KEY`.\n *\n * ```bash\n * npm install @langchain/anthropic\n * export ANTHROPIC_API_KEY=\"your-api-key\"\n * ```\n *\n * ## [Constructor args](https://api.js.langchain.com/classes/langchain_anthropic.ChatAnthropic.html#constructor)\n *\n * ## [Runtime args](https://api.js.langchain.com/interfaces/langchain_anthropic.ChatAnthropicCallOptions.html)\n *\n * Runtime args can be passed as the second argument to any of the base runnable methods `.invoke`. `.stream`, `.batch`, etc.\n * They can also be passed via `.bind`, or the second arg in `.bindTools`, like shown in the examples below:\n *\n * ```typescript\n * // When calling `.bind`, call options should be passed via the first argument\n * const llmWithArgsBound = llm.bindTools([...]).withConfig({\n * stop: [\"\\n\"],\n * });\n *\n * // When calling `.bindTools`, call options should be passed via the second argument\n * const llmWithTools = llm.bindTools(\n * [...],\n * {\n * tool_choice: \"auto\",\n * }\n * );\n * ```\n *\n * ## Examples\n *\n * <details open>\n * <summary><strong>Instantiate</strong></summary>\n *\n * ```typescript\n * import { ChatAnthropic } from '@langchain/anthropic';\n *\n * const llm = new ChatAnthropic({\n * model: \"claude-sonnet-4-5-20250929\",\n * temperature: 0,\n * maxTokens: undefined,\n * maxRetries: 2,\n * // apiKey: \"...\",\n * // baseUrl: \"...\",\n * // other params...\n * });\n * ```\n * </details>\n *\n * <br />\n *\n * <details>\n * <summary><strong>Invoking</strong></summary>\n *\n * ```typescript\n * const input = `Translate \"I love programming\" into French.`;\n *\n * // Models also accept a list of chat messages or a formatted prompt\n * const result = await llm.invoke(input);\n * console.log(result);\n * ```\n *\n * ```txt\n * AIMessage {\n * \"id\": \"msg_01QDpd78JUHpRP6bRRNyzbW3\",\n * \"content\": \"Here's the translation to French:\\n\\nJ'adore la programmation.\",\n * \"response_metadata\": {\n * \"id\": \"msg_01QDpd78JUHpRP6bRRNyzbW3\",\n * \"model\": \"claude-sonnet-4-5-20250929\",\n * \"stop_reason\": \"end_turn\",\n * \"stop_sequence\": null,\n * \"usage\": {\n * \"input_tokens\": 25,\n * \"output_tokens\": 19\n * },\n * \"type\": \"message\",\n * \"role\": \"assistant\"\n * },\n * \"usage_metadata\": {\n * \"input_tokens\": 25,\n * \"output_tokens\": 19,\n * \"total_tokens\": 44\n * }\n * }\n * ```\n * </details>\n *\n * <br />\n *\n * <details>\n * <summary><strong>Streaming Chunks</strong></summary>\n *\n * ```typescript\n * for await (const chunk of await llm.stream(input)) {\n * console.log(chunk);\n * }\n * ```\n *\n * ```txt\n * AIMessageChunk {\n * \"id\": \"msg_01N8MwoYxiKo9w4chE4gXUs4\",\n * \"content\": \"\",\n * \"additional_kwargs\": {\n * \"id\": \"msg_01N8MwoYxiKo9w4chE4gXUs4\",\n * \"type\": \"message\",\n * \"role\": \"assistant\",\n * \"model\": \"claude-sonnet-4-5-20250929\"\n * },\n * \"usage_metadata\": {\n * \"input_tokens\": 25,\n * \"output_tokens\": 1,\n * \"total_tokens\": 26\n * }\n * }\n * AIMessageChunk {\n * \"content\": \"\",\n * }\n * AIMessageChunk {\n * \"content\": \"Here\",\n * }\n * AIMessageChunk {\n * \"content\": \"'s\",\n * }\n * AIMessageChunk {\n * \"content\": \" the translation to\",\n * }\n * AIMessageChunk {\n * \"content\": \" French:\\n\\nJ\",\n * }\n * AIMessageChunk {\n * \"content\": \"'adore la programmation\",\n * }\n * AIMessageChunk {\n * \"content\": \".\",\n * }\n * AIMessageChunk {\n * \"content\": \"\",\n * \"additional_kwargs\": {\n * \"stop_reason\": \"end_turn\",\n * \"stop_sequence\": null\n * },\n * \"usage_metadata\": {\n * \"input_tokens\": 0,\n * \"output_tokens\": 19,\n * \"total_tokens\": 19\n * }\n * }\n * ```\n * </details>\n *\n * <br />\n *\n * <details>\n * <summary><strong>Aggregate Streamed Chunks</strong></summary>\n *\n * ```typescript\n * import { AIMessageChunk } from '@langchain/core/messages';\n * import { concat } from '@langchain/core/utils/stream';\n *\n * const stream = await llm.stream(input);\n * let full: AIMessageChunk | undefined;\n * for await (const chunk of stream) {\n * full = !full ? chunk : concat(full, chunk);\n * }\n * console.log(full);\n * ```\n *\n * ```txt\n * AIMessageChunk {\n * \"id\": \"msg_01SBTb5zSGXfjUc7yQ8EKEEA\",\n * \"content\": \"Here's the translation to French:\\n\\nJ'adore la programmation.\",\n * \"additional_kwargs\": {\n * \"id\": \"msg_01SBTb5zSGXfjUc7yQ8EKEEA\",\n * \"type\": \"message\",\n * \"role\": \"assistant\",\n * \"model\": \"claude-sonnet-4-5-20250929\",\n * \"stop_reason\": \"end_turn\",\n * \"stop_sequence\": null\n * },\n * \"usage_metadata\": {\n * \"input_tokens\": 25,\n * \"output_tokens\": 20,\n * \"total_tokens\": 45\n * }\n * }\n * ```\n * </details>\n *\n * <br />\n *\n * <details>\n * <summary><strong>Bind tools</strong></summary>\n *\n * ```typescript\n * import { z } from 'zod';\n *\n * const GetWeather = {\n * name: \"GetWeather\",\n * description: \"Get the current weather in a given location\",\n * schema: z.object({\n * location: z.string().describe(\"The city and state, e.g. San Francisco, CA\")\n * }),\n * }\n *\n * const GetPopulation = {\n * name: \"GetPopulation\",\n * description: \"Get the current population in a given location\",\n * schema: z.object({\n * location: z.string().describe(\"The city and state, e.g. San Francisco, CA\")\n * }),\n * }\n *\n * const llmWithTools = llm.bindTools([GetWeather, GetPopulation]);\n * const aiMsg = await llmWithTools.invoke(\n * \"Which city is hotter today and which is bigger: LA or NY?\"\n * );\n * console.log(aiMsg.tool_calls);\n * ```\n *\n * ```txt\n * [\n * {\n * name: 'GetWeather',\n * args: { location: 'Los Angeles, CA' },\n * id: 'toolu_01WjW3Dann6BPJVtLhovdBD5',\n * type: 'tool_call'\n * },\n * {\n * name: 'GetWeather',\n * args: { location: 'New York, NY' },\n * id: 'toolu_01G6wfJgqi5zRmJomsmkyZXe',\n * type: 'tool_call'\n * },\n * {\n * name: 'GetPopulation',\n * args: { location: 'Los Angeles, CA' },\n * id: 'toolu_0165qYWBA2VFyUst5RA18zew',\n * type: 'tool_call'\n * },\n * {\n * name: 'GetPopulation',\n * args: { location: 'New York, NY' },\n * id: 'toolu_01PGNyP33vxr13tGqr7i3rDo',\n * type: 'tool_call'\n * }\n * ]\n * ```\n * </details>\n *\n * <br />\n *\n * <details>\n * <summary><strong>Tool Search</strong></summary>\n *\n * Tool search enables Claude to dynamically discover and load tools on-demand\n * instead of loading all tool definitions upfront. This is useful when you have\n * many tools but want to avoid the overhead of sending all definitions with every request.\n *\n * ```typescript\n * import { ChatAnthropic } from \"@langchain/anthropic\";\n *\n * const model = new ChatAnthropic({\n * model: \"claude-sonnet-4-5-20250929\",\n * });\n *\n * const tools = [\n * // Tool search server tool\n * {\n * type: \"tool_search_tool_regex_20251119\",\n * name: \"tool_search_tool_regex\",\n * },\n * // Tools with defer_loading are loaded on-demand\n * {\n * name: \"get_weather\",\n * description: \"Get the current weather for a location\",\n * input_schema: {\n * type: \"object\",\n * properties: {\n * location: { type: \"string\", description: \"City name\" },\n * unit: {\n * type: \"string\",\n * enum: [\"celsius\", \"fahrenheit\"],\n * },\n * },\n * required: [\"location\"],\n * },\n * defer_loading: true, // Tool is loaded on-demand\n * },\n * {\n * name: \"search_files\",\n * description: \"Search through files in the workspace\",\n * input_schema: {\n * type: \"object\",\n * properties: {\n * query: { type: \"string\" },\n * },\n * required: [\"query\"],\n * },\n * defer_loading: true, // Tool is loaded on-demand\n * },\n * ];\n *\n * const modelWithTools = model.bindTools(tools);\n * const response = await modelWithTools.invoke(\"What's the weather in San Francisco?\");\n * ```\n *\n * You can also use the `tool()` helper with the `extras` field:\n *\n * ```typescript\n * import { tool } from \"@langchain/core/tools\";\n * import { z } from \"zod\";\n *\n * const getWeather = tool(\n * async (input) => `Weather in ${input.location}`,\n * {\n * name: \"get_weather\",\n * description: \"Get weather for a location\",\n * schema: z.object({ location: z.string() }),\n * extras: { defer_loading: true },\n * }\n * );\n * ```\n *\n * **Note:** The required `advanced-tool-use-2025-11-20` beta header is automatically\n * appended to the request when using tool search tools.\n *\n * **Best practices:**\n * - Tools with `defer_loading: true` are only loaded when Claude discovers them via search\n * - Keep your 3-5 most frequently used tools as non-deferred for optimal performance\n * - Both regex and bm25 variants search tool names, descriptions, and argument info\n *\n * See the {@link https://platform.claude.com/docs/en/agents-and-tools/tool-use/tool-search-tool | Claude docs}\n * for more information.\n * </details>\n *\n * <br />\n *\n * <details>\n * <summary><strong>Structured Output</strong></summary>\n *\n * ChatAnthropic supports structured output through two main approaches:\n *\n * 1. **Function Calling with `withStructuredOutput()`**: Uses Anthropic's tool calling\n * under the hood to constrain outputs to a specific schema.\n * 2. **JSON Schema Mode**: Uses Anthropic's native JSON schema support for direct\n * structured output without tool calling overhead.\n *\n * **Using withStructuredOutput (Function Calling)**\n *\n * This method leverages Anthropic's tool calling capabilities to ensure the model\n * returns data matching your schema:\n *\n * ```typescript\n * import { z } from 'zod';\n *\n * const Joke = z.object({\n * setup: z.string().describe(\"The setup of the joke\"),\n * punchline: z.string().describe(\"The punchline to the joke\"),\n * rating: z.number().optional().describe(\"How funny the joke is, from 1 to 10\")\n * }).describe('Joke to tell user.');\n *\n * const structuredLlm = llm.withStructuredOutput(Joke, { name: \"Joke\" });\n * const jokeResult = await structuredLlm.invoke(\"Tell me a joke about cats\");\n * console.log(jokeResult);\n * ```\n *\n * ```txt\n * {\n * setup: \"Why don't cats play poker in the jungle?\",\n * punchline: 'Too many cheetahs!',\n * rating: 7\n * }\n * ```\n *\n * **Using JSON Schema Mode**\n *\n * For more direct control, you can use Anthropic's native JSON schema support by\n * passing `method: \"jsonSchema\"`:\n *\n * ```typescript\n * import { z } from 'zod';\n *\n * const RecipeSchema = z.object({\n * recipeName: z.string().describe(\"Name of the recipe\"),\n * ingredients: z.array(z.string()).describe(\"List of ingredients needed\"),\n * steps: z.array(z.string()).describe(\"Cooking steps in order\"),\n * prepTime: z.number().describe(\"Preparation time in minutes\")\n * });\n *\n * const structuredLlm = llm.withStructuredOutput(RecipeSchema, {\n * method: \"jsonSchema\"\n * });\n *\n * const recipe = await structuredLlm.invoke(\n * \"Give me a simple recipe for chocolate chip cookies\"\n * );\n * console.log(recipe);\n * ```\n *\n * ```txt\n * {\n * recipeName: 'Classic Chocolate Chip Cookies',\n * ingredients: [\n * '2 1/4 cups all-purpose flour',\n * '1 cup butter, softened',\n * ...\n * ],\n * steps: [\n * 'Preheat oven to 375°F',\n * 'Mix butter and sugars until creamy',\n * ...\n * ],\n * prepTime: 15\n * }\n * ```\n * </details>\n *\n * <br />\n *\n * <details>\n * <summary><strong>Multimodal</strong></summary>\n *\n * ```typescript\n * import { HumanMessage } from '@langchain/core/messages';\n *\n * const imageUrl = \"https://example.com/image.jpg\";\n * const imageData = await fetch(imageUrl).then(res => res.arrayBuffer());\n * const base64Image = Buffer.from(imageData).toString('base64');\n *\n * const message = new HumanMessage({\n * content: [\n * { type: \"text\", text: \"describe the weather in this image\" },\n * {\n * type: \"image_url\",\n * image_url: { url: `data:image/jpeg;base64,${base64Image}` },\n * },\n * ]\n * });\n *\n * const imageDescriptionAiMsg = await llm.invoke([message]);\n * console.log(imageDescriptionAiMsg.content);\n * ```\n *\n * ```txt\n * The weather in this image appears to be beautiful and clear. The sky is a vibrant blue with scattered white clouds, suggesting a sunny and pleasant day. The clouds are wispy and light, indicating calm conditions without any signs of storms or heavy weather. The bright green grass on the rolling hills looks lush and well-watered, which could mean recent rainfall or good growing conditions. Overall, the scene depicts a perfect spring or early summer day with mild temperatures, plenty of sunshine, and gentle breezes - ideal weather for enjoying the outdoors or for plant growth.\n * ```\n * </details>\n *\n * <br />\n *\n * <details>\n * <summary><strong>Usage Metadata</strong></summary>\n *\n * ```typescript\n * const aiMsgForMetadata = await llm.invoke(input);\n * console.log(aiMsgForMetadata.usage_metadata);\n * ```\n *\n * ```txt\n * { input_tokens: 25, output_tokens: 19, total_tokens: 44 }\n * ```\n * </details>\n *\n * <br />\n *\n * <details>\n * <summary><strong>Stream Usage Metadata</strong></summary>\n *\n * ```typescript\n * const streamForMetadata = await llm.stream(\n * input,\n * {\n * streamUsage: true\n * }\n * );\n * let fullForMetadata: AIMessageChunk | undefined;\n * for await (const chunk of streamForMetadata) {\n * fullForMetadata = !fullForMetadata ? chunk : concat(fullForMetadata, chunk);\n * }\n * console.log(fullForMetadata?.usage_metadata);\n * ```\n *\n * ```txt\n * { input_tokens: 25, output_tokens: 20, total_tokens: 45 }\n * ```\n * </details>\n *\n * <br />\n *\n * <details>\n * <summary><strong>Response Metadata</strong></summary>\n *\n * ```typescript\n * const aiMsgForResponseMetadata = await llm.invoke(input);\n * console.log(aiMsgForResponseMetadata.response_metadata);\n * ```\n *\n * ```txt\n * {\n * id: 'msg_01STxeQxJmp4sCSpioD6vK3L',\n * model: 'claude-sonnet-4-5-20250929',\n * stop_reason: 'end_turn',\n * stop_sequence: null,\n * usage: { input_tokens: 25, output_tokens: 19 },\n * type: 'message',\n * role: 'assistant'\n * }\n * ```\n * </details>\n *\n * <br />\n */\nexport declare class ChatAnthropicMessages<CallOptions extends ChatAnthropicCallOptions = ChatAnthropicCallOptions> extends BaseChatModel<CallOptions, AIMessageChunk> implements AnthropicInput {\n static lc_name(): string;\n get lc_secrets(): {\n [key: string]: string;\n } | undefined;\n get lc_aliases(): Record<string, string>;\n lc_serializable: boolean;\n anthropicApiKey?: string;\n apiKey?: string;\n apiUrl?: string;\n temperature?: number;\n topK?: number;\n topP?: number;\n maxTokens: number;\n modelName: string;\n model: string;\n invocationKwargs?: Kwargs;\n stopSequences?: string[];\n streaming: boolean;\n clientOptions: ClientOptions;\n thinking: AnthropicThinkingConfigParam;\n contextManagement?: AnthropicContextManagementConfigParam;\n outputConfig?: AnthropicOutputConfig;\n inferenceGeo?: string;\n protected batchClient: Anthropic;\n protected streamingClient: Anthropic;\n streamUsage: boolean;\n betas?: AnthropicBeta[];\n /**\n * Optional method that returns an initialized underlying Anthropic client.\n * Useful for accessing Anthropic models hosted on other cloud services\n * such as Google Vertex.\n */\n createClient: (options: ClientOptions) => Anthropic;\n constructor(fields?: ChatAnthropicInput);\n getLsParams(options: this[\"ParsedCallOptions\"]): LangSmithParams;\n /**\n * Formats LangChain StructuredTools to AnthropicTools.\n *\n * @param {ChatAnthropicCallOptions[\"tools\"]} tools The tools to format\n * @returns {AnthropicTool[] | undefined} The formatted tools, or undefined if none are passed.\n */\n formatStructuredToolToAnthropic(tools: ChatAnthropicCallOptions[\"tools\"]): Anthropic.Messages.ToolUnion[] | undefined;\n bindTools(tools: ChatAnthropicToolType[], kwargs?: Partial<CallOptions>): Runnable<BaseLanguageModelInput, AIMessageChunk, CallOptions>;\n /**\n * Get the parameters used to invoke the model\n */\n invocationParams(options?: this[\"ParsedCallOptions\"]): AnthropicInvocationParams;\n /** @ignore */\n _identifyingParams(): {\n max_tokens: number;\n model: Anthropic.Model;\n inference_geo?: string | null | undefined;\n metadata?: Anthropic.Metadata | undefined;\n output_config?: Anthropic.OutputConfig | undefined;\n service_tier?: \"auto\" | \"standard_only\" | undefined;\n stop_sequences?: string[] | undefined;\n system?: string | Anthropic.TextBlockParam[] | undefined;\n temperature?: number | undefined;\n thinking?: Anthropic.ThinkingConfigParam | undefined;\n tool_choice?: Anthropic.ToolChoice | undefined;\n tools?: Anthropic.ToolUnion[] | undefined;\n top_k?: number | undefined;\n top_p?: number | undefined;\n stream?: boolean | undefined;\n model_name: string;\n };\n /**\n * Get the identifying parameters for the model\n */\n identifyingParams(): {\n max_tokens: number;\n model: Anthropic.Model;\n inference_geo?: string | null | undefined;\n metadata?: Anthropic.Metadata | undefined;\n output_config?: Anthropic.OutputConfig | undefined;\n service_tier?: \"auto\" | \"standard_only\" | undefined;\n stop_sequences?: string[] | undefined;\n system?: string | Anthropic.TextBlockParam[] | undefined;\n temperature?: number | undefined;\n thinking?: Anthropic.ThinkingConfigParam | undefined;\n tool_choice?: Anthropic.ToolChoice | undefined;\n tools?: Anthropic.ToolUnion[] | undefined;\n top_k?: number | undefined;\n top_p?: number | undefined;\n stream?: boolean | undefined;\n model_name: string;\n };\n _streamResponseChunks(messages: BaseMessage[], options: this[\"ParsedCallOptions\"], runManager?: CallbackManagerForLLMRun): AsyncGenerator<ChatGenerationChunk>;\n /** @ignore */\n _generateNonStreaming(messages: BaseMessage[], params: Omit<Anthropic.Messages.MessageCreateParamsNonStreaming | Anthropic.Messages.MessageCreateParamsStreaming, \"messages\"> & Kwargs, requestOptions: AnthropicRequestOptions, cacheControl?: {\n type: \"ephemeral\";\n ttl?: \"5m\" | \"1h\";\n }): Promise<{\n generations: import(\"@langchain/core/outputs\").ChatGeneration[];\n llmOutput: {\n id: string;\n model: Anthropic.Model;\n stop_reason: Anthropic.StopReason | null;\n stop_sequence: string | null;\n usage: Anthropic.Usage;\n };\n }>;\n /** @ignore */\n _generate(messages: BaseMessage[], options: this[\"ParsedCallOptions\"], runManager?: CallbackManagerForLLMRun): Promise<ChatResult>;\n /**\n * Creates a streaming request with retry.\n * @param request The parameters for creating a completion.\n * @param options\n * @returns A streaming request.\n */\n protected createStreamWithRetry(request: AnthropicStreamingMessageCreateParams & Kwargs, options?: AnthropicRequestOptions): Promise<Stream<AnthropicMessageStreamEvent>>;\n /** @ignore */\n protected completionWithRetry(request: AnthropicMessageCreateParams & Kwargs, options: AnthropicRequestOptions): Promise<Anthropic.Message>;\n _llmType(): string;\n /**\n * Return profiling information for the model.\n *\n * Provides information about the model's capabilities and constraints,\n * including token limits, multimodal support, and advanced features like\n * tool calling and structured output.\n *\n * @returns {ModelProfile} An object describing the model's capabilities and constraints\n *\n * @example\n * ```typescript\n * const model = new ChatAnthropic({ model: \"claude-opus-4-0\" });\n * const profile = model.profile;\n * console.log(profile.maxInputTokens); // 200000\n * console.log(profile.imageInputs); // true\n * ```\n */\n get profile(): ModelProfile;\n withStructuredOutput<RunOutput extends Record<string, any> = Record<string, any>>(outputSchema: InteropZodType<RunOutput> | Record<string, any>, config?: StructuredOutputMethodOptions<false>): Runnable<BaseLanguageModelInput, RunOutput>;\n withStructuredOutput<RunOutput extends Record<string, any> = Record<string, any>>(outputSchema: InteropZodType<RunOutput> | Record<string, any>, config?: StructuredOutputMethodOptions<true>): Runnable<BaseLanguageModelInput, {\n raw: BaseMessage;\n parsed: RunOutput;\n }>;\n}\nexport declare class ChatAnthropic extends ChatAnthropicMessages {\n}\n//# sourceMappingURL=chat_models.d.ts.map"],"mappings":";;;;;;;;;;;;;;;;;;;AAgBA;AAIiBgC,UAJAD,qBAAAA,CAIwB;EAAwCE,IAAAA,EAAAA,WAAAA;EACrEN,GAAAA,CAAAA,EAAAA,IAAAA,GAAAA,IAAAA;;AAUEO,UAXGF,wBAAAA,SAAiCvB,wBAWpCyB,EAX8DC,IAW9DD,CAXmED,cAWnEC,EAAAA,aAAAA,CAAAA,CAAAA;EAUKR,KAAAA,CAAAA,EApBPC,qBAoBOD,EAAAA;EAKAD;;;;EA1B+BhB,WAAAA,CAAAA,EAMhCe,mBANgCf;EAA0B0B;AAAI;AA2DhF;AAIA;EAwCgBC,OAAAA,CAAAA,EA5FFF,MA4FEE,CAAAA,MAAAA,EAAAA,MAAAA,CAAAA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AAUqC;;eAENrC,WAAAA,CAAU8C;oBACL9C,WAAAA,CAAU+C;;;sBAGR/C,WAAAA,CAAUgD;;eAEjBhD,WAAAA,CAAUiD;kBACPjD,WAAAA,CAAUkD;YAChBlD,WAAAA,CAAU4C;;;;;;;;;;;WAWX5C,WAAAA,CAAUqC;;eAENrC,WAAAA,CAAU8C;oBACL9C,WAAAA,CAAU+C;;;sBAGR/C,WAAAA,CAAUgD;;eAEjBhD,WAAAA,CAAUiD;kBACPjD,WAAAA,CAAUkD;YAChBlD,WAAAA,CAAU4C;;;;;;kCAMUvC,gEAAgEF,2BAA2BgD,eAAe7C;;kCAE1GD,uBAAuBiD,KAAKtD,WAAAA,CAAU2C,QAAAA,CAASS,kCAAkCpD,WAAAA,CAAU2C,QAAAA,CAASU,4CAA4CxB,wBAAwBR;;;MAGpMsC;iBAH2NJ,wBAAAA,CAI5KC,cAAAA;;;aAGpCxD,WAAAA,CAAUqC;mBACJrC,WAAAA,CAAUyD;;aAEhBzD,WAAAA,CAAU0D;;;;sBAILrD,gEAAgEF,2BAA2BwD,QAAQpD;;;;;;;2CAO9Ee,wCAAwCO,kBAAkBR,0BAA0BsC,QAAQzD,OAAOkB;;yCAErGD,+BAA+BU,iBAAiBR,0BAA0BsC,QAAQ3D,WAAAA,CAAU4D;;;;;;;;;;;;;;;;;;;iBAmBpH9C;yCACwBoB,sBAAsBA,mCAAmClB,eAAeyB,aAAaP,8BAA8BtB,uCAAuCG,SAASF,wBAAwB4B;yCAC3LP,sBAAsBA,mCAAmClB,eAAeyB,aAAaP,8BAA8BtB,sCAAsCG,SAASF;SAChMR;YACGoC;;;cAGKoB,aAAAA,SAAsBrB,qBAAqB"}
|
package/dist/chat_models.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AnthropicContextManagementConfigParam, AnthropicInvocationParams, AnthropicMCPServerURLDefinition, AnthropicMessageCreateParams, AnthropicMessageStreamEvent, AnthropicRequestOptions, AnthropicStreamingMessageCreateParams, AnthropicThinkingConfigParam, AnthropicToolChoice, ChatAnthropicOutputFormat, ChatAnthropicToolType, Kwargs } from "./types.js";
|
|
1
|
+
import { AnthropicContextManagementConfigParam, AnthropicInvocationParams, AnthropicMCPServerURLDefinition, AnthropicMessageCreateParams, AnthropicMessageStreamEvent, AnthropicOutputConfig, AnthropicRequestOptions, AnthropicStreamingMessageCreateParams, AnthropicThinkingConfigParam, AnthropicToolChoice, ChatAnthropicOutputFormat, ChatAnthropicToolType, Kwargs } from "./types.js";
|
|
2
2
|
import { Anthropic as Anthropic$1, ClientOptions } from "@anthropic-ai/sdk";
|
|
3
3
|
import { AIMessageChunk, BaseMessage } from "@langchain/core/messages";
|
|
4
4
|
import * as _langchain_core_outputs0 from "@langchain/core/outputs";
|
|
@@ -40,9 +40,15 @@ interface ChatAnthropicCallOptions extends BaseChatModelCallOptions, Pick<Anthro
|
|
|
40
40
|
*/
|
|
41
41
|
container?: string;
|
|
42
42
|
/**
|
|
43
|
-
*
|
|
43
|
+
* @deprecated Use `outputConfig.format` instead. This parameter will be
|
|
44
|
+
* removed in a future release.
|
|
44
45
|
*/
|
|
45
|
-
|
|
46
|
+
outputFormat?: ChatAnthropicOutputFormat;
|
|
47
|
+
/**
|
|
48
|
+
* Configuration options for the model's output, such as effort level
|
|
49
|
+
* and output format.
|
|
50
|
+
*/
|
|
51
|
+
outputConfig?: AnthropicOutputConfig;
|
|
46
52
|
/**
|
|
47
53
|
* Optional array of beta features to enable for the Anthropic API.
|
|
48
54
|
* Beta features are experimental capabilities that may change or be removed.
|
|
@@ -53,6 +59,12 @@ interface ChatAnthropicCallOptions extends BaseChatModelCallOptions, Pick<Anthro
|
|
|
53
59
|
* Array of MCP server URLs to use for the request.
|
|
54
60
|
*/
|
|
55
61
|
mcp_servers?: AnthropicMCPServerURLDefinition[];
|
|
62
|
+
/**
|
|
63
|
+
* Specifies the geographic region for inference processing.
|
|
64
|
+
* US-only inference is available at 1.1x pricing for models
|
|
65
|
+
* released after February 1, 2026.
|
|
66
|
+
*/
|
|
67
|
+
inferenceGeo?: string;
|
|
56
68
|
/**
|
|
57
69
|
* Cache control configuration for prompt caching.
|
|
58
70
|
* When provided, applies cache_control to the last content block of the
|
|
@@ -142,6 +154,30 @@ interface AnthropicInput {
|
|
|
142
154
|
* Configuration for context management. See https://docs.claude.com/en/docs/build-with-claude/context-editing
|
|
143
155
|
*/
|
|
144
156
|
contextManagement?: AnthropicContextManagementConfigParam;
|
|
157
|
+
/**
|
|
158
|
+
* Configuration options for the model's output, such as effort level
|
|
159
|
+
* and output format. The effort parameter controls how many tokens Claude
|
|
160
|
+
* uses when responding, trading off between response thoroughness and
|
|
161
|
+
* token efficiency.
|
|
162
|
+
*
|
|
163
|
+
* Effort levels: "low", "medium", "high" (default), "max" (Opus 4.6 only).
|
|
164
|
+
*
|
|
165
|
+
* @example
|
|
166
|
+
* ```typescript
|
|
167
|
+
* const model = new ChatAnthropic({
|
|
168
|
+
* model: "claude-opus-4-6",
|
|
169
|
+
* thinking: { type: "adaptive" },
|
|
170
|
+
* outputConfig: { effort: "medium" },
|
|
171
|
+
* });
|
|
172
|
+
* ```
|
|
173
|
+
*/
|
|
174
|
+
outputConfig?: AnthropicOutputConfig;
|
|
175
|
+
/**
|
|
176
|
+
* Specifies the geographic region for inference processing.
|
|
177
|
+
* US-only inference is available at 1.1x pricing for models
|
|
178
|
+
* released after February 1, 2026.
|
|
179
|
+
*/
|
|
180
|
+
inferenceGeo?: string;
|
|
145
181
|
/**
|
|
146
182
|
* Optional array of beta features to enable for the Anthropic API.
|
|
147
183
|
* Beta features are experimental capabilities that may change or be removed.
|
|
@@ -691,6 +727,8 @@ declare class ChatAnthropicMessages<CallOptions extends ChatAnthropicCallOptions
|
|
|
691
727
|
clientOptions: ClientOptions;
|
|
692
728
|
thinking: AnthropicThinkingConfigParam;
|
|
693
729
|
contextManagement?: AnthropicContextManagementConfigParam;
|
|
730
|
+
outputConfig?: AnthropicOutputConfig;
|
|
731
|
+
inferenceGeo?: string;
|
|
694
732
|
protected batchClient: Anthropic$1;
|
|
695
733
|
protected streamingClient: Anthropic$1;
|
|
696
734
|
streamUsage: boolean;
|
|
@@ -719,7 +757,9 @@ declare class ChatAnthropicMessages<CallOptions extends ChatAnthropicCallOptions
|
|
|
719
757
|
_identifyingParams(): {
|
|
720
758
|
max_tokens: number;
|
|
721
759
|
model: Anthropic$1.Model;
|
|
760
|
+
inference_geo?: string | null | undefined;
|
|
722
761
|
metadata?: Anthropic$1.Metadata | undefined;
|
|
762
|
+
output_config?: Anthropic$1.OutputConfig | undefined;
|
|
723
763
|
service_tier?: "auto" | "standard_only" | undefined;
|
|
724
764
|
stop_sequences?: string[] | undefined;
|
|
725
765
|
system?: string | Anthropic$1.TextBlockParam[] | undefined;
|
|
@@ -738,7 +778,9 @@ declare class ChatAnthropicMessages<CallOptions extends ChatAnthropicCallOptions
|
|
|
738
778
|
identifyingParams(): {
|
|
739
779
|
max_tokens: number;
|
|
740
780
|
model: Anthropic$1.Model;
|
|
781
|
+
inference_geo?: string | null | undefined;
|
|
741
782
|
metadata?: Anthropic$1.Metadata | undefined;
|
|
783
|
+
output_config?: Anthropic$1.OutputConfig | undefined;
|
|
742
784
|
service_tier?: "auto" | "standard_only" | undefined;
|
|
743
785
|
stop_sequences?: string[] | undefined;
|
|
744
786
|
system?: string | Anthropic$1.TextBlockParam[] | undefined;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chat_models.d.ts","names":["Anthropic","ClientOptions","Stream","CallbackManagerForLLMRun","AIMessageChunk","BaseMessage","ChatGenerationChunk","ChatResult","BaseChatModel","BaseChatModelCallOptions","LangSmithParams","BaseChatModelParams","StructuredOutputMethodOptions","BaseLanguageModelInput","ModelProfile","Runnable","InteropZodType","AnthropicContextManagementConfigParam","AnthropicInvocationParams","AnthropicMessageCreateParams","AnthropicMessageStreamEvent","AnthropicRequestOptions","AnthropicStreamingMessageCreateParams","AnthropicThinkingConfigParam","AnthropicToolChoice","ChatAnthropicOutputFormat","ChatAnthropicToolType","AnthropicMCPServerURLDefinition","Kwargs","AnthropicBeta","AnthropicCacheControl","ChatAnthropicCallOptions","AnthropicInput","Record","Pick","AnthropicMessagesModelId","Model","NonNullable","ChatAnthropicInput","ChatAnthropicMessages","RunOutput","CallOptions","Messages","ToolUnion","Partial","Metadata","TextBlockParam","ThinkingConfigParam","ToolChoice","AsyncGenerator","MessageCreateParamsNonStreaming","MessageCreateParamsStreaming","Omit","_langchain_core_outputs0","ChatGeneration","StopReason","Usage","Promise","Message","ChatAnthropic"],"sources":["../src/chat_models.d.ts"],"sourcesContent":["import { Anthropic, type ClientOptions } from \"@anthropic-ai/sdk\";\nimport type { Stream } from \"@anthropic-ai/sdk/streaming\";\nimport { CallbackManagerForLLMRun } from \"@langchain/core/callbacks/manager\";\nimport { AIMessageChunk, type BaseMessage } from \"@langchain/core/messages\";\nimport { ChatGenerationChunk, type ChatResult } from \"@langchain/core/outputs\";\nimport { BaseChatModel, BaseChatModelCallOptions, LangSmithParams, type BaseChatModelParams } from \"@langchain/core/language_models/chat_models\";\nimport { type StructuredOutputMethodOptions, type BaseLanguageModelInput } from \"@langchain/core/language_models/base\";\nimport { ModelProfile } from \"@langchain/core/language_models/profile\";\nimport { Runnable } from \"@langchain/core/runnables\";\nimport { InteropZodType } from \"@langchain/core/utils/types\";\nimport { AnthropicContextManagementConfigParam, AnthropicInvocationParams, AnthropicMessageCreateParams, AnthropicMessageStreamEvent, AnthropicRequestOptions, AnthropicStreamingMessageCreateParams, AnthropicThinkingConfigParam, AnthropicToolChoice, ChatAnthropicOutputFormat, ChatAnthropicToolType, AnthropicMCPServerURLDefinition, Kwargs } from \"./types.js\";\nimport { AnthropicBeta } from \"@anthropic-ai/sdk/resources\";\n/**\n * Cache control configuration for Anthropic prompt caching.\n * @see https://docs.anthropic.com/en/docs/build-with-claude/prompt-caching\n */\nexport interface AnthropicCacheControl {\n type: \"ephemeral\";\n ttl?: \"5m\" | \"1h\";\n}\nexport interface ChatAnthropicCallOptions extends BaseChatModelCallOptions, Pick<AnthropicInput, \"streamUsage\"> {\n tools?: ChatAnthropicToolType[];\n /**\n * Whether or not to specify what tool the model should use\n * @default \"auto\"\n */\n tool_choice?: AnthropicToolChoice;\n /**\n * Custom headers to pass to the Anthropic API\n * when making a request.\n */\n headers?: Record<string, string>;\n /**\n * Container ID for file persistence across turns with code execution.\n * Used with the code_execution_20250825 tool.\n */\n container?: string;\n /**\n * Output format to use for the response.\n */\n output_format?: ChatAnthropicOutputFormat;\n /**\n * Optional array of beta features to enable for the Anthropic API.\n * Beta features are experimental capabilities that may change or be removed.\n * See https://docs.anthropic.com/en/api/versioning for available beta features.\n */\n betas?: AnthropicBeta[];\n /**\n * Array of MCP server URLs to use for the request.\n */\n mcp_servers?: AnthropicMCPServerURLDefinition[];\n /**\n * Cache control configuration for prompt caching.\n * When provided, applies cache_control to the last content block of the\n * last message, enabling Anthropic's prompt caching feature.\n *\n * This is the recommended way to enable prompt caching as it applies\n * cache_control at the final message formatting layer, avoiding issues\n * with message content block manipulation during earlier processing stages.\n *\n * @see https://docs.anthropic.com/en/docs/build-with-claude/prompt-caching\n */\n cache_control?: AnthropicCacheControl;\n}\n/**\n * @see https://docs.anthropic.com/claude/docs/models-overview\n */\nexport type AnthropicMessagesModelId = Anthropic.Model | (string & NonNullable<unknown>);\n/**\n * Input to AnthropicChat class.\n */\nexport interface AnthropicInput {\n /**\n * Amount of randomness injected into the response. Ranges\n * from 0 to 1. Use temperature closer to 0 for analytical /\n * multiple choice, and temperature closer to 1 for creative\n * and generative tasks.\n */\n temperature?: number;\n /**\n * Only sample from the top K options for each subsequent\n * token. Used to remove \"long tail\" low probability\n * responses.\n */\n topK?: number;\n /**\n * Does nucleus sampling, in which we compute the\n * cumulative distribution over all the options for each\n * subsequent token in decreasing probability order and\n * cut it off once it reaches a particular probability\n * specified by top_p. Note that you should either alter\n * temperature or top_p, but not both.\n */\n topP?: number | null;\n /** A maximum number of tokens to generate before stopping. */\n maxTokens?: number;\n /**\n * A list of strings upon which to stop generating.\n * You probably want `[\"\\n\\nHuman:\"]`, as that's the cue for\n * the next turn in the dialog agent.\n */\n stopSequences?: string[];\n /** Whether to stream the results or not */\n streaming?: boolean;\n /** Anthropic API key */\n anthropicApiKey?: string;\n /** Anthropic API key */\n apiKey?: string;\n /** Anthropic API URL */\n anthropicApiUrl?: string;\n /** @deprecated Use \"model\" instead */\n modelName?: AnthropicMessagesModelId;\n /** Model name to use */\n model?: AnthropicMessagesModelId;\n /** Overridable Anthropic ClientOptions */\n clientOptions?: ClientOptions;\n /** Holds any additional parameters that are valid to pass to {@link\n * https://console.anthropic.com/docs/api/reference |\n * `anthropic.messages`} that are not explicitly specified on this class.\n */\n invocationKwargs?: Kwargs;\n /**\n * Whether or not to include token usage data in streamed chunks.\n * @default true\n */\n streamUsage?: boolean;\n /**\n * Optional method that returns an initialized underlying Anthropic client.\n * Useful for accessing Anthropic models hosted on other cloud services\n * such as Google Vertex.\n */\n createClient?: (options: ClientOptions) => any;\n /**\n * Options for extended thinking.\n */\n thinking?: AnthropicThinkingConfigParam;\n /**\n * Configuration for context management. See https://docs.claude.com/en/docs/build-with-claude/context-editing\n */\n contextManagement?: AnthropicContextManagementConfigParam;\n /**\n * Optional array of beta features to enable for the Anthropic API.\n * Beta features are experimental capabilities that may change or be removed.\n * See https://docs.claude.com/en/api/beta-headers for available beta features.\n */\n betas?: AnthropicBeta[];\n}\n/**\n * Input to ChatAnthropic class.\n */\nexport type ChatAnthropicInput = AnthropicInput & BaseChatModelParams;\n/**\n * Anthropic chat model integration.\n *\n * Setup:\n * Install `@langchain/anthropic` and set an environment variable named `ANTHROPIC_API_KEY`.\n *\n * ```bash\n * npm install @langchain/anthropic\n * export ANTHROPIC_API_KEY=\"your-api-key\"\n * ```\n *\n * ## [Constructor args](https://api.js.langchain.com/classes/langchain_anthropic.ChatAnthropic.html#constructor)\n *\n * ## [Runtime args](https://api.js.langchain.com/interfaces/langchain_anthropic.ChatAnthropicCallOptions.html)\n *\n * Runtime args can be passed as the second argument to any of the base runnable methods `.invoke`. `.stream`, `.batch`, etc.\n * They can also be passed via `.bind`, or the second arg in `.bindTools`, like shown in the examples below:\n *\n * ```typescript\n * // When calling `.bind`, call options should be passed via the first argument\n * const llmWithArgsBound = llm.bindTools([...]).withConfig({\n * stop: [\"\\n\"],\n * });\n *\n * // When calling `.bindTools`, call options should be passed via the second argument\n * const llmWithTools = llm.bindTools(\n * [...],\n * {\n * tool_choice: \"auto\",\n * }\n * );\n * ```\n *\n * ## Examples\n *\n * <details open>\n * <summary><strong>Instantiate</strong></summary>\n *\n * ```typescript\n * import { ChatAnthropic } from '@langchain/anthropic';\n *\n * const llm = new ChatAnthropic({\n * model: \"claude-sonnet-4-5-20250929\",\n * temperature: 0,\n * maxTokens: undefined,\n * maxRetries: 2,\n * // apiKey: \"...\",\n * // baseUrl: \"...\",\n * // other params...\n * });\n * ```\n * </details>\n *\n * <br />\n *\n * <details>\n * <summary><strong>Invoking</strong></summary>\n *\n * ```typescript\n * const input = `Translate \"I love programming\" into French.`;\n *\n * // Models also accept a list of chat messages or a formatted prompt\n * const result = await llm.invoke(input);\n * console.log(result);\n * ```\n *\n * ```txt\n * AIMessage {\n * \"id\": \"msg_01QDpd78JUHpRP6bRRNyzbW3\",\n * \"content\": \"Here's the translation to French:\\n\\nJ'adore la programmation.\",\n * \"response_metadata\": {\n * \"id\": \"msg_01QDpd78JUHpRP6bRRNyzbW3\",\n * \"model\": \"claude-sonnet-4-5-20250929\",\n * \"stop_reason\": \"end_turn\",\n * \"stop_sequence\": null,\n * \"usage\": {\n * \"input_tokens\": 25,\n * \"output_tokens\": 19\n * },\n * \"type\": \"message\",\n * \"role\": \"assistant\"\n * },\n * \"usage_metadata\": {\n * \"input_tokens\": 25,\n * \"output_tokens\": 19,\n * \"total_tokens\": 44\n * }\n * }\n * ```\n * </details>\n *\n * <br />\n *\n * <details>\n * <summary><strong>Streaming Chunks</strong></summary>\n *\n * ```typescript\n * for await (const chunk of await llm.stream(input)) {\n * console.log(chunk);\n * }\n * ```\n *\n * ```txt\n * AIMessageChunk {\n * \"id\": \"msg_01N8MwoYxiKo9w4chE4gXUs4\",\n * \"content\": \"\",\n * \"additional_kwargs\": {\n * \"id\": \"msg_01N8MwoYxiKo9w4chE4gXUs4\",\n * \"type\": \"message\",\n * \"role\": \"assistant\",\n * \"model\": \"claude-sonnet-4-5-20250929\"\n * },\n * \"usage_metadata\": {\n * \"input_tokens\": 25,\n * \"output_tokens\": 1,\n * \"total_tokens\": 26\n * }\n * }\n * AIMessageChunk {\n * \"content\": \"\",\n * }\n * AIMessageChunk {\n * \"content\": \"Here\",\n * }\n * AIMessageChunk {\n * \"content\": \"'s\",\n * }\n * AIMessageChunk {\n * \"content\": \" the translation to\",\n * }\n * AIMessageChunk {\n * \"content\": \" French:\\n\\nJ\",\n * }\n * AIMessageChunk {\n * \"content\": \"'adore la programmation\",\n * }\n * AIMessageChunk {\n * \"content\": \".\",\n * }\n * AIMessageChunk {\n * \"content\": \"\",\n * \"additional_kwargs\": {\n * \"stop_reason\": \"end_turn\",\n * \"stop_sequence\": null\n * },\n * \"usage_metadata\": {\n * \"input_tokens\": 0,\n * \"output_tokens\": 19,\n * \"total_tokens\": 19\n * }\n * }\n * ```\n * </details>\n *\n * <br />\n *\n * <details>\n * <summary><strong>Aggregate Streamed Chunks</strong></summary>\n *\n * ```typescript\n * import { AIMessageChunk } from '@langchain/core/messages';\n * import { concat } from '@langchain/core/utils/stream';\n *\n * const stream = await llm.stream(input);\n * let full: AIMessageChunk | undefined;\n * for await (const chunk of stream) {\n * full = !full ? chunk : concat(full, chunk);\n * }\n * console.log(full);\n * ```\n *\n * ```txt\n * AIMessageChunk {\n * \"id\": \"msg_01SBTb5zSGXfjUc7yQ8EKEEA\",\n * \"content\": \"Here's the translation to French:\\n\\nJ'adore la programmation.\",\n * \"additional_kwargs\": {\n * \"id\": \"msg_01SBTb5zSGXfjUc7yQ8EKEEA\",\n * \"type\": \"message\",\n * \"role\": \"assistant\",\n * \"model\": \"claude-sonnet-4-5-20250929\",\n * \"stop_reason\": \"end_turn\",\n * \"stop_sequence\": null\n * },\n * \"usage_metadata\": {\n * \"input_tokens\": 25,\n * \"output_tokens\": 20,\n * \"total_tokens\": 45\n * }\n * }\n * ```\n * </details>\n *\n * <br />\n *\n * <details>\n * <summary><strong>Bind tools</strong></summary>\n *\n * ```typescript\n * import { z } from 'zod';\n *\n * const GetWeather = {\n * name: \"GetWeather\",\n * description: \"Get the current weather in a given location\",\n * schema: z.object({\n * location: z.string().describe(\"The city and state, e.g. San Francisco, CA\")\n * }),\n * }\n *\n * const GetPopulation = {\n * name: \"GetPopulation\",\n * description: \"Get the current population in a given location\",\n * schema: z.object({\n * location: z.string().describe(\"The city and state, e.g. San Francisco, CA\")\n * }),\n * }\n *\n * const llmWithTools = llm.bindTools([GetWeather, GetPopulation]);\n * const aiMsg = await llmWithTools.invoke(\n * \"Which city is hotter today and which is bigger: LA or NY?\"\n * );\n * console.log(aiMsg.tool_calls);\n * ```\n *\n * ```txt\n * [\n * {\n * name: 'GetWeather',\n * args: { location: 'Los Angeles, CA' },\n * id: 'toolu_01WjW3Dann6BPJVtLhovdBD5',\n * type: 'tool_call'\n * },\n * {\n * name: 'GetWeather',\n * args: { location: 'New York, NY' },\n * id: 'toolu_01G6wfJgqi5zRmJomsmkyZXe',\n * type: 'tool_call'\n * },\n * {\n * name: 'GetPopulation',\n * args: { location: 'Los Angeles, CA' },\n * id: 'toolu_0165qYWBA2VFyUst5RA18zew',\n * type: 'tool_call'\n * },\n * {\n * name: 'GetPopulation',\n * args: { location: 'New York, NY' },\n * id: 'toolu_01PGNyP33vxr13tGqr7i3rDo',\n * type: 'tool_call'\n * }\n * ]\n * ```\n * </details>\n *\n * <br />\n *\n * <details>\n * <summary><strong>Tool Search</strong></summary>\n *\n * Tool search enables Claude to dynamically discover and load tools on-demand\n * instead of loading all tool definitions upfront. This is useful when you have\n * many tools but want to avoid the overhead of sending all definitions with every request.\n *\n * ```typescript\n * import { ChatAnthropic } from \"@langchain/anthropic\";\n *\n * const model = new ChatAnthropic({\n * model: \"claude-sonnet-4-5-20250929\",\n * });\n *\n * const tools = [\n * // Tool search server tool\n * {\n * type: \"tool_search_tool_regex_20251119\",\n * name: \"tool_search_tool_regex\",\n * },\n * // Tools with defer_loading are loaded on-demand\n * {\n * name: \"get_weather\",\n * description: \"Get the current weather for a location\",\n * input_schema: {\n * type: \"object\",\n * properties: {\n * location: { type: \"string\", description: \"City name\" },\n * unit: {\n * type: \"string\",\n * enum: [\"celsius\", \"fahrenheit\"],\n * },\n * },\n * required: [\"location\"],\n * },\n * defer_loading: true, // Tool is loaded on-demand\n * },\n * {\n * name: \"search_files\",\n * description: \"Search through files in the workspace\",\n * input_schema: {\n * type: \"object\",\n * properties: {\n * query: { type: \"string\" },\n * },\n * required: [\"query\"],\n * },\n * defer_loading: true, // Tool is loaded on-demand\n * },\n * ];\n *\n * const modelWithTools = model.bindTools(tools);\n * const response = await modelWithTools.invoke(\"What's the weather in San Francisco?\");\n * ```\n *\n * You can also use the `tool()` helper with the `extras` field:\n *\n * ```typescript\n * import { tool } from \"@langchain/core/tools\";\n * import { z } from \"zod\";\n *\n * const getWeather = tool(\n * async (input) => `Weather in ${input.location}`,\n * {\n * name: \"get_weather\",\n * description: \"Get weather for a location\",\n * schema: z.object({ location: z.string() }),\n * extras: { defer_loading: true },\n * }\n * );\n * ```\n *\n * **Note:** The required `advanced-tool-use-2025-11-20` beta header is automatically\n * appended to the request when using tool search tools.\n *\n * **Best practices:**\n * - Tools with `defer_loading: true` are only loaded when Claude discovers them via search\n * - Keep your 3-5 most frequently used tools as non-deferred for optimal performance\n * - Both regex and bm25 variants search tool names, descriptions, and argument info\n *\n * See the {@link https://platform.claude.com/docs/en/agents-and-tools/tool-use/tool-search-tool | Claude docs}\n * for more information.\n * </details>\n *\n * <br />\n *\n * <details>\n * <summary><strong>Structured Output</strong></summary>\n *\n * ChatAnthropic supports structured output through two main approaches:\n *\n * 1. **Function Calling with `withStructuredOutput()`**: Uses Anthropic's tool calling\n * under the hood to constrain outputs to a specific schema.\n * 2. **JSON Schema Mode**: Uses Anthropic's native JSON schema support for direct\n * structured output without tool calling overhead.\n *\n * **Using withStructuredOutput (Function Calling)**\n *\n * This method leverages Anthropic's tool calling capabilities to ensure the model\n * returns data matching your schema:\n *\n * ```typescript\n * import { z } from 'zod';\n *\n * const Joke = z.object({\n * setup: z.string().describe(\"The setup of the joke\"),\n * punchline: z.string().describe(\"The punchline to the joke\"),\n * rating: z.number().optional().describe(\"How funny the joke is, from 1 to 10\")\n * }).describe('Joke to tell user.');\n *\n * const structuredLlm = llm.withStructuredOutput(Joke, { name: \"Joke\" });\n * const jokeResult = await structuredLlm.invoke(\"Tell me a joke about cats\");\n * console.log(jokeResult);\n * ```\n *\n * ```txt\n * {\n * setup: \"Why don't cats play poker in the jungle?\",\n * punchline: 'Too many cheetahs!',\n * rating: 7\n * }\n * ```\n *\n * **Using JSON Schema Mode**\n *\n * For more direct control, you can use Anthropic's native JSON schema support by\n * passing `method: \"jsonSchema\"`:\n *\n * ```typescript\n * import { z } from 'zod';\n *\n * const RecipeSchema = z.object({\n * recipeName: z.string().describe(\"Name of the recipe\"),\n * ingredients: z.array(z.string()).describe(\"List of ingredients needed\"),\n * steps: z.array(z.string()).describe(\"Cooking steps in order\"),\n * prepTime: z.number().describe(\"Preparation time in minutes\")\n * });\n *\n * const structuredLlm = llm.withStructuredOutput(RecipeSchema, {\n * method: \"jsonSchema\"\n * });\n *\n * const recipe = await structuredLlm.invoke(\n * \"Give me a simple recipe for chocolate chip cookies\"\n * );\n * console.log(recipe);\n * ```\n *\n * ```txt\n * {\n * recipeName: 'Classic Chocolate Chip Cookies',\n * ingredients: [\n * '2 1/4 cups all-purpose flour',\n * '1 cup butter, softened',\n * ...\n * ],\n * steps: [\n * 'Preheat oven to 375°F',\n * 'Mix butter and sugars until creamy',\n * ...\n * ],\n * prepTime: 15\n * }\n * ```\n * </details>\n *\n * <br />\n *\n * <details>\n * <summary><strong>Multimodal</strong></summary>\n *\n * ```typescript\n * import { HumanMessage } from '@langchain/core/messages';\n *\n * const imageUrl = \"https://example.com/image.jpg\";\n * const imageData = await fetch(imageUrl).then(res => res.arrayBuffer());\n * const base64Image = Buffer.from(imageData).toString('base64');\n *\n * const message = new HumanMessage({\n * content: [\n * { type: \"text\", text: \"describe the weather in this image\" },\n * {\n * type: \"image_url\",\n * image_url: { url: `data:image/jpeg;base64,${base64Image}` },\n * },\n * ]\n * });\n *\n * const imageDescriptionAiMsg = await llm.invoke([message]);\n * console.log(imageDescriptionAiMsg.content);\n * ```\n *\n * ```txt\n * The weather in this image appears to be beautiful and clear. The sky is a vibrant blue with scattered white clouds, suggesting a sunny and pleasant day. The clouds are wispy and light, indicating calm conditions without any signs of storms or heavy weather. The bright green grass on the rolling hills looks lush and well-watered, which could mean recent rainfall or good growing conditions. Overall, the scene depicts a perfect spring or early summer day with mild temperatures, plenty of sunshine, and gentle breezes - ideal weather for enjoying the outdoors or for plant growth.\n * ```\n * </details>\n *\n * <br />\n *\n * <details>\n * <summary><strong>Usage Metadata</strong></summary>\n *\n * ```typescript\n * const aiMsgForMetadata = await llm.invoke(input);\n * console.log(aiMsgForMetadata.usage_metadata);\n * ```\n *\n * ```txt\n * { input_tokens: 25, output_tokens: 19, total_tokens: 44 }\n * ```\n * </details>\n *\n * <br />\n *\n * <details>\n * <summary><strong>Stream Usage Metadata</strong></summary>\n *\n * ```typescript\n * const streamForMetadata = await llm.stream(\n * input,\n * {\n * streamUsage: true\n * }\n * );\n * let fullForMetadata: AIMessageChunk | undefined;\n * for await (const chunk of streamForMetadata) {\n * fullForMetadata = !fullForMetadata ? chunk : concat(fullForMetadata, chunk);\n * }\n * console.log(fullForMetadata?.usage_metadata);\n * ```\n *\n * ```txt\n * { input_tokens: 25, output_tokens: 20, total_tokens: 45 }\n * ```\n * </details>\n *\n * <br />\n *\n * <details>\n * <summary><strong>Response Metadata</strong></summary>\n *\n * ```typescript\n * const aiMsgForResponseMetadata = await llm.invoke(input);\n * console.log(aiMsgForResponseMetadata.response_metadata);\n * ```\n *\n * ```txt\n * {\n * id: 'msg_01STxeQxJmp4sCSpioD6vK3L',\n * model: 'claude-sonnet-4-5-20250929',\n * stop_reason: 'end_turn',\n * stop_sequence: null,\n * usage: { input_tokens: 25, output_tokens: 19 },\n * type: 'message',\n * role: 'assistant'\n * }\n * ```\n * </details>\n *\n * <br />\n */\nexport declare class ChatAnthropicMessages<CallOptions extends ChatAnthropicCallOptions = ChatAnthropicCallOptions> extends BaseChatModel<CallOptions, AIMessageChunk> implements AnthropicInput {\n static lc_name(): string;\n get lc_secrets(): {\n [key: string]: string;\n } | undefined;\n get lc_aliases(): Record<string, string>;\n lc_serializable: boolean;\n anthropicApiKey?: string;\n apiKey?: string;\n apiUrl?: string;\n temperature?: number;\n topK?: number;\n topP?: number;\n maxTokens: number;\n modelName: string;\n model: string;\n invocationKwargs?: Kwargs;\n stopSequences?: string[];\n streaming: boolean;\n clientOptions: ClientOptions;\n thinking: AnthropicThinkingConfigParam;\n contextManagement?: AnthropicContextManagementConfigParam;\n protected batchClient: Anthropic;\n protected streamingClient: Anthropic;\n streamUsage: boolean;\n betas?: AnthropicBeta[];\n /**\n * Optional method that returns an initialized underlying Anthropic client.\n * Useful for accessing Anthropic models hosted on other cloud services\n * such as Google Vertex.\n */\n createClient: (options: ClientOptions) => Anthropic;\n constructor(fields?: ChatAnthropicInput);\n getLsParams(options: this[\"ParsedCallOptions\"]): LangSmithParams;\n /**\n * Formats LangChain StructuredTools to AnthropicTools.\n *\n * @param {ChatAnthropicCallOptions[\"tools\"]} tools The tools to format\n * @returns {AnthropicTool[] | undefined} The formatted tools, or undefined if none are passed.\n */\n formatStructuredToolToAnthropic(tools: ChatAnthropicCallOptions[\"tools\"]): Anthropic.Messages.ToolUnion[] | undefined;\n bindTools(tools: ChatAnthropicToolType[], kwargs?: Partial<CallOptions>): Runnable<BaseLanguageModelInput, AIMessageChunk, CallOptions>;\n /**\n * Get the parameters used to invoke the model\n */\n invocationParams(options?: this[\"ParsedCallOptions\"]): AnthropicInvocationParams;\n /** @ignore */\n _identifyingParams(): {\n max_tokens: number;\n model: Anthropic.Model;\n metadata?: Anthropic.Metadata | undefined;\n service_tier?: \"auto\" | \"standard_only\" | undefined;\n stop_sequences?: string[] | undefined;\n system?: string | Anthropic.TextBlockParam[] | undefined;\n temperature?: number | undefined;\n thinking?: Anthropic.ThinkingConfigParam | undefined;\n tool_choice?: Anthropic.ToolChoice | undefined;\n tools?: Anthropic.ToolUnion[] | undefined;\n top_k?: number | undefined;\n top_p?: number | undefined;\n stream?: boolean | undefined;\n model_name: string;\n };\n /**\n * Get the identifying parameters for the model\n */\n identifyingParams(): {\n max_tokens: number;\n model: Anthropic.Model;\n metadata?: Anthropic.Metadata | undefined;\n service_tier?: \"auto\" | \"standard_only\" | undefined;\n stop_sequences?: string[] | undefined;\n system?: string | Anthropic.TextBlockParam[] | undefined;\n temperature?: number | undefined;\n thinking?: Anthropic.ThinkingConfigParam | undefined;\n tool_choice?: Anthropic.ToolChoice | undefined;\n tools?: Anthropic.ToolUnion[] | undefined;\n top_k?: number | undefined;\n top_p?: number | undefined;\n stream?: boolean | undefined;\n model_name: string;\n };\n _streamResponseChunks(messages: BaseMessage[], options: this[\"ParsedCallOptions\"], runManager?: CallbackManagerForLLMRun): AsyncGenerator<ChatGenerationChunk>;\n /** @ignore */\n _generateNonStreaming(messages: BaseMessage[], params: Omit<Anthropic.Messages.MessageCreateParamsNonStreaming | Anthropic.Messages.MessageCreateParamsStreaming, \"messages\"> & Kwargs, requestOptions: AnthropicRequestOptions, cacheControl?: {\n type: \"ephemeral\";\n ttl?: \"5m\" | \"1h\";\n }): Promise<{\n generations: import(\"@langchain/core/outputs\").ChatGeneration[];\n llmOutput: {\n id: string;\n model: Anthropic.Model;\n stop_reason: Anthropic.StopReason | null;\n stop_sequence: string | null;\n usage: Anthropic.Usage;\n };\n }>;\n /** @ignore */\n _generate(messages: BaseMessage[], options: this[\"ParsedCallOptions\"], runManager?: CallbackManagerForLLMRun): Promise<ChatResult>;\n /**\n * Creates a streaming request with retry.\n * @param request The parameters for creating a completion.\n * @param options\n * @returns A streaming request.\n */\n protected createStreamWithRetry(request: AnthropicStreamingMessageCreateParams & Kwargs, options?: AnthropicRequestOptions): Promise<Stream<AnthropicMessageStreamEvent>>;\n /** @ignore */\n protected completionWithRetry(request: AnthropicMessageCreateParams & Kwargs, options: AnthropicRequestOptions): Promise<Anthropic.Message>;\n _llmType(): string;\n /**\n * Return profiling information for the model.\n *\n * Provides information about the model's capabilities and constraints,\n * including token limits, multimodal support, and advanced features like\n * tool calling and structured output.\n *\n * @returns {ModelProfile} An object describing the model's capabilities and constraints\n *\n * @example\n * ```typescript\n * const model = new ChatAnthropic({ model: \"claude-opus-4-0\" });\n * const profile = model.profile;\n * console.log(profile.maxInputTokens); // 200000\n * console.log(profile.imageInputs); // true\n * ```\n */\n get profile(): ModelProfile;\n withStructuredOutput<RunOutput extends Record<string, any> = Record<string, any>>(outputSchema: InteropZodType<RunOutput> | Record<string, any>, config?: StructuredOutputMethodOptions<false>): Runnable<BaseLanguageModelInput, RunOutput>;\n withStructuredOutput<RunOutput extends Record<string, any> = Record<string, any>>(outputSchema: InteropZodType<RunOutput> | Record<string, any>, config?: StructuredOutputMethodOptions<true>): Runnable<BaseLanguageModelInput, {\n raw: BaseMessage;\n parsed: RunOutput;\n }>;\n}\nexport declare class ChatAnthropic extends ChatAnthropicMessages {\n}\n//# sourceMappingURL=chat_models.d.ts.map"],"mappings":";;;;;;;;;;;;;;;;;;;AAgBA;AAIiB+B,UAJAD,qBAAAA,CAIwB;EAAwCE,IAAAA,EAAAA,WAAAA;EACrEN,GAAAA,CAAAA,EAAAA,IAAAA,GAAAA,IAAAA;;AAUEO,UAXGF,wBAAAA,SAAiCtB,wBAWpCwB,EAX8DC,IAW9DD,CAXmED,cAWnEC,EAAAA,aAAAA,CAAAA,CAAA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ChatResult","BaseChatModel","BaseChatModelCallOptions","LangSmithParams","BaseChatModelParams","StructuredOutputMethodOptions","BaseLanguageModelInput","ModelProfile","Runnable","InteropZodType","AnthropicContextManagementConfigParam","AnthropicInvocationParams","AnthropicMessageCreateParams","AnthropicMessageStreamEvent","AnthropicRequestOptions","AnthropicStreamingMessageCreateParams","AnthropicThinkingConfigParam","AnthropicToolChoice","AnthropicOutputConfig","ChatAnthropicOutputFormat","ChatAnthropicToolType","AnthropicMCPServerURLDefinition","Kwargs","AnthropicBeta","AnthropicCacheControl","ChatAnthropicCallOptions","AnthropicInput","Record","Pick","AnthropicMessagesModelId","Model","NonNullable","ChatAnthropicInput","ChatAnthropicMessages","RunOutput","CallOptions","Messages","ToolUnion","Partial","Metadata","OutputConfig","TextBlockParam","ThinkingConfigParam","ToolChoice","AsyncGenerator","MessageCreateParamsNonStreaming","MessageCreateParamsStreaming","Omit","_langchain_core_outputs0","ChatGeneration","StopReason","Usage","Promise","Message","ChatAnthropic"],"sources":["../src/chat_models.d.ts"],"sourcesContent":["import { Anthropic, type ClientOptions } from \"@anthropic-ai/sdk\";\nimport type { Stream } from \"@anthropic-ai/sdk/streaming\";\nimport { CallbackManagerForLLMRun } from \"@langchain/core/callbacks/manager\";\nimport { AIMessageChunk, type BaseMessage } from \"@langchain/core/messages\";\nimport { ChatGenerationChunk, type ChatResult } from \"@langchain/core/outputs\";\nimport { BaseChatModel, BaseChatModelCallOptions, LangSmithParams, type BaseChatModelParams } from \"@langchain/core/language_models/chat_models\";\nimport { type StructuredOutputMethodOptions, type BaseLanguageModelInput } from \"@langchain/core/language_models/base\";\nimport { ModelProfile } from \"@langchain/core/language_models/profile\";\nimport { Runnable } from \"@langchain/core/runnables\";\nimport { InteropZodType } from \"@langchain/core/utils/types\";\nimport { AnthropicContextManagementConfigParam, AnthropicInvocationParams, AnthropicMessageCreateParams, AnthropicMessageStreamEvent, AnthropicRequestOptions, AnthropicStreamingMessageCreateParams, AnthropicThinkingConfigParam, AnthropicToolChoice, AnthropicOutputConfig, ChatAnthropicOutputFormat, ChatAnthropicToolType, AnthropicMCPServerURLDefinition, Kwargs } from \"./types.js\";\nimport { AnthropicBeta } from \"@anthropic-ai/sdk/resources\";\n/**\n * Cache control configuration for Anthropic prompt caching.\n * @see https://docs.anthropic.com/en/docs/build-with-claude/prompt-caching\n */\nexport interface AnthropicCacheControl {\n type: \"ephemeral\";\n ttl?: \"5m\" | \"1h\";\n}\nexport interface ChatAnthropicCallOptions extends BaseChatModelCallOptions, Pick<AnthropicInput, \"streamUsage\"> {\n tools?: ChatAnthropicToolType[];\n /**\n * Whether or not to specify what tool the model should use\n * @default \"auto\"\n */\n tool_choice?: AnthropicToolChoice;\n /**\n * Custom headers to pass to the Anthropic API\n * when making a request.\n */\n headers?: Record<string, string>;\n /**\n * Container ID for file persistence across turns with code execution.\n * Used with the code_execution_20250825 tool.\n */\n container?: string;\n /**\n * @deprecated Use `outputConfig.format` instead. This parameter will be\n * removed in a future release.\n */\n outputFormat?: ChatAnthropicOutputFormat;\n /**\n * Configuration options for the model's output, such as effort level\n * and output format.\n */\n outputConfig?: AnthropicOutputConfig;\n /**\n * Optional array of beta features to enable for the Anthropic API.\n * Beta features are experimental capabilities that may change or be removed.\n * See https://docs.anthropic.com/en/api/versioning for available beta features.\n */\n betas?: AnthropicBeta[];\n /**\n * Array of MCP server URLs to use for the request.\n */\n mcp_servers?: AnthropicMCPServerURLDefinition[];\n /**\n * Specifies the geographic region for inference processing.\n * US-only inference is available at 1.1x pricing for models\n * released after February 1, 2026.\n */\n inferenceGeo?: string;\n /**\n * Cache control configuration for prompt caching.\n * When provided, applies cache_control to the last content block of the\n * last message, enabling Anthropic's prompt caching feature.\n *\n * This is the recommended way to enable prompt caching as it applies\n * cache_control at the final message formatting layer, avoiding issues\n * with message content block manipulation during earlier processing stages.\n *\n * @see https://docs.anthropic.com/en/docs/build-with-claude/prompt-caching\n */\n cache_control?: AnthropicCacheControl;\n}\n/**\n * @see https://docs.anthropic.com/claude/docs/models-overview\n */\nexport type AnthropicMessagesModelId = Anthropic.Model | (string & NonNullable<unknown>);\n/**\n * Input to AnthropicChat class.\n */\nexport interface AnthropicInput {\n /**\n * Amount of randomness injected into the response. Ranges\n * from 0 to 1. Use temperature closer to 0 for analytical /\n * multiple choice, and temperature closer to 1 for creative\n * and generative tasks.\n */\n temperature?: number;\n /**\n * Only sample from the top K options for each subsequent\n * token. Used to remove \"long tail\" low probability\n * responses.\n */\n topK?: number;\n /**\n * Does nucleus sampling, in which we compute the\n * cumulative distribution over all the options for each\n * subsequent token in decreasing probability order and\n * cut it off once it reaches a particular probability\n * specified by top_p. Note that you should either alter\n * temperature or top_p, but not both.\n */\n topP?: number | null;\n /** A maximum number of tokens to generate before stopping. */\n maxTokens?: number;\n /**\n * A list of strings upon which to stop generating.\n * You probably want `[\"\\n\\nHuman:\"]`, as that's the cue for\n * the next turn in the dialog agent.\n */\n stopSequences?: string[];\n /** Whether to stream the results or not */\n streaming?: boolean;\n /** Anthropic API key */\n anthropicApiKey?: string;\n /** Anthropic API key */\n apiKey?: string;\n /** Anthropic API URL */\n anthropicApiUrl?: string;\n /** @deprecated Use \"model\" instead */\n modelName?: AnthropicMessagesModelId;\n /** Model name to use */\n model?: AnthropicMessagesModelId;\n /** Overridable Anthropic ClientOptions */\n clientOptions?: ClientOptions;\n /** Holds any additional parameters that are valid to pass to {@link\n * https://console.anthropic.com/docs/api/reference |\n * `anthropic.messages`} that are not explicitly specified on this class.\n */\n invocationKwargs?: Kwargs;\n /**\n * Whether or not to include token usage data in streamed chunks.\n * @default true\n */\n streamUsage?: boolean;\n /**\n * Optional method that returns an initialized underlying Anthropic client.\n * Useful for accessing Anthropic models hosted on other cloud services\n * such as Google Vertex.\n */\n createClient?: (options: ClientOptions) => any;\n /**\n * Options for extended thinking.\n */\n thinking?: AnthropicThinkingConfigParam;\n /**\n * Configuration for context management. See https://docs.claude.com/en/docs/build-with-claude/context-editing\n */\n contextManagement?: AnthropicContextManagementConfigParam;\n /**\n * Configuration options for the model's output, such as effort level\n * and output format. The effort parameter controls how many tokens Claude\n * uses when responding, trading off between response thoroughness and\n * token efficiency.\n *\n * Effort levels: \"low\", \"medium\", \"high\" (default), \"max\" (Opus 4.6 only).\n *\n * @example\n * ```typescript\n * const model = new ChatAnthropic({\n * model: \"claude-opus-4-6\",\n * thinking: { type: \"adaptive\" },\n * outputConfig: { effort: \"medium\" },\n * });\n * ```\n */\n outputConfig?: AnthropicOutputConfig;\n /**\n * Specifies the geographic region for inference processing.\n * US-only inference is available at 1.1x pricing for models\n * released after February 1, 2026.\n */\n inferenceGeo?: string;\n /**\n * Optional array of beta features to enable for the Anthropic API.\n * Beta features are experimental capabilities that may change or be removed.\n * See https://docs.claude.com/en/api/beta-headers for available beta features.\n */\n betas?: AnthropicBeta[];\n}\n/**\n * Input to ChatAnthropic class.\n */\nexport type ChatAnthropicInput = AnthropicInput & BaseChatModelParams;\n/**\n * Anthropic chat model integration.\n *\n * Setup:\n * Install `@langchain/anthropic` and set an environment variable named `ANTHROPIC_API_KEY`.\n *\n * ```bash\n * npm install @langchain/anthropic\n * export ANTHROPIC_API_KEY=\"your-api-key\"\n * ```\n *\n * ## [Constructor args](https://api.js.langchain.com/classes/langchain_anthropic.ChatAnthropic.html#constructor)\n *\n * ## [Runtime args](https://api.js.langchain.com/interfaces/langchain_anthropic.ChatAnthropicCallOptions.html)\n *\n * Runtime args can be passed as the second argument to any of the base runnable methods `.invoke`. `.stream`, `.batch`, etc.\n * They can also be passed via `.bind`, or the second arg in `.bindTools`, like shown in the examples below:\n *\n * ```typescript\n * // When calling `.bind`, call options should be passed via the first argument\n * const llmWithArgsBound = llm.bindTools([...]).withConfig({\n * stop: [\"\\n\"],\n * });\n *\n * // When calling `.bindTools`, call options should be passed via the second argument\n * const llmWithTools = llm.bindTools(\n * [...],\n * {\n * tool_choice: \"auto\",\n * }\n * );\n * ```\n *\n * ## Examples\n *\n * <details open>\n * <summary><strong>Instantiate</strong></summary>\n *\n * ```typescript\n * import { ChatAnthropic } from '@langchain/anthropic';\n *\n * const llm = new ChatAnthropic({\n * model: \"claude-sonnet-4-5-20250929\",\n * temperature: 0,\n * maxTokens: undefined,\n * maxRetries: 2,\n * // apiKey: \"...\",\n * // baseUrl: \"...\",\n * // other params...\n * });\n * ```\n * </details>\n *\n * <br />\n *\n * <details>\n * <summary><strong>Invoking</strong></summary>\n *\n * ```typescript\n * const input = `Translate \"I love programming\" into French.`;\n *\n * // Models also accept a list of chat messages or a formatted prompt\n * const result = await llm.invoke(input);\n * console.log(result);\n * ```\n *\n * ```txt\n * AIMessage {\n * \"id\": \"msg_01QDpd78JUHpRP6bRRNyzbW3\",\n * \"content\": \"Here's the translation to French:\\n\\nJ'adore la programmation.\",\n * \"response_metadata\": {\n * \"id\": \"msg_01QDpd78JUHpRP6bRRNyzbW3\",\n * \"model\": \"claude-sonnet-4-5-20250929\",\n * \"stop_reason\": \"end_turn\",\n * \"stop_sequence\": null,\n * \"usage\": {\n * \"input_tokens\": 25,\n * \"output_tokens\": 19\n * },\n * \"type\": \"message\",\n * \"role\": \"assistant\"\n * },\n * \"usage_metadata\": {\n * \"input_tokens\": 25,\n * \"output_tokens\": 19,\n * \"total_tokens\": 44\n * }\n * }\n * ```\n * </details>\n *\n * <br />\n *\n * <details>\n * <summary><strong>Streaming Chunks</strong></summary>\n *\n * ```typescript\n * for await (const chunk of await llm.stream(input)) {\n * console.log(chunk);\n * }\n * ```\n *\n * ```txt\n * AIMessageChunk {\n * \"id\": \"msg_01N8MwoYxiKo9w4chE4gXUs4\",\n * \"content\": \"\",\n * \"additional_kwargs\": {\n * \"id\": \"msg_01N8MwoYxiKo9w4chE4gXUs4\",\n * \"type\": \"message\",\n * \"role\": \"assistant\",\n * \"model\": \"claude-sonnet-4-5-20250929\"\n * },\n * \"usage_metadata\": {\n * \"input_tokens\": 25,\n * \"output_tokens\": 1,\n * \"total_tokens\": 26\n * }\n * }\n * AIMessageChunk {\n * \"content\": \"\",\n * }\n * AIMessageChunk {\n * \"content\": \"Here\",\n * }\n * AIMessageChunk {\n * \"content\": \"'s\",\n * }\n * AIMessageChunk {\n * \"content\": \" the translation to\",\n * }\n * AIMessageChunk {\n * \"content\": \" French:\\n\\nJ\",\n * }\n * AIMessageChunk {\n * \"content\": \"'adore la programmation\",\n * }\n * AIMessageChunk {\n * \"content\": \".\",\n * }\n * AIMessageChunk {\n * \"content\": \"\",\n * \"additional_kwargs\": {\n * \"stop_reason\": \"end_turn\",\n * \"stop_sequence\": null\n * },\n * \"usage_metadata\": {\n * \"input_tokens\": 0,\n * \"output_tokens\": 19,\n * \"total_tokens\": 19\n * }\n * }\n * ```\n * </details>\n *\n * <br />\n *\n * <details>\n * <summary><strong>Aggregate Streamed Chunks</strong></summary>\n *\n * ```typescript\n * import { AIMessageChunk } from '@langchain/core/messages';\n * import { concat } from '@langchain/core/utils/stream';\n *\n * const stream = await llm.stream(input);\n * let full: AIMessageChunk | undefined;\n * for await (const chunk of stream) {\n * full = !full ? chunk : concat(full, chunk);\n * }\n * console.log(full);\n * ```\n *\n * ```txt\n * AIMessageChunk {\n * \"id\": \"msg_01SBTb5zSGXfjUc7yQ8EKEEA\",\n * \"content\": \"Here's the translation to French:\\n\\nJ'adore la programmation.\",\n * \"additional_kwargs\": {\n * \"id\": \"msg_01SBTb5zSGXfjUc7yQ8EKEEA\",\n * \"type\": \"message\",\n * \"role\": \"assistant\",\n * \"model\": \"claude-sonnet-4-5-20250929\",\n * \"stop_reason\": \"end_turn\",\n * \"stop_sequence\": null\n * },\n * \"usage_metadata\": {\n * \"input_tokens\": 25,\n * \"output_tokens\": 20,\n * \"total_tokens\": 45\n * }\n * }\n * ```\n * </details>\n *\n * <br />\n *\n * <details>\n * <summary><strong>Bind tools</strong></summary>\n *\n * ```typescript\n * import { z } from 'zod';\n *\n * const GetWeather = {\n * name: \"GetWeather\",\n * description: \"Get the current weather in a given location\",\n * schema: z.object({\n * location: z.string().describe(\"The city and state, e.g. San Francisco, CA\")\n * }),\n * }\n *\n * const GetPopulation = {\n * name: \"GetPopulation\",\n * description: \"Get the current population in a given location\",\n * schema: z.object({\n * location: z.string().describe(\"The city and state, e.g. San Francisco, CA\")\n * }),\n * }\n *\n * const llmWithTools = llm.bindTools([GetWeather, GetPopulation]);\n * const aiMsg = await llmWithTools.invoke(\n * \"Which city is hotter today and which is bigger: LA or NY?\"\n * );\n * console.log(aiMsg.tool_calls);\n * ```\n *\n * ```txt\n * [\n * {\n * name: 'GetWeather',\n * args: { location: 'Los Angeles, CA' },\n * id: 'toolu_01WjW3Dann6BPJVtLhovdBD5',\n * type: 'tool_call'\n * },\n * {\n * name: 'GetWeather',\n * args: { location: 'New York, NY' },\n * id: 'toolu_01G6wfJgqi5zRmJomsmkyZXe',\n * type: 'tool_call'\n * },\n * {\n * name: 'GetPopulation',\n * args: { location: 'Los Angeles, CA' },\n * id: 'toolu_0165qYWBA2VFyUst5RA18zew',\n * type: 'tool_call'\n * },\n * {\n * name: 'GetPopulation',\n * args: { location: 'New York, NY' },\n * id: 'toolu_01PGNyP33vxr13tGqr7i3rDo',\n * type: 'tool_call'\n * }\n * ]\n * ```\n * </details>\n *\n * <br />\n *\n * <details>\n * <summary><strong>Tool Search</strong></summary>\n *\n * Tool search enables Claude to dynamically discover and load tools on-demand\n * instead of loading all tool definitions upfront. This is useful when you have\n * many tools but want to avoid the overhead of sending all definitions with every request.\n *\n * ```typescript\n * import { ChatAnthropic } from \"@langchain/anthropic\";\n *\n * const model = new ChatAnthropic({\n * model: \"claude-sonnet-4-5-20250929\",\n * });\n *\n * const tools = [\n * // Tool search server tool\n * {\n * type: \"tool_search_tool_regex_20251119\",\n * name: \"tool_search_tool_regex\",\n * },\n * // Tools with defer_loading are loaded on-demand\n * {\n * name: \"get_weather\",\n * description: \"Get the current weather for a location\",\n * input_schema: {\n * type: \"object\",\n * properties: {\n * location: { type: \"string\", description: \"City name\" },\n * unit: {\n * type: \"string\",\n * enum: [\"celsius\", \"fahrenheit\"],\n * },\n * },\n * required: [\"location\"],\n * },\n * defer_loading: true, // Tool is loaded on-demand\n * },\n * {\n * name: \"search_files\",\n * description: \"Search through files in the workspace\",\n * input_schema: {\n * type: \"object\",\n * properties: {\n * query: { type: \"string\" },\n * },\n * required: [\"query\"],\n * },\n * defer_loading: true, // Tool is loaded on-demand\n * },\n * ];\n *\n * const modelWithTools = model.bindTools(tools);\n * const response = await modelWithTools.invoke(\"What's the weather in San Francisco?\");\n * ```\n *\n * You can also use the `tool()` helper with the `extras` field:\n *\n * ```typescript\n * import { tool } from \"@langchain/core/tools\";\n * import { z } from \"zod\";\n *\n * const getWeather = tool(\n * async (input) => `Weather in ${input.location}`,\n * {\n * name: \"get_weather\",\n * description: \"Get weather for a location\",\n * schema: z.object({ location: z.string() }),\n * extras: { defer_loading: true },\n * }\n * );\n * ```\n *\n * **Note:** The required `advanced-tool-use-2025-11-20` beta header is automatically\n * appended to the request when using tool search tools.\n *\n * **Best practices:**\n * - Tools with `defer_loading: true` are only loaded when Claude discovers them via search\n * - Keep your 3-5 most frequently used tools as non-deferred for optimal performance\n * - Both regex and bm25 variants search tool names, descriptions, and argument info\n *\n * See the {@link https://platform.claude.com/docs/en/agents-and-tools/tool-use/tool-search-tool | Claude docs}\n * for more information.\n * </details>\n *\n * <br />\n *\n * <details>\n * <summary><strong>Structured Output</strong></summary>\n *\n * ChatAnthropic supports structured output through two main approaches:\n *\n * 1. **Function Calling with `withStructuredOutput()`**: Uses Anthropic's tool calling\n * under the hood to constrain outputs to a specific schema.\n * 2. **JSON Schema Mode**: Uses Anthropic's native JSON schema support for direct\n * structured output without tool calling overhead.\n *\n * **Using withStructuredOutput (Function Calling)**\n *\n * This method leverages Anthropic's tool calling capabilities to ensure the model\n * returns data matching your schema:\n *\n * ```typescript\n * import { z } from 'zod';\n *\n * const Joke = z.object({\n * setup: z.string().describe(\"The setup of the joke\"),\n * punchline: z.string().describe(\"The punchline to the joke\"),\n * rating: z.number().optional().describe(\"How funny the joke is, from 1 to 10\")\n * }).describe('Joke to tell user.');\n *\n * const structuredLlm = llm.withStructuredOutput(Joke, { name: \"Joke\" });\n * const jokeResult = await structuredLlm.invoke(\"Tell me a joke about cats\");\n * console.log(jokeResult);\n * ```\n *\n * ```txt\n * {\n * setup: \"Why don't cats play poker in the jungle?\",\n * punchline: 'Too many cheetahs!',\n * rating: 7\n * }\n * ```\n *\n * **Using JSON Schema Mode**\n *\n * For more direct control, you can use Anthropic's native JSON schema support by\n * passing `method: \"jsonSchema\"`:\n *\n * ```typescript\n * import { z } from 'zod';\n *\n * const RecipeSchema = z.object({\n * recipeName: z.string().describe(\"Name of the recipe\"),\n * ingredients: z.array(z.string()).describe(\"List of ingredients needed\"),\n * steps: z.array(z.string()).describe(\"Cooking steps in order\"),\n * prepTime: z.number().describe(\"Preparation time in minutes\")\n * });\n *\n * const structuredLlm = llm.withStructuredOutput(RecipeSchema, {\n * method: \"jsonSchema\"\n * });\n *\n * const recipe = await structuredLlm.invoke(\n * \"Give me a simple recipe for chocolate chip cookies\"\n * );\n * console.log(recipe);\n * ```\n *\n * ```txt\n * {\n * recipeName: 'Classic Chocolate Chip Cookies',\n * ingredients: [\n * '2 1/4 cups all-purpose flour',\n * '1 cup butter, softened',\n * ...\n * ],\n * steps: [\n * 'Preheat oven to 375°F',\n * 'Mix butter and sugars until creamy',\n * ...\n * ],\n * prepTime: 15\n * }\n * ```\n * </details>\n *\n * <br />\n *\n * <details>\n * <summary><strong>Multimodal</strong></summary>\n *\n * ```typescript\n * import { HumanMessage } from '@langchain/core/messages';\n *\n * const imageUrl = \"https://example.com/image.jpg\";\n * const imageData = await fetch(imageUrl).then(res => res.arrayBuffer());\n * const base64Image = Buffer.from(imageData).toString('base64');\n *\n * const message = new HumanMessage({\n * content: [\n * { type: \"text\", text: \"describe the weather in this image\" },\n * {\n * type: \"image_url\",\n * image_url: { url: `data:image/jpeg;base64,${base64Image}` },\n * },\n * ]\n * });\n *\n * const imageDescriptionAiMsg = await llm.invoke([message]);\n * console.log(imageDescriptionAiMsg.content);\n * ```\n *\n * ```txt\n * The weather in this image appears to be beautiful and clear. The sky is a vibrant blue with scattered white clouds, suggesting a sunny and pleasant day. The clouds are wispy and light, indicating calm conditions without any signs of storms or heavy weather. The bright green grass on the rolling hills looks lush and well-watered, which could mean recent rainfall or good growing conditions. Overall, the scene depicts a perfect spring or early summer day with mild temperatures, plenty of sunshine, and gentle breezes - ideal weather for enjoying the outdoors or for plant growth.\n * ```\n * </details>\n *\n * <br />\n *\n * <details>\n * <summary><strong>Usage Metadata</strong></summary>\n *\n * ```typescript\n * const aiMsgForMetadata = await llm.invoke(input);\n * console.log(aiMsgForMetadata.usage_metadata);\n * ```\n *\n * ```txt\n * { input_tokens: 25, output_tokens: 19, total_tokens: 44 }\n * ```\n * </details>\n *\n * <br />\n *\n * <details>\n * <summary><strong>Stream Usage Metadata</strong></summary>\n *\n * ```typescript\n * const streamForMetadata = await llm.stream(\n * input,\n * {\n * streamUsage: true\n * }\n * );\n * let fullForMetadata: AIMessageChunk | undefined;\n * for await (const chunk of streamForMetadata) {\n * fullForMetadata = !fullForMetadata ? chunk : concat(fullForMetadata, chunk);\n * }\n * console.log(fullForMetadata?.usage_metadata);\n * ```\n *\n * ```txt\n * { input_tokens: 25, output_tokens: 20, total_tokens: 45 }\n * ```\n * </details>\n *\n * <br />\n *\n * <details>\n * <summary><strong>Response Metadata</strong></summary>\n *\n * ```typescript\n * const aiMsgForResponseMetadata = await llm.invoke(input);\n * console.log(aiMsgForResponseMetadata.response_metadata);\n * ```\n *\n * ```txt\n * {\n * id: 'msg_01STxeQxJmp4sCSpioD6vK3L',\n * model: 'claude-sonnet-4-5-20250929',\n * stop_reason: 'end_turn',\n * stop_sequence: null,\n * usage: { input_tokens: 25, output_tokens: 19 },\n * type: 'message',\n * role: 'assistant'\n * }\n * ```\n * </details>\n *\n * <br />\n */\nexport declare class ChatAnthropicMessages<CallOptions extends ChatAnthropicCallOptions = ChatAnthropicCallOptions> extends BaseChatModel<CallOptions, AIMessageChunk> implements AnthropicInput {\n static lc_name(): string;\n get lc_secrets(): {\n [key: string]: string;\n } | undefined;\n get lc_aliases(): Record<string, string>;\n lc_serializable: boolean;\n anthropicApiKey?: string;\n apiKey?: string;\n apiUrl?: string;\n temperature?: number;\n topK?: number;\n topP?: number;\n maxTokens: number;\n modelName: string;\n model: string;\n invocationKwargs?: Kwargs;\n stopSequences?: string[];\n streaming: boolean;\n clientOptions: ClientOptions;\n thinking: AnthropicThinkingConfigParam;\n contextManagement?: AnthropicContextManagementConfigParam;\n outputConfig?: AnthropicOutputConfig;\n inferenceGeo?: string;\n protected batchClient: Anthropic;\n protected streamingClient: Anthropic;\n streamUsage: boolean;\n betas?: AnthropicBeta[];\n /**\n * Optional method that returns an initialized underlying Anthropic client.\n * Useful for accessing Anthropic models hosted on other cloud services\n * such as Google Vertex.\n */\n createClient: (options: ClientOptions) => Anthropic;\n constructor(fields?: ChatAnthropicInput);\n getLsParams(options: this[\"ParsedCallOptions\"]): LangSmithParams;\n /**\n * Formats LangChain StructuredTools to AnthropicTools.\n *\n * @param {ChatAnthropicCallOptions[\"tools\"]} tools The tools to format\n * @returns {AnthropicTool[] | undefined} The formatted tools, or undefined if none are passed.\n */\n formatStructuredToolToAnthropic(tools: ChatAnthropicCallOptions[\"tools\"]): Anthropic.Messages.ToolUnion[] | undefined;\n bindTools(tools: ChatAnthropicToolType[], kwargs?: Partial<CallOptions>): Runnable<BaseLanguageModelInput, AIMessageChunk, CallOptions>;\n /**\n * Get the parameters used to invoke the model\n */\n invocationParams(options?: this[\"ParsedCallOptions\"]): AnthropicInvocationParams;\n /** @ignore */\n _identifyingParams(): {\n max_tokens: number;\n model: Anthropic.Model;\n inference_geo?: string | null | undefined;\n metadata?: Anthropic.Metadata | undefined;\n output_config?: Anthropic.OutputConfig | undefined;\n service_tier?: \"auto\" | \"standard_only\" | undefined;\n stop_sequences?: string[] | undefined;\n system?: string | Anthropic.TextBlockParam[] | undefined;\n temperature?: number | undefined;\n thinking?: Anthropic.ThinkingConfigParam | undefined;\n tool_choice?: Anthropic.ToolChoice | undefined;\n tools?: Anthropic.ToolUnion[] | undefined;\n top_k?: number | undefined;\n top_p?: number | undefined;\n stream?: boolean | undefined;\n model_name: string;\n };\n /**\n * Get the identifying parameters for the model\n */\n identifyingParams(): {\n max_tokens: number;\n model: Anthropic.Model;\n inference_geo?: string | null | undefined;\n metadata?: Anthropic.Metadata | undefined;\n output_config?: Anthropic.OutputConfig | undefined;\n service_tier?: \"auto\" | \"standard_only\" | undefined;\n stop_sequences?: string[] | undefined;\n system?: string | Anthropic.TextBlockParam[] | undefined;\n temperature?: number | undefined;\n thinking?: Anthropic.ThinkingConfigParam | undefined;\n tool_choice?: Anthropic.ToolChoice | undefined;\n tools?: Anthropic.ToolUnion[] | undefined;\n top_k?: number | undefined;\n top_p?: number | undefined;\n stream?: boolean | undefined;\n model_name: string;\n };\n _streamResponseChunks(messages: BaseMessage[], options: this[\"ParsedCallOptions\"], runManager?: CallbackManagerForLLMRun): AsyncGenerator<ChatGenerationChunk>;\n /** @ignore */\n _generateNonStreaming(messages: BaseMessage[], params: Omit<Anthropic.Messages.MessageCreateParamsNonStreaming | Anthropic.Messages.MessageCreateParamsStreaming, \"messages\"> & Kwargs, requestOptions: AnthropicRequestOptions, cacheControl?: {\n type: \"ephemeral\";\n ttl?: \"5m\" | \"1h\";\n }): Promise<{\n generations: import(\"@langchain/core/outputs\").ChatGeneration[];\n llmOutput: {\n id: string;\n model: Anthropic.Model;\n stop_reason: Anthropic.StopReason | null;\n stop_sequence: string | null;\n usage: Anthropic.Usage;\n };\n }>;\n /** @ignore */\n _generate(messages: BaseMessage[], options: this[\"ParsedCallOptions\"], runManager?: CallbackManagerForLLMRun): Promise<ChatResult>;\n /**\n * Creates a streaming request with retry.\n * @param request The parameters for creating a completion.\n * @param options\n * @returns A streaming request.\n */\n protected createStreamWithRetry(request: AnthropicStreamingMessageCreateParams & Kwargs, options?: AnthropicRequestOptions): Promise<Stream<AnthropicMessageStreamEvent>>;\n /** @ignore */\n protected completionWithRetry(request: AnthropicMessageCreateParams & Kwargs, options: AnthropicRequestOptions): Promise<Anthropic.Message>;\n _llmType(): string;\n /**\n * Return profiling information for the model.\n *\n * Provides information about the model's capabilities and constraints,\n * including token limits, multimodal support, and advanced features like\n * tool calling and structured output.\n *\n * @returns {ModelProfile} An object describing the model's capabilities and constraints\n *\n * @example\n * ```typescript\n * const model = new ChatAnthropic({ model: \"claude-opus-4-0\" });\n * const profile = model.profile;\n * console.log(profile.maxInputTokens); // 200000\n * console.log(profile.imageInputs); // true\n * ```\n */\n get profile(): ModelProfile;\n withStructuredOutput<RunOutput extends Record<string, any> = Record<string, any>>(outputSchema: InteropZodType<RunOutput> | Record<string, any>, config?: StructuredOutputMethodOptions<false>): Runnable<BaseLanguageModelInput, RunOutput>;\n withStructuredOutput<RunOutput extends Record<string, any> = Record<string, any>>(outputSchema: InteropZodType<RunOutput> | Record<string, any>, config?: StructuredOutputMethodOptions<true>): Runnable<BaseLanguageModelInput, {\n raw: BaseMessage;\n parsed: RunOutput;\n }>;\n}\nexport declare class ChatAnthropic extends ChatAnthropicMessages {\n}\n//# sourceMappingURL=chat_models.d.ts.map"],"mappings":";;;;;;;;;;;;;;;;;;;AAgBA;AAIiBgC,UAJAD,qBAAAA,CAIwB;EAAwCE,IAAAA,EAAAA,WAAAA;EACrEN,GAAAA,CAAAA,EAAAA,IAAAA,GAAAA,IAAAA;;AAUEO,UAXGF,wBAAAA,SAAiCvB,wBAWpCyB,EAX8DC,IAW9DD,CAXmED,cAWnEC,EAAAA,aAAAA,CAAAA,CAAAA;EAUKR,KAAAA,CAAAA,EApBPC,qBAoBOD,EAAAA;EAKAD;;;;EA1B+BhB,WAAAA,CAAAA,EAMhCe,mBANgCf;EAA0B0B;AAAI;AA2DhF;AAIA;EAwCgBC,OAAAA,CAAAA,EA5FFF,MA4FEE,CAAAA,MAAAA,EAAAA,MAAAA,CAAAA;EAEJA;;;;EAsBGb,SAAAA,CAAA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BACL9C,WAAAA,CAAU+C;;;sBAGR/C,WAAAA,CAAUgD;;eAEjBhD,WAAAA,CAAUiD;kBACPjD,WAAAA,CAAUkD;YAChBlD,WAAAA,CAAU4C;;;;;;;;;;;WAWX5C,WAAAA,CAAUqC;;eAENrC,WAAAA,CAAU8C;oBACL9C,WAAAA,CAAU+C;;;sBAGR/C,WAAAA,CAAUgD;;eAEjBhD,WAAAA,CAAUiD;kBACPjD,WAAAA,CAAUkD;YAChBlD,WAAAA,CAAU4C;;;;;;kCAMUvC,gEAAgEF,2BAA2BgD,eAAe7C;;kCAE1GD,uBAAuBiD,KAAKtD,WAAAA,CAAU2C,QAAAA,CAASS,kCAAkCpD,WAAAA,CAAU2C,QAAAA,CAASU,4CAA4CxB,wBAAwBR;;;MAGpMsC;iBAH2NJ,wBAAAA,CAI5KC,cAAAA;;;aAGpCxD,WAAAA,CAAUqC;mBACJrC,WAAAA,CAAUyD;;aAEhBzD,WAAAA,CAAU0D;;;;sBAILrD,gEAAgEF,2BAA2BwD,QAAQpD;;;;;;;2CAO9Ee,wCAAwCO,kBAAkBR,0BAA0BsC,QAAQzD,OAAOkB;;yCAErGD,+BAA+BU,iBAAiBR,0BAA0BsC,QAAQ3D,WAAAA,CAAU4D;;;;;;;;;;;;;;;;;;;iBAmBpH9C;yCACwBoB,sBAAsBA,mCAAmClB,eAAeyB,aAAaP,8BAA8BtB,uCAAuCG,SAASF,wBAAwB4B;yCAC3LP,sBAAsBA,mCAAmClB,eAAeyB,aAAaP,8BAA8BtB,sCAAsCG,SAASF;SAChMR;YACGoC;;;cAGKoB,aAAAA,SAAsBrB,qBAAqB"}
|
package/dist/chat_models.js
CHANGED
|
@@ -19,6 +19,8 @@ import { isLangChainTool } from "@langchain/core/utils/function_calling";
|
|
|
19
19
|
|
|
20
20
|
//#region src/chat_models.ts
|
|
21
21
|
const MODEL_DEFAULT_MAX_OUTPUT_TOKENS = {
|
|
22
|
+
"claude-opus-4-6": 16384,
|
|
23
|
+
"claude-opus-4-5": 8192,
|
|
22
24
|
"claude-opus-4-1": 8192,
|
|
23
25
|
"claude-opus-4": 8192,
|
|
24
26
|
"claude-sonnet-4": 8192,
|
|
@@ -44,7 +46,11 @@ function _documentsInParams(params) {
|
|
|
44
46
|
return false;
|
|
45
47
|
}
|
|
46
48
|
function _thinkingInParams(params) {
|
|
47
|
-
return !!(params.thinking && params.thinking.type === "enabled");
|
|
49
|
+
return !!(params.thinking && (params.thinking.type === "enabled" || params.thinking.type === "adaptive"));
|
|
50
|
+
}
|
|
51
|
+
function _compactionInParams(params) {
|
|
52
|
+
const cm = params.context_management;
|
|
53
|
+
return !!cm?.edits?.some((e) => e.type === "compact_20260112");
|
|
48
54
|
}
|
|
49
55
|
function isAnthropicTool(tool) {
|
|
50
56
|
return "input_schema" in tool;
|
|
@@ -623,6 +629,8 @@ var ChatAnthropicMessages = class extends BaseChatModel {
|
|
|
623
629
|
clientOptions;
|
|
624
630
|
thinking = { type: "disabled" };
|
|
625
631
|
contextManagement;
|
|
632
|
+
outputConfig;
|
|
633
|
+
inferenceGeo;
|
|
626
634
|
batchClient;
|
|
627
635
|
streamingClient;
|
|
628
636
|
streamUsage = true;
|
|
@@ -654,6 +662,8 @@ var ChatAnthropicMessages = class extends BaseChatModel {
|
|
|
654
662
|
this.streamUsage = fields?.streamUsage ?? this.streamUsage;
|
|
655
663
|
this.thinking = fields?.thinking ?? this.thinking;
|
|
656
664
|
this.contextManagement = fields?.contextManagement ?? this.contextManagement;
|
|
665
|
+
this.outputConfig = fields?.outputConfig ?? this.outputConfig;
|
|
666
|
+
this.inferenceGeo = fields?.inferenceGeo ?? this.inferenceGeo;
|
|
657
667
|
this.betas = fields?.betas ?? this.betas;
|
|
658
668
|
this.createClient = fields?.createClient ?? ((options) => new Anthropic$1(options));
|
|
659
669
|
}
|
|
@@ -712,6 +722,16 @@ var ChatAnthropicMessages = class extends BaseChatModel {
|
|
|
712
722
|
}
|
|
713
723
|
return acc;
|
|
714
724
|
}, []);
|
|
725
|
+
const mergedOutputConfig = (() => {
|
|
726
|
+
const base = {
|
|
727
|
+
...this.outputConfig,
|
|
728
|
+
...options?.outputConfig
|
|
729
|
+
};
|
|
730
|
+
if (options?.outputFormat && !base.format) base.format = options.outputFormat;
|
|
731
|
+
return Object.keys(base).length > 0 ? base : void 0;
|
|
732
|
+
})();
|
|
733
|
+
const hasCompaction = this.contextManagement?.edits?.some((e) => e.type === "compact_20260112");
|
|
734
|
+
const compactionBetas = hasCompaction ? ["compact-2026-01-12"] : [];
|
|
715
735
|
const output = {
|
|
716
736
|
model: this.model,
|
|
717
737
|
stop_sequences: options?.stop ?? this.stopSequences,
|
|
@@ -723,11 +743,12 @@ var ChatAnthropicMessages = class extends BaseChatModel {
|
|
|
723
743
|
context_management: this.contextManagement,
|
|
724
744
|
...this.invocationKwargs,
|
|
725
745
|
container: options?.container,
|
|
726
|
-
betas: _combineBetas(this.betas, options?.betas, toolBetas ?? []),
|
|
727
|
-
|
|
746
|
+
betas: _combineBetas(this.betas, options?.betas, toolBetas ?? [], compactionBetas),
|
|
747
|
+
output_config: mergedOutputConfig,
|
|
748
|
+
inference_geo: options?.inferenceGeo ?? this.inferenceGeo,
|
|
728
749
|
mcp_servers: options?.mcp_servers
|
|
729
750
|
};
|
|
730
|
-
if (this.thinking.type === "enabled") {
|
|
751
|
+
if (this.thinking.type === "enabled" || this.thinking.type === "adaptive") {
|
|
731
752
|
if (this.topP !== void 0 && this.topK !== -1) throw new Error("topK is not supported when thinking is enabled");
|
|
732
753
|
if (this.temperature !== void 0 && this.temperature !== 1) throw new Error("temperature is not supported when thinking is enabled");
|
|
733
754
|
} else {
|
|
@@ -762,7 +783,7 @@ var ChatAnthropicMessages = class extends BaseChatModel {
|
|
|
762
783
|
...formattedMessages,
|
|
763
784
|
stream: true
|
|
764
785
|
};
|
|
765
|
-
const coerceContentToString = !_toolsInParams(payload) && !_documentsInParams(payload) && !_thinkingInParams(payload);
|
|
786
|
+
const coerceContentToString = !_toolsInParams(payload) && !_documentsInParams(payload) && !_thinkingInParams(payload) && !_compactionInParams(payload);
|
|
766
787
|
const stream = await this.createStreamWithRetry(payload, {
|
|
767
788
|
headers: options.headers,
|
|
768
789
|
signal: options.signal
|
|
@@ -947,11 +968,10 @@ var ChatAnthropicMessages = class extends BaseChatModel {
|
|
|
947
968
|
const jsonSchema = transformJSONSchema(toJsonSchema(schema));
|
|
948
969
|
llm = this.withConfig({
|
|
949
970
|
outputVersion: "v0",
|
|
950
|
-
|
|
971
|
+
outputConfig: { format: {
|
|
951
972
|
type: "json_schema",
|
|
952
973
|
schema: jsonSchema
|
|
953
|
-
},
|
|
954
|
-
betas: ["structured-outputs-2025-11-13"],
|
|
974
|
+
} },
|
|
955
975
|
ls_structured_output_format: {
|
|
956
976
|
kwargs: { method: "json_schema" },
|
|
957
977
|
schema: jsonSchema
|
|
@@ -988,7 +1008,7 @@ var ChatAnthropicMessages = class extends BaseChatModel {
|
|
|
988
1008
|
keyName: functionName
|
|
989
1009
|
});
|
|
990
1010
|
}
|
|
991
|
-
if (this.thinking?.type === "enabled") {
|
|
1011
|
+
if (this.thinking?.type === "enabled" || this.thinking?.type === "adaptive") {
|
|
992
1012
|
const thinkingAdmonition = "Anthropic structured output relies on forced tool calling, which is not supported when `thinking` is enabled. This method will raise OutputParserException if tool calls are not generated. Consider disabling `thinking` or adjust your prompt to ensure the tool is called.";
|
|
993
1013
|
console.warn(thinkingAdmonition);
|
|
994
1014
|
llm = this.withConfig({
|