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

[Skip to content](#_top)

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

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

[Custom Providers](https://developers.cloudflare.com/api/python/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

ai\_gateway.custom\_providers.create(CustomProviderCreateParams\*\*kwargs) -> [CustomProviderCreateResponse](<https://developers.cloudflare.com/api/python/resources/ai_gateway#(resource)%20ai_gateway.custom_providers%20%3E%20(model)%20custom_provider_create_response%20%3E%20(schema)>)

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

account\_id: str

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

base\_url: str

formaturi

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

name: str

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

slug: str

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

beta: Optional\[[bool](<https://developers.cloudflare.com/api/python/resources/ai_gateway/subresources/custom_providers/methods/create#(resource)%20ai_gateway.custom_providers%20%3E%20(method)%20create%20%3E%20(params)%20default%20%3E%20(param)%20beta%20%3E%20(schema)>)]

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

curl\_example: Optional\[str]

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

description: Optional\[str]

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

enable: Optional\[[bool](<https://developers.cloudflare.com/api/python/resources/ai_gateway/subresources/custom_providers/methods/create#(resource)%20ai_gateway.custom_providers%20%3E%20(method)%20create%20%3E%20(params)%20default%20%3E%20(param)%20enable%20%3E%20(schema)>)]

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

headers: Optional\[str]

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

maxLength8192

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

js\_example: Optional\[str]

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

link: Optional\[str]

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

position: Optional\[int]

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

##### ReturnsExpand Collapse

<details>

<summary>

class CustomProviderCreateResponse: …

</summary>

id: str

formatuuid

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

base\_url: str

formaturi

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

created\_at: datetime

formatdate-time

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

modified\_at: datetime

formatdate-time

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

name: str

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

slug: str

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

beta: Optional\[bool]

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

curl\_example: Optional\[str]

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

description: Optional\[str]

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

enable: Optional\[bool]

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

headers: Optional\[str]

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)%20custom_provider_create_response%20%3E%20(schema)%20%3E%20(property)%20headers">Link to this property</a>

js\_example: Optional\[str]

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

link: Optional\[str]

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

logo: Optional\[str]

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

position: Optional\[int]

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

### Create a custom provider

Python

HTTPTypeScriptPythonGoTerraform

```
import os
from cloudflare import Cloudflare

client = Cloudflare(
    api_token=os.environ.get("CLOUDFLARE_API_TOKEN"),  # This is the default and can be omitted
)
custom_provider = client.ai_gateway.custom_providers.create(
    account_id="3ebbcb006d4d46d7bb6a8c7f14676cb0",
    base_url="https://example.com",
    name="name",
    slug="slug",
)
print(custom_provider.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
}
```