@mastra/openai 1.1.1-alpha.0 → 1.1.1-alpha.1
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/README.md +14 -60
- package/dist/docs/SKILL.md +1 -1
- package/dist/docs/assets/SOURCE_MAP.json +1 -1
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -1,24 +1,20 @@
|
|
|
1
1
|
# @mastra/openai
|
|
2
2
|
|
|
3
|
-
`@mastra/openai` connects Mastra to the OpenAI Agents SDK. Use it when you want
|
|
3
|
+
`@mastra/openai` connects Mastra to the OpenAI Agents SDK. Use it when you want the OpenAI SDK's native agent loop, handoffs, and tools while exposing the agent through Mastra-compatible `generate()` and `stream()` methods.
|
|
4
4
|
|
|
5
5
|
## Installation
|
|
6
6
|
|
|
7
7
|
```bash
|
|
8
|
-
npm install @mastra/openai
|
|
8
|
+
npm install @mastra/openai
|
|
9
|
+
npm install @openai/agents
|
|
9
10
|
```
|
|
10
11
|
|
|
11
|
-
##
|
|
12
|
+
## Usage
|
|
12
13
|
|
|
13
|
-
|
|
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.
|
|
14
|
+
Set `OPENAI_API_KEY` before creating the agent.
|
|
20
15
|
|
|
21
16
|
```typescript
|
|
17
|
+
import { Mastra } from '@mastra/core/mastra';
|
|
22
18
|
import { OpenAISDKAgent } from '@mastra/openai';
|
|
23
19
|
|
|
24
20
|
export const openaiAgent = new OpenAISDKAgent({
|
|
@@ -28,65 +24,23 @@ export const openaiAgent = new OpenAISDKAgent({
|
|
|
28
24
|
sdkOptions: {
|
|
29
25
|
name: 'Repository assistant',
|
|
30
26
|
instructions: 'Answer clearly and cite the relevant files.',
|
|
31
|
-
model: '
|
|
27
|
+
model: 'openai/gpt-5.6-sol',
|
|
32
28
|
},
|
|
33
29
|
});
|
|
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
30
|
|
|
60
31
|
export const mastra = new Mastra({
|
|
61
|
-
agents: {
|
|
62
|
-
openaiAgent,
|
|
63
|
-
},
|
|
32
|
+
agents: { openaiAgent },
|
|
64
33
|
});
|
|
65
34
|
```
|
|
66
35
|
|
|
67
|
-
##
|
|
36
|
+
## Documentation
|
|
68
37
|
|
|
69
|
-
|
|
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
|
-
```
|
|
38
|
+
- [OpenAI Agents SDK integration](https://mastra.ai/docs/connections/sdk-agents#openai-agents-sdk)
|
|
77
39
|
|
|
78
|
-
|
|
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
|
-
```
|
|
40
|
+
## Changelog
|
|
87
41
|
|
|
88
|
-
|
|
42
|
+
See the [package changelog](https://github.com/mastra-ai/mastra/blob/main/agent-sdks/openai/CHANGELOG.md) for version history and release notes.
|
|
89
43
|
|
|
90
|
-
|
|
44
|
+
## Support
|
|
91
45
|
|
|
92
|
-
|
|
46
|
+
We have an [open community Discord](https://discord.gg/mastra-ai). Come and say hello and let us know if you have any questions or need any help getting things running.
|
package/dist/docs/SKILL.md
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mastra/openai",
|
|
3
|
-
"version": "1.1.1-alpha.
|
|
3
|
+
"version": "1.1.1-alpha.1",
|
|
4
4
|
"description": "OpenAI Agents SDK package for Mastra",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -35,9 +35,9 @@
|
|
|
35
35
|
"typescript": "^7.0.2",
|
|
36
36
|
"vitest": "4.1.10",
|
|
37
37
|
"zod": "^4.4.3",
|
|
38
|
-
"@internal/lint": "0.0.129",
|
|
39
38
|
"@internal/types-builder": "0.0.104",
|
|
40
|
-
"@
|
|
39
|
+
"@internal/lint": "0.0.129",
|
|
40
|
+
"@mastra/core": "1.64.0-alpha.7"
|
|
41
41
|
},
|
|
42
42
|
"homepage": "https://mastra.ai",
|
|
43
43
|
"repository": {
|