You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: pages/public_cloud/ai_machine_learning/deploy_guide_03_tokens/guide.en-gb.md
+92-44Lines changed: 92 additions & 44 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,7 +1,7 @@
1
1
---
2
2
title: AI Deploy - Accessing your app with tokens
3
-
excerpt: Discover how to create a scoped token and query your AI Deploy app
4
-
updated: 2023-04-04
3
+
excerpt: Learn how to create scoped tokens to securely access your AI Deploy applications
4
+
updated: 2025-07-28
5
5
---
6
6
7
7
> [!primary]
@@ -13,92 +13,136 @@ updated: 2023-04-04
13
13
14
14
This guide covers the creation of application tokens for AI Deploy.
15
15
16
+
This is particularly useful when you want to make your app accessible to others without sharing your username and password. Moreover, using tokens facilitates the integration of your app with other services or scripts, such as those using curl, allowing for a more automated and flexible interaction with your AI Deploy application.
17
+
18
+
In this tutorial, we will create and assign tokens to a basic AI Deploy app, running the [infrastructureascode/hello-world](https://hub.docker.com/r/infrastructureascode/hello-world) Docker image.
19
+
16
20
## Requirements
17
21
18
22
- a **Public cloud** project
19
23
- access to the [OVHcloud Control Panel](/links/manager)
20
-
- a Running AI Deploy app (the deployed app in this guide uses the Docker image [infrastructureascode/hello-world](https://hub.docker.com/r/infrastructureascode/hello-world))
21
24
22
25
## Instructions
23
26
24
-
### Adding labels to an App
27
+
By default, the 2 following labels are systematically added to each AI Deploy application:
25
28
26
-
Tokens are scoped based on labels added to your AI Deploy app. To scope a token you need to add a label to your AI Deploy app upon submission.
29
+
-`ovh/id` whose value is the ID of the AI Deploy app
30
+
-`ovh/type` whose value is `app`, the type of AI resource
> These labels are prefixed by `ovh/`, meaning these are reserved by the platform. These labels will be automatically overwritten by the platform if you attempt to redefine them during submission. They won't be displayed in the manager UI.
29
34
30
-
In this instance we add the label `group=A` to the AI Deploy app. In addition to this, the 2 following labels are systematically added by default to each AI Deploy application:
35
+
In addition to these default labels, you can **create new ones** to further customize and secure your application access.
31
36
32
-
-`ovh/id` whose value is the ID of the AI Deploy app
33
-
-`ovh/type` with value `app`, the type of AI resource
37
+
### Adding labels to an app
34
38
35
-
> [!primary]
36
-
> These labels are prefixed by `ovh/`, meaning these are reserved by the platform. Those labels are overriden upon submission if any are provided.
39
+
Tokens are scoped based on labels added to your AI Deploy app. To scope a token, you must add a label to your AI Deploy app. This can be done either during the app creation process or after the app is deployed. You can add multiple labels by repeating the following process.
37
40
38
-
All the labels of an AI Deploy app are listed on the AI Deploy app details under **Tags**:
To add a label when creating an AI Deploy app, access the `Advanced Configuration`{.action} step in the app creation process. This section allows you to specify a custom Docker command, the mounted volumes, and **the app labels**.
41
44
42
-
### Generating tokens
45
+
From this last sub-section, you can add a key-value pair. The key is the label identifier (e.g., `group`), while the value is the corresponding value assigned to this key (e.g., `A`). In this tutorial, we use the example `group=A` as the label of the AI Deploy app:
43
46
44
-
From the **AI Deploy** page, you access the tokens management page by clicking the `Tokens`{.action} tab.
{.thumbnail}
53
+
#### Adding label to an existing app
54
+
55
+
If your app is already deployed, you can still add or update labels at any time using the Control Panel (UI) or the `ovhai` CLI.
56
+
57
+
> [!tabs]
58
+
> **Using the Control Panel (UI)**
59
+
>>
60
+
>> Navigate to the **AI Deploy** section where all your apps are listed. **Click the name of your app** to open its details page. Locate the **Labels** section. Enter the key-value pair and click `+`{.action} to add the label to your app.
>> After saving, the added label will be visible in the **Labels** section of the app details.
65
+
>>
66
+
> **Using ovhai CLI**
67
+
>>
68
+
>> To follow this part, make sure you have installed the [ovhai CLI](/pages/public_cloud/ai_machine_learning/cli_10_howto_install_cli) on your computer or on an instance.
69
+
>>
70
+
>> You can also add labels to an existing app using the `ovhai` CLI. Run the following command:
71
+
>>
72
+
>> ```console
73
+
>> ovhai app set-label <app_id> <name> <value>
74
+
>> ```
75
+
>>
76
+
>> Replace <app_id> with the unique identifier of your app (found in the app details or by running `ovhai app ls`). And replace <name> and <value> with your desired key and value pair. For example:
77
+
>>
78
+
>> ```console
79
+
>> ovhai app set-label a8318623-8357-48b4-bd3b-648c3e343ec9 group A
80
+
>> ```
81
+
>>
82
+
>> This command adds the label `group=A` to the app with ID `a8318623-8357-48b4-bd3b-648c3e343ec9`.
83
+
>>
84
+
>> You can verify app labels by running `ovhai app get <app_id>`. Labels will be displayed at the top of app details, in the *Labels* field.
51
85
52
-
#### Read token
86
+
### Generating tokens
53
87
54
-
There are two types of roles that can be assigned to a token:
88
+
From the **AI Dashboard** page, you can access the tokens management page by clicking the `Tokens`{.action} tab. From there, you can click on the `+ Create a token`{.action} button to create a new token:
55
89
56
-
- AI Platform - Read-only
57
-
- AI Platform - Operator
90
+
{.thumbnail}
58
91
59
-
A Read-only token will only grant you the right to query the deployed app while an Operator token would also allow you to manage the AI Deploy app itself.
92
+
There are two types of roles that can be assigned to a token:
60
93
61
-
Let us create a token for the AI Deploy apps matching the label `group=A` with read-only access in the GRA cluster.
62
-
To create an AI Deploy app token we need to specify 3 parameters:
94
+
- **AI Platform - Reader**: allows only querying the app
95
+
- **AI Platform - Operator**: allows querying and full lifecycle management (start/stop/delete)
63
96
64
-
- The token scope is specified through label selectors, and a token will be scoped over any app matching the set of label selectors. In this case `group=A`
65
-
- The token role: AI Training - Read-only
66
-
- The region (cluster in which are deployed the AI Deploy apps): GRA.
97
+
#### Read token
67
98
68
-
Fill out the form:
99
+
Let's create a token for the AI Deploy apps matching the label `group=A` with read-only access in the GRA (Gravelines) cluster. To do this, we will need to fill 4 parameters:
- **Token name**: used for token identification, management only.
104
+
- **Label selector**: determines which apps the token applies to (e.g., `group=A`).
105
+
- **Role**: choose from:
106
+
- `AI Reader`: read-only
107
+
- `AI Operator`: read & manage
108
+
- **Region**: e.g., `GRA` (for Gravelines)
75
109
76
-
Save the token string for later use.
110
+
After completing the form, click `Generate`{.action} to confirm token creation.
77
111
78
112
> [!warning]
79
-
> The token is only displayed once, make sure to save it before leaving the page or you will need to regenerate the token.
113
+
> You will then receive the value of your new token, which you must **carefully save**, as its value is only displayed once. If you lose the token value, you will need to [regenerate it](#regenerating-a-token).
114
+
115
+
Then, you will be redirected to the token list with the newly generated token displayed at the top:
This newly generated token provides read access over all resources tagged with the label `group=A` including the ones submitted after the creation of the token.
82
120
83
-
#### Operator token
121
+
If you prefer working from the command line, you can generate the same token using the `ovhai` CLI:
84
122
85
-
An operator token grants read access along with management access for the matching apps. This means that you can manage the AI Deploy app lifecycle (start/stop/delete) using either the CLI (more info [here](/pages/public_cloud/ai_machine_learning/cli_10_howto_install_cli)) or the [AI Training API](https://gra.ai.cloud.ovh.net/) by providing this token.
This Operator token will be scoped on a specific AI Deploy app and we will use the default `ovh/id` label to do so (since it is reserved, there is only one AI Deploy app that can match this label selector).
An operator token grants read access along with management access for the matching apps. This allows you to manage the AI Deploy app lifecycle (start/stop/delete) using either the CLI (more info [here](/pages/public_cloud/ai_machine_learning/cli_10_howto_install_cli)) or the [AI API](https://gra.ai.cloud.ovh.net/) by providing this token.
Additional information about the use of a token to manage an AI Training resource can be found [here](/pages/public_cloud/ai_machine_learning/cli_13_howto_app_token_cli#use-the-app-token).
You can also scope a token to a specific app using `ovh/id` label and the app’s ID as its value. This label is added automatically by default as explained [above](#instructions) and, because it is reserved, it will uniquely match only one app.
96
140
97
141
### Using a token to query an AI Deploy app
98
142
99
143
With the token we generated in the previous step, we will now query the app. For this demonstration, we deployed a simple Hello World app that always responds `Hello, World!`.
100
144
101
-
You can get the access URL of your app in the details of the AI Deploy app, above the **Tags**.
145
+
You can get the access URL of your app in the details of the AI Deploy app, above the **Labels**.
102
146
103
147
#### Browser
104
148
@@ -114,7 +158,7 @@ You now land on the exposed AI Deploy app service:
114
158
115
159
#### Code integration
116
160
117
-
You can also directly CURL the AI Deploy app using the token as an `Authorization` header:
161
+
You can also use CURL to directly query the AI Deploy app using the token as an `Authorization` header:
118
162
119
163
```bash
120
164
export TOKEN=<your-token>
@@ -137,7 +181,7 @@ From the list of tokens, click on the action menu and select `Regenerate`{.actio
@@ -147,6 +191,10 @@ If you simply need to invalidate the token, you can delete it using the same act
147
191
148
192

149
193
194
+
## Go further
195
+
196
+
Additional information about the use of a token to manage AI Solutions using `ovhai` CLI can be found [here](/pages/public_cloud/ai_machine_learning/cli_13_howto_app_token_cli).
197
+
150
198
## Feedback
151
199
152
200
Please feel free to send us your questions, feedback and suggestions to help our team improve the service on the OVHcloud [Discord server](https://discord.gg/ovhcloud)
0 commit comments