> For the complete documentation index, see [llms.txt](https://docs.console.zenlayer.com/welcome/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/welcome/ai-gateway/create-an-ai-gateway.md).

# Create an AI Gateway

An AI Gateway is an API access key with its own model scope, spending limit, expiration, and IP restrictions. Everything you set here can be changed later from the AI Gateway list.

| Setting            | Default               | Change it later                         |
| ------------------ | --------------------- | --------------------------------------- |
| Model access       | Full Access           | **Actions** > **Manage Model Access**   |
| Spending limit     | Off (no spending cap) | **Actions** > **Manage Spending Limit** |
| API key expiration | Long-lived            | **Actions** > **Manage Expiration**     |
| IP restrictions    | Off                   | Gateway details page                    |

## Procedures

{% stepper %}
{% step %}

#### Sign In

Go to [**zenConsole**](https://console.zenlayer.com/) and log in with your account. On the left menu bar, go to **Products** > **GPU & AI** > **AI Gateway**, and click **Create AI Gateway**.
{% endstep %}

{% step %}

#### Fill in Basic Information

* **Label your AI gateway**: a default name such as `AI-Gateway-01` is filled in for you. Replace it with your own.
* **Select a resource group**: the resource group decides which team members can view and manage this gateway, and which models it can use (set by your administrator in Model Access). It defaults to **Default Resource Group**. See [Create a Resource Group](https://docs.console.zenlayer.com/welcome/platform/team-management/create-a-resource-group.md) and [Manage Model Access](https://docs.console.zenlayer.com/welcome/ai-gateway/manage-model-access.md) for details.
  {% endstep %}

{% step %}

#### Set Budget and Validity

**Spending limit** is off by default, so there is no spending cap. Turn it on to cap what this gateway can spend, then enter at least one of:

* **Daily spending limit (USD)**
* **Monthly spending limit (USD)**
* **Total spending limit (USD)**

Limits are checked against the total AI usage cost before any discounts; your actual charge reflects the discounted price. Once a limit is reached, the gateway stops serving requests until the limit is updated.

**Set API key expiration** defaults to **Long-lived**. For temporary or project-based access, choose `7 days`, `30 days`, `60 days`, or `90 days`, or choose `Custom` and pick a date in **Custom key lifetime**.
{% endstep %}

{% step %}

#### Configure Model Access

Choose which models this AI Gateway can call. The line under the heading shows how many models and providers the gateway can currently call. Click the model count to see the full list.

* **Full Access** (default): every model allowed for the resource group, including models allowed later.
* **Custom Access**: clicking **Custom Access** opens the model picker. Check the providers or individual models you want, then click **Confirm**. Filter by task type (LLM, text-to-speech, text embedding, image generation, and so on) or use the search box to find a provider or model. Checking a provider selects all of its current models. After you confirm, the line under the heading lists the selected models by provider; click **Edit** to change them.

The models you can choose from are decided by your team administrator in [Model Access](https://docs.console.zenlayer.com/welcome/ai-gateway/manage-model-access.md), per resource group. Only the models allowed for the selected resource group are listed, and restricted models your administrator has allowed appear in a separate **Restricted models** group. If a model you need is missing, ask your administrator to allow it for the resource group. Switching the resource group resets model access to Full Access.

{% hint style="info" %}
You can adjust the model access scope at any time after creation.
{% endhint %}
{% endstep %}

{% step %}

#### *<mark style="color:green;">(Optional)</mark>* Advanced Settings

**IP Restrictions** is off by default, so any IP can call this gateway. Turn it on to control access by client IP address. The two modes are mutually exclusive:

* **Allow List**: only the listed IP addresses can call the gateway.
* **Block List**: the listed IP addresses are rejected; every other address can call the gateway.

Enter one or more IP addresses, separated by `;`.

Expand **More Settings (Tag Management)** to add up to 20 **tags** to the gateway.
{% endstep %}

{% step %}

#### Complete Creation

Read and accept the Zenlayer Customer Agreement and the AI Gateway Terms. If your model scope includes Anthropic models, also confirm the Anthropic compliance statement. Then click ***Create***.
{% endstep %}
{% endstepper %}

## Result

Once created, you receive an **API Access Key** together with the **Base URL** for API calls. The key is shown only once: copy it now and store it securely. See [**API docs**](https://docs.console.zenlayer.com/api-reference/compute/aig) to view all related API interfaces.

## What to Do Next

Click the AI Gateway name to view the details page of logs, data analysis and basic information.

You can also perform the following operations in **Actions** if you need:

### Manage Model Access

Switch between **Full Access** and **Custom Access**, or change the selected models, within the models allowed for the resource group.

### Manage Spending Limit

Turn **Spending limit** on or off and enter daily, monthly, or total limits.

### Manage Expiration

Select the desired API key expiration.

### Duplicate AI Gateway

Click ***Duplicate AI Gateway*** to create an AI Gateway with the same configuration.

### Disable or Delete

Click ***Disable*** to stop a gateway from serving requests without deleting it, and ***Enable*** to resume. Click ***Delete*** and type `Delete` to confirm if you don't need the gateway any more; all of its data is erased and cannot be restored.
