@providerprotocol/ai 0.0.20 → 0.0.22
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/dist/anthropic/index.d.ts +184 -14
- package/dist/anthropic/index.js +306 -107
- package/dist/anthropic/index.js.map +1 -1
- package/dist/{chunk-P5IRTEM5.js → chunk-7WYBJPJJ.js} +2 -2
- package/dist/chunk-I2VHCGQE.js +49 -0
- package/dist/chunk-I2VHCGQE.js.map +1 -0
- package/dist/{chunk-UMKWXGO3.js → chunk-M4BMM5IB.js} +86 -2
- package/dist/chunk-M4BMM5IB.js.map +1 -0
- package/dist/{chunk-SKY2JLA7.js → chunk-MKDLXV4O.js} +1 -1
- package/dist/chunk-MKDLXV4O.js.map +1 -0
- package/dist/{chunk-Z7RBRCRN.js → chunk-NWS5IKNR.js} +37 -11
- package/dist/chunk-NWS5IKNR.js.map +1 -0
- package/dist/{chunk-U3FZWV4U.js → chunk-RFWLEFAB.js} +100 -43
- package/dist/chunk-RFWLEFAB.js.map +1 -0
- package/dist/{chunk-U4JJC2YX.js → chunk-RS7C25LS.js} +36 -11
- package/dist/chunk-RS7C25LS.js.map +1 -0
- package/dist/google/index.d.ts +35 -24
- package/dist/google/index.js +273 -99
- package/dist/google/index.js.map +1 -1
- package/dist/http/index.d.ts +3 -3
- package/dist/http/index.js +4 -4
- package/dist/index.d.ts +103 -38
- package/dist/index.js +346 -153
- package/dist/index.js.map +1 -1
- package/dist/ollama/index.d.ts +14 -16
- package/dist/ollama/index.js +68 -16
- package/dist/ollama/index.js.map +1 -1
- package/dist/openai/index.d.ts +25 -133
- package/dist/openai/index.js +208 -122
- package/dist/openai/index.js.map +1 -1
- package/dist/openrouter/index.d.ts +28 -53
- package/dist/openrouter/index.js +179 -72
- package/dist/openrouter/index.js.map +1 -1
- package/dist/provider-DWEAzeM5.d.ts +1329 -0
- package/dist/proxy/index.d.ts +2 -3
- package/dist/proxy/index.js +174 -17
- package/dist/proxy/index.js.map +1 -1
- package/dist/{retry-DR7YRJDz.d.ts → retry-DmPmqZL6.d.ts} +12 -3
- package/dist/{stream-DRHy6q1a.d.ts → stream-DbkLOIbJ.d.ts} +15 -5
- package/dist/xai/index.d.ts +16 -88
- package/dist/xai/index.js +167 -86
- package/dist/xai/index.js.map +1 -1
- package/package.json +4 -1
- package/dist/chunk-MSR5P65T.js +0 -39
- package/dist/chunk-MSR5P65T.js.map +0 -1
- package/dist/chunk-SKY2JLA7.js.map +0 -1
- package/dist/chunk-U3FZWV4U.js.map +0 -1
- package/dist/chunk-U4JJC2YX.js.map +0 -1
- package/dist/chunk-UMKWXGO3.js.map +0 -1
- package/dist/chunk-Z7RBRCRN.js.map +0 -1
- package/dist/content-DEl3z_W2.d.ts +0 -276
- package/dist/image-Dhq-Yuq4.d.ts +0 -456
- package/dist/provider-BBMBZuGn.d.ts +0 -570
- /package/dist/{chunk-P5IRTEM5.js.map → chunk-7WYBJPJJ.js.map} +0 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { g as Provider } from '../provider-DWEAzeM5.js';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* @fileoverview Anthropic API type definitions.
|
|
@@ -6,6 +6,83 @@ import { d as Provider } from '../provider-BBMBZuGn.js';
|
|
|
6
6
|
* Contains TypeScript interfaces for Anthropic's Messages API request/response
|
|
7
7
|
* structures, streaming events, and provider-specific parameters.
|
|
8
8
|
*/
|
|
9
|
+
/**
|
|
10
|
+
* Known Anthropic beta header values.
|
|
11
|
+
*
|
|
12
|
+
* Beta features are enabled by passing these values in the `betas` config option
|
|
13
|
+
* or via the `anthropic-beta` HTTP header. Multiple betas can be enabled simultaneously.
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* ```typescript
|
|
17
|
+
* import { anthropic, betas } from 'provider-protocol/anthropic';
|
|
18
|
+
*
|
|
19
|
+
* // Using the betas config option (recommended)
|
|
20
|
+
* const provider = anthropic('claude-sonnet-4-20250514', {
|
|
21
|
+
* betas: [betas.structuredOutputs, betas.interleavedThinking],
|
|
22
|
+
* });
|
|
23
|
+
*
|
|
24
|
+
* // Or use string values directly for new/unlisted betas
|
|
25
|
+
* const provider = anthropic('claude-sonnet-4-20250514', {
|
|
26
|
+
* betas: ['new-beta-2025-12-01'],
|
|
27
|
+
* });
|
|
28
|
+
* ```
|
|
29
|
+
*/
|
|
30
|
+
declare const betas: {
|
|
31
|
+
/** Guaranteed JSON schema conformance for responses. Available for Claude Sonnet 4.5+. */
|
|
32
|
+
readonly structuredOutputs: "structured-outputs-2025-11-13";
|
|
33
|
+
/** Enables Claude to think between tool calls in Claude 4 models. */
|
|
34
|
+
readonly interleavedThinking: "interleaved-thinking-2025-05-14";
|
|
35
|
+
/** Developer mode for full thinking output visibility. */
|
|
36
|
+
readonly devFullThinking: "dev-full-thinking-2025-05-14";
|
|
37
|
+
/** Effort parameter for Claude Opus 4.5 - controls response thoroughness vs efficiency. */
|
|
38
|
+
readonly effort: "effort-2025-11-24";
|
|
39
|
+
/** Legacy computer use tool (Claude 3.x models). */
|
|
40
|
+
readonly computerUseLegacy: "computer-use-2024-10-22";
|
|
41
|
+
/** Computer use tool for Claude 4 models (mouse, keyboard, screenshots). */
|
|
42
|
+
readonly computerUse: "computer-use-2025-01-24";
|
|
43
|
+
/** Computer use tool for Claude Opus 4.5 with additional commands. */
|
|
44
|
+
readonly computerUseOpus: "computer-use-2025-11-24";
|
|
45
|
+
/** Enables up to 8,192 output tokens from Claude Sonnet 3.5. */
|
|
46
|
+
readonly maxTokens35Sonnet: "max-tokens-3-5-sonnet-2024-07-15";
|
|
47
|
+
/** Enables 128K token output length. */
|
|
48
|
+
readonly output128k: "output-128k-2025-02-19";
|
|
49
|
+
/** Enables 1 million token context window for Claude Sonnet 4. */
|
|
50
|
+
readonly context1m: "context-1m-2025-08-07";
|
|
51
|
+
/** Reduces output token consumption by up to 70% for tool calls. */
|
|
52
|
+
readonly tokenEfficientTools: "token-efficient-tools-2025-02-19";
|
|
53
|
+
/** Streams tool use parameters without buffering/JSON validation. */
|
|
54
|
+
readonly fineGrainedToolStreaming: "fine-grained-tool-streaming-2025-05-14";
|
|
55
|
+
/** Code execution tool for running Python/Bash in secure sandbox. */
|
|
56
|
+
readonly codeExecution: "code-execution-2025-08-25";
|
|
57
|
+
/** Advanced tool use: Tool Search, Programmatic Tool Calling, Tool Use Examples. */
|
|
58
|
+
readonly advancedToolUse: "advanced-tool-use-2025-11-20";
|
|
59
|
+
/** Files API for uploading and managing files. */
|
|
60
|
+
readonly filesApi: "files-api-2025-04-14";
|
|
61
|
+
/** PDF document support. */
|
|
62
|
+
readonly pdfs: "pdfs-2024-09-25";
|
|
63
|
+
/** MCP connector to connect to remote MCP servers. */
|
|
64
|
+
readonly mcpClient: "mcp-client-2025-04-04";
|
|
65
|
+
/** Updated MCP client. */
|
|
66
|
+
readonly mcpClientLatest: "mcp-client-2025-11-20";
|
|
67
|
+
/** Prompt caching for reduced latency and costs. Now works automatically with cache_control. */
|
|
68
|
+
readonly promptCaching: "prompt-caching-2024-07-31";
|
|
69
|
+
/** Enables 1-hour cache TTL (vs default 5-minute). */
|
|
70
|
+
readonly extendedCacheTtl: "extended-cache-ttl-2025-04-11";
|
|
71
|
+
/** Automatic tool call clearing for context management. */
|
|
72
|
+
readonly contextManagement: "context-management-2025-06-27";
|
|
73
|
+
/** Handling for when model context window is exceeded. */
|
|
74
|
+
readonly modelContextWindowExceeded: "model-context-window-exceeded-2025-08-26";
|
|
75
|
+
/** Message Batches API for async processing at 50% cost. */
|
|
76
|
+
readonly messageBatches: "message-batches-2024-09-24";
|
|
77
|
+
/** Token counting endpoint. */
|
|
78
|
+
readonly tokenCounting: "token-counting-2024-11-01";
|
|
79
|
+
/** Agent Skills for specialized tasks (PowerPoint, Excel, Word, PDF). */
|
|
80
|
+
readonly skills: "skills-2025-10-02";
|
|
81
|
+
};
|
|
82
|
+
/** Type representing any valid beta key from the betas object. */
|
|
83
|
+
type BetaKey = keyof typeof betas;
|
|
84
|
+
/** Type representing a beta value (either a known constant or arbitrary string). */
|
|
85
|
+
type BetaValue = (typeof betas)[BetaKey] | string;
|
|
9
86
|
/**
|
|
10
87
|
* Provider-specific parameters for Anthropic Claude models.
|
|
11
88
|
*
|
|
@@ -68,7 +145,7 @@ interface AnthropicLLMParams {
|
|
|
68
145
|
* const model = llm({
|
|
69
146
|
* model: anthropic('claude-sonnet-4-20250514'),
|
|
70
147
|
* params: {
|
|
71
|
-
*
|
|
148
|
+
* tools: [
|
|
72
149
|
* tools.webSearch({ max_uses: 5 }),
|
|
73
150
|
* tools.codeExecution(),
|
|
74
151
|
* ],
|
|
@@ -76,13 +153,56 @@ interface AnthropicLLMParams {
|
|
|
76
153
|
* });
|
|
77
154
|
* ```
|
|
78
155
|
*/
|
|
79
|
-
|
|
156
|
+
tools?: AnthropicBuiltInTool[];
|
|
80
157
|
/**
|
|
81
158
|
* Container ID for code execution tool reuse.
|
|
82
159
|
* Pass the container ID from a previous response to reuse the same environment.
|
|
83
160
|
*/
|
|
84
161
|
container?: string;
|
|
85
162
|
}
|
|
163
|
+
/**
|
|
164
|
+
* Request body structure for Anthropic's Messages API.
|
|
165
|
+
*
|
|
166
|
+
* This interface represents the full request payload sent to the
|
|
167
|
+
* `/v1/messages` endpoint.
|
|
168
|
+
*/
|
|
169
|
+
/**
|
|
170
|
+
* Native structured output format configuration.
|
|
171
|
+
*
|
|
172
|
+
* When provided, Claude's response will be constrained to match the
|
|
173
|
+
* specified JSON schema. Requires the beta header `structured-outputs-2025-11-13`.
|
|
174
|
+
*
|
|
175
|
+
* @example
|
|
176
|
+
* ```typescript
|
|
177
|
+
* const outputFormat: AnthropicOutputFormat = {
|
|
178
|
+
* type: 'json_schema',
|
|
179
|
+
* schema: {
|
|
180
|
+
* type: 'object',
|
|
181
|
+
* properties: {
|
|
182
|
+
* name: { type: 'string' },
|
|
183
|
+
* age: { type: 'integer' },
|
|
184
|
+
* },
|
|
185
|
+
* required: ['name', 'age'],
|
|
186
|
+
* additionalProperties: false,
|
|
187
|
+
* },
|
|
188
|
+
* };
|
|
189
|
+
* ```
|
|
190
|
+
*/
|
|
191
|
+
interface AnthropicOutputFormat {
|
|
192
|
+
/** Output format type - currently only 'json_schema' is supported. */
|
|
193
|
+
type: 'json_schema';
|
|
194
|
+
/** JSON Schema defining the expected response structure. */
|
|
195
|
+
schema: {
|
|
196
|
+
/** Schema type (always 'object' for structured outputs). */
|
|
197
|
+
type: 'object';
|
|
198
|
+
/** Property definitions for each field. */
|
|
199
|
+
properties: Record<string, unknown>;
|
|
200
|
+
/** List of required property names. */
|
|
201
|
+
required?: string[];
|
|
202
|
+
/** Must be false for structured outputs. */
|
|
203
|
+
additionalProperties?: false;
|
|
204
|
+
};
|
|
205
|
+
}
|
|
86
206
|
/**
|
|
87
207
|
* Anthropic-specific HTTP headers for API requests.
|
|
88
208
|
*
|
|
@@ -454,7 +574,7 @@ declare function toolSearchTool(options?: {
|
|
|
454
574
|
* const model = llm({
|
|
455
575
|
* model: anthropic('claude-sonnet-4-20250514'),
|
|
456
576
|
* params: {
|
|
457
|
-
*
|
|
577
|
+
* tools: [
|
|
458
578
|
* tools.webSearch({ max_uses: 5 }),
|
|
459
579
|
* tools.codeExecution(),
|
|
460
580
|
* ],
|
|
@@ -478,25 +598,75 @@ declare const tools: {
|
|
|
478
598
|
};
|
|
479
599
|
|
|
480
600
|
/**
|
|
481
|
-
*
|
|
601
|
+
* Options for configuring an Anthropic model reference.
|
|
602
|
+
*
|
|
603
|
+
* @example
|
|
604
|
+
* ```typescript
|
|
605
|
+
* import { anthropic, betas } from 'provider-protocol/anthropic';
|
|
606
|
+
*
|
|
607
|
+
* // Enable structured outputs beta
|
|
608
|
+
* const model = anthropic('claude-sonnet-4-20250514', {
|
|
609
|
+
* betas: [betas.structuredOutputs],
|
|
610
|
+
* });
|
|
611
|
+
*
|
|
612
|
+
* // Enable multiple betas
|
|
613
|
+
* const modelWithBetas = anthropic('claude-sonnet-4-20250514', {
|
|
614
|
+
* betas: [betas.structuredOutputs, betas.interleavedThinking],
|
|
615
|
+
* });
|
|
616
|
+
*
|
|
617
|
+
* // Use string values for new/unlisted betas
|
|
618
|
+
* const modelWithCustomBeta = anthropic('claude-sonnet-4-20250514', {
|
|
619
|
+
* betas: ['new-beta-2025-12-01'],
|
|
620
|
+
* });
|
|
621
|
+
* ```
|
|
622
|
+
*/
|
|
623
|
+
interface AnthropicModelOptions {
|
|
624
|
+
/**
|
|
625
|
+
* Beta features to enable for this model.
|
|
626
|
+
*
|
|
627
|
+
* Use values from the `betas` export or pass arbitrary strings for new betas.
|
|
628
|
+
* Multiple betas are combined into a comma-separated `anthropic-beta` header.
|
|
629
|
+
*/
|
|
630
|
+
betas?: BetaValue[];
|
|
631
|
+
}
|
|
632
|
+
/**
|
|
633
|
+
* Anthropic provider for the Universal Provider Protocol.
|
|
482
634
|
*
|
|
483
635
|
* Provides access to Claude language models through a unified interface.
|
|
484
|
-
*
|
|
485
|
-
*
|
|
636
|
+
* Supports LLM modality with streaming, tool use, structured output,
|
|
637
|
+
* and image input capabilities.
|
|
638
|
+
*
|
|
639
|
+
* @param modelId - The model identifier (e.g., 'claude-sonnet-4-20250514')
|
|
640
|
+
* @param options - Optional configuration including beta features
|
|
641
|
+
* @returns A model reference for use with `llm()`
|
|
486
642
|
*
|
|
487
643
|
* @example
|
|
488
644
|
* ```typescript
|
|
489
|
-
* import { anthropic } from '
|
|
645
|
+
* import { anthropic, betas } from 'provider-protocol/anthropic';
|
|
646
|
+
* import { llm } from 'provider-protocol';
|
|
647
|
+
*
|
|
648
|
+
* // Basic usage
|
|
649
|
+
* const model = llm({ model: anthropic('claude-sonnet-4-20250514') });
|
|
650
|
+
*
|
|
651
|
+
* // With structured outputs beta
|
|
652
|
+
* const modelWithBetas = llm({
|
|
653
|
+
* model: anthropic('claude-sonnet-4-20250514', {
|
|
654
|
+
* betas: [betas.structuredOutputs],
|
|
655
|
+
* }),
|
|
656
|
+
* structure: { properties: { name: { type: 'string' } } },
|
|
657
|
+
* });
|
|
490
658
|
*
|
|
491
|
-
*
|
|
492
|
-
* const
|
|
493
|
-
*
|
|
494
|
-
*
|
|
659
|
+
* // With multiple betas
|
|
660
|
+
* const advancedModel = llm({
|
|
661
|
+
* model: anthropic('claude-sonnet-4-20250514', {
|
|
662
|
+
* betas: [betas.structuredOutputs, betas.tokenEfficientTools],
|
|
663
|
+
* }),
|
|
495
664
|
* });
|
|
496
665
|
* ```
|
|
497
666
|
*
|
|
667
|
+
* @see {@link betas} for available beta features
|
|
498
668
|
* @see {@link AnthropicLLMParams} for provider-specific parameters
|
|
499
669
|
*/
|
|
500
|
-
declare const anthropic: Provider<
|
|
670
|
+
declare const anthropic: Provider<AnthropicModelOptions>;
|
|
501
671
|
|
|
502
|
-
export { type AnthropicBashTool, type AnthropicBuiltInTool, type AnthropicCodeExecutionTool, type AnthropicComputerTool, type AnthropicHeaders, type AnthropicLLMParams, type AnthropicTextEditorTool, type AnthropicToolSearchTool, type AnthropicUserLocation, type AnthropicWebSearchTool, anthropic, tools };
|
|
672
|
+
export { type AnthropicBashTool, type AnthropicBuiltInTool, type AnthropicCodeExecutionTool, type AnthropicComputerTool, type AnthropicHeaders, type AnthropicLLMParams, type AnthropicModelOptions, type AnthropicOutputFormat, type AnthropicTextEditorTool, type AnthropicToolSearchTool, type AnthropicUserLocation, type AnthropicWebSearchTool, type BetaKey, type BetaValue, anthropic, betas, tools };
|