@mastra/core
Version:
Mastra is a framework for building AI-powered applications and agents with a modern TypeScript stack.
47 lines (30 loc) • 1.41 kB
Markdown
# dataset.startExperimentAsync()
**Added in:** `@mastra/core@1.4.0`
Starts an experiment asynchronously (fire-and-forget). Returns immediately with the experiment ID and a `'pending'` status. The experiment runs in the background.
## Usage example
```typescript
import { Mastra } from '@mastra/core'
const mastra = new Mastra({
/* storage config */
})
const dataset = await mastra.datasets.get({ id: 'dataset-id' })
// Start experiment without waiting
const { experimentId, status } = await dataset.startExperimentAsync({
targetType: 'agent',
targetId: 'my-agent',
scorers: ['accuracy'],
})
console.log(`Experiment ${experimentId} started with status: ${status}`)
// Check progress later
const experiment = await dataset.getExperiment({ experimentId })
console.log(`Current status: ${experiment.status}`)
```
## Parameters
Takes the same `StartExperimentConfig` as [`dataset.startExperiment()`](https://mastra.ai/reference/datasets/startExperiment).
## Returns
**result** (`Promise<object>`): Immediate response with experiment ID.
**result.experimentId** (`string`): Unique ID of the created experiment.
**result.status** (`'pending'`): Always \`'pending'\` since the experiment hasn't started executing yet.
## Related
- [dataset.startExperiment()](https://mastra.ai/reference/datasets/startExperiment)
- [dataset.getExperiment()](https://mastra.ai/reference/datasets/getExperiment)