Skip to content

Commit a54ed45

Browse files
committed
updated-code-snippets
1 parent c7c30e4 commit a54ed45

File tree

1 file changed

+33
-26
lines changed

1 file changed

+33
-26
lines changed
Lines changed: 33 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,48 @@
11
---
22
title: Secrets Store now available with AI Gateway: centralize storage, management, and security of your AI provider keys with Cloudflare Secrets Store
3-
date: 2025-08-25T11:00:00Z
3+
date: 2025-08-26T11:00:00Z
44
products:
55
- secrets-store
6+
- ai-gateway
67
---
78

89
import { Card, Render, Details } from "~/components"
910

10-
Cloudflare Secrets Store is now integrated with AI Gateway, allowing you to store, manage, and deploy your AI provider keys in a secure and seamless configuration.
11+
Cloudflare Secrets Store is now integrated with AI Gateway, allowing you to store, manage, and deploy your AI provider keys in a secure and seamless configuration through [Bring Your Own Key](https://developers.cloudflare.com/ai-gateway/configuration/bring-your-own-keys/). Instead of passing your AI provider keys directly in every request header, you can centrally manage each key with Secrets Store and deploy in your gateway configuration using only a reference.
1112

1213
You can now create a secret directly from your AI Gateway [in the dashboard:](http://dash.cloudflare.com/?to=/:account/ai-gateway) by navigating into your gateway -> **Provider Keys** -> **Add**.
1314

1415
![Import repo or choose template](~/assets/images/ssl/add-secret-ai-gateway.png)
1516

16-
You can create your secret with the newly available **ai_gateway** scope via [wrangler](https://developers.cloudflare.com/workers/wrangler/commands/), the [Secrets Store dashboard](http://dash.cloudflare.com/?to=/:account/secrets-store), or the [API](https://developers.cloudflare.com/api/resources/secrets_store/):
17+
You can also create your secret with the newly available **ai_gateway** scope via [wrangler](https://developers.cloudflare.com/workers/wrangler/commands/), the [Secrets Store dashboard](http://dash.cloudflare.com/?to=/:account/secrets-store), or the [API](https://developers.cloudflare.com/api/resources/secrets_store/):
18+
19+
Once you have created your secret with an **AI Gateway** scope, pass the key in the request header using its Secrets Store reference:
1720

1821
```
19-
curl "https://api.cloudflare.com/client/v4/accounts/$ACCOUNT_ID/secrets_store/stores/$STORE_ID/secrets" \
20-
--request POST \
21-
--header "X-Auth-Email: $CLOUDFLARE_EMAIL" \
22-
--header "X-Auth-Key: $CLOUDFLARE_API_KEY" \
23-
--json '[
24-
{
25-
"name": "<MY_SECRET_NAME>",
26-
"value": "<SECRET_VALUE>",
27-
"scopes": [
28-
"workers"
29-
],
30-
"comment": ""
31-
},
32-
{
33-
"name": "<MY_SECRET_NAME_2>",
34-
"value": "<SECRET_VALUE>",
35-
"scopes": [
36-
"ai_gateway"
37-
],
38-
"comment": ""
39-
}
40-
]'
41-
```
22+
curl -X POST https://gateway.ai.cloudflare.com/v1/<ACCOUNT_ID>/my-gateway/anthropic/v1/messages \
23+
--header 'cf-aig-authorization: CLOUDFLARE_AI_GATEWAY_TOKEN \
24+
--header 'anthropic-version: 2023-06-01' \
25+
--header 'Content-Type: application/json' \
26+
--data '{"model": "claude-3-opus-20240229", "messages": [{"role": "user", "content": "What is Cloudflare?"}]}'
27+
```
28+
29+
Or, using Javascript:
30+
31+
```
32+
import Anthropic from '@anthropic-ai/sdk';
33+
34+
35+
const anthropic = new Anthropic({
36+
apiKey: "CLOUDFLARE_AI_GATEWAY_TOKEN",
37+
baseURL: "https://gateway.ai.cloudflare.com/v1/<ACCOUNT_ID>/my-gateway/anthropic",
38+
});
39+
40+
41+
const message = await anthropic.messages.create({
42+
model: 'claude-3-opus-20240229',
43+
messages: [{role: "user", content: "What is Cloudflare?"}],
44+
max_tokens: 1024
45+
});
46+
```
47+
48+
For more information, check out the [blog](https://blog.cloudflare.com/ai-gateway-aug-2025-refresh)!

0 commit comments

Comments
 (0)