@mastra/voyageai 0.0.0

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.
@@ -0,0 +1,251 @@
1
+ /**
2
+ * VoyageAI Embeddings - Type Definitions
3
+ */
4
+ /**
5
+ * VoyageAI text embedding models
6
+ */
7
+ export type VoyageTextModel = 'voyage-4-large' | 'voyage-4' | 'voyage-4-lite' | 'voyage-3-large' | 'voyage-3.5' | 'voyage-3.5-lite' | 'voyage-code-3' | 'voyage-finance-2' | 'voyage-law-2';
8
+ /**
9
+ * VoyageAI multimodal embedding models
10
+ */
11
+ export type VoyageMultimodalModel = 'voyage-multimodal-3' | 'voyage-multimodal-3.5';
12
+ /**
13
+ * VoyageAI contextualized chunk embedding models
14
+ */
15
+ export type VoyageContextModel = 'voyage-context-3';
16
+ /**
17
+ * All VoyageAI embedding models
18
+ */
19
+ export type VoyageModel = VoyageTextModel | VoyageMultimodalModel | VoyageContextModel;
20
+ /**
21
+ * Input type for retrieval optimization
22
+ * - 'query': For search queries - Voyage prepends a query-specific prompt
23
+ * - 'document': For documents being indexed - Voyage prepends a document-specific prompt
24
+ * - null/undefined: No prompt prepended
25
+ */
26
+ export type VoyageInputType = 'query' | 'document' | null;
27
+ /**
28
+ * Output data type options for embeddings
29
+ */
30
+ export type VoyageOutputDtype = 'float' | 'int8' | 'uint8' | 'binary' | 'ubinary';
31
+ /**
32
+ * Supported output dimensions for flexible dimensionality models
33
+ */
34
+ export type VoyageOutputDimension = 256 | 512 | 1024 | 2048;
35
+ /**
36
+ * Configuration for VoyageAI text embedding models
37
+ */
38
+ export interface VoyageTextEmbeddingConfig {
39
+ /** The model to use for embeddings */
40
+ model: VoyageTextModel;
41
+ /** API key (defaults to VOYAGE_API_KEY env var) */
42
+ apiKey?: string;
43
+ /** Input type for retrieval optimization */
44
+ inputType?: VoyageInputType;
45
+ /** Output embedding dimension (model-dependent, default 1024) */
46
+ outputDimension?: VoyageOutputDimension;
47
+ /** Output data type (default 'float') */
48
+ outputDtype?: VoyageOutputDtype;
49
+ /** Whether to truncate inputs that exceed context length (default true) */
50
+ truncation?: boolean;
51
+ }
52
+ /**
53
+ * Text content for multimodal embeddings
54
+ */
55
+ export interface VoyageTextContent {
56
+ type: 'text';
57
+ text: string;
58
+ }
59
+ /**
60
+ * Image URL content for multimodal embeddings
61
+ */
62
+ export interface VoyageImageUrlContent {
63
+ type: 'image_url';
64
+ image_url: string;
65
+ }
66
+ /**
67
+ * Base64-encoded image content for multimodal embeddings
68
+ */
69
+ export interface VoyageImageBase64Content {
70
+ type: 'image_base64';
71
+ image_base64: string;
72
+ }
73
+ /**
74
+ * Video URL content for multimodal embeddings (voyage-multimodal-3.5 only)
75
+ */
76
+ export interface VoyageVideoUrlContent {
77
+ type: 'video_url';
78
+ video_url: string;
79
+ }
80
+ /**
81
+ * All multimodal content types
82
+ */
83
+ export type VoyageMultimodalContent = VoyageTextContent | VoyageImageUrlContent | VoyageImageBase64Content | VoyageVideoUrlContent;
84
+ /**
85
+ * Single multimodal input - an array of interleaved content
86
+ */
87
+ export interface VoyageMultimodalInput {
88
+ content: VoyageMultimodalContent[];
89
+ }
90
+ /**
91
+ * Configuration for VoyageAI multimodal embedding models
92
+ */
93
+ export interface VoyageMultimodalEmbeddingConfig {
94
+ /** The model to use (voyage-multimodal-3 or voyage-multimodal-3.5) */
95
+ model: VoyageMultimodalModel;
96
+ /** API key (defaults to VOYAGE_API_KEY env var) */
97
+ apiKey?: string;
98
+ /** Input type for retrieval optimization */
99
+ inputType?: VoyageInputType;
100
+ /** Whether to truncate inputs that exceed context length (default true) */
101
+ truncation?: boolean;
102
+ }
103
+ /**
104
+ * Configuration for VoyageAI contextualized chunk embedding models
105
+ */
106
+ export interface VoyageContextualizedEmbeddingConfig {
107
+ /** The model to use (voyage-context-3) */
108
+ model: VoyageContextModel;
109
+ /** API key (defaults to VOYAGE_API_KEY env var) */
110
+ apiKey?: string;
111
+ /** Input type for retrieval optimization */
112
+ inputType?: VoyageInputType;
113
+ /** Output embedding dimension (default 1024) */
114
+ outputDimension?: VoyageOutputDimension;
115
+ /** Output data type (default 'float') */
116
+ outputDtype?: VoyageOutputDtype;
117
+ }
118
+ /**
119
+ * VoyageAI-specific provider options for runtime configuration
120
+ * Used with Mastra's providerOptions to override embedding config at call time
121
+ */
122
+ export interface VoyageProviderOptions {
123
+ voyage?: {
124
+ /** Input type for retrieval optimization */
125
+ inputType?: VoyageInputType;
126
+ /** Output embedding dimension */
127
+ outputDimension?: VoyageOutputDimension;
128
+ /** Output data type */
129
+ outputDtype?: VoyageOutputDtype;
130
+ /** Whether to truncate inputs */
131
+ truncation?: boolean;
132
+ };
133
+ }
134
+ /**
135
+ * Metadata for VoyageAI embedding models
136
+ */
137
+ export interface VoyageModelInfo {
138
+ id: VoyageModel;
139
+ maxInputTokens: number;
140
+ defaultDimension: number;
141
+ supportedDimensions?: VoyageOutputDimension[];
142
+ isMultimodal: boolean;
143
+ isContextualized: boolean;
144
+ }
145
+ /**
146
+ * Model metadata for all VoyageAI text embedding models
147
+ */
148
+ export declare const TEXT_MODEL_INFO: Record<VoyageTextModel, Omit<VoyageModelInfo, 'id'>>;
149
+ /**
150
+ * Model metadata for VoyageAI multimodal embedding models
151
+ */
152
+ export declare const MULTIMODAL_MODEL_INFO: Record<VoyageMultimodalModel, Omit<VoyageModelInfo, 'id'>>;
153
+ /**
154
+ * Model metadata for VoyageAI contextualized embedding models
155
+ */
156
+ export declare const CONTEXTUALIZED_MODEL_INFO: Record<VoyageContextModel, Omit<VoyageModelInfo, 'id'>>;
157
+ /**
158
+ * VoyageAI embedding response
159
+ */
160
+ export interface VoyageEmbeddingResponse {
161
+ object: 'list';
162
+ data: Array<{
163
+ object: 'embedding';
164
+ embedding: number[];
165
+ index: number;
166
+ }>;
167
+ model: string;
168
+ usage: {
169
+ total_tokens: number;
170
+ };
171
+ }
172
+ /**
173
+ * Single chunk embedding from contextualized embeddings API
174
+ */
175
+ export interface VoyageContextualizedChunkEmbedding {
176
+ /** The object type, which is always "embedding" */
177
+ object?: string;
178
+ /** The embedding vector for this chunk */
179
+ embedding?: number[];
180
+ /** The index of this chunk within the document */
181
+ index?: number;
182
+ }
183
+ /**
184
+ * Single document result from contextualized embeddings API
185
+ */
186
+ export interface VoyageContextualizedDocumentResult {
187
+ /** The object type, which is always "list" */
188
+ object?: string;
189
+ /** Array of chunk embeddings for this document */
190
+ data?: VoyageContextualizedChunkEmbedding[];
191
+ /** The index of this document within the input list */
192
+ index?: number;
193
+ }
194
+ /**
195
+ * VoyageAI contextualized embedding response
196
+ * Structure: response.data[docIndex].data[chunkIndex].embedding
197
+ */
198
+ export interface VoyageContextualizedEmbeddingResponse {
199
+ object: 'list';
200
+ /** Array of document results, each containing chunk embeddings */
201
+ data: VoyageContextualizedDocumentResult[];
202
+ model: string;
203
+ usage: {
204
+ total_tokens: number;
205
+ };
206
+ }
207
+ /**
208
+ * VoyageAI reranking models
209
+ */
210
+ export type VoyageRerankerModel = 'rerank-2.5' | 'rerank-2.5-lite' | 'rerank-2' | 'rerank-2-lite' | 'rerank-1' | 'rerank-lite-1';
211
+ /**
212
+ * Configuration for VoyageAI reranker
213
+ */
214
+ export interface VoyageRerankerConfig {
215
+ /** The reranker model to use */
216
+ model: VoyageRerankerModel;
217
+ /** API key (defaults to VOYAGE_API_KEY env var) */
218
+ apiKey?: string;
219
+ /** Whether to truncate inputs that exceed context length (default true) */
220
+ truncation?: boolean;
221
+ }
222
+ /**
223
+ * Single reranking result from VoyageAI
224
+ */
225
+ export interface VoyageRerankResult {
226
+ /** Index of the document in the original input array */
227
+ index: number;
228
+ /** The original document text */
229
+ document: string;
230
+ /** Relevance score (higher = more relevant) */
231
+ relevance_score: number;
232
+ }
233
+ /**
234
+ * VoyageAI reranking API response
235
+ */
236
+ export interface VoyageRerankResponse {
237
+ object: 'list';
238
+ data: VoyageRerankResult[];
239
+ model: string;
240
+ usage: {
241
+ total_tokens: number;
242
+ };
243
+ }
244
+ /**
245
+ * Model metadata for VoyageAI reranker models
246
+ */
247
+ export declare const RERANKER_MODEL_INFO: Record<VoyageRerankerModel, {
248
+ contextLength: number;
249
+ description: string;
250
+ }>;
251
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AAMH;;GAEG;AACH,MAAM,MAAM,eAAe,GACvB,gBAAgB,GAChB,UAAU,GACV,eAAe,GACf,gBAAgB,GAChB,YAAY,GACZ,iBAAiB,GACjB,eAAe,GACf,kBAAkB,GAClB,cAAc,CAAC;AAEnB;;GAEG;AACH,MAAM,MAAM,qBAAqB,GAAG,qBAAqB,GAAG,uBAAuB,CAAC;AAEpF;;GAEG;AACH,MAAM,MAAM,kBAAkB,GAAG,kBAAkB,CAAC;AAEpD;;GAEG;AACH,MAAM,MAAM,WAAW,GAAG,eAAe,GAAG,qBAAqB,GAAG,kBAAkB,CAAC;AAMvF;;;;;GAKG;AACH,MAAM,MAAM,eAAe,GAAG,OAAO,GAAG,UAAU,GAAG,IAAI,CAAC;AAE1D;;GAEG;AACH,MAAM,MAAM,iBAAiB,GAAG,OAAO,GAAG,MAAM,GAAG,OAAO,GAAG,QAAQ,GAAG,SAAS,CAAC;AAElF;;GAEG;AACH,MAAM,MAAM,qBAAqB,GAAG,GAAG,GAAG,GAAG,GAAG,IAAI,GAAG,IAAI,CAAC;AAM5D;;GAEG;AACH,MAAM,WAAW,yBAAyB;IACxC,sCAAsC;IACtC,KAAK,EAAE,eAAe,CAAC;IACvB,mDAAmD;IACnD,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,4CAA4C;IAC5C,SAAS,CAAC,EAAE,eAAe,CAAC;IAC5B,iEAAiE;IACjE,eAAe,CAAC,EAAE,qBAAqB,CAAC;IACxC,yCAAyC;IACzC,WAAW,CAAC,EAAE,iBAAiB,CAAC;IAChC,2EAA2E;IAC3E,UAAU,CAAC,EAAE,OAAO,CA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BAAmB,EAAE,MAAM,CAAC,mBAAmB,EAAE;IAAE,aAAa,EAAE,MAAM,CAAC;IAAC,WAAW,EAAE,MAAM,CAAA;CAAE,CAyB3G,CAAC"}
package/package.json ADDED
@@ -0,0 +1,73 @@
1
+ {
2
+ "name": "@mastra/voyageai",
3
+ "version": "0.0.0",
4
+ "description": "VoyageAI embeddings integration for Mastra - text, multimodal, and contextualized chunk embeddings",
5
+ "license": "Apache-2.0",
6
+ "type": "module",
7
+ "main": "dist/index.js",
8
+ "types": "dist/index.d.ts",
9
+ "exports": {
10
+ ".": {
11
+ "import": {
12
+ "types": "./dist/index.d.ts",
13
+ "default": "./dist/index.js"
14
+ },
15
+ "require": {
16
+ "types": "./dist/index.d.ts",
17
+ "default": "./dist/index.cjs"
18
+ }
19
+ },
20
+ "./package.json": "./package.json"
21
+ },
22
+ "files": [
23
+ "dist",
24
+ "CHANGELOG.md"
25
+ ],
26
+ "homepage": "https://mastra.ai",
27
+ "repository": {
28
+ "type": "git",
29
+ "url": "git+https://github.com/mastra-ai/mastra.git",
30
+ "directory": "embedders/voyageai"
31
+ },
32
+ "bugs": {
33
+ "url": "https://github.com/mastra-ai/mastra/issues"
34
+ },
35
+ "scripts": {
36
+ "build": "tsup --silent --config tsup.config.ts",
37
+ "build:watch": "tsup --watch --silent --config tsup.config.ts",
38
+ "test": "vitest run"
39
+ },
40
+ "dependencies": {
41
+ "voyageai": "^0.2.1"
42
+ },
43
+ "peerDependencies": {
44
+ "zod": "^3.25.0 || ^4.0.0"
45
+ },
46
+ "devDependencies": {
47
+ "@internal/ai-sdk-v4": "workspace:*",
48
+ "@internal/ai-sdk-v5": "workspace:*",
49
+ "@internal/ai-v6": "workspace:*",
50
+ "@internal/lint": "workspace:*",
51
+ "@internal/types-builder": "workspace:*",
52
+ "@types/node": "22.19.15",
53
+ "@vitest/coverage-v8": "catalog:",
54
+ "@vitest/ui": "catalog:",
55
+ "tsup": "^8.5.0",
56
+ "typescript": "catalog:",
57
+ "vitest": "catalog:",
58
+ "zod": "catalog:"
59
+ },
60
+ "engines": {
61
+ "node": ">=22.13.0"
62
+ },
63
+ "keywords": [
64
+ "mastra",
65
+ "voyage",
66
+ "voyageai",
67
+ "embeddings",
68
+ "multimodal",
69
+ "ai",
70
+ "rag",
71
+ "vector"
72
+ ]
73
+ }