Skip to content

Commit f5dbe97

Browse files
committed
Add code block highlighting
1 parent 4a3e77b commit f5dbe97

File tree

1 file changed

+7
-11
lines changed

1 file changed

+7
-11
lines changed

src/content/docs/cloudflare-one/tutorials/ai-wrapper-tenant-control.mdx

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -108,9 +108,7 @@ You can now build the Worker using the online code editor by selecting **Edit co
108108

109109
The following is an example starter Worker that serves a simple front-end to allow a user to interact with an AI provider behind AI Gateway. This example uses OpenAI as its AI provider:
110110

111-
<Details header="Example AI wrapper Worker">
112-
113-
```javascript
111+
```javascript {9} collapse={54-230}
114112
export default {
115113
async fetch(request, env) {
116114
if (request.url.endsWith("/api/chat")) {
@@ -119,7 +117,7 @@ export default {
119117
const { messages } = await request.json();
120118

121119
const response = await fetch(
122-
"https://gateway.ai.cloudflare.com/v1/<ACCOUNT_ID>/<GATEWAY_ID>/openai/chat/completions",
120+
"https://gateway.ai.cloudflare.com/v1/$ACCOUNT_ID/$GATEWAY_ID/openai/chat/completions",
123121
{
124122
method: "POST",
125123
headers: {
@@ -344,8 +342,6 @@ const HTML = `<!DOCTYPE html>
344342
</html>`;
345343
```
346344

347-
</Details>
348-
349345
Note that the account ID and gateway ID need to be replaced in the AI Gateway endpoint. You can add these as [environment variables](/workers/configuration/environment-variables/) or [secrets](/workers/configuration/secrets/) in Workers. If you chose to use Authenticated Gateway when creating your AI gateway, make sure to also add your token as a secret and pass its value to the AI gateway in the `cf-aig-authorization` header.
350346

351347
### 3. Publish the Worker
@@ -356,16 +352,16 @@ Once the Worker code is complete, you need to make the Worker addressable using
356352

357353
Edit the `wrangler.toml` configuration file and add the following information to ensure that the Worker is only accessible using the custom hostname:
358354

359-
```toml
355+
```diff lang="toml"
360356
name = "ai-agent-wrapper"
361357
main = "src/index.js"
362358
compatibility_date = "2023-10-30"
363359
workers_dev = false
364360

365-
# replace with your custom domain
366-
routes = [
367-
{ pattern = "<YOUR_CUSTOM_DOMAIN>", custom_domain = true }
368-
]
361+
+# Replace with your custom domain
362+
+routes = [
363+
+ { pattern = "<YOUR_CUSTOM_DOMAIN>", custom_domain = true }
364+
+]
369365

370366
[vars]
371367
# Add any environment variables here

0 commit comments

Comments
 (0)