-
Notifications
You must be signed in to change notification settings - Fork 10.2k
[Browser Rendering] quick actions API #20221
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 6 commits
Commits
Show all changes
77 commits
Select commit
Hold shift + click to select a range
16d5d9e
Guardails docs
daisyfaithauma 8e7de6b
Merge branch 'production' of https://github.com/cloudflare/cloudflare…
daisyfaithauma 1deed6d
Merge branch 'production' of https://github.com/cloudflare/cloudflare…
daisyfaithauma b9b204a
Merge branch 'production' of https://github.com/cloudflare/cloudflare…
daisyfaithauma 912be66
Initial commit
daisyfaithauma 9bc1e3d
quick actions endpoints
daisyfaithauma 7a32d66
Fix
kodster28 33e5fa8
change to bullets
daisyfaithauma 0e582ac
moved get started to a file
daisyfaithauma 1ac96e4
summary
daisyfaithauma 963a7f3
summar of endpoints
daisyfaithauma 80549ce
fixed merge conflict
kodster28 423edaa
code samples
daisyfaithauma 17c3b53
Merge branch 'rendering-quick-actions' of https://github.com/cloudfla…
daisyfaithauma 7f85bbc
code samples and title change
daisyfaithauma 888f77b
Update src/content/docs/browser-rendering/quick-actions-rest-api/scra…
daisyfaithauma 13fbe0b
Update src/content/docs/browser-rendering/quick-actions-rest-api/snap…
daisyfaithauma 8a9346d
Update src/content/docs/browser-rendering/quick-actions-rest-api/snap…
daisyfaithauma 412e75e
Update src/content/docs/browser-rendering/quick-actions-rest-api/scra…
daisyfaithauma 08f7fe5
director listing
daisyfaithauma 26957d9
Merge branch 'rendering-quick-actions' of https://github.com/cloudfla…
daisyfaithauma 1e91167
added code sample
daisyfaithauma 864b0ee
index descriptions
daisyfaithauma 7159abb
redirects
daisyfaithauma f01f28d
Update src/content/docs/browser-rendering/quick-actions-rest-api/cont…
daisyfaithauma 7602ec4
delete custom css
daisyfaithauma e162f5a
Merge branch 'rendering-quick-actions' of https://github.com/cloudfla…
daisyfaithauma daa44b8
fixes from responses
daisyfaithauma 17a6931
Update src/content/docs/browser-rendering/quick-actions-rest-api/scra…
daisyfaithauma 10d25f4
code fixes
daisyfaithauma 105a878
parameters added
daisyfaithauma d17637a
Update get-started.mdx
kathayl 7863d7c
Update src/content/docs/browser-rendering/quick-actions-rest-api/cont…
daisyfaithauma b5bb84f
Update src/content/docs/browser-rendering/quick-actions-rest-api/cont…
daisyfaithauma e90f198
Update src/content/docs/browser-rendering/quick-actions-rest-api/inde…
daisyfaithauma 43ba4b1
Update src/content/docs/browser-rendering/quick-actions-rest-api/cont…
daisyfaithauma 8afb47e
Update src/content/docs/browser-rendering/quick-actions-rest-api/pdf-…
daisyfaithauma 41a5fc8
Update src/content/docs/browser-rendering/quick-actions-rest-api/snap…
daisyfaithauma b8655d5
Update src/content/docs/browser-rendering/quick-actions-rest-api/snap…
daisyfaithauma 93bff6e
Update src/content/docs/browser-rendering/quick-actions-rest-api/snap…
daisyfaithauma 581c2d3
Update src/content/docs/browser-rendering/quick-actions-rest-api/scra…
daisyfaithauma 3109164
Update src/content/docs/browser-rendering/quick-actions-rest-api/scra…
daisyfaithauma 8ee92dd
Update src/content/docs/browser-rendering/quick-actions-rest-api/scre…
daisyfaithauma 161492d
Update src/content/docs/browser-rendering/quick-actions-rest-api/snap…
daisyfaithauma 5335a26
minor fixes
daisyfaithauma e5fe663
Update src/content/docs/browser-rendering/quick-actions-rest-api/scre…
daisyfaithauma 3db0a71
Update src/content/docs/browser-rendering/quick-actions-rest-api/scre…
daisyfaithauma 048a6e2
Update src/content/docs/browser-rendering/quick-actions-rest-api/scre…
daisyfaithauma 5371bdf
Update src/content/docs/browser-rendering/quick-actions-rest-api/scre…
daisyfaithauma d6b0ad7
Update src/content/docs/browser-rendering/quick-actions-rest-api/snap…
daisyfaithauma 0de2ee8
Update src/content/docs/browser-rendering/quick-actions-rest-api/snap…
daisyfaithauma 51803f9
Update src/content/docs/browser-rendering/quick-actions-rest-api/scre…
daisyfaithauma 69f7a8d
Update src/content/docs/browser-rendering/quick-actions-rest-api/cont…
daisyfaithauma 5adf461
Update src/content/docs/browser-rendering/quick-actions-rest-api/inde…
daisyfaithauma 9225637
Update src/content/docs/browser-rendering/quick-actions-rest-api/inde…
daisyfaithauma 21bb019
Update src/content/docs/browser-rendering/workers-binding-api/index.mdx
daisyfaithauma a4d75c9
Update src/content/docs/browser-rendering/quick-actions-rest-api/snap…
daisyfaithauma b68d7e6
Update src/content/docs/browser-rendering/quick-actions-rest-api/pdf-…
daisyfaithauma 35e2abd
Update src/content/docs/browser-rendering/quick-actions-rest-api/scre…
daisyfaithauma 6fb4b3b
Update src/content/docs/browser-rendering/quick-actions-rest-api/scre…
daisyfaithauma a80e9c8
Update src/content/docs/browser-rendering/quick-actions-rest-api/cont…
daisyfaithauma ad050ce
Update src/content/docs/browser-rendering/quick-actions-rest-api/pdf-…
daisyfaithauma 11c235f
Update src/content/docs/browser-rendering/quick-actions-rest-api/pdf-…
daisyfaithauma 4653fd5
Update src/content/docs/browser-rendering/quick-actions-rest-api/pdf-…
daisyfaithauma 96fe9a2
Update src/content/docs/browser-rendering/quick-actions-rest-api/pdf-…
daisyfaithauma e0d8002
Update src/content/docs/browser-rendering/quick-actions-rest-api/scre…
daisyfaithauma 048a8b1
Update src/content/docs/browser-rendering/quick-actions-rest-api/scre…
daisyfaithauma d567aaf
Update src/content/docs/browser-rendering/quick-actions-rest-api/scre…
daisyfaithauma eff3d93
minor fixes
daisyfaithauma e31c9ad
links fix
daisyfaithauma 227b7b1
Update src/content/docs/browser-rendering/workers-binding-api/reuse-s…
daisyfaithauma ffd76d6
code fix
daisyfaithauma d4c37ca
removed link
daisyfaithauma bd711a5
Fix error
kodster28 0540b69
Added beta badge
kodster28 7034b6e
Update public/_redirects
kodster28 84accea
Small edit
kodster28 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| --- | ||
| title: Guardrails in AI Gateway | ||
| pcx_content_type: navigation | ||
| order: 1 | ||
| sidebar: | ||
| order: 8 | ||
| group: | ||
| badge: Beta | ||
| --- | ||
|
|
||
| Guardrails help you deploy AI applications safely by intercepting and evaluating both user prompts and model responses for harmful content. Acting as a proxy between your application and [model providers](/ai-gateway/providers)(such as OpenAI, Anthropic, DeepSeek, and others), Guardrails ensures a consistent and secure experience across your entire AI ecosystem. | ||
|
|
||
| Guardrails proactively monitor interactions between users and AI models, allowing you to: | ||
|
|
||
| - Protect users by detecting and mitigating harmful content. | ||
| - Meet compliance requirements by aligning with evolving regulatory standards. | ||
| - Optimize costs by preventing unnecessary processing of harmful requests early. | ||
53 changes: 53 additions & 0 deletions
53
src/content/docs/ai-gateway/guardrails/set-up-guardrail.mdx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,53 @@ | ||
| --- | ||
| pcx_content_type: how-to | ||
| title: How Guardrails works | ||
| sidebar: | ||
| order: 3 | ||
| --- | ||
|
|
||
| AI Gateway inspects all interactions in real time by evaluating content against predefined safety parameters. Below a breakdown of the process: | ||
|
|
||
| 1. Intercepting interactions: | ||
| AI Gateway proxies requests and responses, sitting between the user and the AI model. | ||
|
|
||
| 2. Inspecting content: | ||
|
|
||
| - User prompts: AI Gateway checks prompts against safety parameters (for example, violence, hate, or sexual content). Based on your settings, prompts can be flagged or blocked before reaching the model. | ||
| - Model responses: Once processed, the AI model response is inspected. If hazardous content is detected, it can be flagged or blocked before being delivered to the user. | ||
|
|
||
| 3. Applying actions: | ||
| Depending on your configuration, flagged content is logged for review, while blocked content is prevented from proceeding. | ||
|
|
||
| ## Supported model types | ||
|
|
||
| Guardrails determines the type of AI model being used and applies safety checks accordingly: | ||
|
|
||
| - Text generation models: Both prompts and responses are evaluated. | ||
| - Embedding models: Only the prompt is evaluated, and the response is passed directly back to the user. | ||
| - Unknown models: If the model type cannot be determined, prompts are evaluated, but responses bypass Guardrails. | ||
|
|
||
| If Guardrails cannot access the underlying model, requests set to "block" will result in an error, while flagged requests will proceed. | ||
|
|
||
| ## Configuration | ||
|
|
||
| Within AI Gateway settings, you can customize Guardrails: | ||
|
|
||
| - Enable or disable content moderation. | ||
| - Choose evaluation scope: Analyze user prompts, model responses, or both. | ||
| - Define hazard categories: Select categories like violence, hate, or sexual content and assign actions (ignore, flag, or block). | ||
|
|
||
| ## Workers AI and Guardrails | ||
|
|
||
| Guardrails currently uses [Llama Guard 3 8B](https://ai.meta.com/research/publications/llama-guard-llm-based-input-output-safeguard-for-human-ai-conversations/) on [Workers AI](/workers-ai/) to perform content evaluations. The underlying model may be updated in the future, and we will reflect those changes within Guardrails. | ||
|
|
||
| Since Guardrails runs on Workers AI, enabling it incurs usage on Workers AI. You can monitor usage through the Workers AI Dashboard. | ||
|
|
||
| ## Additional considerations | ||
|
|
||
| - Latency impact: Enabling Guardrails adds some latency. Consider this when balancing safety and speed. | ||
|
|
||
| :::note | ||
|
|
||
| Llama Guard is provided as-is without any representations, warranties, or guarantees. Any rules or examples contained in blogs, developer docs, or other reference materials are provided for informational purposes only. You acknowledge and understand that you are responsible for the results and outcomes of your use of AI Gateway. | ||
|
|
||
| ::: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 15 additions & 0 deletions
15
src/content/docs/browser-rendering/quick-actions-rest-api/content-endpoint.mdx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| --- | ||
| pcx_content_type: how-to | ||
| title: Retrieve HTML content | ||
| sidebar: | ||
| order: 2 | ||
| --- | ||
|
|
||
| Retrieve the HTML content of a specified URL by sending a POST request to the `/content` endpoint. | ||
|
|
||
| ``` | ||
daisyfaithauma marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| curl -X 'POST' 'https://api.cloudflare.com/client/v4/accounts/<accountTag>/browser-rendering/content' \ | ||
daisyfaithauma marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| -H 'Content-Type: application/json' \ | ||
| -H 'Authorization: Bearer <apiToken>' \ | ||
| -d '{"url": "https://example.com"}' | ||
| ``` | ||
30 changes: 30 additions & 0 deletions
30
src/content/docs/browser-rendering/quick-actions-rest-api/custom-css.mdx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| --- | ||
| pcx_content_type: how-to | ||
| title: Customize CSS and take a screenshot | ||
| sidebar: | ||
| order: 4 | ||
| --- | ||
|
|
||
| Customise the rendering by adding external JavaScript and CSS before capturing a screenshot. | ||
|
|
||
| ``` | ||
| curl -X POST 'https://api.cloudflare.com/client/v4/accounts/<accountTag>/browser-rendering/screenshot' \ | ||
| -H 'Authorization: Bearer <apiToken>' \ | ||
| -H 'Content-Type: application/json' \ | ||
| -d '{ | ||
| "url": "https://example.com/", | ||
| "addScriptTag": [ | ||
| { "url": "https://code.jquery.com/jquery-3.7.1.min.js" }, | ||
| { "content": "document.querySelector(`h1`).innerText = `Hello World!!!`" } | ||
| ], | ||
| "addStyleTag": [ | ||
| { | ||
| "content": "body { background: linear-gradient(45deg, #da5a44, #a32784); }" | ||
| }, | ||
| { | ||
| "url": "https://interactive-examples.mdn.mozilla.net/live-examples/css-examples/text-decoration/text-decoration-color.css" | ||
| } | ||
| ] | ||
| }' \ | ||
| --output "screenshot.webp" | ||
| ``` |
10 changes: 10 additions & 0 deletions
10
src/content/docs/browser-rendering/quick-actions-rest-api/index.mdx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| --- | ||
| pcx_content_type: navigation | ||
| title: Quick Actions API | ||
| sidebar: | ||
| order: 2 | ||
| --- | ||
|
|
||
| The Quick Actions API is a RESTful interface that provides endpoints for common browser actions such as capturing screenshots, extracting HTML content, generating PDFs, and more. This API is designed to help you interact with web pages quickly and efficiently. | ||
daisyfaithauma marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
daisyfaithauma marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| Before you begin, make sure to create a custom **API Token** with your Account > **Browser Rendering**> **Edit** permissions from the [Cloudflare dashboard](https://dash.cloudflare.com/). | ||
daisyfaithauma marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
daisyfaithauma marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
19 changes: 19 additions & 0 deletions
19
src/content/docs/browser-rendering/quick-actions-rest-api/pdf-endpoint.mdx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| --- | ||
| pcx_content_type: how-to | ||
| title: Generate PDF | ||
| sidebar: | ||
| order: 5 | ||
| --- | ||
|
|
||
daisyfaithauma marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| ``` | ||
| curl -X POST 'https://api.cloudflare.com/client/v4/accounts/<accountTag>/browser-rendering/pdf' \ | ||
| -H 'Authorization: Bearer <apiToken>' \ | ||
| -H 'Content-Type: application/json' \ | ||
| -d '{ | ||
| "url": "https://example.com/", | ||
| "addStyleTag": [ | ||
| { "content": "body { font-family: Arial; }" } | ||
daisyfaithauma marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| ] | ||
| }' \ | ||
| --output "output.pdf" | ||
| ``` | ||
18 changes: 18 additions & 0 deletions
18
src/content/docs/browser-rendering/quick-actions-rest-api/scrape-endpoint.mdx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| --- | ||
| pcx_content_type: how-to | ||
| title: Scrape content | ||
| sidebar: | ||
| order: 7 | ||
| --- | ||
|
|
||
| ``` | ||
daisyfaithauma marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| curl -X POST 'https://api.cloudflare.com/client/v4/accounts/<accountTag>/browser-rendering/scrape' \ | ||
| -H 'Authorization: Bearer <apiToken>' \ | ||
| -H 'Content-Type: application/json' \ | ||
| -d '{ | ||
| "url": "https://example.com/", | ||
daisyfaithauma marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| "scrapeOptions": { | ||
| "selectors": ["h1", ".article"] | ||
| } | ||
| }' | ||
| ``` | ||
22 changes: 22 additions & 0 deletions
22
src/content/docs/browser-rendering/quick-actions-rest-api/screenshot-endpoint.mdx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| --- | ||
| pcx_content_type: how-to | ||
| title: Render HTML and capture screenshot | ||
| sidebar: | ||
| order: 3 | ||
| --- | ||
|
|
||
| Render a provided HTML string and capture a screenshot with specific options. | ||
|
|
||
| ``` | ||
| curl -X POST 'https://api.cloudflare.com/client/v4/accounts/<accountTag>/browser-rendering/screenshot' \ | ||
| -H 'Authorization: Bearer <apiToken>' \ | ||
| -H 'Content-Type: application/json' \ | ||
| -d '{ | ||
| "html": "Hello World!", | ||
| "screenshotOptions": { | ||
| "type": "webp", | ||
daisyfaithauma marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| "omitBackground": true | ||
| } | ||
| }' \ | ||
| --output "screenshot.webp" | ||
| ``` | ||
18 changes: 18 additions & 0 deletions
18
src/content/docs/browser-rendering/quick-actions-rest-api/snapshot.mdx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| --- | ||
| pcx_content_type: how-to | ||
| title: Capture snapshot | ||
| sidebar: | ||
| order: 6 | ||
| --- | ||
|
|
||
| ``` | ||
daisyfaithauma marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| curl -X POST 'https://api.cloudflare.com/client/v4/accounts/<accountTag>/browser-rendering/snapshot' \ | ||
| -H 'Authorization: Bearer <apiToken>' \ | ||
| -H 'Content-Type: application/json' \ | ||
| -d '{ | ||
| "url": "https://example.com/", | ||
| "addScriptTag": [ | ||
| { "content": "document.title = \"Snapshot Page\";" } | ||
daisyfaithauma marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| ] | ||
| }' | ||
| ``` | ||
File renamed without changes.
11 changes: 11 additions & 0 deletions
11
src/content/docs/browser-rendering/workers-binding-api/index.mdx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| --- | ||
| pcx_content_type: navigation | ||
| title: Workers Binding API | ||
| sidebar: | ||
| order: 2 | ||
| group: | ||
daisyfaithauma marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| --- | ||
|
|
||
| import { DirectoryListing } from "~/components"; | ||
|
|
||
| <DirectoryListing /> | ||
daisyfaithauma marked this conversation as resolved.
Show resolved
Hide resolved
daisyfaithauma marked this conversation as resolved.
Show resolved
Hide resolved
|
||
File renamed without changes.
File renamed without changes.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.