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

[Skip to content](#_top)

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

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

[Provider Configs](https://developers.cloudflare.com/api/go/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

client.AIGateway.ProviderConfigs.New(ctx, gatewayID, params) (\*[ProviderConfigNewResponse](<https://developers.cloudflare.com/api/go/resources/ai_gateway#(resource)%20ai_gateway.provider_configs%20%3E%20(model)%20ProviderConfigNewResponse%20%3E%20(schema)>), error)

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`

##### ParametersExpand Collapse

gatewayID 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)>)

<details>

<summary>

params ProviderConfigNewParams

</summary>

AccountID param.Field\[string]

Path param

<a href="#(resource)%20ai_gateway.provider_configs%20%3E%20(method)%20create%20%3E%20(params)%20default%20%3E%20(param)%20account_id">Link to this property</a>

Alias param.Field\[string]

Body param

<a href="#(resource)%20ai_gateway.provider_configs%20%3E%20(method)%20create%20%3E%20(params)%20default%20%3E%20(param)%20alias">Link to this property</a>

DefaultConfig param.Field\[bool]

Body param

<a href="#(resource)%20ai_gateway.provider_configs%20%3E%20(method)%20create%20%3E%20(params)%20default%20%3E%20(param)%20default_config">Link to this property</a>

ProviderSlug param.Field\[string]

Body param

<a href="#(resource)%20ai_gateway.provider_configs%20%3E%20(method)%20create%20%3E%20(params)%20default%20%3E%20(param)%20provider_slug">Link to this property</a>

RateLimit param.Field\[float64]Optional

Body param

<a href="#(resource)%20ai_gateway.provider_configs%20%3E%20(method)%20create%20%3E%20(params)%20default%20%3E%20(param)%20rate_limit">Link to this property</a>

RateLimitPeriod param.Field\[float64]Optional

Body param

<a href="#(resource)%20ai_gateway.provider_configs%20%3E%20(method)%20create%20%3E%20(params)%20default%20%3E%20(param)%20rate_limit_period">Link to this property</a>

Secret param.Field\[string]Optional

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

<a href="#(resource)%20ai_gateway.provider_configs%20%3E%20(method)%20create%20%3E%20(params)%20default%20%3E%20(param)%20secret">Link to this property</a>

SecretID param.Field\[string]Optional

Body param

<a href="#(resource)%20ai_gateway.provider_configs%20%3E%20(method)%20create%20%3E%20(params)%20default%20%3E%20(param)%20secret_id">Link to this property</a>

</details>

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

##### ReturnsExpand Collapse

<details>

<summary>

type ProviderConfigNewResponse struct{…}

</summary>

ID string

<a href="#(resource)%20ai_gateway.provider_configs%20%3E%20(model)%20ProviderConfigNewResponse%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(model)%20ProviderConfigNewResponse%20%3E%20(schema)%20%3E%20(property)%20alias">Link to this property</a>

DefaultConfig bool

<a href="#(resource)%20ai_gateway.provider_configs%20%3E%20(model)%20ProviderConfigNewResponse%20%3E%20(schema)%20%3E%20(property)%20default_config">Link to this property</a>

GatewayID string

Unique identifier of the AI Gateway within the account.

maxLength64

minLength1

<a href="#(resource)%20ai_gateway.provider_configs%20%3E%20(model)%20ProviderConfigNewResponse%20%3E%20(schema)%20%3E%20(property)%20gateway_id">Link to this property</a>

ModifiedAt Time

formatdate-time

<a href="#(resource)%20ai_gateway.provider_configs%20%3E%20(model)%20ProviderConfigNewResponse%20%3E%20(schema)%20%3E%20(property)%20modified_at">Link to this property</a>

ProviderSlug string

<a href="#(resource)%20ai_gateway.provider_configs%20%3E%20(model)%20ProviderConfigNewResponse%20%3E%20(schema)%20%3E%20(property)%20provider_slug">Link to this property</a>

SecretID string

<a href="#(resource)%20ai_gateway.provider_configs%20%3E%20(model)%20ProviderConfigNewResponse%20%3E%20(schema)%20%3E%20(property)%20secret_id">Link to this property</a>

SecretPreview string

<a href="#(resource)%20ai_gateway.provider_configs%20%3E%20(model)%20ProviderConfigNewResponse%20%3E%20(schema)%20%3E%20(property)%20secret_preview">Link to this property</a>

RateLimit float64Optional

<a href="#(resource)%20ai_gateway.provider_configs%20%3E%20(model)%20ProviderConfigNewResponse%20%3E%20(schema)%20%3E%20(property)%20rate_limit">Link to this property</a>

RateLimitPeriod float64Optional

<a href="#(resource)%20ai_gateway.provider_configs%20%3E%20(model)%20ProviderConfigNewResponse%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(model)%20ProviderConfigNewResponse%20%3E%20(schema)>)

### Store a provider key

Go

HTTPTypeScriptPythonGoTerraform

```
package main

import (
  "context"
  "fmt"

  "github.com/cloudflare/cloudflare-go"
  "github.com/cloudflare/cloudflare-go/ai_gateway"
  "github.com/cloudflare/cloudflare-go/option"
)

func main() {
  client := cloudflare.NewClient(
    option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"),
  )
  providerConfig, err := client.AIGateway.ProviderConfigs.New(
    context.TODO(),
    "my-gateway",
    ai_gateway.ProviderConfigNewParams{
      AccountID: cloudflare.F("3ebbcb006d4d46d7bb6a8c7f14676cb0"),
      Alias: cloudflare.F("alias"),
      DefaultConfig: cloudflare.F(true),
      ProviderSlug: cloudflare.F("provider_slug"),
    },
  )
  if err != nil {
    panic(err.Error())
  }
  fmt.Printf("%+v\n", providerConfig.ID)
}
```

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
}
```