DatasetsManager.create()
Added in: @mastra/core@1.4.0
Creates a new dataset. Use Standard JSON Schema (Zod, Valibot, ArkType, etc.) for defining schemas.
Usage exampleDirect link to Usage example
import { Mastra } from '@mastra/core'
import { z } from 'zod'
const mastra = new Mastra({
/* storage config */
})
// Create with metadata
const dataset = await mastra.datasets.create({
name: 'QA evaluation set',
description: 'Question-answer pairs for testing',
metadata: { team: 'ml' },
})
// Create with Zod schema (library that supports Standard JSON Schema)
const typedDataset = await mastra.datasets.create({
name: 'Typed QA set',
inputSchema: z.object({
question: z.string(),
context: z.string().optional(),
}),
groundTruthSchema: z.object({
answer: z.string(),
}),
})
ParametersDirect link to Parameters
name:
string
Display name for the dataset.
description?:
string
Description of the dataset.
inputSchema?:
StandardJSONSchemaV1
Standard JSON Schema for item inputs.
groundTruthSchema?:
StandardJSONSchemaV1
Standard JSON Schema for item ground truths.
metadata?:
Record<string, unknown>
Arbitrary metadata.
ReturnsDirect link to Returns
result:
Promise<Dataset>
A Dataset instance for the newly created dataset.