@mastra/openai 1.0.1-alpha.9 → 1.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +126 -0
- package/LICENSE.md +30 -0
- package/README.md +92 -0
- package/dist/docs/SKILL.md +23 -0
- package/dist/docs/assets/SOURCE_MAP.json +6 -0
- package/dist/docs/references/docs-agents-sdk-agents.md +425 -0
- package/dist/docs/references/docs-memory-memory-processors.md +314 -0
- package/dist/index.cjs +1177 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.ts +67 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +1175 -0
- package/dist/index.js.map +1 -0
- package/dist/utils.d.ts +147 -0
- package/dist/utils.d.ts.map +1 -0
- package/package.json +58 -52
- package/src/Openai.test.ts +0 -61
- package/src/assets/openai.png +0 -0
- package/src/client/index.ts +0 -4
- package/src/client/schemas.gen.ts +0 -9928
- package/src/client/service-comments.ts +0 -390
- package/src/client/services.gen.ts +0 -1481
- package/src/client/types.gen.ts +0 -7500
- package/src/client/zodSchema.ts +0 -3898
- package/src/index.ts +0 -59
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
# @mastra/openai
|
|
2
|
+
|
|
3
|
+
## 0.1.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- Added structured output support for Claude and OpenAI SDK agents using their provider-native structured output APIs. Cursor SDK agent calls now fail clearly when structuredOutput is requested because the Cursor TypeScript SDK does not expose a schema-constrained output API. SDK agents now implement provider-native resume through Mastra's existing resumeGenerate/resumeStream methods by accepting provider-specific resumeData with a message payload. Cursor SDK agent options now use the same clear source split as OpenAI: pass either a pre-created agent or SDK options for wrapper-created agents. ([#17580](https://github.com/mastra-ai/mastra/pull/17580))
|
|
8
|
+
|
|
9
|
+
Example:
|
|
10
|
+
|
|
11
|
+
```ts
|
|
12
|
+
await claudeAgent.resumeGenerate({
|
|
13
|
+
message: 'Continue the task.',
|
|
14
|
+
sessionId: 'claude-session-id',
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
await openAIAgent.resumeStream({
|
|
18
|
+
message: 'Continue the task.',
|
|
19
|
+
previousResponseId: 'resp_123',
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
const result = await openAIAgent.generate('Return the answer as JSON.', {
|
|
23
|
+
structuredOutput: {
|
|
24
|
+
schema: z.object({ answer: z.string() }),
|
|
25
|
+
},
|
|
26
|
+
});
|
|
27
|
+
// result.object has shape { answer: string }
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
Claude and OpenAI SDK agents support `structuredOutput` through their native SDK APIs. `CursorSDKAgent` throws a clear error when `structuredOutput` is requested because the Cursor TypeScript SDK does not expose schema-constrained output.
|
|
31
|
+
|
|
32
|
+
- Added `@mastra/openai`, a new package for using OpenAI Agents SDK agents in Mastra. ([#17525](https://github.com/mastra-ai/mastra/pull/17525))
|
|
33
|
+
|
|
34
|
+
`OpenAISDKAgent` lets you register an OpenAI Agents SDK agent with Mastra, call it with Mastra-compatible `generate()` and `stream()` methods, and keep usage and tracing data connected to the Mastra run.
|
|
35
|
+
|
|
36
|
+
```ts
|
|
37
|
+
import { OpenAISDKAgent } from '@mastra/openai';
|
|
38
|
+
|
|
39
|
+
export const openaiAgent = new OpenAISDKAgent({
|
|
40
|
+
id: 'openai-sdk-agent',
|
|
41
|
+
name: 'OpenAI SDK Agent',
|
|
42
|
+
description: 'Use OpenAI Agents SDK through Mastra.',
|
|
43
|
+
sdkOptions: {
|
|
44
|
+
name: 'Repository assistant',
|
|
45
|
+
instructions: 'Answer clearly and cite the relevant files.',
|
|
46
|
+
model: '__GATEWAY_OPENAI_MODEL_BASE__',
|
|
47
|
+
},
|
|
48
|
+
});
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
Use `sdkOptions` when you want Mastra to create the OpenAI SDK agent. Pass `agent` when your app already creates and owns the SDK agent.
|
|
52
|
+
|
|
53
|
+
### Patch Changes
|
|
54
|
+
|
|
55
|
+
- Updated dependencies [[`d468acb`](https://github.com/mastra-ai/mastra/commit/d468acb07aec1bb19a2cb0ada8042b05b46746b2), [`575f815`](https://github.com/mastra-ai/mastra/commit/575f815c5c3567b71c0b83cbb7fa98c8253a9d9c), [`34839c1`](https://github.com/mastra-ai/mastra/commit/34839c1910b6964bf59ed0cee58844efebbb684e), [`053735a`](https://github.com/mastra-ai/mastra/commit/053735a75c2c18e23ce34d9468007efa4a45f4c4), [`306909a`](https://github.com/mastra-ai/mastra/commit/306909a693de77d709b38706e2673c9547d24a28), [`5191af8`](https://github.com/mastra-ai/mastra/commit/5191af80c799eea25357c545fc05d91b3883531d), [`43bd3d4`](https://github.com/mastra-ai/mastra/commit/43bd3d421987463fdf35386a45199c49499ed069), [`e6fa79e`](https://github.com/mastra-ai/mastra/commit/e6fa79ec72a2ddffdd25e85270398951e9d552a4), [`904bcdf`](https://github.com/mastra-ai/mastra/commit/904bcdf7b8004aa7be823f9f70ca63580e47e470), [`7f5ee1d`](https://github.com/mastra-ai/mastra/commit/7f5ee1dca46daee8d2817f2ebe49e6335da81956), [`1e9aab5`](https://github.com/mastra-ai/mastra/commit/1e9aab50ff11e6e88fde4d7cbf512c44a9fe8d61), [`2bccba4`](https://github.com/mastra-ai/mastra/commit/2bccba4c03cadc815c2d54cbf4dd43a922140a8d), [`bf8eb6d`](https://github.com/mastra-ai/mastra/commit/bf8eb6d0ec213a403eb9265a594ad283c44ab3dc), [`e9be4e7`](https://github.com/mastra-ai/mastra/commit/e9be4e747ec3d8b65548bff92f9377db06105376), [`493a328`](https://github.com/mastra-ai/mastra/commit/493a328f4346a1deeb9f1e2e44c8f2a3a4d7591b), [`d53cfc2`](https://github.com/mastra-ai/mastra/commit/d53cfc2c7f8d78343a4aa84ec4e129ba25f3325e), [`65799d4`](https://github.com/mastra-ai/mastra/commit/65799d4d549e5ebb9c848fbe3f51ac090f64becf), [`c268c89`](https://github.com/mastra-ai/mastra/commit/c268c89f4c63a93ee474d3cffdf3ea60bf00d4f2), [`34839c1`](https://github.com/mastra-ai/mastra/commit/34839c1910b6964bf59ed0cee58844efebbb684e), [`014e00f`](https://github.com/mastra-ai/mastra/commit/014e00f2b3a597a016b72f9901c6ab27d491f822), [`029a414`](https://github.com/mastra-ai/mastra/commit/029a4141719793bd3e898a39eb5a0466a55f5f3a), [`d468acb`](https://github.com/mastra-ai/mastra/commit/d468acb07aec1bb19a2cb0ada8042b05b46746b2), [`b147b29`](https://github.com/mastra-ai/mastra/commit/b147b2907f0cd1aa812efe6d6e3f58d22e66fc88), [`d371ac1`](https://github.com/mastra-ai/mastra/commit/d371ac1d9820afaaf7cfdbc380a475946a994d8f), [`2bccba4`](https://github.com/mastra-ai/mastra/commit/2bccba4c03cadc815c2d54cbf4dd43a922140a8d), [`0c72f03`](https://github.com/mastra-ai/mastra/commit/0c72f032abb13254df5a7856d64be2f207b8006d), [`cf182b7`](https://github.com/mastra-ai/mastra/commit/cf182b7fb495767946d9840ef29f19cfa906f31f), [`3b45ea9`](https://github.com/mastra-ai/mastra/commit/3b45ea95015557a6cb9d70dc5252af54ab1b78ac), [`a049c2a`](https://github.com/mastra-ai/mastra/commit/a049c2a9dfb41d0ee2e7a28874a88cd64fd5669f), [`f084be1`](https://github.com/mastra-ai/mastra/commit/f084be1fcbe33ad7480913e44d6130c421c0976f), [`b147b29`](https://github.com/mastra-ai/mastra/commit/b147b2907f0cd1aa812efe6d6e3f58d22e66fc88), [`2a96528`](https://github.com/mastra-ai/mastra/commit/2a9652848dfa3c5a2426f952e9d93554c26fd90f), [`f2ab060`](https://github.com/mastra-ai/mastra/commit/f2ab060162bea81505fda553e2cee29c1979fd04), [`5d302c8`](https://github.com/mastra-ai/mastra/commit/5d302c8eda1a6ac74eab5e442c4f64db6cc97a06), [`34839c1`](https://github.com/mastra-ai/mastra/commit/34839c1910b6964bf59ed0cee58844efebbb684e), [`a952852`](https://github.com/mastra-ai/mastra/commit/a952852c971a21fb646cd907c75fcf4443cdc963), [`2656d9c`](https://github.com/mastra-ai/mastra/commit/2656d9c2976d4f3354253bfbbbf9b88a1b2bbf34), [`63e3fe1`](https://github.com/mastra-ai/mastra/commit/63e3fe13cc1ea96f91d7c68aea92f400faf9e4da), [`1d4ce8d`](https://github.com/mastra-ai/mastra/commit/1d4ce8daaa54511f325c1b609d31b8e54009d677), [`8c68372`](https://github.com/mastra-ai/mastra/commit/8c68372e85fe0b066ec12c58bd29ffb93e54c552)]:
|
|
56
|
+
- @mastra/core@1.42.0
|
|
57
|
+
|
|
58
|
+
## 0.1.0-alpha.2
|
|
59
|
+
|
|
60
|
+
### Minor Changes
|
|
61
|
+
|
|
62
|
+
- Added structured output support for Claude and OpenAI SDK agents using their provider-native structured output APIs. Cursor SDK agent calls now fail clearly when structuredOutput is requested because the Cursor TypeScript SDK does not expose a schema-constrained output API. SDK agents now implement provider-native resume through Mastra's existing resumeGenerate/resumeStream methods by accepting provider-specific resumeData with a message payload. Cursor SDK agent options now use the same clear source split as OpenAI: pass either a pre-created agent or SDK options for wrapper-created agents. ([#17580](https://github.com/mastra-ai/mastra/pull/17580))
|
|
63
|
+
|
|
64
|
+
Example:
|
|
65
|
+
|
|
66
|
+
```ts
|
|
67
|
+
await claudeAgent.resumeGenerate({
|
|
68
|
+
message: 'Continue the task.',
|
|
69
|
+
sessionId: 'claude-session-id',
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
await openAIAgent.resumeStream({
|
|
73
|
+
message: 'Continue the task.',
|
|
74
|
+
previousResponseId: 'resp_123',
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
const result = await openAIAgent.generate('Return the answer as JSON.', {
|
|
78
|
+
structuredOutput: {
|
|
79
|
+
schema: z.object({ answer: z.string() }),
|
|
80
|
+
},
|
|
81
|
+
});
|
|
82
|
+
// result.object has shape { answer: string }
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
Claude and OpenAI SDK agents support `structuredOutput` through their native SDK APIs. `CursorSDKAgent` throws a clear error when `structuredOutput` is requested because the Cursor TypeScript SDK does not expose schema-constrained output.
|
|
86
|
+
|
|
87
|
+
### Patch Changes
|
|
88
|
+
|
|
89
|
+
- Updated dependencies [[`575f815`](https://github.com/mastra-ai/mastra/commit/575f815c5c3567b71c0b83cbb7fa98c8253a9d9c), [`306909a`](https://github.com/mastra-ai/mastra/commit/306909a693de77d709b38706e2673c9547d24a28), [`5191af8`](https://github.com/mastra-ai/mastra/commit/5191af80c799eea25357c545fc05d91b3883531d), [`43bd3d4`](https://github.com/mastra-ai/mastra/commit/43bd3d421987463fdf35386a45199c49499ed069), [`e6fa79e`](https://github.com/mastra-ai/mastra/commit/e6fa79ec72a2ddffdd25e85270398951e9d552a4), [`904bcdf`](https://github.com/mastra-ai/mastra/commit/904bcdf7b8004aa7be823f9f70ca63580e47e470), [`7f5ee1d`](https://github.com/mastra-ai/mastra/commit/7f5ee1dca46daee8d2817f2ebe49e6335da81956), [`1e9aab5`](https://github.com/mastra-ai/mastra/commit/1e9aab50ff11e6e88fde4d7cbf512c44a9fe8d61), [`bf8eb6d`](https://github.com/mastra-ai/mastra/commit/bf8eb6d0ec213a403eb9265a594ad283c44ab3dc), [`493a328`](https://github.com/mastra-ai/mastra/commit/493a328f4346a1deeb9f1e2e44c8f2a3a4d7591b), [`029a414`](https://github.com/mastra-ai/mastra/commit/029a4141719793bd3e898a39eb5a0466a55f5f3a), [`b147b29`](https://github.com/mastra-ai/mastra/commit/b147b2907f0cd1aa812efe6d6e3f58d22e66fc88), [`d371ac1`](https://github.com/mastra-ai/mastra/commit/d371ac1d9820afaaf7cfdbc380a475946a994d8f), [`cf182b7`](https://github.com/mastra-ai/mastra/commit/cf182b7fb495767946d9840ef29f19cfa906f31f), [`a049c2a`](https://github.com/mastra-ai/mastra/commit/a049c2a9dfb41d0ee2e7a28874a88cd64fd5669f), [`b147b29`](https://github.com/mastra-ai/mastra/commit/b147b2907f0cd1aa812efe6d6e3f58d22e66fc88), [`2a96528`](https://github.com/mastra-ai/mastra/commit/2a9652848dfa3c5a2426f952e9d93554c26fd90f), [`2656d9c`](https://github.com/mastra-ai/mastra/commit/2656d9c2976d4f3354253bfbbbf9b88a1b2bbf34), [`63e3fe1`](https://github.com/mastra-ai/mastra/commit/63e3fe13cc1ea96f91d7c68aea92f400faf9e4da), [`1d4ce8d`](https://github.com/mastra-ai/mastra/commit/1d4ce8daaa54511f325c1b609d31b8e54009d677), [`8c68372`](https://github.com/mastra-ai/mastra/commit/8c68372e85fe0b066ec12c58bd29ffb93e54c552)]:
|
|
90
|
+
- @mastra/core@1.42.0-alpha.4
|
|
91
|
+
|
|
92
|
+
## 0.1.0-alpha.1
|
|
93
|
+
|
|
94
|
+
### Minor Changes
|
|
95
|
+
|
|
96
|
+
- Added `@mastra/openai`, a new package for using OpenAI Agents SDK agents in Mastra. ([#17525](https://github.com/mastra-ai/mastra/pull/17525))
|
|
97
|
+
|
|
98
|
+
`OpenAISDKAgent` lets you register an OpenAI Agents SDK agent with Mastra, call it with Mastra-compatible `generate()` and `stream()` methods, and keep usage and tracing data connected to the Mastra run.
|
|
99
|
+
|
|
100
|
+
```ts
|
|
101
|
+
import { OpenAISDKAgent } from '@mastra/openai';
|
|
102
|
+
|
|
103
|
+
export const openaiAgent = new OpenAISDKAgent({
|
|
104
|
+
id: 'openai-sdk-agent',
|
|
105
|
+
name: 'OpenAI SDK Agent',
|
|
106
|
+
description: 'Use OpenAI Agents SDK through Mastra.',
|
|
107
|
+
sdkOptions: {
|
|
108
|
+
name: 'Repository assistant',
|
|
109
|
+
instructions: 'Answer clearly and cite the relevant files.',
|
|
110
|
+
model: '__GATEWAY_OPENAI_MODEL_BASE__',
|
|
111
|
+
},
|
|
112
|
+
});
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
Use `sdkOptions` when you want Mastra to create the OpenAI SDK agent. Pass `agent` when your app already creates and owns the SDK agent.
|
|
116
|
+
|
|
117
|
+
### Patch Changes
|
|
118
|
+
|
|
119
|
+
- Updated dependencies [[`d468acb`](https://github.com/mastra-ai/mastra/commit/d468acb07aec1bb19a2cb0ada8042b05b46746b2), [`e9be4e7`](https://github.com/mastra-ai/mastra/commit/e9be4e747ec3d8b65548bff92f9377db06105376), [`d53cfc2`](https://github.com/mastra-ai/mastra/commit/d53cfc2c7f8d78343a4aa84ec4e129ba25f3325e), [`65799d4`](https://github.com/mastra-ai/mastra/commit/65799d4d549e5ebb9c848fbe3f51ac090f64becf), [`c268c89`](https://github.com/mastra-ai/mastra/commit/c268c89f4c63a93ee474d3cffdf3ea60bf00d4f2), [`d468acb`](https://github.com/mastra-ai/mastra/commit/d468acb07aec1bb19a2cb0ada8042b05b46746b2), [`0c72f03`](https://github.com/mastra-ai/mastra/commit/0c72f032abb13254df5a7856d64be2f207b8006d), [`3b45ea9`](https://github.com/mastra-ai/mastra/commit/3b45ea95015557a6cb9d70dc5252af54ab1b78ac), [`f084be1`](https://github.com/mastra-ai/mastra/commit/f084be1fcbe33ad7480913e44d6130c421c0976f)]:
|
|
120
|
+
- @mastra/core@1.42.0-alpha.0
|
|
121
|
+
|
|
122
|
+
## 0.1.0-alpha.0
|
|
123
|
+
|
|
124
|
+
### Initial release
|
|
125
|
+
|
|
126
|
+
- Added `OpenAISDKAgent` for registering OpenAI Agents SDK agents with Mastra.
|
package/LICENSE.md
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
Portions of this software are licensed as follows:
|
|
2
|
+
|
|
3
|
+
- All content that resides under any directory named "ee/" within this
|
|
4
|
+
repository, including but not limited to:
|
|
5
|
+
- `packages/core/src/auth/ee/`
|
|
6
|
+
- `packages/server/src/server/auth/ee/`
|
|
7
|
+
is licensed under the license defined in `ee/LICENSE`.
|
|
8
|
+
|
|
9
|
+
- All third-party components incorporated into the Mastra Software are
|
|
10
|
+
licensed under the original license provided by the owner of the
|
|
11
|
+
applicable component.
|
|
12
|
+
|
|
13
|
+
- Content outside of the above-mentioned directories or restrictions is
|
|
14
|
+
available under the "Apache License 2.0" as defined below.
|
|
15
|
+
|
|
16
|
+
# Apache License 2.0
|
|
17
|
+
|
|
18
|
+
Copyright (c) 2025 Kepler Software, Inc.
|
|
19
|
+
|
|
20
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
21
|
+
you may not use this file except in compliance with the License.
|
|
22
|
+
You may obtain a copy of the License at
|
|
23
|
+
|
|
24
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
25
|
+
|
|
26
|
+
Unless required by applicable law or agreed to in writing, software
|
|
27
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
28
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
29
|
+
See the License for the specific language governing permissions and
|
|
30
|
+
limitations under the License.
|
package/README.md
ADDED
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
# @mastra/openai
|
|
2
|
+
|
|
3
|
+
`@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.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @mastra/openai @openai/agents
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Overview
|
|
12
|
+
|
|
13
|
+
The package exports `OpenAISDKAgent`, a Mastra `Agent` wrapper around the OpenAI Agents SDK run loop.
|
|
14
|
+
|
|
15
|
+
`OpenAISDKAgent` keeps the OpenAI SDK run loop in charge. Mastra receives compatible outputs, usage data, and tracing data for the run.
|
|
16
|
+
|
|
17
|
+
## Create an OpenAI SDK agent
|
|
18
|
+
|
|
19
|
+
Pass OpenAI Agents SDK configuration through `sdkOptions`. `OpenAISDKAgent` creates the SDK agent on first use.
|
|
20
|
+
|
|
21
|
+
```typescript
|
|
22
|
+
import { OpenAISDKAgent } from '@mastra/openai';
|
|
23
|
+
|
|
24
|
+
export const openaiAgent = new OpenAISDKAgent({
|
|
25
|
+
id: 'openai-sdk-agent',
|
|
26
|
+
name: 'OpenAI SDK Agent',
|
|
27
|
+
description: 'Use OpenAI Agents SDK through Mastra.',
|
|
28
|
+
sdkOptions: {
|
|
29
|
+
name: 'Repository assistant',
|
|
30
|
+
instructions: 'Answer clearly and cite the relevant files.',
|
|
31
|
+
model: '__GATEWAY_OPENAI_MODEL_BASE__',
|
|
32
|
+
},
|
|
33
|
+
});
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
You can also pass an existing OpenAI SDK agent when your app already creates or owns it.
|
|
37
|
+
|
|
38
|
+
```typescript
|
|
39
|
+
import { Agent as OpenAIAgent } from '@openai/agents';
|
|
40
|
+
import { OpenAISDKAgent } from '@mastra/openai';
|
|
41
|
+
|
|
42
|
+
const sdkAgent = new OpenAIAgent({
|
|
43
|
+
name: 'Repository assistant',
|
|
44
|
+
instructions: 'Answer clearly and cite the relevant files.',
|
|
45
|
+
model: '__GATEWAY_OPENAI_MODEL_BASE__',
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
export const openaiAgent = new OpenAISDKAgent({
|
|
49
|
+
id: 'openai-sdk-agent',
|
|
50
|
+
description: 'Use OpenAI Agents SDK through Mastra.',
|
|
51
|
+
agent: sdkAgent,
|
|
52
|
+
});
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
You can register the wrapper anywhere Mastra accepts an `Agent`.
|
|
56
|
+
|
|
57
|
+
```typescript
|
|
58
|
+
import { Mastra } from '@mastra/core/mastra';
|
|
59
|
+
|
|
60
|
+
export const mastra = new Mastra({
|
|
61
|
+
agents: {
|
|
62
|
+
openaiAgent,
|
|
63
|
+
},
|
|
64
|
+
});
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
## Run the agent
|
|
68
|
+
|
|
69
|
+
```typescript
|
|
70
|
+
const result = await openaiAgent.generate('Summarize the latest changes in this repository.', {
|
|
71
|
+
runId: 'openai-run',
|
|
72
|
+
maxSteps: 3,
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
console.log(result.text);
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
```typescript
|
|
79
|
+
const stream = await openaiAgent.stream('Review this package for test gaps.');
|
|
80
|
+
|
|
81
|
+
for await (const chunk of stream.fullStream) {
|
|
82
|
+
if (chunk.type === 'text-delta') {
|
|
83
|
+
process.stdout.write(chunk.payload.text);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
## Configure OpenAI
|
|
89
|
+
|
|
90
|
+
`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.
|
|
91
|
+
|
|
92
|
+
Mastra `generate()` and `stream()` execution options drive the run. `maxSteps` maps to OpenAI `maxTurns`, and `abortSignal` maps to OpenAI `signal`.
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: mastra-openai
|
|
3
|
+
description: Documentation for @mastra/openai. Use when working with @mastra/openai APIs, configuration, or implementation.
|
|
4
|
+
metadata:
|
|
5
|
+
package: "@mastra/openai"
|
|
6
|
+
version: "1.0.3"
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
## When to use
|
|
10
|
+
|
|
11
|
+
Use this skill whenever you are working with @mastra/openai to obtain the domain-specific knowledge.
|
|
12
|
+
|
|
13
|
+
## How to use
|
|
14
|
+
|
|
15
|
+
Read the individual reference documents for detailed explanations and code examples.
|
|
16
|
+
|
|
17
|
+
### Docs
|
|
18
|
+
|
|
19
|
+
- [SDK agents](references/docs-agents-sdk-agents.md) - Use Claude Agent SDK, Cursor Agent SDK, and OpenAI Agents SDK agents from Mastra.
|
|
20
|
+
- [Memory processors](references/docs-memory-memory-processors.md) - Learn how to use memory processors in Mastra to filter, trim, and transform messages before they're sent to the language model to manage context window limits.
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
Read [assets/SOURCE_MAP.json](assets/SOURCE_MAP.json) for source code references.
|