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: src/content/docs/browser-rendering/rest-api/json-endpoint.mdx
+78-2Lines changed: 78 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -7,11 +7,11 @@ sidebar:
7
7
8
8
import { Tabs, TabItem } from"~/components";
9
9
10
-
The `/json` endpoint extracts structured data from a webpage. You can specify the expected output using either a `prompt` or a `response_format` parameter which accepts a JSON schema. The endpoint returns the extracted data in JSON format.
10
+
The `/json` endpoint extracts structured data from a webpage. You can specify the expected output using either a `prompt` or a `response_format` parameter which accepts a JSON schema. The endpoint returns the extracted data in JSON format. By default, this endpoint leverages [Workers AI](/workers-ai/). If you would like to specify your own AI model for the extraction, you can use the `custom_ai` parameter.
11
11
12
12
:::note[Note]
13
13
14
-
The`/json` endpoint leverages [Workers AI](/workers-ai/) for data extraction. Using this endpoint incurs usage on Workers AI, which you can monitor usage through the Workers AI Dashboard.
14
+
By default, the`/json` endpoint leverages [Workers AI](/workers-ai/) for data extraction. Using this endpoint incurs usage on Workers AI, which you can monitor usage through the Workers AI Dashboard.
Browser Rendering can use a custom model for which you supply credentials. List the model(s) in the `custom_ai` array:
254
+
255
+
-`model` should be formed as `<provider>/<model_name>` and the provider must be one of these [supported providers](/ai-gateway/chat-completion/#supported-providers).
256
+
-`authorization` is the bearer token or API key that allows Browser Rendering to call the provider on your behalf.
257
+
258
+
This example uses the `custom_ai` parameter to instruct Browser Rendering to use a custom Anthropic model. The prompt asks the model to extract the main <h1> and <h2> headings from the target URL and return them in a structured JSON object.
"prompt": "Get the heading from the page in the form of an object like h1, h2. If there are many headings of the same kind then grab the first one.",
268
+
"response_format": {
269
+
"type": "json_schema",
270
+
"json_schema": {
271
+
"type": "object",
272
+
"properties": {
273
+
"h1": {
274
+
"type": "string"
275
+
},
276
+
"h2": {
277
+
"type": "string"
278
+
}
279
+
},
280
+
"required": [
281
+
"h1"
282
+
]
283
+
}
284
+
},
285
+
"custom_ai": [
286
+
{
287
+
"model": "anthropic/claude-sonnet-4-20250514",
288
+
"authorization": "Bearer <ANTHROPIC_API_KEY>"
289
+
}
290
+
]
291
+
}
292
+
```
293
+
294
+
```json output
295
+
{
296
+
"success": true,
297
+
"result": {
298
+
"h1": "Heading 1",
299
+
"h2": "Heading 2"
300
+
}
301
+
}
302
+
```
303
+
304
+
### Using a custom model with fallbacks
305
+
306
+
You may specify multiple models to provide automatic failover. Browser Rendering will attempt the models in order until one succeeds. To add failover, list additional models.
307
+
308
+
In this example, Browser Rendering first calls claude-sonnet-4-20250514. If that request returns an error, it automatically retries with gpt-4o.
0 commit comments