You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/src/content/docs/guides/voice-agents/quickstart.mdx
+4-3Lines changed: 4 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -31,7 +31,7 @@ import thinClientExample from '../../../../../../examples/docs/voice-agents/thin
31
31
In this quickstart we will create a voice agent you can use in the browser. If you want to check out a new project, you can try out [`Next.js`](https://nextjs.org/docs/getting-started/installation) or [`Vite`](https://vite.dev/guide/installation.html).
@@ -47,6 +47,7 @@ import thinClientExample from '../../../../../../examples/docs/voice-agents/thin
47
47
As this application will run in the user's browser, we need a secure way to connect to the model through the Realtime API. For this we can use an [ephemeral client key](https://platform.openai.com/docs/guides/realtime#creating-an-ephemeral-token) that should be generated on your backend server. For testing purposes you can also generate a key using `curl` and your regular OpenAI API key.
48
48
49
49
```bash
50
+
export OPENAI_API_KEY="sk-proj-...(your own key here)"
50
51
curl -X POST https://api.openai.com/v1/realtime/client_secrets \
51
52
-H "Authorization: Bearer $OPENAI_API_KEY" \
52
53
-H "Content-Type: application/json" \
@@ -58,7 +59,7 @@ import thinClientExample from '../../../../../../examples/docs/voice-agents/thin
58
59
}'
59
60
```
60
61
61
-
The response will contain a `client_secret.value` value that you can use to connect later on. Note that this key is only valid for a short period of time and will need to be regenerated.
62
+
The response will contain a "value" string a the top level, which starts with "ek\_" prefix. You can use this ephemeral key to establish a WebRTC connection later on. Note that this key is only valid for a short period of time and will need to be regenerated.
62
63
63
64
3.**Create your first Agent**
64
65
@@ -92,7 +93,7 @@ import thinClientExample from '../../../../../../examples/docs/voice-agents/thin
92
93
To connect to the session you need to pass the client ephemeral token you generated earlier on.
awaitsession.connect({ apiKey: 'ek_...(put your own key here)' });
96
97
```
97
98
98
99
This will connect to the Realtime API using WebRTC in the browser and automatically configure your microphone and speaker for audio input and output. If you are running your `RealtimeSession` on a backend server (like Node.js) the SDK will automatically use WebSocket as a connection. You can learn more about the different transport layers in the [Realtime Transport Layer](/openai-agents-js/guides/voice-agents/transport) guide.
0 commit comments