---
title: AI Gateway API 參考
description: Platform API v1 的 AI Gateway：每個操作的路徑、參數、請求與回應欄位、scope、冪等與錯誤，直接取自 API 合約。
url: https://agentlab.cresclab.com/docs/zh-tw/api/ai-gateway
language: zh-Hant
updated: 2026-12-05
---

# AI Gateway API 參考

Platform API v1 的 AI Gateway：每個操作的路徑、參數、請求與回應欄位、scope、冪等與錯誤，直接取自 API 合約。

> [!NOTE]
> 由 API 合約（Agent Lab Platform API 1.0.0-alpha.1）產生。說明文字是合約的英文原文。

Whether the workspace's AI Gateway is on, and its plan and prepaid credit. The scope is
restricted: it reads money.

## The workspace's AI Gateway, plan and credit

`GET /v1/workspaces/{workspaceId}/gateway`

Whether the workspace's AI Gateway is on (`enabled`) and whether Agent Lab turned it off
(`operatorDisabled`), for any active member. `plan` is the Gateway's plan this UTC month,
its included and used requests, its spending cap and what was spent, and its prepaid credit
in US dollars, as the console's plan page shows them; it is null while the Gateway is off
and for a member who may not read the workspace's usage. An amount the platform could not
price is null, never zero; `credit` is null before the workspace's first credit.

| Scope | 身分 | 驗證方式 | Idempotency-Key |
| --- | --- | --- | --- |
| `billing:read` | `member` | `installationToken` | — |

### 參數

| 名稱 | 位置 | 型別 | 必填 | 說明 |
| --- | --- | --- | --- | --- |
| `workspaceId` | path | `string` | 是 | The workspace, by id. It must be the installation's. |
| `Agentlab-On-Behalf-Of` | header | `string` | 是 | The account id of the member the installation acts for: a current member of the workspace whose sign-in to the application there is still live, neither revoked nor expired. When the member's sign-in expires, the application acts for them again once they sign in again. |

### 回應

| 狀態碼 | 內容 | 說明 |
| --- | --- | --- |
| `200` | `application/json`: [Gateway](https://agentlab.cresclab.com/docs/zh-tw/api/schemas.md#Gateway) | The AI Gateway. |
| `400` | `application/json`: [Error](https://agentlab.cresclab.com/docs/zh-tw/api/schemas.md#Error) | The request itself is wrong, such as a `cursor` this list did not answer (`recovery: none`). |
| `401` | `application/json`: [Error](https://agentlab.cresclab.com/docs/zh-tw/api/schemas.md#Error) | No token, or a token the platform does not honor. |
| `403` | `application/json`: [Error](https://agentlab.cresclab.com/docs/zh-tw/api/schemas.md#Error) | Refused: `SCOPE_NOT_GRANTED` (`configure`); `WORKSPACE_NOT_INSTALLED`, the path names a workspace other than the installation's (`configure`); `MEMBER_REQUIRED`, no single `Agentlab-On-Behalf-Of` (`none`); `MEMBER_NOT_AUTHORIZED`, the named account is not a current member who signed in to the application here, or the member may not read or do this (`authorize`); `SERVER_TO_SERVER_ONLY`, sent from a browser (`none`); `PRODUCT_ACCESS_DENIED`, the workspace's plan does not include it (`configure`). |
| `404` | `application/json`: [Error](https://agentlab.cresclab.com/docs/zh-tw/api/schemas.md#Error) | No such operation or resource. |
| `429` | `application/json`: [Error](https://agentlab.cresclab.com/docs/zh-tw/api/schemas.md#Error) | Rate limited (`recovery: retry`). |
| `503` | `application/json`: [Error](https://agentlab.cresclab.com/docs/zh-tw/api/schemas.md#Error) | Try again later (`recovery: retry`). |
