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
excerpt: Discover how to create a scoped token and query your AI Deploy app
4
-
updated: 2023-04-04
2
+
title: AI Deploy - Accessing your app with tokens (EN)
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,137 @@ 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 following two labels are automatically 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.
34
+
>
29
35
30
-
In this instance we add the label `group=A`to the AI Deploy app. A set of defaults labels is added to all AI Deploy apps:
36
+
In addition to these default labels, you can **create new ones** to further customize and secure your application access.
31
37
32
-
-`ovh/id` whose value is the ID of the AI Deploy app
33
-
-`ovh/type` with value `app`, the type of AI resource
38
+
### Adding labels to an app
34
39
35
-
> [!primary]
36
-
> Labels prefixed by `ovh/` are reserved by the platform, those labels are overriden upon submission if any are provided.
40
+
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
41
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
45
42
-
### Generating tokens
46
+
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
47
44
-
From the **AI Deploy** page, you access the tokens management page by clicking the `Tokens`{.action} tab.
{.thumbnail}
54
+
#### Adding label to an existing app
55
+
56
+
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.
57
+
58
+
> [!tabs]
59
+
> **Using the Control Panel (UI)**
60
+
>>
61
+
>> 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.
66
+
>>
67
+
> **Using ovhai CLI**
68
+
>>
69
+
>> To follow this section, 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.
70
+
>>
71
+
>> You can also add labels to an existing app using the `ovhai` CLI. Run the following command:
72
+
>>
73
+
>> ```console
74
+
>> ovhai app set-label <app_id> <name> <value>
75
+
>> ```
76
+
>>
77
+
>> 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:
78
+
>>
79
+
>> ```console
80
+
>> ovhai app set-label a8318623-8357-48b4-bd3b-648c3e343ec9 group A
81
+
>> ```
82
+
>>
83
+
>> This command adds the label `group=A` to the app with ID `a8318623-8357-48b4-bd3b-648c3e343ec9`.
84
+
>>
85
+
>> 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
86
52
-
#### Read token
87
+
### Generating tokens
53
88
54
-
There are two types of roles that can be assigned to a token:
89
+
From the **AI Dashboard** page, you can access the tokens management page by clicking on the `Tokens`{.action} tab. From there, you can click on the `+ Create a token`{.action} button to create a new token:
55
90
56
-
- AI Platform - Read-only
57
-
- AI Platform - Operator
91
+
{.thumbnail}
58
92
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.
93
+
There are two types of roles that can be assigned to a token:
60
94
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:
95
+
- **AI Platform - Reader**: allows only querying the app
96
+
- **AI Platform - Operator**: allows querying and full lifecycle management (start/stop/delete)
63
97
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.
98
+
#### Read token
67
99
68
-
Fill out the form:
100
+
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.
105
+
- **Label selector**: determines which apps the token applies to (e.g., `group=A`).
106
+
- **Role**: choose from:
107
+
- `AI Reader`: read-only
108
+
- `AI Operator`: read & manage
109
+
- **Region**: e.g., `GRA` (for Gravelines)
75
110
76
-
Save the token string for later use.
111
+
After completing the form, click `Generate`{.action} to confirm the token creation.
77
112
78
113
> [!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.
114
+
> 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).
115
+
116
+
You will then be redirected to the token list, where the newly generated token will be 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
121
83
-
#### Operator token
122
+
If you prefer working from the command line, you can generate the same token using the `ovhai` CLI:
84
123
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 the `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
141
97
142
### Using a token to query an AI Deploy app
98
143
99
144
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
145
101
-
You can get the access URL of your app in the details of the AI Deploy app, above the **Tags**.
146
+
You can get the access URL of your app in the details of the AI Deploy app, above the **Labels**.
102
147
103
148
#### Browser
104
149
@@ -114,7 +159,7 @@ You now land on the exposed AI Deploy app service:
114
159
115
160
#### Code integration
116
161
117
-
You can also directly CURL the AI Deploy app using the token as an `Authorization` header:
162
+
You can also use CURL to directly query the AI Deploy app using the token as an `Authorization` header:
118
163
119
164
```bash
120
165
export TOKEN=<your-token>
@@ -137,7 +182,7 @@ From the list of tokens, click on the action menu and select `Regenerate`{.actio
@@ -147,8 +192,12 @@ If you simply need to invalidate the token, you can delete it using the same act
147
192
148
193

149
194
195
+
## Go further
196
+
197
+
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).
198
+
150
199
## Feedback
151
200
152
201
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)
153
202
154
-
If you need training or technical assistance to implement our solutions, contact your sales representative or click on [this link](/links/professional-services) to get a quote and ask our Professional Services experts for a custom analysis of your project.
203
+
If you need training or technical assistance to implement our solutions, contact your sales representative or click on [this link](/links/professional-services) to get a quote and ask our Professional Services experts for a custom analysis of your project.
0 commit comments