From 9187b378720af1e421a01eeb26d3589dd5a519cb Mon Sep 17 00:00:00 2001 From: daisyfaithauma Date: Fri, 8 Nov 2024 15:37:10 +0000 Subject: [PATCH 01/18] Initial authentication documentation --- .../configuration/authentication.mdx | 50 +++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 src/content/docs/ai-gateway/configuration/authentication.mdx diff --git a/src/content/docs/ai-gateway/configuration/authentication.mdx b/src/content/docs/ai-gateway/configuration/authentication.mdx new file mode 100644 index 00000000000000..a9718961a5be74 --- /dev/null +++ b/src/content/docs/ai-gateway/configuration/authentication.mdx @@ -0,0 +1,50 @@ +--- +pcx_content_type: configuration +title: Authentication +sidebar: + order: 7 +head: [] +description: Add security by requiring a valid authorization token for each request. +--- + +The Authenticated Gateway feature in AI Gateway adds security by requiring a valid authorization token for each request. This feature is especially useful when storing logs persistently, as it prevents unauthorized access and protects against “log bombing.” With Authenticated Gateway enabled, only requests with the correct token are processed. + +:::note[Note] +We recommend enabling Authenticated Gateway when opting to store logs with AI Gateway. +::: + +:::caution[Caution] +If Authenticated Gateway is enabled but a request does not include the required `cf-aig-authorization` header, the request will fail. This setting ensures that only verified requests pass through the gateway. To bypass the need for the `cf-aig-authorization` header, make sure to disable Authenticated Gateway. +::: + +## Setting up Authenticated Gateway using the Dashboard + +1. Go to the Settings for the specific gateway you want to enable authentication for. +2. Select **Create authentication token** to generate a custom token with the required `Run` permissions. Be sure to securely save this token, as it will not be displayed again. +3. Include the `cf-aig-authorization` header with your API token in each request for this gateway. +4. Return to the settings page and toggle on Authenticated Gateway. + +## Example request with OpenAI + +```bash +curl https://gateway.ai.cloudflare.com/v1/{account_id}/{gateway_id}/openai/chat/completions \ + --header 'cf-aig-authorization: Bearer {CF_AIG_TOKEN}' \ + --header 'Authorization: Bearer OPENAI_TOKEN' \ + --header 'Content-Type: application/json' \ + --data '{"model": "gpt-3.5-turbo", "messages": [{"role": "user", "content": "What is Cloudflare?"}]}' +``` + +## Setting Authenticated Gateway using the API + +For API setup, see the [API documentation](https://developers.cloudflare.com/api/operations/aig-config-create-gateway/). + +## Expected behavior + +The following table outlines gateway behavior based on the authentication settings and header status: + +| Authentication Setting | Header Info | Gateway State | Response | +| ---------------------- | -------------- | ----------------------- | ------------------------------------------ | +| On | Header present | Authenticated gateway | Request succeeds | +| On | No header | Error | Request fails due to missing authorization | +| Off | Header present | Unauthenticated gateway | Request succeeds | +| Off | No header | Unauthenticated gateway | Request succeeds | From 3f47dc4320f65a5543d50f3063e4473c43d8d620 Mon Sep 17 00:00:00 2001 From: daisyfaithauma Date: Fri, 8 Nov 2024 15:47:00 +0000 Subject: [PATCH 02/18] Added links to authentication --- src/content/docs/ai-gateway/get-started.mdx | 4 ++++ src/content/docs/ai-gateway/observability/logging/index.mdx | 2 ++ 2 files changed, 6 insertions(+) diff --git a/src/content/docs/ai-gateway/get-started.mdx b/src/content/docs/ai-gateway/get-started.mdx index 7b46c3f7043630..69d44a16b6a462 100644 --- a/src/content/docs/ai-gateway/get-started.mdx +++ b/src/content/docs/ai-gateway/get-started.mdx @@ -24,6 +24,10 @@ Then, create a new AI Gateway. +## Choosing Gateway Authentication + +When setting up a new gateway, you can choose between an authenticated and unauthenticated gateway. Enabling an authenticated gateway requires each request to include a valid authorization token, adding an extra layer of security. We recommend using an authenticated gateway when storing logs persistently to prevent unauthorized access and potential “log bombing”. Learn more about setting up an [authenticated gateway](/ai-gateway/configuration/authentication/). + ## Connect application Next, connect your AI provider to your gateway. diff --git a/src/content/docs/ai-gateway/observability/logging/index.mdx b/src/content/docs/ai-gateway/observability/logging/index.mdx index 3f19cc64702b73..c9f56b0e864464 100644 --- a/src/content/docs/ai-gateway/observability/logging/index.mdx +++ b/src/content/docs/ai-gateway/observability/logging/index.mdx @@ -16,6 +16,8 @@ You can store up to 10 million logs per gateway. If your limit is reached, new l To learn more about your plan limits, refer to [Limits](/ai-gateway/reference/limits/). +We recommend using an authenticated gateway when storing logs persistently to prevent unauthorized access and potential “log bombing”. Learn more about setting up an [authenticated gateway](/ai-gateway/configuration/authentication/). + ## Default configuration Logs, which include metrics as well as request and response data, are enabled by default for each gateway. This logging behavior will be uniformly applied to all requests in the gateway. If you are concerned about privacy or compliance and want to turn log collection off, you can go to settings and opt out of logs. If you need to modify the log settings for specific requests, you can override this setting on a per-request basis. From 14d07085cdd7edad42f996043cbd7de3dc3ff687 Mon Sep 17 00:00:00 2001 From: daisyfaithauma Date: Fri, 8 Nov 2024 15:48:17 +0000 Subject: [PATCH 03/18] Update src/content/docs/ai-gateway/configuration/authentication.mdx api link Co-authored-by: hyperlint-ai[bot] <154288675+hyperlint-ai[bot]@users.noreply.github.com> --- src/content/docs/ai-gateway/configuration/authentication.mdx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/content/docs/ai-gateway/configuration/authentication.mdx b/src/content/docs/ai-gateway/configuration/authentication.mdx index a9718961a5be74..f6a8d611595a2e 100644 --- a/src/content/docs/ai-gateway/configuration/authentication.mdx +++ b/src/content/docs/ai-gateway/configuration/authentication.mdx @@ -36,7 +36,7 @@ curl https://gateway.ai.cloudflare.com/v1/{account_id}/{gateway_id}/openai/chat/ ## Setting Authenticated Gateway using the API -For API setup, see the [API documentation](https://developers.cloudflare.com/api/operations/aig-config-create-gateway/). +For API setup, see the [API documentation](/api/operations/aig-config-create-gateway/). ## Expected behavior From e50d2c426e829784a367aaa9760731d3767546c8 Mon Sep 17 00:00:00 2001 From: daisyfaithauma Date: Fri, 8 Nov 2024 15:48:28 +0000 Subject: [PATCH 04/18] Update src/content/docs/ai-gateway/configuration/authentication.mdx Co-authored-by: hyperlint-ai[bot] <154288675+hyperlint-ai[bot]@users.noreply.github.com> --- src/content/docs/ai-gateway/configuration/authentication.mdx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/content/docs/ai-gateway/configuration/authentication.mdx b/src/content/docs/ai-gateway/configuration/authentication.mdx index f6a8d611595a2e..e97ec268be3f54 100644 --- a/src/content/docs/ai-gateway/configuration/authentication.mdx +++ b/src/content/docs/ai-gateway/configuration/authentication.mdx @@ -7,7 +7,7 @@ head: [] description: Add security by requiring a valid authorization token for each request. --- -The Authenticated Gateway feature in AI Gateway adds security by requiring a valid authorization token for each request. This feature is especially useful when storing logs persistently, as it prevents unauthorized access and protects against “log bombing.” With Authenticated Gateway enabled, only requests with the correct token are processed. +The Authenticated Gateway feature in AI Gateway adds security by requiring a valid authorization token for each request. This feature is especially useful when storing logs persistently, as it prevents unauthorized access and protects against "log bombing." With Authenticated Gateway enabled, only requests with the correct token are processed. :::note[Note] We recommend enabling Authenticated Gateway when opting to store logs with AI Gateway. From 15aabf3be2b6bcb14bf30e66c0ec54c8dd55a1fa Mon Sep 17 00:00:00 2001 From: daisyfaithauma Date: Fri, 8 Nov 2024 15:48:36 +0000 Subject: [PATCH 05/18] Update src/content/docs/ai-gateway/get-started.mdx Co-authored-by: hyperlint-ai[bot] <154288675+hyperlint-ai[bot]@users.noreply.github.com> --- src/content/docs/ai-gateway/get-started.mdx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/content/docs/ai-gateway/get-started.mdx b/src/content/docs/ai-gateway/get-started.mdx index 69d44a16b6a462..f065b10184e310 100644 --- a/src/content/docs/ai-gateway/get-started.mdx +++ b/src/content/docs/ai-gateway/get-started.mdx @@ -26,7 +26,7 @@ Then, create a new AI Gateway. ## Choosing Gateway Authentication -When setting up a new gateway, you can choose between an authenticated and unauthenticated gateway. Enabling an authenticated gateway requires each request to include a valid authorization token, adding an extra layer of security. We recommend using an authenticated gateway when storing logs persistently to prevent unauthorized access and potential “log bombing”. Learn more about setting up an [authenticated gateway](/ai-gateway/configuration/authentication/). +When setting up a new gateway, you can choose between an authenticated and unauthenticated gateway. Enabling an authenticated gateway requires each request to include a valid authorization token, adding an extra layer of security. We recommend using an authenticated gateway when storing logs persistently to prevent unauthorized access and potential "log bombing". Learn more about setting up an [authenticated gateway](/ai-gateway/configuration/authentication/). ## Connect application From 94b22572f642654df486960f03a2100e06da1b61 Mon Sep 17 00:00:00 2001 From: daisyfaithauma Date: Fri, 8 Nov 2024 15:48:47 +0000 Subject: [PATCH 06/18] Update src/content/docs/ai-gateway/observability/logging/index.mdx Co-authored-by: hyperlint-ai[bot] <154288675+hyperlint-ai[bot]@users.noreply.github.com> --- src/content/docs/ai-gateway/observability/logging/index.mdx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/content/docs/ai-gateway/observability/logging/index.mdx b/src/content/docs/ai-gateway/observability/logging/index.mdx index c9f56b0e864464..9259ed4ad41378 100644 --- a/src/content/docs/ai-gateway/observability/logging/index.mdx +++ b/src/content/docs/ai-gateway/observability/logging/index.mdx @@ -16,7 +16,7 @@ You can store up to 10 million logs per gateway. If your limit is reached, new l To learn more about your plan limits, refer to [Limits](/ai-gateway/reference/limits/). -We recommend using an authenticated gateway when storing logs persistently to prevent unauthorized access and potential “log bombing”. Learn more about setting up an [authenticated gateway](/ai-gateway/configuration/authentication/). +We recommend using an authenticated gateway when storing logs persistently to prevent unauthorized access and potential "log bombing". Learn more about setting up an [authenticated gateway](/ai-gateway/configuration/authentication/). ## Default configuration From 6ad4ce9276368cf18a2bb61877b16d4491f217fb Mon Sep 17 00:00:00 2001 From: daisyfaithauma Date: Fri, 8 Nov 2024 17:47:34 +0000 Subject: [PATCH 07/18] Update src/content/docs/ai-gateway/get-started.mdx Co-authored-by: Jun Lee --- src/content/docs/ai-gateway/get-started.mdx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/content/docs/ai-gateway/get-started.mdx b/src/content/docs/ai-gateway/get-started.mdx index f065b10184e310..f1f223c5a31ff4 100644 --- a/src/content/docs/ai-gateway/get-started.mdx +++ b/src/content/docs/ai-gateway/get-started.mdx @@ -24,7 +24,7 @@ Then, create a new AI Gateway. -## Choosing Gateway Authentication +## Choosing gateway authentication When setting up a new gateway, you can choose between an authenticated and unauthenticated gateway. Enabling an authenticated gateway requires each request to include a valid authorization token, adding an extra layer of security. We recommend using an authenticated gateway when storing logs persistently to prevent unauthorized access and potential "log bombing". Learn more about setting up an [authenticated gateway](/ai-gateway/configuration/authentication/). From 760bf2764e88cec209c42dfe350e41f4a1b87351 Mon Sep 17 00:00:00 2001 From: daisyfaithauma Date: Fri, 8 Nov 2024 17:47:47 +0000 Subject: [PATCH 08/18] Update src/content/docs/ai-gateway/get-started.mdx Co-authored-by: Jun Lee --- src/content/docs/ai-gateway/get-started.mdx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/content/docs/ai-gateway/get-started.mdx b/src/content/docs/ai-gateway/get-started.mdx index f1f223c5a31ff4..f2d0c860025b96 100644 --- a/src/content/docs/ai-gateway/get-started.mdx +++ b/src/content/docs/ai-gateway/get-started.mdx @@ -26,7 +26,7 @@ Then, create a new AI Gateway. ## Choosing gateway authentication -When setting up a new gateway, you can choose between an authenticated and unauthenticated gateway. Enabling an authenticated gateway requires each request to include a valid authorization token, adding an extra layer of security. We recommend using an authenticated gateway when storing logs persistently to prevent unauthorized access and potential "log bombing". Learn more about setting up an [authenticated gateway](/ai-gateway/configuration/authentication/). +When setting up a new gateway, you can choose between an authenticated and unauthenticated gateway. Enabling an authenticated gateway requires each request to include a valid authorization token, adding an extra layer of security. We recommend using an authenticated gateway when storing logs persistently to prevent unauthorized access and potential "log bombing". Learn more about setting up an [Authenticated Gateway](/ai-gateway/configuration/authentication/). ## Connect application From 78ff3deabc7a84f4be2c2459585a19725489b558 Mon Sep 17 00:00:00 2001 From: daisyfaithauma Date: Fri, 8 Nov 2024 17:48:00 +0000 Subject: [PATCH 09/18] Update src/content/docs/ai-gateway/configuration/authentication.mdx Co-authored-by: Jun Lee --- src/content/docs/ai-gateway/configuration/authentication.mdx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/content/docs/ai-gateway/configuration/authentication.mdx b/src/content/docs/ai-gateway/configuration/authentication.mdx index e97ec268be3f54..78b75dd3f9adcd 100644 --- a/src/content/docs/ai-gateway/configuration/authentication.mdx +++ b/src/content/docs/ai-gateway/configuration/authentication.mdx @@ -9,7 +9,7 @@ description: Add security by requiring a valid authorization token for each requ The Authenticated Gateway feature in AI Gateway adds security by requiring a valid authorization token for each request. This feature is especially useful when storing logs persistently, as it prevents unauthorized access and protects against "log bombing." With Authenticated Gateway enabled, only requests with the correct token are processed. -:::note[Note] +:::note We recommend enabling Authenticated Gateway when opting to store logs with AI Gateway. ::: From 818d677ea061425de139fd990d7783b65ef5dbc2 Mon Sep 17 00:00:00 2001 From: Kathy <153706637+kathayl@users.noreply.github.com> Date: Fri, 8 Nov 2024 15:03:14 -0800 Subject: [PATCH 10/18] Update authentication.mdx --- src/content/docs/ai-gateway/configuration/authentication.mdx | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/content/docs/ai-gateway/configuration/authentication.mdx b/src/content/docs/ai-gateway/configuration/authentication.mdx index 78b75dd3f9adcd..984649a3729198 100644 --- a/src/content/docs/ai-gateway/configuration/authentication.mdx +++ b/src/content/docs/ai-gateway/configuration/authentication.mdx @@ -7,13 +7,11 @@ head: [] description: Add security by requiring a valid authorization token for each request. --- -The Authenticated Gateway feature in AI Gateway adds security by requiring a valid authorization token for each request. This feature is especially useful when storing logs persistently, as it prevents unauthorized access and protects against "log bombing." With Authenticated Gateway enabled, only requests with the correct token are processed. +Using an Authenticated Gateway in AI Gateway adds security by requiring a valid authorization token for each request. This feature is especially useful when storing logs, as it prevents unauthorized access and protects against "log bombing." With Authenticated Gateway enabled, only requests with the correct token are processed. :::note We recommend enabling Authenticated Gateway when opting to store logs with AI Gateway. -::: -:::caution[Caution] If Authenticated Gateway is enabled but a request does not include the required `cf-aig-authorization` header, the request will fail. This setting ensures that only verified requests pass through the gateway. To bypass the need for the `cf-aig-authorization` header, make sure to disable Authenticated Gateway. ::: From 27164e8655c1d7e746a318e843db78cb79fbaaa3 Mon Sep 17 00:00:00 2001 From: Kathy <153706637+kathayl@users.noreply.github.com> Date: Fri, 8 Nov 2024 15:03:34 -0800 Subject: [PATCH 11/18] Update get-started.mdx --- src/content/docs/ai-gateway/get-started.mdx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/content/docs/ai-gateway/get-started.mdx b/src/content/docs/ai-gateway/get-started.mdx index f2d0c860025b96..acb32d9da30ecf 100644 --- a/src/content/docs/ai-gateway/get-started.mdx +++ b/src/content/docs/ai-gateway/get-started.mdx @@ -26,7 +26,7 @@ Then, create a new AI Gateway. ## Choosing gateway authentication -When setting up a new gateway, you can choose between an authenticated and unauthenticated gateway. Enabling an authenticated gateway requires each request to include a valid authorization token, adding an extra layer of security. We recommend using an authenticated gateway when storing logs persistently to prevent unauthorized access and potential "log bombing". Learn more about setting up an [Authenticated Gateway](/ai-gateway/configuration/authentication/). +When setting up a new gateway, you can choose between an authenticated and unauthenticated gateway. Enabling an authenticated gateway requires each request to include a valid authorization token, adding an extra layer of security. We recommend using an authenticated gateway when storing logs to prevent unauthorized access and potential "log bombing". Learn more about setting up an [Authenticated Gateway](/ai-gateway/configuration/authentication/). ## Connect application From 4fb4a444d1efcbf77c5c726b90d68fd0cd40da63 Mon Sep 17 00:00:00 2001 From: Kathy <153706637+kathayl@users.noreply.github.com> Date: Fri, 8 Nov 2024 15:04:20 -0800 Subject: [PATCH 12/18] Update index.mdx --- src/content/docs/ai-gateway/observability/logging/index.mdx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/content/docs/ai-gateway/observability/logging/index.mdx b/src/content/docs/ai-gateway/observability/logging/index.mdx index 9259ed4ad41378..129f06d65e7106 100644 --- a/src/content/docs/ai-gateway/observability/logging/index.mdx +++ b/src/content/docs/ai-gateway/observability/logging/index.mdx @@ -16,7 +16,7 @@ You can store up to 10 million logs per gateway. If your limit is reached, new l To learn more about your plan limits, refer to [Limits](/ai-gateway/reference/limits/). -We recommend using an authenticated gateway when storing logs persistently to prevent unauthorized access and potential "log bombing". Learn more about setting up an [authenticated gateway](/ai-gateway/configuration/authentication/). +We recommend using an authenticated gateway when storing logs to prevent unauthorized access and potential "log bombing". Learn more about setting up an [authenticated gateway](/ai-gateway/configuration/authentication/). ## Default configuration From edec4d105b4813962cdf1b69b9fc32066907395d Mon Sep 17 00:00:00 2001 From: Kathy <153706637+kathayl@users.noreply.github.com> Date: Wed, 13 Nov 2024 16:39:14 -0800 Subject: [PATCH 13/18] Update authentication.mdx --- src/content/docs/ai-gateway/configuration/authentication.mdx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/content/docs/ai-gateway/configuration/authentication.mdx b/src/content/docs/ai-gateway/configuration/authentication.mdx index 984649a3729198..f00e8d4b4333c6 100644 --- a/src/content/docs/ai-gateway/configuration/authentication.mdx +++ b/src/content/docs/ai-gateway/configuration/authentication.mdx @@ -7,7 +7,7 @@ head: [] description: Add security by requiring a valid authorization token for each request. --- -Using an Authenticated Gateway in AI Gateway adds security by requiring a valid authorization token for each request. This feature is especially useful when storing logs, as it prevents unauthorized access and protects against "log bombing." With Authenticated Gateway enabled, only requests with the correct token are processed. +Using an Authenticated Gateway in AI Gateway adds security by requiring a valid authorization token for each request. This feature is especially useful when storing logs, as it prevents unauthorized access and protects against invalid requests that can inflate log storage usage and make it harder to find the data you need. With Authenticated Gateway enabled, only requests with the correct token are processed. :::note We recommend enabling Authenticated Gateway when opting to store logs with AI Gateway. From c2f69dc88804ad8bd557c8c8c3b22d4e5a1d4ab8 Mon Sep 17 00:00:00 2001 From: Kathy <153706637+kathayl@users.noreply.github.com> Date: Wed, 13 Nov 2024 16:40:25 -0800 Subject: [PATCH 14/18] Update get-started.mdx --- src/content/docs/ai-gateway/get-started.mdx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/content/docs/ai-gateway/get-started.mdx b/src/content/docs/ai-gateway/get-started.mdx index acb32d9da30ecf..6dc187bf19c5d7 100644 --- a/src/content/docs/ai-gateway/get-started.mdx +++ b/src/content/docs/ai-gateway/get-started.mdx @@ -26,7 +26,7 @@ Then, create a new AI Gateway. ## Choosing gateway authentication -When setting up a new gateway, you can choose between an authenticated and unauthenticated gateway. Enabling an authenticated gateway requires each request to include a valid authorization token, adding an extra layer of security. We recommend using an authenticated gateway when storing logs to prevent unauthorized access and potential "log bombing". Learn more about setting up an [Authenticated Gateway](/ai-gateway/configuration/authentication/). +When setting up a new gateway, you can choose between an authenticated and unauthenticated gateway. Enabling an authenticated gateway requires each request to include a valid authorization token, adding an extra layer of security. We recommend using an authenticated gateway when storing logs to prevent unauthorized access and protect against invalid requests that can inflate log storage usage and make it harder to find the data you need. Learn more about setting up an [Authenticated Gateway](/ai-gateway/configuration/authentication/). ## Connect application From d513d589033de1bce1a0d537ac98b91a4b6dd578 Mon Sep 17 00:00:00 2001 From: Kathy <153706637+kathayl@users.noreply.github.com> Date: Wed, 13 Nov 2024 16:40:54 -0800 Subject: [PATCH 15/18] Update index.mdx --- src/content/docs/ai-gateway/observability/logging/index.mdx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/content/docs/ai-gateway/observability/logging/index.mdx b/src/content/docs/ai-gateway/observability/logging/index.mdx index 129f06d65e7106..7303bed04ff42c 100644 --- a/src/content/docs/ai-gateway/observability/logging/index.mdx +++ b/src/content/docs/ai-gateway/observability/logging/index.mdx @@ -16,7 +16,7 @@ You can store up to 10 million logs per gateway. If your limit is reached, new l To learn more about your plan limits, refer to [Limits](/ai-gateway/reference/limits/). -We recommend using an authenticated gateway when storing logs to prevent unauthorized access and potential "log bombing". Learn more about setting up an [authenticated gateway](/ai-gateway/configuration/authentication/). +We recommend using an authenticated gateway when storing logs to prevent unauthorized access and protecs against invalid requests that can inflate log storage usage and make it harder to find the data you need. Learn more about setting up an [authenticated gateway](/ai-gateway/configuration/authentication/). ## Default configuration From 6e16f6a48871ccc1cc3b8e7a63914262afc3ce42 Mon Sep 17 00:00:00 2001 From: daisyfaithauma Date: Thu, 14 Nov 2024 14:23:34 +0000 Subject: [PATCH 16/18] added examples and changelog --- src/content/changelogs/ai-gateway.yaml | 7 ++++- .../configuration/authentication.mdx | 29 +++++++++++++++++-- 2 files changed, 32 insertions(+), 4 deletions(-) diff --git a/src/content/changelogs/ai-gateway.yaml b/src/content/changelogs/ai-gateway.yaml index 4a92867c03a1bc..eea7f51657e376 100644 --- a/src/content/changelogs/ai-gateway.yaml +++ b/src/content/changelogs/ai-gateway.yaml @@ -5,11 +5,16 @@ productLink: "/ai-gateway/" productArea: Developer platform productAreaLink: /workers/platform/changelog/platform/ entries: + - publish_date: "2024-11-19" + title: Authentication + description: |- + * **Configuration**: Added [Authentication](/ai-gateway/configuration/authentication/) which adds security by requiring a valid authorization token for each request. + - publish_date: "2024-10-28" title: Grok description: |- * **Providers**: Added [Grok](/ai-gateway/providers/grok/) as a new provider. - + - publish_date: "2024-10-17" title: Vercel SDK description: |- diff --git a/src/content/docs/ai-gateway/configuration/authentication.mdx b/src/content/docs/ai-gateway/configuration/authentication.mdx index f00e8d4b4333c6..9b576ce9b05338 100644 --- a/src/content/docs/ai-gateway/configuration/authentication.mdx +++ b/src/content/docs/ai-gateway/configuration/authentication.mdx @@ -22,7 +22,7 @@ If Authenticated Gateway is enabled but a request does not include the required 3. Include the `cf-aig-authorization` header with your API token in each request for this gateway. 4. Return to the settings page and toggle on Authenticated Gateway. -## Example request with OpenAI +## Example requests with OpenAI ```bash curl https://gateway.ai.cloudflare.com/v1/{account_id}/{gateway_id}/openai/chat/completions \ @@ -32,9 +32,32 @@ curl https://gateway.ai.cloudflare.com/v1/{account_id}/{gateway_id}/openai/chat/ --data '{"model": "gpt-3.5-turbo", "messages": [{"role": "user", "content": "What is Cloudflare?"}]}' ``` -## Setting Authenticated Gateway using the API +Using OpenAI sdk: -For API setup, see the [API documentation](/api/operations/aig-config-create-gateway/). +```javascript +import OpenAI from "openai"; + +const openai = new OpenAI({ + apiKey: process.env.OPENAI_API_KEY, + baseURL: "https://gateway.ai.cloudflare.com/v1/account-id/gateway/openai", + defaultHeaders: { + "cf-aig-token": `Bearer {token}`, + }, +}); +``` + +## Example requests with Vercel sdk + +```javascript +import { createOpenAI } from "@ai-sdk/openai"; + +const openai = createOpenAI({ + baseURL: "https://gateway.ai.cloudflare.com/v1/account-id/gateway/openai", + headers: { + "cf-aig-token": `Bearer {token}`, + }, +}); +``` ## Expected behavior From 8d754b6136dbacd41fa56fa689be686102b11c7b Mon Sep 17 00:00:00 2001 From: daisyfaithauma Date: Mon, 18 Nov 2024 16:51:13 +0000 Subject: [PATCH 17/18] websockets changelog --- src/content/changelogs/ai-gateway.yaml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/content/changelogs/ai-gateway.yaml b/src/content/changelogs/ai-gateway.yaml index eea7f51657e376..638296c089c1a0 100644 --- a/src/content/changelogs/ai-gateway.yaml +++ b/src/content/changelogs/ai-gateway.yaml @@ -5,6 +5,10 @@ productLink: "/ai-gateway/" productArea: Developer platform productAreaLink: /workers/platform/changelog/platform/ entries: + - publish_date: "2024-11-19" + title: WebsocketS API + description: |- + * **Configuration**: Added [WebSockets API](/ai-gateway/configuration/websockets-api/) which provides a single persistent connection, enabling continuous communication. - publish_date: "2024-11-19" title: Authentication description: |- From 37827bf8f22a38caad44765814d278041b9d2387 Mon Sep 17 00:00:00 2001 From: Kathy <153706637+kathayl@users.noreply.github.com> Date: Mon, 18 Nov 2024 09:56:46 -0800 Subject: [PATCH 18/18] Update authentication.mdx --- src/content/docs/ai-gateway/configuration/authentication.mdx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/content/docs/ai-gateway/configuration/authentication.mdx b/src/content/docs/ai-gateway/configuration/authentication.mdx index 9b576ce9b05338..126114fbdfd23c 100644 --- a/src/content/docs/ai-gateway/configuration/authentication.mdx +++ b/src/content/docs/ai-gateway/configuration/authentication.mdx @@ -32,7 +32,7 @@ curl https://gateway.ai.cloudflare.com/v1/{account_id}/{gateway_id}/openai/chat/ --data '{"model": "gpt-3.5-turbo", "messages": [{"role": "user", "content": "What is Cloudflare?"}]}' ``` -Using OpenAI sdk: +Using the OpenAI SDK: ```javascript import OpenAI from "openai"; @@ -46,7 +46,7 @@ const openai = new OpenAI({ }); ``` -## Example requests with Vercel sdk +## Example requests with the Vercel AI SDK ```javascript import { createOpenAI } from "@ai-sdk/openai";