mastra-ai/mastra · error
toAISdkFormat() has been deprecated. Please use toAISdkStrea
Error message
toAISdkFormat() has been deprecated. Please use toAISdkStream() instead.
Migration:
import { toAISdkFormat } from "@mastra/ai-sdk";
// Change to:
import { toAISdkStream } from "@mastra/ai-sdk";
The function signature remains the same. What it means
toAISdkFormat was removed and replaced by toAISdkStream in @mastra/ai-sdk. The old export now always throws this deprecation error with migration instructions; the function signature is unchanged, so only the name needs updating.
Source
Thrown at client-sdks/ai-sdk/src/to-ai-sdk-format.ts:16
/**
* @deprecated Use `toAISdkStream` instead. This function has been renamed for clarity.
*
* @example
* ```typescript
* // Old (deprecated):
* import { toAISdkFormat } from '@mastra/ai-sdk';
* const stream = toAISdkFormat(agentStream, { from: 'agent' });
*
* // New:
* import { toAISdkStream } from '@mastra/ai-sdk';
* const stream = toAISdkStream(agentStream, { from: 'agent' });
* ```
*/
export function toAISdkFormat(): never {
throw new Error(
'toAISdkFormat() has been deprecated. Please use toAISdkStream() instead.\n\n' +
'Migration:\n' +
' import { toAISdkFormat } from "@mastra/ai-sdk";\n' +
' // Change to:\n' +
' import { toAISdkStream } from "@mastra/ai-sdk";\n\n' +
'The function signature remains the same.',
);
}
View on GitHub (pinned to 75dd419e61)
Solutions
- Rename the call from toAISdkFormat to toAISdkStream; arguments stay the same.
- Update the import to: import { toAISdkStream } from '@mastra/ai-sdk'.
- Search the codebase for toAISdkFormat to catch all call sites.
- Follow the migration note in the @mastra/ai-sdk changelog for the release you upgraded to.
Example fix
// before
import { toAISdkFormat } from '@mastra/ai-sdk';
const uiStream = toAISdkFormat(agentStream, { from: 'agent' });
// after
import { toAISdkStream } from '@mastra/ai-sdk';
const uiStream = toAISdkStream(agentStream, { from: 'agent' }); Defensive patterns
Strategy: try-catch
Validate before calling
import * as aiSdk from '@mastra/ai-sdk';
if (!('toAISdkStream' in aiSdk)) throw new Error('Upgrade @mastra/ai-sdk'); Try / catch
let uiStream;
try {
uiStream = toAISdkStream(agentStream, { from: 'agent' });
} catch (e) {
if (e instanceof Error && e.message.includes('deprecated')) {
uiStream = toAISdkStream(agentStream, { from: 'agent' });
} else throw e;
} Prevention
- Grep for removed API names after each @mastra/ai-sdk upgrade.
- Follow changelogs/codemods for renamed exports.
- Avoid importing deprecated exports; prefer the current documented API.
When it happens
Trigger: Calling toAISdkFormat(agentStream, { from: 'agent' }) anywhere in app code after upgrading to a @mastra/ai-sdk version where the export was deprecated; importing the old name from autocomplete or older docs/snippets.
Common situations: Upgrading @mastra/ai-sdk without following the codemod/changelog; copy-pasted tutorial code written against the old API; TypeScript types don't flag it because the export still exists (typed as never).
Related errors
- The 'processors' option in Memory is deprecated and has been
- MastraFactory: 'sandbox' is now a callback, not an options o
- The workingMemory.use option has been removed. Working memor
- The threads.generateTitle option has been moved. Use the top
- The "elicitation" key is now nested under "mcp.elicitation"
AI-assisted analysis of mastra-ai/mastra@75dd419e61 (2026-08-30).
Data as JSON: /api/errors/a0e638711bb33ad2.
Report an issue: GitHub.