@mastra/client-js 0.0.0-error-handler-fix-20251020202607 → 0.0.0-esbuild-bundle-worker-20260807182016
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 +9405 -3
- package/LICENSE.md +15 -0
- package/README.md +11 -13
- package/dist/_types/@ai-sdk_provider/dist/index.d.ts +1587 -0
- package/dist/_types/@ai-sdk_provider-utils/dist/index.d.ts +379 -0
- package/dist/_types/@ai-sdk_ui-utils/dist/index.d.ts +820 -0
- package/dist/agent-learning.d.ts +182 -0
- package/dist/agent-learning.d.ts.map +1 -0
- package/dist/client.d.ts +767 -80
- package/dist/client.d.ts.map +1 -1
- package/dist/docs/SKILL.md +52 -0
- package/dist/docs/assets/SOURCE_MAP.json +6 -0
- package/dist/docs/references/docs-agents-a2a.md +340 -0
- package/dist/docs/references/docs-editor-overview.md +349 -0
- package/dist/docs/references/docs-long-running-agents-schedules.md +201 -0
- package/dist/docs/references/docs-long-running-agents-signals.md +426 -0
- package/dist/docs/references/docs-server-auth-auth0.md +262 -0
- package/dist/docs/references/docs-server-auth-clerk.md +154 -0
- package/dist/docs/references/docs-server-auth-firebase.md +294 -0
- package/dist/docs/references/docs-server-auth-jwt.md +116 -0
- package/dist/docs/references/docs-server-auth-supabase.md +139 -0
- package/dist/docs/references/docs-server-auth-workos.md +271 -0
- package/dist/docs/references/docs-server-mastra-client.md +323 -0
- package/dist/docs/references/reference-ai-sdk-to-ai-sdk-messages.md +97 -0
- package/dist/docs/references/reference-ai-sdk-to-ai-sdk-stream.md +282 -0
- package/dist/docs/references/reference-ai-sdk-to-ai-sdk-v4-messages.md +81 -0
- package/dist/docs/references/reference-ai-sdk-to-ai-sdk-v5-messages.md +78 -0
- package/dist/docs/references/reference-client-js-agents.md +959 -0
- package/dist/docs/references/reference-client-js-conversations.md +137 -0
- package/dist/docs/references/reference-client-js-error-handling.md +18 -0
- package/dist/docs/references/reference-client-js-logs.md +26 -0
- package/dist/docs/references/reference-client-js-mastra-client.md +96 -0
- package/dist/docs/references/reference-client-js-memory.md +237 -0
- package/dist/docs/references/reference-client-js-observability.md +183 -0
- package/dist/docs/references/reference-client-js-responses.md +219 -0
- package/dist/docs/references/reference-client-js-telemetry.md +22 -0
- package/dist/docs/references/reference-client-js-tools.md +46 -0
- package/dist/docs/references/reference-client-js-vectors.md +81 -0
- package/dist/docs/references/reference-client-js-workflows.md +393 -0
- package/dist/docs/references/reference-editor-versioning.md +130 -0
- package/dist/index.cjs +7638 -3257
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +9 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +7606 -3252
- package/dist/index.js.map +1 -1
- package/dist/observability/collector.d.ts +45 -0
- package/dist/observability/collector.d.ts.map +1 -0
- package/dist/observability/index.d.ts +14 -0
- package/dist/observability/index.d.ts.map +1 -0
- package/dist/observability/types.d.ts +27 -0
- package/dist/observability/types.d.ts.map +1 -0
- package/dist/resources/a2a.d.ts +80 -11
- package/dist/resources/a2a.d.ts.map +1 -1
- package/dist/resources/agent-builder.d.ts +57 -72
- package/dist/resources/agent-builder.d.ts.map +1 -1
- package/dist/resources/agent-controller.d.ts +589 -0
- package/dist/resources/agent-controller.d.ts.map +1 -0
- package/dist/resources/agent.d.ts +368 -59
- package/dist/resources/agent.d.ts.map +1 -1
- package/dist/resources/base.d.ts +2 -1
- package/dist/resources/base.d.ts.map +1 -1
- package/dist/resources/channels.d.ts +63 -0
- package/dist/resources/channels.d.ts.map +1 -0
- package/dist/resources/conversations.d.ts +15 -0
- package/dist/resources/conversations.d.ts.map +1 -0
- package/dist/resources/index.d.ts +14 -0
- package/dist/resources/index.d.ts.map +1 -1
- package/dist/resources/mcp-tool.d.ts +5 -5
- package/dist/resources/mcp-tool.d.ts.map +1 -1
- package/dist/resources/memory-thread.d.ts +51 -16
- package/dist/resources/memory-thread.d.ts.map +1 -1
- package/dist/resources/observability.d.ts +222 -19
- package/dist/resources/observability.d.ts.map +1 -1
- package/dist/resources/processor-provider.d.ts +15 -0
- package/dist/resources/processor-provider.d.ts.map +1 -0
- package/dist/resources/processor.d.ts +20 -0
- package/dist/resources/processor.d.ts.map +1 -0
- package/dist/resources/responses.d.ts +22 -0
- package/dist/resources/responses.d.ts.map +1 -0
- package/dist/resources/run.d.ts +256 -0
- package/dist/resources/run.d.ts.map +1 -0
- package/dist/resources/stored-agent.d.ts +112 -0
- package/dist/resources/stored-agent.d.ts.map +1 -0
- package/dist/resources/stored-mcp-client.d.ts +30 -0
- package/dist/resources/stored-mcp-client.d.ts.map +1 -0
- package/dist/resources/stored-prompt-block.d.ts +83 -0
- package/dist/resources/stored-prompt-block.d.ts.map +1 -0
- package/dist/resources/stored-scorer.d.ts +83 -0
- package/dist/resources/stored-scorer.d.ts.map +1 -0
- package/dist/resources/stored-skill.d.ts +40 -0
- package/dist/resources/stored-skill.d.ts.map +1 -0
- package/dist/resources/stored-workflow.d.ts +18 -0
- package/dist/resources/stored-workflow.d.ts.map +1 -0
- package/dist/resources/tool-provider.d.ts +80 -0
- package/dist/resources/tool-provider.d.ts.map +1 -0
- package/dist/resources/tool.d.ts +4 -4
- package/dist/resources/vector.d.ts +9 -9
- package/dist/resources/vector.d.ts.map +1 -1
- package/dist/resources/workflow.d.ts +32 -231
- package/dist/resources/workflow.d.ts.map +1 -1
- package/dist/resources/workspace.d.ts +129 -0
- package/dist/resources/workspace.d.ts.map +1 -0
- package/dist/route-types.generated.d.ts +18087 -0
- package/dist/route-types.generated.d.ts.map +1 -0
- package/dist/tools.d.ts +3 -6
- package/dist/tools.d.ts.map +1 -1
- package/dist/types.d.ts +2740 -197
- package/dist/types.d.ts.map +1 -1
- package/dist/utils/client-tool-model-output.d.ts +16 -0
- package/dist/utils/client-tool-model-output.d.ts.map +1 -0
- package/dist/utils/index.d.ts +65 -4
- package/dist/utils/index.d.ts.map +1 -1
- package/dist/utils/process-a2a-stream.d.ts +4 -0
- package/dist/utils/process-a2a-stream.d.ts.map +1 -0
- package/dist/utils/process-client-tools.d.ts.map +1 -1
- package/dist/utils/process-mastra-stream.d.ts +8 -7
- package/dist/utils/process-mastra-stream.d.ts.map +1 -1
- package/dist/utils/stream-transforms.d.ts +9 -0
- package/dist/utils/stream-transforms.d.ts.map +1 -0
- package/dist/utils/verify-agent-card-signature.d.ts +21 -0
- package/dist/utils/verify-agent-card-signature.d.ts.map +1 -0
- package/dist/utils/zod-to-json-schema.d.ts +11 -2
- package/dist/utils/zod-to-json-schema.d.ts.map +1 -1
- package/package.json +26 -19
- package/dist/resources/network-memory-thread.d.ts +0 -47
- package/dist/resources/network-memory-thread.d.ts.map +0 -1
|
@@ -0,0 +1,219 @@
|
|
|
1
|
+
> Discover all available pages from the documentation index: https://mastra.ai/llms.txt
|
|
2
|
+
|
|
3
|
+
# OpenAI Responses API
|
|
4
|
+
|
|
5
|
+
This OpenAI-compatible, agent-backed interface lets you use Mastra Agents as a Responses API. It provides methods to create, retrieve, stream, and delete responses through Mastra agents.
|
|
6
|
+
|
|
7
|
+
These routes are agent-backed adapters over Mastra agents, memory, and storage. Use `agent_id` to select the Mastra agent that should handle the request. You can pass `model` to override the agent's configured model for a single request, or omit it to use the model already configured on the agent.
|
|
8
|
+
|
|
9
|
+
Stored responses also return `conversation_id`. In Mastra, this is the raw memory `threadId`.
|
|
10
|
+
|
|
11
|
+
This API is currently experimental.
|
|
12
|
+
|
|
13
|
+
## Usage example
|
|
14
|
+
|
|
15
|
+
```typescript
|
|
16
|
+
import { MastraClient } from '@mastra/client-js'
|
|
17
|
+
|
|
18
|
+
const client = new MastraClient({
|
|
19
|
+
baseUrl: 'http://localhost:4111',
|
|
20
|
+
})
|
|
21
|
+
|
|
22
|
+
const response = await client.responses.create({
|
|
23
|
+
agent_id: 'support-agent',
|
|
24
|
+
input: 'Summarize this ticket',
|
|
25
|
+
store: true,
|
|
26
|
+
})
|
|
27
|
+
|
|
28
|
+
console.log(response.output_text)
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
## Methods
|
|
32
|
+
|
|
33
|
+
### Lifecycle
|
|
34
|
+
|
|
35
|
+
#### `create(params)`
|
|
36
|
+
|
|
37
|
+
Creates a response.
|
|
38
|
+
|
|
39
|
+
```typescript
|
|
40
|
+
const response = await client.responses.create({
|
|
41
|
+
agent_id: 'support-agent',
|
|
42
|
+
input: 'Summarize this ticket',
|
|
43
|
+
})
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
**Returns:** `Promise<ResponsesResponse>` when `stream` is omitted or `false`.
|
|
47
|
+
|
|
48
|
+
When `stream: true`, `create()` returns an async iterable of SSE-style event payloads:
|
|
49
|
+
|
|
50
|
+
```typescript
|
|
51
|
+
const stream = await client.responses.create({
|
|
52
|
+
agent_id: 'support-agent',
|
|
53
|
+
input: 'Summarize this ticket',
|
|
54
|
+
stream: true,
|
|
55
|
+
})
|
|
56
|
+
|
|
57
|
+
for await (const event of stream) {
|
|
58
|
+
if (event.type === 'response.output_text.delta') {
|
|
59
|
+
process.stdout.write(event.delta)
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
Streaming responses can also include tool events. Tool-call streams use `response.output_item.added`, `response.function_call_arguments.delta`, `response.function_call_arguments.done`, and `response.output_item.done` events. Tool results appear as `function_call_output` items with `<toolCallId>:output` IDs.
|
|
65
|
+
|
|
66
|
+
**Returns:** `Promise<ResponsesStream>`.
|
|
67
|
+
|
|
68
|
+
#### `retrieve(responseId, requestContext?)`
|
|
69
|
+
|
|
70
|
+
Retrieves a stored response.
|
|
71
|
+
|
|
72
|
+
```typescript
|
|
73
|
+
const response = await client.responses.retrieve('msg_123')
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
**Returns:** `Promise<ResponsesResponse>`.
|
|
77
|
+
|
|
78
|
+
#### `delete(responseId, requestContext?)`
|
|
79
|
+
|
|
80
|
+
Deletes a stored response.
|
|
81
|
+
|
|
82
|
+
```typescript
|
|
83
|
+
const deleted = await client.responses.delete('msg_123')
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
**Returns:** `Promise<{ id: string; object: "response"; deleted: true }>`
|
|
87
|
+
|
|
88
|
+
#### `stream(params)`
|
|
89
|
+
|
|
90
|
+
Creates a streaming response.
|
|
91
|
+
|
|
92
|
+
```typescript
|
|
93
|
+
const stream = await client.responses.stream({
|
|
94
|
+
agent_id: 'support-agent',
|
|
95
|
+
input: 'Say hello',
|
|
96
|
+
})
|
|
97
|
+
|
|
98
|
+
for await (const event of stream) {
|
|
99
|
+
console.log(event.type)
|
|
100
|
+
}
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
**Returns:** `Promise<ResponsesStream>`.
|
|
104
|
+
|
|
105
|
+
## Stored responses and conversations
|
|
106
|
+
|
|
107
|
+
Stored responses include both `response.id` and `conversation_id`.
|
|
108
|
+
|
|
109
|
+
- `response.id` is the response ID. For stored agent-backed responses, this is the persisted assistant message ID.
|
|
110
|
+
- `conversation_id` is the raw Mastra thread ID.
|
|
111
|
+
|
|
112
|
+
Use `previous_response_id` when you want to continue from a previous stored response. Use `conversation_id` when you want to target a known thread directly.
|
|
113
|
+
|
|
114
|
+
```typescript
|
|
115
|
+
const first = await client.responses.create({
|
|
116
|
+
agent_id: 'support-agent',
|
|
117
|
+
input: 'Start a support thread',
|
|
118
|
+
store: true,
|
|
119
|
+
})
|
|
120
|
+
|
|
121
|
+
const second = await client.responses.create({
|
|
122
|
+
agent_id: 'support-agent',
|
|
123
|
+
conversation_id: first.conversation_id!,
|
|
124
|
+
input: 'Add a follow-up to the same thread',
|
|
125
|
+
store: true,
|
|
126
|
+
})
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
Use [`client.conversations`](https://mastra.ai/reference/client-js/conversations) when you want to create, retrieve, delete, or inspect the underlying OpenAI Responses API conversation directly.
|
|
130
|
+
|
|
131
|
+
## Function calling (tools)
|
|
132
|
+
|
|
133
|
+
`response.tools` contains the configured function definitions available for the request.
|
|
134
|
+
|
|
135
|
+
If the model calls a function, that activity is included in `response.output` as `function_call` and `function_call_output` items alongside the final assistant `message`.
|
|
136
|
+
|
|
137
|
+
When `stream: true`, function calls are also emitted as Responses stream events. Read `response.function_call_arguments.delta` events for partial argument chunks and prefer `response.function_call_arguments.done` for the finalized arguments payload and tool name. Read `response.output_item.done` events for completed `function_call` and `function_call_output` items. Tool output items use `<toolCallId>:output` IDs.
|
|
138
|
+
|
|
139
|
+
## Structured output
|
|
140
|
+
|
|
141
|
+
Use `text.format` when you want JSON output.
|
|
142
|
+
|
|
143
|
+
- `json_object` enables JSON mode.
|
|
144
|
+
- `json_schema` enables schema-constrained structured output.
|
|
145
|
+
|
|
146
|
+
Both formats return JSON in the assistant message content. Use `json_schema` when you need strict schema enforcement. Use `json_object` when you only need valid JSON output.
|
|
147
|
+
|
|
148
|
+
```typescript
|
|
149
|
+
const response = await client.responses.create({
|
|
150
|
+
agent_id: 'support-agent',
|
|
151
|
+
input: 'Return a structured support ticket summary.',
|
|
152
|
+
text: {
|
|
153
|
+
format: {
|
|
154
|
+
type: 'json_schema',
|
|
155
|
+
name: 'ticket_summary',
|
|
156
|
+
schema: {
|
|
157
|
+
type: 'object',
|
|
158
|
+
properties: {
|
|
159
|
+
summary: { type: 'string' },
|
|
160
|
+
priority: { type: 'string' },
|
|
161
|
+
},
|
|
162
|
+
required: ['summary', 'priority'],
|
|
163
|
+
additionalProperties: false,
|
|
164
|
+
},
|
|
165
|
+
},
|
|
166
|
+
},
|
|
167
|
+
})
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
## Provider-backed requests
|
|
171
|
+
|
|
172
|
+
Use `providerOptions` when you need provider-specific options that Mastra doesn't normalize at the Responses layer.
|
|
173
|
+
|
|
174
|
+
```typescript
|
|
175
|
+
const response = await client.responses.create({
|
|
176
|
+
agent_id: 'support-agent',
|
|
177
|
+
input: 'Continue this exchange',
|
|
178
|
+
providerOptions: {
|
|
179
|
+
openai: {
|
|
180
|
+
previousResponseId: 'resp_123',
|
|
181
|
+
},
|
|
182
|
+
},
|
|
183
|
+
})
|
|
184
|
+
```
|
|
185
|
+
|
|
186
|
+
## Response shape
|
|
187
|
+
|
|
188
|
+
The returned response object includes:
|
|
189
|
+
|
|
190
|
+
- `id`: The response ID
|
|
191
|
+
- `output`: Output items such as the assistant `message`, `function_call`, and `function_call_output`
|
|
192
|
+
- `output_text`: Convenience getter that joins assistant text output
|
|
193
|
+
- `tools`: Configured tool definitions for the request
|
|
194
|
+
- `conversation_id`: The raw thread ID for stored responses
|
|
195
|
+
- `text`: The requested text output format, when provided
|
|
196
|
+
|
|
197
|
+
## Parameters
|
|
198
|
+
|
|
199
|
+
**agent\_id** (`string`): Required on initial requests. Selects the Mastra agent that executes the request. Stored follow-up turns can omit it when continuing with previous\_response\_id.
|
|
200
|
+
|
|
201
|
+
**model** (`string`): Optional model override for this request, such as openai/gpt-5. If omitted, Mastra uses the model configured on the selected agent.
|
|
202
|
+
|
|
203
|
+
**input** (`string | Array<{ role: 'system' | 'developer' | 'user' | 'assistant'; content: string | Array<{ type: 'input_text' | 'text' | 'output_text'; text: string }> }>`): Required. Input text or message array for the response.
|
|
204
|
+
|
|
205
|
+
**instructions** (`string`): Optional instruction override for this request.
|
|
206
|
+
|
|
207
|
+
**text** (`{ format: { type: 'json_object' } | { type: 'json_schema'; name: string; schema: Record<string, unknown>; description?: string; strict?: boolean } }`): Optional text output format. Use json\_object for JSON mode or json\_schema for schema-constrained structured output.
|
|
208
|
+
|
|
209
|
+
**providerOptions** (`Record<string, Record<string, unknown> | undefined>`): Optional provider-specific options passed through to the underlying model call.
|
|
210
|
+
|
|
211
|
+
**stream** (`boolean`): When true, returns an async iterable of Responses API events.
|
|
212
|
+
|
|
213
|
+
**store** (`boolean`): When true, persists the response through the selected agent memory.
|
|
214
|
+
|
|
215
|
+
**conversation\_id** (`string`): Optional conversation identifier. In Mastra, this is the raw memory thread ID.
|
|
216
|
+
|
|
217
|
+
**previous\_response\_id** (`string`): Continues a stored response chain from a previous stored response.
|
|
218
|
+
|
|
219
|
+
**requestContext** (`RequestContext | Record<string, any>`): Optional request context forwarded to the Mastra server.
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
> Discover all available pages from the documentation index: https://mastra.ai/llms.txt
|
|
2
|
+
|
|
3
|
+
# Telemetry API
|
|
4
|
+
|
|
5
|
+
The Telemetry API provides methods to retrieve and analyze traces from your Mastra application. This helps you monitor and debug your application's behavior and performance.
|
|
6
|
+
|
|
7
|
+
## Getting traces
|
|
8
|
+
|
|
9
|
+
Retrieve traces with optional filtering and pagination:
|
|
10
|
+
|
|
11
|
+
```typescript
|
|
12
|
+
const telemetry = await mastraClient.getTelemetry({
|
|
13
|
+
name: 'trace-name', // Optional: Filter by trace name
|
|
14
|
+
scope: 'scope-name', // Optional: Filter by scope
|
|
15
|
+
page: 1, // Optional: Page number for pagination
|
|
16
|
+
perPage: 10, // Optional: Number of items per page
|
|
17
|
+
attribute: {
|
|
18
|
+
// Optional: Filter by custom attributes
|
|
19
|
+
key: 'value',
|
|
20
|
+
},
|
|
21
|
+
})
|
|
22
|
+
```
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
> Discover all available pages from the documentation index: https://mastra.ai/llms.txt
|
|
2
|
+
|
|
3
|
+
# Tools API
|
|
4
|
+
|
|
5
|
+
The Tools API provides methods to interact with and execute tools available in the Mastra platform.
|
|
6
|
+
|
|
7
|
+
## Getting all tools
|
|
8
|
+
|
|
9
|
+
Retrieve a list of all available tools:
|
|
10
|
+
|
|
11
|
+
```typescript
|
|
12
|
+
const tools = await mastraClient.listTools()
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## Working with a specific tool
|
|
16
|
+
|
|
17
|
+
Get an instance of a specific tool:
|
|
18
|
+
|
|
19
|
+
```typescript
|
|
20
|
+
const tool = mastraClient.getTool('tool-id')
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
## Tool methods
|
|
24
|
+
|
|
25
|
+
### Get Tool Details
|
|
26
|
+
|
|
27
|
+
Retrieve detailed information about a tool:
|
|
28
|
+
|
|
29
|
+
```typescript
|
|
30
|
+
const details = await tool.details()
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
### Execute Tool
|
|
34
|
+
|
|
35
|
+
Execute a tool with specific arguments:
|
|
36
|
+
|
|
37
|
+
```typescript
|
|
38
|
+
const result = await tool.execute({
|
|
39
|
+
args: {
|
|
40
|
+
param1: 'value1',
|
|
41
|
+
param2: 'value2',
|
|
42
|
+
},
|
|
43
|
+
threadId: 'thread-1', // Optional: Thread context
|
|
44
|
+
resourceId: 'resource-1', // Optional: Resource identifier
|
|
45
|
+
})
|
|
46
|
+
```
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
> Discover all available pages from the documentation index: https://mastra.ai/llms.txt
|
|
2
|
+
|
|
3
|
+
# Vectors API
|
|
4
|
+
|
|
5
|
+
The Vectors API provides methods to work with vector embeddings for semantic search and similarity matching in Mastra.
|
|
6
|
+
|
|
7
|
+
## Working with vectors
|
|
8
|
+
|
|
9
|
+
Get an instance of a vector store:
|
|
10
|
+
|
|
11
|
+
```typescript
|
|
12
|
+
const vector = mastraClient.getVector('vector-name')
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## Vector methods
|
|
16
|
+
|
|
17
|
+
### Get Vector Index Details
|
|
18
|
+
|
|
19
|
+
Retrieve information about a specific vector index:
|
|
20
|
+
|
|
21
|
+
```typescript
|
|
22
|
+
const details = await vector.details('index-name')
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
### Create Vector Index
|
|
26
|
+
|
|
27
|
+
Create a new vector index:
|
|
28
|
+
|
|
29
|
+
```typescript
|
|
30
|
+
const result = await vector.createIndex({
|
|
31
|
+
indexName: 'new-index',
|
|
32
|
+
dimension: 128,
|
|
33
|
+
metric: 'cosine', // 'cosine', 'euclidean', or 'dotproduct'
|
|
34
|
+
})
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
### Upsert Vectors
|
|
38
|
+
|
|
39
|
+
Add or update vectors in an index:
|
|
40
|
+
|
|
41
|
+
```typescript
|
|
42
|
+
const ids = await vector.upsert({
|
|
43
|
+
indexName: 'my-index',
|
|
44
|
+
vectors: [
|
|
45
|
+
[0.1, 0.2, 0.3], // First vector
|
|
46
|
+
[0.4, 0.5, 0.6], // Second vector
|
|
47
|
+
],
|
|
48
|
+
metadata: [{ label: 'first' }, { label: 'second' }],
|
|
49
|
+
ids: ['id1', 'id2'], // Optional: Custom IDs
|
|
50
|
+
})
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
### Query Vectors
|
|
54
|
+
|
|
55
|
+
Search for similar vectors:
|
|
56
|
+
|
|
57
|
+
```typescript
|
|
58
|
+
const results = await vector.query({
|
|
59
|
+
indexName: 'my-index',
|
|
60
|
+
queryVector: [0.1, 0.2, 0.3],
|
|
61
|
+
topK: 10,
|
|
62
|
+
filter: { label: 'first' }, // Optional: Metadata filter
|
|
63
|
+
includeVector: true, // Optional: Include vectors in results
|
|
64
|
+
})
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
### Get All Indexes
|
|
68
|
+
|
|
69
|
+
List all available indexes:
|
|
70
|
+
|
|
71
|
+
```typescript
|
|
72
|
+
const indexes = await vector.getIndexes()
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
### Delete Index
|
|
76
|
+
|
|
77
|
+
Delete a vector index:
|
|
78
|
+
|
|
79
|
+
```typescript
|
|
80
|
+
const result = await vector.delete('index-name')
|
|
81
|
+
```
|