---
title: Create a custom provider
---

[Skip to content](#_top)

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

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

[Custom Providers](https://developers.cloudflare.com/api/go/resources/ai_gateway/subresources/custom_providers)

Copy Markdown

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

---

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

# Create a custom provider

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

POST/accounts/{account\_id}/ai-gateway/custom-providers

Creates an account-level custom provider that forwards AI Gateway requests to the HTTPS base URL you supply. Requests reference the provider as `custom-{slug}`, so the slug must be unique within the account.

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

`AI Gateway Write`

##### ParametersExpand Collapse

<details>

<summary>

params CustomProviderNewParams

</summary>

AccountID param.Field\[string]

Path param

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

BaseURL param.Field\[string]

Body param

formaturi

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

Name param.Field\[string]

Body param

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

Slug param.Field\[string]

Body param

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

Beta param.Field\[bool]Optional

Body param

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

CurlExample param.Field\[string]Optional

Body param

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

Description param.Field\[string]Optional

Body param

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

Enable param.Field\[bool]Optional

Body param

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

Headers param.Field\[string]Optional

Body param: JSON object of extra HTTP headers that AI Gateway sends to the provider. Values can contain credentials.

maxLength8192

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

JSExample param.Field\[string]Optional

Body param

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

Link param.Field\[string]Optional

Body param

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

Position param.Field\[int64]Optional

Body param

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

</details>

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

##### ReturnsExpand Collapse

<details>

<summary>

type CustomProviderNewResponse struct{…}

</summary>

ID string

formatuuid

<a href="#(resource)%20ai_gateway.custom_providers%20%3E%20(model)%20CustomProviderNewResponse%20%3E%20(schema)%20%3E%20(property)%20id">Link to this property</a>

BaseURL string

formaturi

<a href="#(resource)%20ai_gateway.custom_providers%20%3E%20(model)%20CustomProviderNewResponse%20%3E%20(schema)%20%3E%20(property)%20base_url">Link to this property</a>

CreatedAt Time

formatdate-time

<a href="#(resource)%20ai_gateway.custom_providers%20%3E%20(model)%20CustomProviderNewResponse%20%3E%20(schema)%20%3E%20(property)%20created_at">Link to this property</a>

ModifiedAt Time

formatdate-time

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

Name string

<a href="#(resource)%20ai_gateway.custom_providers%20%3E%20(model)%20CustomProviderNewResponse%20%3E%20(schema)%20%3E%20(property)%20name">Link to this property</a>

Slug string

<a href="#(resource)%20ai_gateway.custom_providers%20%3E%20(model)%20CustomProviderNewResponse%20%3E%20(schema)%20%3E%20(property)%20slug">Link to this property</a>

Beta boolOptional

<a href="#(resource)%20ai_gateway.custom_providers%20%3E%20(model)%20CustomProviderNewResponse%20%3E%20(schema)%20%3E%20(property)%20beta">Link to this property</a>

CurlExample stringOptional

<a href="#(resource)%20ai_gateway.custom_providers%20%3E%20(model)%20CustomProviderNewResponse%20%3E%20(schema)%20%3E%20(property)%20curl_example">Link to this property</a>

Description stringOptional

<a href="#(resource)%20ai_gateway.custom_providers%20%3E%20(model)%20CustomProviderNewResponse%20%3E%20(schema)%20%3E%20(property)%20description">Link to this property</a>

Enable boolOptional

<a href="#(resource)%20ai_gateway.custom_providers%20%3E%20(model)%20CustomProviderNewResponse%20%3E%20(schema)%20%3E%20(property)%20enable">Link to this property</a>

Headers stringOptional

JSON object of extra HTTP headers that AI Gateway sends to the provider. Values can contain credentials.

maxLength8192

<a href="#(resource)%20ai_gateway.custom_providers%20%3E%20(model)%20CustomProviderNewResponse%20%3E%20(schema)%20%3E%20(property)%20headers">Link to this property</a>

JSExample stringOptional

<a href="#(resource)%20ai_gateway.custom_providers%20%3E%20(model)%20CustomProviderNewResponse%20%3E%20(schema)%20%3E%20(property)%20js_example">Link to this property</a>

Link stringOptional

<a href="#(resource)%20ai_gateway.custom_providers%20%3E%20(model)%20CustomProviderNewResponse%20%3E%20(schema)%20%3E%20(property)%20link">Link to this property</a>

Logo stringOptional

<a href="#(resource)%20ai_gateway.custom_providers%20%3E%20(model)%20CustomProviderNewResponse%20%3E%20(schema)%20%3E%20(property)%20logo">Link to this property</a>

Position int64Optional

<a href="#(resource)%20ai_gateway.custom_providers%20%3E%20(model)%20CustomProviderNewResponse%20%3E%20(schema)%20%3E%20(property)%20position">Link to this property</a>

</details>

[Link to this property](<#(resource)%20ai_gateway.custom_providers%20%3E%20(model)%20CustomProviderNewResponse%20%3E%20(schema)>)

### Create a custom provider

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"),
  )
  customProvider, err := client.AIGateway.CustomProviders.New(context.TODO(), ai_gateway.CustomProviderNewParams{
    AccountID: cloudflare.F("3ebbcb006d4d46d7bb6a8c7f14676cb0"),
    BaseURL: cloudflare.F("https://example.com"),
    Name: cloudflare.F("name"),
    Slug: cloudflare.F("slug"),
  })
  if err != nil {
    panic(err.Error())
  }
  fmt.Printf("%+v\n", customProvider.ID)
}
```

200 example

```
{
  "result": {
    "id": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
    "base_url": "https://example.com",
    "created_at": "2019-12-27T18:11:19.117Z",
    "modified_at": "2019-12-27T18:11:19.117Z",
    "name": "name",
    "slug": "slug",
    "beta": true,
    "curl_example": "curl_example",
    "description": "description",
    "enable": true,
    "headers": "headers",
    "js_example": "js_example",
    "link": "link",
    "logo": "logo",
    "position": 0
  },
  "success": true
}
```

##### Returns Examples

200 example

```
{
  "result": {
    "id": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
    "base_url": "https://example.com",
    "created_at": "2019-12-27T18:11:19.117Z",
    "modified_at": "2019-12-27T18:11:19.117Z",
    "name": "name",
    "slug": "slug",
    "beta": true,
    "curl_example": "curl_example",
    "description": "description",
    "enable": true,
    "headers": "headers",
    "js_example": "js_example",
    "link": "link",
    "logo": "logo",
    "position": 0
  },
  "success": true
}
```