Skip to main content

DatasetsManager.create()

Added in: @mastra/core@1.4.0

Creates a new dataset. Zod schemas passed as inputSchema or groundTruthSchema are automatically converted to JSON Schema.

Usage example
Direct 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 schemas
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(),
}),
})

Parameters
Direct link to Parameters

name:

string
Display name for the dataset.

description?:

string
Description of the dataset.

inputSchema?:

unknown
JSON Schema or Zod schema for item inputs. Zod schemas are auto-converted.

groundTruthSchema?:

unknown
JSON Schema or Zod schema for item ground truths. Zod schemas are auto-converted.

metadata?:

Record<string, unknown>
Arbitrary metadata.

Returns
Direct link to Returns

result:

Promise<Dataset>
A Dataset instance for the newly created dataset.
On this page