# AI API Key


<style>
  span[class^="pill-"] {
    color: white;
    padding: 2px 12px;
    border-radius: 12px;
    font-size: 0.6em;
    vertical-align: middle;
    margin-right: 12px;
    font-family: sans-serif;
    font-weight: bold;
    display: inline-block;
    line-height: 1;
  }
  span.pill-GET { background-color: #61affe; }
  span.pill-POST { background-color: #49cc90; }
  span.pill-PUT { background-color: #fca130; }
  span.pill-DELETE { background-color: #f93e3e; }
  span.pill-PATCH { background-color: #50e3c2; }
  span[class^="pill-"]:after {
    content: attr(data-label);
    font-size: 0.9rem;
  }
</style>

## <span data-label="POST" class="pill-POST"></span>create-ai-api-key

Create AI API Key

```
POST /ai/ai-api-key
```

Create a new AI API key

### Request body

Content-Type: `application/json`

| Property | Type | Required | Description |
| --- | --- | --- | --- |
| `name` | string | **yes** | Human-readable name for the AI API key |
| `scope` | string | **yes** | Key scope: 'public' for all deployments, or a specific deployment UUID |

<details>
<summary>Example</summary>

```json
{
  "name": "string",
  "scope": "string"
}
```
</details>


### Responses

**`200`**: 200

Content-Type: `application/json`


<details>
<summary>Example output</summary>

```json
{}
```
</details>

**`400`**: 400

Content-Type: `application/json`

| Property | Type | Description |
| --- | --- | --- |
| `detail` | string |  |
| `errors` | array of [Errors](/reference/api/_schemas/error-response/#errors) |  |
| `instance` | string |  |
| `status` | integer |  |
| `title` | string |  |
| `type` | string |  |

<details>
<summary>Example output</summary>

```json
{
  "detail": "string",
  "errors": [
    {
      "detail": "string",
      "location": "string",
      "path": "string",
      "pointer": "string"
    }
  ],
  "instance": "string",
  "status": 0,
  "title": "string",
  "type": "string"
}
```
</details>

**`403`**: 403

Content-Type: `application/json`

| Property | Type | Description |
| --- | --- | --- |
| `code` | string | Machine-readable forbidden error code<br/><br/>Allowed values: `forbidden_operation`. |
| `error` | string | Forbidden error message |

<details>
<summary>Example output</summary>

```json
{
  "code": "forbidden_operation",
  "error": "string"
}
```
</details>

**`404`**: 404

Content-Type: `application/json`

| Property | Type | Description |
| --- | --- | --- |
| `detail` | string |  |
| `errors` | array of [Errors](/reference/api/_schemas/error-response/#errors) |  |
| `instance` | string |  |
| `status` | integer |  |
| `title` | string |  |
| `type` | string |  |

<details>
<summary>Example output</summary>

```json
{
  "detail": "string",
  "errors": [
    {
      "detail": "string",
      "location": "string",
      "path": "string",
      "pointer": "string"
    }
  ],
  "instance": "string",
  "status": 0,
  "title": "string",
  "type": "string"
}
```
</details>


SDK reference for `create-ai-api-key`: [golang](https://pkg.go.dev/github.com/exoscale/egoscale/v3#Client.CreateAIAPIKey) | [Python](https://exoscale.github.io/python-exoscale/v2.html#exoscale.api.v2.Client.create_ai_api_key) | [Java](https://exoscale.github.io/exoscale-sdk-java/com/exoscale/sdk/api/ExoscaleApi.html#createAiApiKey(com.exoscale.sdk.model.CreateAiApiKeyRequest))

[CLI](https://community.exoscale.com/tools/command-line-interface/): `exo api create-ai-api-key`

## <span data-label="GET" class="pill-GET"></span>get-ai-api-key

Get AI API Key

```
GET /ai/ai-api-key/{id}
```

Get AI API key metadata

### Path parameters

| Name | In | Description |
| --- | --- | --- |
| `id` | `path` |  |

### Responses

**`200`**: 200

Content-Type: `application/json`

| Property | Type | Description |
| --- | --- | --- |
| `created-at` | string | Creation timestamp |
| `id` | string | AI API key ID |
| `name` | string | Human-readable name for the AI API key |
| `org-uuid` | string | Organization UUID that owns this key |
| `scope` | string | Key scope: 'public' for all deployments, or a specific deployment UUID |
| `updated-at` | string | Last update timestamp |

<details>
<summary>Example output</summary>

```json
{
  "created-at": "2024-01-01T12:00:00Z",
  "id": "string",
  "name": "string",
  "org-uuid": "string",
  "scope": "string",
  "updated-at": "2024-01-01T12:00:00Z"
}
```
</details>

**`403`**: 403

Content-Type: `application/json`

| Property | Type | Description |
| --- | --- | --- |
| `code` | string | Machine-readable forbidden error code<br/><br/>Allowed values: `forbidden_operation`. |
| `error` | string | Forbidden error message |

<details>
<summary>Example output</summary>

```json
{
  "code": "forbidden_operation",
  "error": "string"
}
```
</details>

**`404`**: 404

Content-Type: `application/json`

| Property | Type | Description |
| --- | --- | --- |
| `detail` | string |  |
| `errors` | array of [Errors](/reference/api/_schemas/error-response/#errors) |  |
| `instance` | string |  |
| `status` | integer |  |
| `title` | string |  |
| `type` | string |  |

<details>
<summary>Example output</summary>

```json
{
  "detail": "string",
  "errors": [
    {
      "detail": "string",
      "location": "string",
      "path": "string",
      "pointer": "string"
    }
  ],
  "instance": "string",
  "status": 0,
  "title": "string",
  "type": "string"
}
```
</details>


SDK reference for `get-ai-api-key`: [golang](https://pkg.go.dev/github.com/exoscale/egoscale/v3#Client.GetAIAPIKey) | [Python](https://exoscale.github.io/python-exoscale/v2.html#exoscale.api.v2.Client.get_ai_api_key) | [Java](https://exoscale.github.io/exoscale-sdk-java/com/exoscale/sdk/api/ExoscaleApi.html#getAiApiKey(java.util.UUID))

[CLI](https://community.exoscale.com/tools/command-line-interface/): `exo api get-ai-api-key`

## <span data-label="PATCH" class="pill-PATCH"></span>update-ai-api-key

Update AI API Key

```
PATCH /ai/ai-api-key/{id}
```

Update AI API key name and/or scope

### Path parameters

| Name | In | Description |
| --- | --- | --- |
| `id` | `path` |  |

### Request body

Content-Type: `application/json`

| Property | Type | Required | Description |
| --- | --- | --- | --- |
| `name` | string | no | Human-readable name for the AI API key |
| `scope` | string | no | Key scope: 'public' for all deployments, or a specific deployment UUID |

<details>
<summary>Example</summary>

```json
{
  "name": "string",
  "scope": "string"
}
```
</details>


### Responses

**`200`**: 200

Content-Type: `application/json`

| Property | Type | Description |
| --- | --- | --- |
| `created-at` | string | Creation timestamp |
| `id` | string | AI API key ID |
| `name` | string | Human-readable name for the AI API key |
| `org-uuid` | string | Organization UUID that owns this key |
| `scope` | string | Key scope: 'public' for all deployments, or a specific deployment UUID |
| `updated-at` | string | Last update timestamp |

<details>
<summary>Example output</summary>

```json
{
  "created-at": "2024-01-01T12:00:00Z",
  "id": "string",
  "name": "string",
  "org-uuid": "string",
  "scope": "string",
  "updated-at": "2024-01-01T12:00:00Z"
}
```
</details>

**`400`**: 400

Content-Type: `application/json`

| Property | Type | Description |
| --- | --- | --- |
| `detail` | string |  |
| `errors` | array of [Errors](/reference/api/_schemas/error-response/#errors) |  |
| `instance` | string |  |
| `status` | integer |  |
| `title` | string |  |
| `type` | string |  |

<details>
<summary>Example output</summary>

```json
{
  "detail": "string",
  "errors": [
    {
      "detail": "string",
      "location": "string",
      "path": "string",
      "pointer": "string"
    }
  ],
  "instance": "string",
  "status": 0,
  "title": "string",
  "type": "string"
}
```
</details>

**`403`**: 403

Content-Type: `application/json`

| Property | Type | Description |
| --- | --- | --- |
| `code` | string | Machine-readable forbidden error code<br/><br/>Allowed values: `forbidden_operation`. |
| `error` | string | Forbidden error message |

<details>
<summary>Example output</summary>

```json
{
  "code": "forbidden_operation",
  "error": "string"
}
```
</details>

**`404`**: 404

Content-Type: `application/json`

| Property | Type | Description |
| --- | --- | --- |
| `detail` | string |  |
| `errors` | array of [Errors](/reference/api/_schemas/error-response/#errors) |  |
| `instance` | string |  |
| `status` | integer |  |
| `title` | string |  |
| `type` | string |  |

<details>
<summary>Example output</summary>

```json
{
  "detail": "string",
  "errors": [
    {
      "detail": "string",
      "location": "string",
      "path": "string",
      "pointer": "string"
    }
  ],
  "instance": "string",
  "status": 0,
  "title": "string",
  "type": "string"
}
```
</details>


SDK reference for `update-ai-api-key`: [golang](https://pkg.go.dev/github.com/exoscale/egoscale/v3#Client.UpdateAIAPIKey) | [Python](https://exoscale.github.io/python-exoscale/v2.html#exoscale.api.v2.Client.update_ai_api_key) | [Java](https://exoscale.github.io/exoscale-sdk-java/com/exoscale/sdk/api/ExoscaleApi.html#updateAiApiKey(java.util.UUID))

[CLI](https://community.exoscale.com/tools/command-line-interface/): `exo api update-ai-api-key`

## <span data-label="DELETE" class="pill-DELETE"></span>delete-ai-api-key

Delete AI API Key

```
DELETE /ai/ai-api-key/{id}
```

Delete AI API key

### Path parameters

| Name | In | Description |
| --- | --- | --- |
| `id` | `path` |  |

### Responses

**`200`**: 200

Content-Type: `application/json`

| Property | Type | Description |
| --- | --- | --- |
| `deleted` | boolean |  |

<details>
<summary>Example output</summary>

```json
{
  "deleted": true
}
```
</details>

**`403`**: 403

Content-Type: `application/json`

| Property | Type | Description |
| --- | --- | --- |
| `code` | string | Machine-readable forbidden error code<br/><br/>Allowed values: `forbidden_operation`. |
| `error` | string | Forbidden error message |

<details>
<summary>Example output</summary>

```json
{
  "code": "forbidden_operation",
  "error": "string"
}
```
</details>

**`404`**: 404

Content-Type: `application/json`

| Property | Type | Description |
| --- | --- | --- |
| `detail` | string |  |
| `errors` | array of [Errors](/reference/api/_schemas/error-response/#errors) |  |
| `instance` | string |  |
| `status` | integer |  |
| `title` | string |  |
| `type` | string |  |

<details>
<summary>Example output</summary>

```json
{
  "detail": "string",
  "errors": [
    {
      "detail": "string",
      "location": "string",
      "path": "string",
      "pointer": "string"
    }
  ],
  "instance": "string",
  "status": 0,
  "title": "string",
  "type": "string"
}
```
</details>


SDK reference for `delete-ai-api-key`: [golang](https://pkg.go.dev/github.com/exoscale/egoscale/v3#Client.DeleteAIAPIKey) | [Python](https://exoscale.github.io/python-exoscale/v2.html#exoscale.api.v2.Client.delete_ai_api_key) | [Java](https://exoscale.github.io/exoscale-sdk-java/com/exoscale/sdk/api/ExoscaleApi.html#deleteAiApiKey(java.util.UUID))

[CLI](https://community.exoscale.com/tools/command-line-interface/): `exo api delete-ai-api-key`


---

## Other Operations

## <span data-label="GET" class="pill-GET"></span>list-ai-api-keys

List AI API Keys

```
GET /ai/ai-api-key
```

List AI API keys for an organization

### Responses

**`200`**: 200

Content-Type: `application/json`

| Property | Type | Description |
| --- | --- | --- |
| `ai-api-keys` | array of [AI API key metadata (without value)](/reference/api/_schemas/ai-api-key/) |  |

<details>
<summary>Example output</summary>

```json
{
  "ai-api-keys": [
    {
      "created-at": "2024-01-01T12:00:00Z",
      "id": "string",
      "name": "string",
      "org-uuid": "string",
      "scope": "string",
      "updated-at": "2024-01-01T12:00:00Z"
    }
  ]
}
```
</details>

**`403`**: 403

Content-Type: `application/json`

| Property | Type | Description |
| --- | --- | --- |
| `code` | string | Machine-readable forbidden error code<br/><br/>Allowed values: `forbidden_operation`. |
| `error` | string | Forbidden error message |

<details>
<summary>Example output</summary>

```json
{
  "code": "forbidden_operation",
  "error": "string"
}
```
</details>


SDK reference for `list-ai-api-keys`: [golang](https://pkg.go.dev/github.com/exoscale/egoscale/v3#Client.ListAIAPIKeys) | [Python](https://exoscale.github.io/python-exoscale/v2.html#exoscale.api.v2.Client.list_ai_api_keys) | [Java](https://exoscale.github.io/exoscale-sdk-java/com/exoscale/sdk/api/ExoscaleApi.html#listAiApiKeys())

[CLI](https://community.exoscale.com/tools/command-line-interface/): `exo api list-ai-api-keys`

## <span data-label="POST" class="pill-POST"></span>rotate-ai-api-key

Rotate AI API Key

```
POST /ai/ai-api-key/{id}/rotate
```

Rotate AI API key value

### Path parameters

| Name | In | Description |
| --- | --- | --- |
| `id` | `path` |  |

### Responses

**`200`**: 200

Content-Type: `application/json`


<details>
<summary>Example output</summary>

```json
{}
```
</details>

**`403`**: 403

Content-Type: `application/json`

| Property | Type | Description |
| --- | --- | --- |
| `code` | string | Machine-readable forbidden error code<br/><br/>Allowed values: `forbidden_operation`. |
| `error` | string | Forbidden error message |

<details>
<summary>Example output</summary>

```json
{
  "code": "forbidden_operation",
  "error": "string"
}
```
</details>

**`404`**: 404

Content-Type: `application/json`

| Property | Type | Description |
| --- | --- | --- |
| `detail` | string |  |
| `errors` | array of [Errors](/reference/api/_schemas/error-response/#errors) |  |
| `instance` | string |  |
| `status` | integer |  |
| `title` | string |  |
| `type` | string |  |

<details>
<summary>Example output</summary>

```json
{
  "detail": "string",
  "errors": [
    {
      "detail": "string",
      "location": "string",
      "path": "string",
      "pointer": "string"
    }
  ],
  "instance": "string",
  "status": 0,
  "title": "string",
  "type": "string"
}
```
</details>


SDK reference for `rotate-ai-api-key`: [golang](https://pkg.go.dev/github.com/exoscale/egoscale/v3#Client.RotateAIAPIKey) | [Python](https://exoscale.github.io/python-exoscale/v2.html#exoscale.api.v2.Client.rotate_ai_api_key) | [Java](https://exoscale.github.io/exoscale-sdk-java/com/exoscale/sdk/api/ExoscaleApi.html#rotateAiApiKey(java.util.UUID))

[CLI](https://community.exoscale.com/tools/command-line-interface/): `exo api rotate-ai-api-key`


