@@ -58,29 +58,30 @@ cd ag-ui/typescript-sdk
58
58
Copy the server-starter template to create your OpenAI server:
59
59
60
60
``` bash
61
- cp -r integrations/server-starter integrations/openai
61
+ cp -r integrations/server-starter integrations/openai-server
62
62
```
63
63
64
64
### Update metadata
65
65
66
- Open ` integrations/openai/package.json ` and update the fields to match your new
66
+ Open ` integrations/openai-server /package.json ` and update the fields to match your new
67
67
folder:
68
68
69
69
``` json
70
70
{
71
- "name" : " @ag-ui/openai" ,
71
+ "name" : " @ag-ui/openai-server " ,
72
72
"author" :
" Your Name <[email protected] >" ,
73
73
"version" : " 0.0.1" ,
74
74
75
75
... rest of package.json
76
76
}
77
77
```
78
78
79
- Next, update the class name inside ` integrations/openai/src/index.ts ` :
79
+ Next, update the class name inside ` integrations/openai-server /src/index.ts ` :
80
80
81
81
``` ts
82
- // change the name to OpenAIAgent
83
- export class OpenAIAgent extends AbstractAgent {}
82
+ // change the name to OpenAIServerAgent
83
+ export class ServerStarterAgent extends HttpAgent { }
84
+
84
85
```
85
86
86
87
Finally, introduce your integration to the dojo by adding it to
@@ -91,35 +92,64 @@ Finally, introduce your integration to the dojo by adding it to
91
92
export const menuIntegrations: MenuIntegrationConfig [] = [
92
93
// ...
93
94
94
- configureIntegration ( {
95
- id: " openai" ,
96
- name: " OpenAI" ,
95
+ {
96
+ id: " openai-server " ,
97
+ name: " OpenAI Server " ,
97
98
features: [" agentic_chat" ],
98
- }) ,
99
+ },
99
100
]
100
101
```
101
102
102
103
And ` apps/dojo/src/agents.ts ` :
103
104
104
105
``` ts
105
106
// ...
106
- import { OpenAIAgent } from " @ag-ui/openai"
107
+ import { OpenAIServerAgent } from " @ag-ui/openai-server "
107
108
108
109
export const agentsIntegrations: AgentIntegrationConfig [] = [
109
110
// ...
110
111
111
112
{
112
- id: " openai" ,
113
+ id: " openai-server " ,
113
114
agents : async () => {
114
115
return {
115
- agentic_chat: new OpenAIAgent (),
116
+ agentic_chat: new OpenAIServerAgent (),
116
117
}
117
118
},
118
119
},
119
120
]
120
121
```
121
122
122
- ## Step 2 – Start the dojo and server
123
+ ## Step 2 – Add package to dojo dependencies
124
+
125
+ Open ` apps/dojo/package.json ` and add the package ` @ag-ui/openai-server ` :
126
+
127
+ ``` json
128
+ {
129
+ "name" : " demo-viewer" ,
130
+ "version" : " 0.1.0" ,
131
+ "private" : true ,
132
+ "scripts" : {
133
+ "dev" : " next dev" ,
134
+ "build" : " next build" ,
135
+ "start" : " next start" ,
136
+ "lint" : " next lint"
137
+ },
138
+ "dependencies" : {
139
+ "@ag-ui/agno" : " workspace:*" ,
140
+ "@ag-ui/langgraph" : " workspace:*" ,
141
+ "@ag-ui/mastra" : " workspace:*" ,
142
+ "@ag-ui/middleware-starter" : " workspace:*" ,
143
+ "@ag-ui/server-starter" : " workspace:*" ,
144
+ "@ag-ui/server-starter-all-features" : " workspace:*" ,
145
+ "@ag-ui/vercel-ai-sdk" : " workspace:*" ,
146
+ "@ag-ui/openai-server" : " workspace:*" , <- Add this line
147
+
148
+ ... rest of package.json
149
+ }
150
+ ```
151
+
152
+ ## Step 3 – Start the dojo and server
123
153
124
154
Now let's see your work in action. First, start your Python server:
125
155
@@ -208,7 +238,7 @@ async def agentic_chat_endpoint(input_data: RunAgentInput, request: Request):
208
238
)
209
239
```
210
240
211
- ## Step 3 – Bridge OpenAI with AG-UI
241
+ ## Step 4 – Bridge OpenAI with AG-UI
212
242
213
243
Let's transform our stub into a real server that streams completions from
214
244
OpenAI.
@@ -383,7 +413,7 @@ Let's break down what your server is doing:
383
413
` TOOL_CALL_CHUNK `
384
414
4 . ** Finish** – We emit ` RUN_FINISHED ` (or ` RUN_ERROR ` if something goes wrong)
385
415
386
- ## Step 4 – Chat with your server
416
+ ## Step 5 – Chat with your server
387
417
388
418
Reload the dojo page and start typing. You'll see GPT-4o streaming its answer in
389
419
real-time, word by word.
0 commit comments