
Research
/Security News
Miasma Mini Shai-Hulud Hits ImmobiliareLabs npm Packages
Miasma Mini Shai-Hulud hits @immobiliarelabs Backstage plugins, targeting GitLab and LDAP auth packages on npm.
@mastra/openai
Advanced tools
Affected versions:
@mastra/openai connects Mastra to the OpenAI Agents SDK. Use it when you want to register an OpenAI SDK agent with Mastra and call it through Mastra-compatible generate() and stream() methods.
npm install @mastra/openai @openai/agents
The package exports OpenAISDKAgent, a Mastra Agent wrapper around the OpenAI Agents SDK run loop.
OpenAISDKAgent keeps the OpenAI SDK run loop in charge. Mastra receives compatible outputs, usage data, and tracing data for the run.
Pass OpenAI Agents SDK configuration through sdkOptions. OpenAISDKAgent creates the SDK agent on first use.
import { OpenAISDKAgent } from '@mastra/openai';
export const openaiAgent = new OpenAISDKAgent({
id: 'openai-sdk-agent',
name: 'OpenAI SDK Agent',
description: 'Use OpenAI Agents SDK through Mastra.',
sdkOptions: {
name: 'Repository assistant',
instructions: 'Answer clearly and cite the relevant files.',
model: '__GATEWAY_OPENAI_MODEL_BASE__',
},
});
You can also pass an existing OpenAI SDK agent when your app already creates or owns it.
import { Agent as OpenAIAgent } from '@openai/agents';
import { OpenAISDKAgent } from '@mastra/openai';
const sdkAgent = new OpenAIAgent({
name: 'Repository assistant',
instructions: 'Answer clearly and cite the relevant files.',
model: '__GATEWAY_OPENAI_MODEL_BASE__',
});
export const openaiAgent = new OpenAISDKAgent({
id: 'openai-sdk-agent',
description: 'Use OpenAI Agents SDK through Mastra.',
agent: sdkAgent,
});
You can register the wrapper anywhere Mastra accepts an Agent.
import { Mastra } from '@mastra/core/mastra';
export const mastra = new Mastra({
agents: {
openaiAgent,
},
});
const result = await openaiAgent.generate('Summarize the latest changes in this repository.', {
runId: 'openai-run',
maxSteps: 3,
});
console.log(result.text);
const stream = await openaiAgent.stream('Review this package for test gaps.');
for await (const chunk of stream.fullStream) {
if (chunk.type === 'text-delta') {
process.stdout.write(chunk.payload.text);
}
}
OpenAISDKAgent forwards sdkOptions to the OpenAI SDK Agent constructor when agent is not provided. These include name, instructions, model, tools, handoffs, guardrails, and other OpenAI Agents SDK agent settings.
Mastra generate() and stream() execution options drive the run. maxSteps maps to OpenAI maxTurns, and abortSignal maps to OpenAI signal.
FAQs
OpenAI Agents SDK package for Mastra
The npm package @mastra/openai receives a total of 1,406 weekly downloads. As such, @mastra/openai popularity was classified as popular.
We found that @mastra/openai demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 6 open source maintainers collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Research
/Security News
Miasma Mini Shai-Hulud hits @immobiliarelabs Backstage plugins, targeting GitLab and LDAP auth packages on npm.

Security News
Rolldown paused Rust React Compiler integration after a 5MB binary size increase raised concerns about shipping React-specific code to all Vite users.

Security News
/Research
Mini Shai-Hulud expands into the Go ecosystem after hitting LeoPlatform npm packages and targeting GitHub Actions workflows.