Skip to content

Commit 3379615

Browse files
authored
Update json-endpoint.mdx
fix typescript example
1 parent 8d6fd15 commit 3379615

File tree

1 file changed

+31
-5
lines changed

1 file changed

+31
-5
lines changed

src/content/docs/browser-rendering/rest-api/json-endpoint.mdx

Lines changed: 31 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -233,14 +233,40 @@ Below is an example using the TypeScript SDK:
233233
import Cloudflare from "cloudflare";
234234

235235
const client = new Cloudflare({
236-
apiEmail: process.env["CLOUDFLARE_EMAIL"], // This is the default and can be omitted
237-
apiKey: process.env["CLOUDFLARE_API_KEY"], // This is the default and can be omitted
236+
apiToken: process.env["CLOUDFLARE_API_TOKEN"], // This is the default and can be omitted
238237
});
239238

240239
const json = await client.browserRendering.json.create({
241-
account_id: "account_id",
242-
});
243-
240+
account_id: process.env["CLOUDFLARE_ACCOUNT_ID"],
241+
url: "https://developers.cloudflare.com/",
242+
prompt: "Get me the list of AI products",
243+
response_format: {
244+
type: "json_schema",
245+
schema: {
246+
type: "object",
247+
properties: {
248+
products: {
249+
type: "array",
250+
items: {
251+
type: "object",
252+
properties: {
253+
name: {
254+
type: "string"
255+
},
256+
link: {
257+
type: "string"
258+
}
259+
},
260+
required: [
261+
"name"
262+
]
263+
}
264+
}
265+
}
266+
}
267+
}
268+
}
269+
);
244270
console.log(json);
245271
```
246272

0 commit comments

Comments
 (0)