> For the complete documentation index, see [llms.txt](https://docs.console.zenlayer.com/api-reference/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.console.zenlayer.com/api-reference/cn/compute/aig/ai-gateway/createaigateway.md).

# CreateAiGateway

## 1. 接口描述

本接口(CreateAiGateway)用于创建AI网关

{% hint style="info" %}
**注意事项**

* 本接口认证方式请参考[认证方式](/api-reference/cn/api-introduction/instruction/authorization.md)
  {% endhint %}

## 2. 请求参数

以下请求参数列表仅列出了接口中需要的请求参数

| 参数名称            | 必选 | 类型                                                                              | 描述                                                                                |
| --------------- | -- | ------------------------------------------------------------------------------- | --------------------------------------------------------------------------------- |
| gatewayName     | 是  | String                                                                          | <p>AI网关名称。</p><p>范围2到63个字符。</p><p>仅支持输入字母、数字、-和英文句点(.)。</p><p>且必须以数字或字母开头和结尾。</p> |
| tokenLimit      | 是  | Integer                                                                         | token配额。                                                                          |
| expireType      | 是  | [ExpireType](/api-reference/cn/compute/aig/datastructure.md#expiretype)         | <p>token过期策略类型。</p><p>可选范围：LONG\_LIVED、CUSTOM。</p>                                |
| modelAccess     | 是  | [ModelAccess](/api-reference/cn/compute/aig/datastructure.md#modelaccess)       | <p>模型访问权限。</p><p>可选范围：UNLIMITED、LIMITED。</p>                                      |
| modelUuids      | 否  | Array of String                                                                 | <p>需要关联的模型uuid列表。</p><p>当modelAccess为<code>LIMITED</code>时必填。</p>                 |
| expireTime      | 否  | String                                                                          | <p>token过期时间。</p><p>当expireType为<code>CUSTOM</code>时必填。</p>                       |
| resourceGroupId | 否  | String                                                                          | 创建后AI网关所在的资源组ID，如不指定则放入默认资源组。                                                     |
| tags            | 否  | [TagAssociation](/api-reference/cn/compute/aig/datastructure.md#tagassociation) | <p>创建AI网关时关联的标签。</p><p>注意：·关联<code>标签键</code>不能重复。</p>                            |

## 3. 响应结果

| 参数名称        | 类型     | 描述                                                       |
| ----------- | ------ | -------------------------------------------------------- |
| requestId   | String | <p>唯一请求 ID。</p><p>每次请求都会返回。定位问题时需要提供该次请求的 requestId。</p> |
| gatewayUuid | String | AI网关uuid。                                                |
| token       | String | AI网关token。                                               |

## 4. 代码示例

{% tabs %}
{% tab title="示例" %}

1. **创建 AI 网关。**

```json
POST / HTTP/1.1
Host: console.zenlayer.com/api/v2/aigw
Content-Type: application/json
X-ZC-Action: CreateAiGateway
<Common Request Params>

Request:
{
    "gatewayName": "AI-Gateway-01",
    "tokenLimit": 1000,
    "expireType": "CUSTOM",
    "expireTime": "2025-12-31T23:59:59Z",
    "resourceGroupId": "47e7f7e0-d7e9-4b28-b4b2-20da9439a294",
    "modelAccess": "UNLIMITED"
}
Response:
{
    "requestId": "TCD1C4FC9-CF4B-4E48-AA9B-63FB4D7DC191",
    "response": {
        "requestId": "TCD1C4FC9-CF4B-4E48-AA9B-63FB4D7DC191",
        "gatewayUuid": "1568676002379339603",
        "token": "sk****"
    }
}
```

{% endtab %}
{% endtabs %}

## 5. 开发者工具

Zenlayer Cloud API 2.0 提供了配套的[开发工具集（SDK）](/api-reference/cn/api-introduction/toolkit.md)，未来会陆续支持更多开发语言，方便快速接入和使用Zenlayer的产品和服务。

## 6. 错误码

下面包含业务逻辑中遇到的错误码，其他错误码见[公共错误码](/api-reference/cn/api-introduction/instruction/commonerrorcode.md)

| HTTP状态码 | 错误码 | 说明 |
| ------- | --- | -- |
