---
title: Store a provider key
---

[Skip to content](#_top)

[API Reference](https://developers.cloudflare.com/api)

[AI Gateway](https://developers.cloudflare.com/api/resources/ai_gateway)

[Provider Configs](https://developers.cloudflare.com/api/resources/ai_gateway/subresources/provider_configs)

Copy Markdown

Open in **Claude**Open in **ChatGPT**Open in **Cursor**

---

**Copy Markdown****View as Markdown**

# Store a provider key

POST/accounts/{account\_id}/ai-gateway/gateways/{gateway\_id}/provider\_configs

Stores an upstream AI provider API key for an AI Gateway in the Secrets Store configured on the gateway, with an optional rate limit. Pass `secret` to store a new key, or omit it to use an existing Secrets Store secret.

##### Security

<details>

<summary>API Token</summary>



The preferred authorization scheme for interacting with the Cloudflare API. <a href="https://developers.cloudflare.com/fundamentals/api/get-started/create-token/">Create a token</a>.

**Example:**<code>Authorization: Bearer Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY</code>

</details>

<details>

<summary>API Email + API Key</summary>



The previous authorization scheme for interacting with the Cloudflare API, used in conjunction with a Global API key.

**Example:**<code>X-Auth-Email: user@example.com</code>

The previous authorization scheme for interacting with the Cloudflare API. When possible, use API tokens instead of Global API keys.

**Example:**<code>X-Auth-Key: 144c9defac04969c7bfad8efaa8ea194</code>

</details>

##### Accepted Permissions (at least one required)

`Secrets Store Write`

##### P ath ParametersExpand Collapse

account\_id: string

[Link to this property](<#(resource)%20ai_gateway.provider_configs%20%3E%20(method)%20create%20%3E%20(params)%20default%20%3E%20(param)%20account_id%20%3E%20(schema)>)

gateway\_id: string

Unique identifier of the AI Gateway within the account.

maxLength64

minLength1

[Link to this property](<#(resource)%20ai_gateway.provider_configs%20%3E%20(method)%20create%20%3E%20(params)%20default%20%3E%20(param)%20gateway_id%20%3E%20(schema)>)

##### Body ParametersJSONExpand Collapse

alias: string

[Link to this property](<#(resource)%20ai_gateway.provider_configs%20%3E%20(method)%20create%20%3E%20(params)%200%20%3E%20(param)%20alias%20%3E%20(schema)>)

default\_config: boolean

[Link to this property](<#(resource)%20ai_gateway.provider_configs%20%3E%20(method)%20create%20%3E%20(params)%200%20%3E%20(param)%20default_config%20%3E%20(schema)>)

provider\_slug: string

[Link to this property](<#(resource)%20ai_gateway.provider_configs%20%3E%20(method)%20create%20%3E%20(params)%200%20%3E%20(param)%20provider_slug%20%3E%20(schema)>)

rate\_limit: optional number

[Link to this property](<#(resource)%20ai_gateway.provider_configs%20%3E%20(method)%20create%20%3E%20(params)%200%20%3E%20(param)%20rate_limit%20%3E%20(schema)>)

rate\_limit\_period: optional number

[Link to this property](<#(resource)%20ai_gateway.provider_configs%20%3E%20(method)%20create%20%3E%20(params)%200%20%3E%20(param)%20rate_limit_period%20%3E%20(schema)>)

secret: optional string

Provider API key to store in the Secrets Store configured on the gateway.

[Link to this property](<#(resource)%20ai_gateway.provider_configs%20%3E%20(method)%20create%20%3E%20(params)%200%20%3E%20(param)%20secret%20%3E%20(schema)>)

secret\_id: optional string

[Link to this property](<#(resource)%20ai_gateway.provider_configs%20%3E%20(method)%20create%20%3E%20(params)%200%20%3E%20(param)%20secret_id%20%3E%20(schema)>)

##### ReturnsExpand Collapse

<details>

<summary>

result: object {id, alias, default\_config, 7 more }

</summary>

id: string

<a href="#(resource)%20ai_gateway.provider_configs%20%3E%20(method)%20create%20%3E%20(network%20schema)%20%3E%20(property)%20result%20%2B%20(resource)%20ai_gateway.provider_configs%20%3E%20(model)%20provider_config_create_response%20%3E%20(schema)%20%3E%20(property)%20id">Link to this property</a>

alias: string

<a href="#(resource)%20ai_gateway.provider_configs%20%3E%20(method)%20create%20%3E%20(network%20schema)%20%3E%20(property)%20result%20%2B%20(resource)%20ai_gateway.provider_configs%20%3E%20(model)%20provider_config_create_response%20%3E%20(schema)%20%3E%20(property)%20alias">Link to this property</a>

default\_config: boolean

<a href="#(resource)%20ai_gateway.provider_configs%20%3E%20(method)%20create%20%3E%20(network%20schema)%20%3E%20(property)%20result%20%2B%20(resource)%20ai_gateway.provider_configs%20%3E%20(model)%20provider_config_create_response%20%3E%20(schema)%20%3E%20(property)%20default_config">Link to this property</a>

gateway\_id: string

Unique identifier of the AI Gateway within the account.

maxLength64

minLength1

<a href="#(resource)%20ai_gateway.provider_configs%20%3E%20(method)%20create%20%3E%20(network%20schema)%20%3E%20(property)%20result%20%2B%20(resource)%20ai_gateway.provider_configs%20%3E%20(model)%20provider_config_create_response%20%3E%20(schema)%20%3E%20(property)%20gateway_id">Link to this property</a>

modified\_at: string

formatdate-time

<a href="#(resource)%20ai_gateway.provider_configs%20%3E%20(method)%20create%20%3E%20(network%20schema)%20%3E%20(property)%20result%20%2B%20(resource)%20ai_gateway.provider_configs%20%3E%20(model)%20provider_config_create_response%20%3E%20(schema)%20%3E%20(property)%20modified_at">Link to this property</a>

provider\_slug: string

<a href="#(resource)%20ai_gateway.provider_configs%20%3E%20(method)%20create%20%3E%20(network%20schema)%20%3E%20(property)%20result%20%2B%20(resource)%20ai_gateway.provider_configs%20%3E%20(model)%20provider_config_create_response%20%3E%20(schema)%20%3E%20(property)%20provider_slug">Link to this property</a>

secret\_id: string

<a href="#(resource)%20ai_gateway.provider_configs%20%3E%20(method)%20create%20%3E%20(network%20schema)%20%3E%20(property)%20result%20%2B%20(resource)%20ai_gateway.provider_configs%20%3E%20(model)%20provider_config_create_response%20%3E%20(schema)%20%3E%20(property)%20secret_id">Link to this property</a>

secret\_preview: string

<a href="#(resource)%20ai_gateway.provider_configs%20%3E%20(method)%20create%20%3E%20(network%20schema)%20%3E%20(property)%20result%20%2B%20(resource)%20ai_gateway.provider_configs%20%3E%20(model)%20provider_config_create_response%20%3E%20(schema)%20%3E%20(property)%20secret_preview">Link to this property</a>

rate\_limit: optional number

<a href="#(resource)%20ai_gateway.provider_configs%20%3E%20(method)%20create%20%3E%20(network%20schema)%20%3E%20(property)%20result%20%2B%20(resource)%20ai_gateway.provider_configs%20%3E%20(model)%20provider_config_create_response%20%3E%20(schema)%20%3E%20(property)%20rate_limit">Link to this property</a>

rate\_limit\_period: optional number

<a href="#(resource)%20ai_gateway.provider_configs%20%3E%20(method)%20create%20%3E%20(network%20schema)%20%3E%20(property)%20result%20%2B%20(resource)%20ai_gateway.provider_configs%20%3E%20(model)%20provider_config_create_response%20%3E%20(schema)%20%3E%20(property)%20rate_limit_period">Link to this property</a>

</details>

[Link to this property](<#(resource)%20ai_gateway.provider_configs%20%3E%20(method)%20create%20%3E%20(network%20schema)%20%3E%20(property)%20result>)

success: boolean

[Link to this property](<#(resource)%20ai_gateway.provider_configs%20%3E%20(method)%20create%20%3E%20(network%20schema)%20%3E%20(property)%20success>)

### Store a provider key

HTTP

HTTPTypeScriptPythonGoTerraform

```
curl https://api.cloudflare.com/client/v4/accounts/$ACCOUNT_ID/ai-gateway/gateways/$GATEWAY_ID/provider_configs \
    -H 'Content-Type: application/json' \
    -H "Authorization: Bearer $CLOUDFLARE_API_TOKEN" \
    -d '{
          "alias": "alias",
          "default_config": true,
          "provider_slug": "provider_slug"
        }'
```

200 example

```
{
  "result": {
    "id": "id",
    "alias": "alias",
    "default_config": true,
    "gateway_id": "my-gateway",
    "modified_at": "2019-12-27T18:11:19.117Z",
    "provider_slug": "provider_slug",
    "secret_id": "secret_id",
    "secret_preview": "secret_preview",
    "rate_limit": 0,
    "rate_limit_period": 0
  },
  "success": true
}
```

##### Returns Examples

200 example

```
{
  "result": {
    "id": "id",
    "alias": "alias",
    "default_config": true,
    "gateway_id": "my-gateway",
    "modified_at": "2019-12-27T18:11:19.117Z",
    "provider_slug": "provider_slug",
    "secret_id": "secret_id",
    "secret_preview": "secret_preview",
    "rate_limit": 0,
    "rate_limit_period": 0
  },
  "success": true
}
```