Skip to content

Commit 09e1253

Browse files
authored
Update stagehand.mdx (#26367)
1 parent f1cf963 commit 09e1253

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

src/content/docs/browser-rendering/stagehand.mdx

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import {
1414
Tabs,
1515
PackageManagers,
1616
Details,
17+
DashButton,
1718
} from "~/components";
1819

1920
[Stagehand](https://www.stagehand.dev/) is an open-source, AI-powered browser automation library. Stagehand lets you combine code with natural-language instructions powered by AI, eliminating the need to dictate exact steps or specify selectors. With Stagehand, your agents are more resilient to website changes and easier to maintain, helping you build more reliably and flexibly.
@@ -187,7 +188,11 @@ https://<your-worker>.workers.dev
187188

188189
[AI Gateway](/ai-gateway/) is a service that adds observability to your AI applications. By routing your requests through AI Gateway, you can monitor and debug your AI applications.
189190

190-
To use AI Gateway with a third-party model, first create a gateway in the [Cloudflare dashboard](https://dash.cloudflare.com/?to=/:account/workers/ai-gateway). In this example, we've named the gateway `stagehand-example-gateway`.
191+
To use AI Gateway with a third-party model, first create a gateway in the **AI Gateway** page of the Cloudflare dashboard.
192+
193+
<DashButton url="/?to=/:account/ai/ai-gateway" />
194+
195+
In this example, we've named the gateway `stagehand-example-gateway`.
191196

192197
```typescript
193198
const stagehand = new Stagehand({
@@ -228,18 +233,27 @@ const stagehand = new Stagehand({
228233

229234
[AI Gateway](/ai-gateway/) is a service that adds observability to your AI applications. By routing your requests through AI Gateway, you can monitor and debug your AI applications.
230235

231-
To use AI Gateway, first create a gateway in the [Cloudflare dashboard](https://dash.cloudflare.com/?to=/:account/workers/ai-gateway). In this example, we are using [OpenAI with AI Gateway](https://developers.cloudflare.com/ai-gateway/usage/providers/openai/). Make sure to add the `baseURL` as shown below, with your own Account ID and Gateway ID.
236+
To use AI Gateway with a third-party model, first create a gateway in the **AI Gateway** page of the Cloudflare dashboard.
237+
238+
<DashButton url="/?to=/:account/ai/ai-gateway" />
239+
240+
In this example, we are using [OpenAI with AI Gateway](/ai-gateway/usage/providers/openai/). Make sure to add the `baseURL` as shown below, with your own Account ID and Gateway ID.
241+
242+
You must specify the `apiKey` in the `modelClientOptions`:
232243

233244
```typescript
234245
const stagehand = new Stagehand({
235246
env: "LOCAL",
236247
localBrowserLaunchOptions: { cdpUrl: endpointURLString(env.BROWSER) },
237248
modelName: "openai/gpt-4.1",
238249
modelClientOptions: {
250+
apiKey: env.OPENAI_API_KEY,
239251
baseURL: `https://gateway.ai.cloudflare.com/v1/{account_id}/{gateway_id}/openai`,
240252
},
241253
});
242254
```
243255

256+
If you are using an authenticated AI Gateway, follow the instructions in [AI Gateway authentication](/ai-gateway/configuration/authentication/) and include `cf-aig-authorization` as a header.
257+
244258
## Stagehand API
245259
For the full list of Stagehand methods and capabilities, refer to the official [Stagehand API documentation](https://docs.stagehand.dev/first-steps/introduction).

0 commit comments

Comments
 (0)