@openrouter/ai-sdk-provider 1.5.3 → 1.5.4
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/index.d.mts +1 -83
- package/dist/index.d.ts +1 -83
- package/dist/index.js +1 -24
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1 -22
- package/dist/index.mjs.map +1 -1
- package/dist/internal/index.js.map +1 -1
- package/dist/internal/index.mjs.map +1 -1
- package/package.json +1 -8
package/dist/index.d.mts
CHANGED
|
@@ -2,8 +2,6 @@ import { LanguageModelV2, LanguageModelV2CallOptions, LanguageModelV2Content, La
|
|
|
2
2
|
export { LanguageModelV2, LanguageModelV2Prompt } from '@ai-sdk/provider';
|
|
3
3
|
import * as models from '@openrouter/sdk/models';
|
|
4
4
|
import { z } from 'zod/v4';
|
|
5
|
-
import { EncodeOptions, DecodeOptions, JsonValue } from '@toon-format/toon';
|
|
6
|
-
export { DecodeOptions, EncodeOptions, JsonValue } from '@toon-format/toon';
|
|
7
5
|
|
|
8
6
|
type OpenRouterChatModelId = string;
|
|
9
7
|
type OpenRouterChatSettings = {
|
|
@@ -551,84 +549,4 @@ declare class OpenRouter {
|
|
|
551
549
|
embedding(modelId: OpenRouterEmbeddingModelId, settings?: OpenRouterEmbeddingSettings): OpenRouterEmbeddingModel;
|
|
552
550
|
}
|
|
553
551
|
|
|
554
|
-
|
|
555
|
-
* TOON (Token-Oriented Object Notation) helper utilities for token-efficient
|
|
556
|
-
* data encoding in LLM prompts.
|
|
557
|
-
*
|
|
558
|
-
* TOON achieves ~40% token reduction vs JSON for tabular data while maintaining
|
|
559
|
-
* high LLM comprehension accuracy.
|
|
560
|
-
*
|
|
561
|
-
* @see https://toonformat.dev
|
|
562
|
-
* @see https://github.com/toon-format/toon
|
|
563
|
-
*
|
|
564
|
-
* @example
|
|
565
|
-
* ```ts
|
|
566
|
-
* import { encodeToon, decodeToon } from '@openrouter/ai-sdk-provider';
|
|
567
|
-
*
|
|
568
|
-
* // Encode data to TOON format
|
|
569
|
-
* const toon = await encodeToon([
|
|
570
|
-
* { id: 1, name: 'Alice', score: 95 },
|
|
571
|
-
* { id: 2, name: 'Bob', score: 87 },
|
|
572
|
-
* ]);
|
|
573
|
-
* // Result: [2]{id,name,score}: 1,Alice,95 2,Bob,87
|
|
574
|
-
*
|
|
575
|
-
* // Decode TOON back to JSON
|
|
576
|
-
* const data = await decodeToon(toon);
|
|
577
|
-
* ```
|
|
578
|
-
*/
|
|
579
|
-
|
|
580
|
-
type ToonEncodeOptions = EncodeOptions;
|
|
581
|
-
type ToonDecodeOptions = DecodeOptions;
|
|
582
|
-
/**
|
|
583
|
-
* Encodes a JavaScript value into TOON format string.
|
|
584
|
-
*
|
|
585
|
-
* TOON is particularly efficient for uniform arrays of objects (tabular data),
|
|
586
|
-
* achieving CSV-like compactness while preserving explicit structure.
|
|
587
|
-
*
|
|
588
|
-
* @param value - Any JavaScript value (objects, arrays, primitives)
|
|
589
|
-
* @param options - Optional encoding configuration
|
|
590
|
-
* @returns Promise resolving to TOON formatted string
|
|
591
|
-
*
|
|
592
|
-
* @example
|
|
593
|
-
* ```ts
|
|
594
|
-
* // Simple object
|
|
595
|
-
* await encodeToon({ name: 'Alice', age: 30 });
|
|
596
|
-
* // name: Alice
|
|
597
|
-
* // age: 30
|
|
598
|
-
*
|
|
599
|
-
* // Tabular array (most efficient)
|
|
600
|
-
* await encodeToon([
|
|
601
|
-
* { id: 1, name: 'Alice' },
|
|
602
|
-
* { id: 2, name: 'Bob' },
|
|
603
|
-
* ]);
|
|
604
|
-
* // [2]{id,name}: 1,Alice 2,Bob
|
|
605
|
-
*
|
|
606
|
-
* // With options
|
|
607
|
-
* await encodeToon(data, { indent: 4, keyFolding: 'safe' });
|
|
608
|
-
* ```
|
|
609
|
-
*/
|
|
610
|
-
declare function encodeToon(value: unknown, options?: ToonEncodeOptions): Promise<string>;
|
|
611
|
-
/**
|
|
612
|
-
* Decodes a TOON format string into a JavaScript value.
|
|
613
|
-
*
|
|
614
|
-
* @param input - TOON formatted string
|
|
615
|
-
* @param options - Optional decoding configuration
|
|
616
|
-
* @returns Promise resolving to parsed JavaScript value
|
|
617
|
-
*
|
|
618
|
-
* @example
|
|
619
|
-
* ```ts
|
|
620
|
-
* // Decode simple object
|
|
621
|
-
* await decodeToon('name: Alice\nage: 30');
|
|
622
|
-
* // { name: 'Alice', age: 30 }
|
|
623
|
-
*
|
|
624
|
-
* // Decode tabular array
|
|
625
|
-
* await decodeToon('[2]{id,name}: 1,Alice 2,Bob');
|
|
626
|
-
* // [{ id: 1, name: 'Alice' }, { id: 2, name: 'Bob' }]
|
|
627
|
-
*
|
|
628
|
-
* // With options
|
|
629
|
-
* await decodeToon(toonString, { strict: false, expandPaths: 'safe' });
|
|
630
|
-
* ```
|
|
631
|
-
*/
|
|
632
|
-
declare function decodeToon(input: string, options?: ToonDecodeOptions): Promise<JsonValue>;
|
|
633
|
-
|
|
634
|
-
export { OpenRouter, type OpenRouterChatSettings, type OpenRouterCompletionSettings, type OpenRouterEmbeddingModelId, type OpenRouterEmbeddingSettings, type OpenRouterProvider, type OpenRouterProviderOptions, type OpenRouterProviderSettings, type OpenRouterSharedSettings, type OpenRouterUsageAccounting, type ToonDecodeOptions, type ToonEncodeOptions, createOpenRouter, decodeToon, encodeToon, openrouter };
|
|
552
|
+
export { OpenRouter, type OpenRouterChatSettings, type OpenRouterCompletionSettings, type OpenRouterEmbeddingModelId, type OpenRouterEmbeddingSettings, type OpenRouterProvider, type OpenRouterProviderOptions, type OpenRouterProviderSettings, type OpenRouterSharedSettings, type OpenRouterUsageAccounting, createOpenRouter, openrouter };
|
package/dist/index.d.ts
CHANGED
|
@@ -2,8 +2,6 @@ import { LanguageModelV2, LanguageModelV2CallOptions, LanguageModelV2Content, La
|
|
|
2
2
|
export { LanguageModelV2, LanguageModelV2Prompt } from '@ai-sdk/provider';
|
|
3
3
|
import * as models from '@openrouter/sdk/models';
|
|
4
4
|
import { z } from 'zod/v4';
|
|
5
|
-
import { EncodeOptions, DecodeOptions, JsonValue } from '@toon-format/toon';
|
|
6
|
-
export { DecodeOptions, EncodeOptions, JsonValue } from '@toon-format/toon';
|
|
7
5
|
|
|
8
6
|
type OpenRouterChatModelId = string;
|
|
9
7
|
type OpenRouterChatSettings = {
|
|
@@ -551,84 +549,4 @@ declare class OpenRouter {
|
|
|
551
549
|
embedding(modelId: OpenRouterEmbeddingModelId, settings?: OpenRouterEmbeddingSettings): OpenRouterEmbeddingModel;
|
|
552
550
|
}
|
|
553
551
|
|
|
554
|
-
|
|
555
|
-
* TOON (Token-Oriented Object Notation) helper utilities for token-efficient
|
|
556
|
-
* data encoding in LLM prompts.
|
|
557
|
-
*
|
|
558
|
-
* TOON achieves ~40% token reduction vs JSON for tabular data while maintaining
|
|
559
|
-
* high LLM comprehension accuracy.
|
|
560
|
-
*
|
|
561
|
-
* @see https://toonformat.dev
|
|
562
|
-
* @see https://github.com/toon-format/toon
|
|
563
|
-
*
|
|
564
|
-
* @example
|
|
565
|
-
* ```ts
|
|
566
|
-
* import { encodeToon, decodeToon } from '@openrouter/ai-sdk-provider';
|
|
567
|
-
*
|
|
568
|
-
* // Encode data to TOON format
|
|
569
|
-
* const toon = await encodeToon([
|
|
570
|
-
* { id: 1, name: 'Alice', score: 95 },
|
|
571
|
-
* { id: 2, name: 'Bob', score: 87 },
|
|
572
|
-
* ]);
|
|
573
|
-
* // Result: [2]{id,name,score}: 1,Alice,95 2,Bob,87
|
|
574
|
-
*
|
|
575
|
-
* // Decode TOON back to JSON
|
|
576
|
-
* const data = await decodeToon(toon);
|
|
577
|
-
* ```
|
|
578
|
-
*/
|
|
579
|
-
|
|
580
|
-
type ToonEncodeOptions = EncodeOptions;
|
|
581
|
-
type ToonDecodeOptions = DecodeOptions;
|
|
582
|
-
/**
|
|
583
|
-
* Encodes a JavaScript value into TOON format string.
|
|
584
|
-
*
|
|
585
|
-
* TOON is particularly efficient for uniform arrays of objects (tabular data),
|
|
586
|
-
* achieving CSV-like compactness while preserving explicit structure.
|
|
587
|
-
*
|
|
588
|
-
* @param value - Any JavaScript value (objects, arrays, primitives)
|
|
589
|
-
* @param options - Optional encoding configuration
|
|
590
|
-
* @returns Promise resolving to TOON formatted string
|
|
591
|
-
*
|
|
592
|
-
* @example
|
|
593
|
-
* ```ts
|
|
594
|
-
* // Simple object
|
|
595
|
-
* await encodeToon({ name: 'Alice', age: 30 });
|
|
596
|
-
* // name: Alice
|
|
597
|
-
* // age: 30
|
|
598
|
-
*
|
|
599
|
-
* // Tabular array (most efficient)
|
|
600
|
-
* await encodeToon([
|
|
601
|
-
* { id: 1, name: 'Alice' },
|
|
602
|
-
* { id: 2, name: 'Bob' },
|
|
603
|
-
* ]);
|
|
604
|
-
* // [2]{id,name}: 1,Alice 2,Bob
|
|
605
|
-
*
|
|
606
|
-
* // With options
|
|
607
|
-
* await encodeToon(data, { indent: 4, keyFolding: 'safe' });
|
|
608
|
-
* ```
|
|
609
|
-
*/
|
|
610
|
-
declare function encodeToon(value: unknown, options?: ToonEncodeOptions): Promise<string>;
|
|
611
|
-
/**
|
|
612
|
-
* Decodes a TOON format string into a JavaScript value.
|
|
613
|
-
*
|
|
614
|
-
* @param input - TOON formatted string
|
|
615
|
-
* @param options - Optional decoding configuration
|
|
616
|
-
* @returns Promise resolving to parsed JavaScript value
|
|
617
|
-
*
|
|
618
|
-
* @example
|
|
619
|
-
* ```ts
|
|
620
|
-
* // Decode simple object
|
|
621
|
-
* await decodeToon('name: Alice\nage: 30');
|
|
622
|
-
* // { name: 'Alice', age: 30 }
|
|
623
|
-
*
|
|
624
|
-
* // Decode tabular array
|
|
625
|
-
* await decodeToon('[2]{id,name}: 1,Alice 2,Bob');
|
|
626
|
-
* // [{ id: 1, name: 'Alice' }, { id: 2, name: 'Bob' }]
|
|
627
|
-
*
|
|
628
|
-
* // With options
|
|
629
|
-
* await decodeToon(toonString, { strict: false, expandPaths: 'safe' });
|
|
630
|
-
* ```
|
|
631
|
-
*/
|
|
632
|
-
declare function decodeToon(input: string, options?: ToonDecodeOptions): Promise<JsonValue>;
|
|
633
|
-
|
|
634
|
-
export { OpenRouter, type OpenRouterChatSettings, type OpenRouterCompletionSettings, type OpenRouterEmbeddingModelId, type OpenRouterEmbeddingSettings, type OpenRouterProvider, type OpenRouterProviderOptions, type OpenRouterProviderSettings, type OpenRouterSharedSettings, type OpenRouterUsageAccounting, type ToonDecodeOptions, type ToonEncodeOptions, createOpenRouter, decodeToon, encodeToon, openrouter };
|
|
552
|
+
export { OpenRouter, type OpenRouterChatSettings, type OpenRouterCompletionSettings, type OpenRouterEmbeddingModelId, type OpenRouterEmbeddingSettings, type OpenRouterProvider, type OpenRouterProviderOptions, type OpenRouterProviderSettings, type OpenRouterSharedSettings, type OpenRouterUsageAccounting, createOpenRouter, openrouter };
|
package/dist/index.js
CHANGED
|
@@ -49,8 +49,6 @@ var index_exports = {};
|
|
|
49
49
|
__export(index_exports, {
|
|
50
50
|
OpenRouter: () => OpenRouter,
|
|
51
51
|
createOpenRouter: () => createOpenRouter,
|
|
52
|
-
decodeToon: () => decodeToon,
|
|
53
|
-
encodeToon: () => encodeToon,
|
|
54
52
|
openrouter: () => openrouter
|
|
55
53
|
});
|
|
56
54
|
module.exports = __toCommonJS(index_exports);
|
|
@@ -2881,7 +2879,7 @@ function withUserAgentSuffix(headers, ...userAgentSuffixParts) {
|
|
|
2881
2879
|
}
|
|
2882
2880
|
|
|
2883
2881
|
// src/version.ts
|
|
2884
|
-
var VERSION = false ? "0.0.0-test" : "1.5.
|
|
2882
|
+
var VERSION = false ? "0.0.0-test" : "1.5.4";
|
|
2885
2883
|
|
|
2886
2884
|
// src/provider.ts
|
|
2887
2885
|
function createOpenRouter(options = {}) {
|
|
@@ -2949,31 +2947,10 @@ var openrouter = createOpenRouter({
|
|
|
2949
2947
|
compatibility: "strict"
|
|
2950
2948
|
// strict for OpenRouter API
|
|
2951
2949
|
});
|
|
2952
|
-
|
|
2953
|
-
// src/toon/index.ts
|
|
2954
|
-
async function getToonModule() {
|
|
2955
|
-
try {
|
|
2956
|
-
return await import("@toon-format/toon");
|
|
2957
|
-
} catch (e) {
|
|
2958
|
-
throw new Error(
|
|
2959
|
-
"The @toon-format/toon package is required for TOON encoding/decoding. Install it with: npm install @toon-format/toon"
|
|
2960
|
-
);
|
|
2961
|
-
}
|
|
2962
|
-
}
|
|
2963
|
-
async function encodeToon(value, options) {
|
|
2964
|
-
const toon = await getToonModule();
|
|
2965
|
-
return toon.encode(value, options);
|
|
2966
|
-
}
|
|
2967
|
-
async function decodeToon(input, options) {
|
|
2968
|
-
const toon = await getToonModule();
|
|
2969
|
-
return toon.decode(input, options);
|
|
2970
|
-
}
|
|
2971
2950
|
// Annotate the CommonJS export names for ESM import in node:
|
|
2972
2951
|
0 && (module.exports = {
|
|
2973
2952
|
OpenRouter,
|
|
2974
2953
|
createOpenRouter,
|
|
2975
|
-
decodeToon,
|
|
2976
|
-
encodeToon,
|
|
2977
2954
|
openrouter
|
|
2978
2955
|
});
|
|
2979
2956
|
//# sourceMappingURL=index.js.map
|