---
title: "CLI - Commandes principales (EN)"
description: "Découvrez les principales commandes de la CLI pour interagir sur les AI Tools"
url: https://docs.ovhcloud.com/fr/guides/public-cloud/ai-machine-learning/ai-cli-overview
lang: fr
lastUpdated: 2023-11-27
---
# CLI - Commandes principales (EN)

## Objective

This guide covers the usage of the **ovhai** CLI.

## Requirements

- a working `ovhai` CLI [how to install ovhai CLI](/fr/guides/public-cloud/ai-machine-learning/ai-cli-install-client.md)

## Instructions

### Run a job

To submit a job you need a **docker image** and optionally some **data**.

First let's submit a simple job, a public ubuntu image which executes a command `echo`:

```console
ovhai job run ubuntu --gpu 1 -- echo "Hello from my first job"
```

:::info

- Add the flag `--help` to get more information about a command.
- You can increase the number of GPUs with the flag `--gpu <x>` or choose to use CPUs with the flag `--cpu <x>`.

:::

You can then list your current and old jobs with:

```console
ovhai job list
```

:::info

- Add the flag `--watch` to watch changes in live.
- Most commands handle the flag `--output <format>` if you want a different output (JSON or YAML)

:::

You should see the job you just ran, you need its `ID` to get more information about it.

To see information about a job use the following command:

```console
ovhai job get <job-id>
```

To see its logs in live use the following command:

```console
ovhai job logs <job-id> --follow
```

You should see the output of the `echo` command:

> Hello from my first job

### Use data in your job

You can upload data to the Object Storage and mount that data when you run a job. If you mount that data with read/write it will be saved to the Object Storage when the job ends.

Let's upload some data and use it in a job that will produce more data.

```console
ovhai bucket object upload `<container>`@`<region>` some-file.txt
```

:::info

- If you already used the Swift CLI, the commands are similar.

:::

Now that you have some data in a container you can mount it when you run a job with the flag `--volume`.

```console
ovhai job run <image> --volume <container>@<region>:/data:rw
```

:::info

- You can use the flag `--volume` more than one time if you want to mount more containers.
- Mounted containers with write access are only synchronized when the job is terminated.

:::

You can list and download data you uploaded or generated by a job with:

```console
ovhai bucket object list `<container>`@`<region>`
ovhai bucket object download `<container>`@`<region>` --prefix /some-data
```

### Synchronize data while a job is running

You can synchronize data to the Object Storage while a job is running with:

```console
ovhai job push-data `<job-id>`
```

You can see the progress with:

```console
ovhai job get `<job-id>`
```

### Execute commands inside a running job

You can execute commands (like `bash`) while a job is running.

```console
ovhai job exec -it <id> -- bash
```

This way you can interact with a running job.

### Run a job with ssh access

You can create a job with some ssh access:

```console
ovhai job run -s ~/.ssh/id_ed25519.pub ovhcom/ai-training-fastai
```

Multiple `-s` arguments can be used to provide multiple SSH public keys.

Once the job is in `RUNNING` state, you can retrieve the `sshUrl` with:

```console
ovhai job get `<job-id>`

---
id: 0d916855-1cd4-4b66-8803-b4782bc13902
createdAt: "2021-02-23T08:45:01.297780Z"
updatedAt: "2021-02-23T08:45:19.823082Z"
user: user-xxx
spec:
  image: ovhcom/ai-training-fastai
  env: []
  defaultHttpPort: 8080
  resources:
    gpu: 1
    gpuModel: Tesla-V100S
    cpu: 7
  volumes: []
  timeout: 0
  name: ai-training-fastai-kind
  sshPublicKeys:
    - ssh-ed25519 AAAAC3NzaC1someKey
status:
  state: RUNNING
  queuedAt: "2021-02-23T08:45:01.297318Z"
  startedAt: "2021-02-23T08:45:13Z"
  stoppedAt: ~
  ip: 10.42.155.122
  infos: ~
  history:
    - state: QUEUED
      date: "2021-02-23T08:45:01.297012Z"
    - state: INITIALIZING
      date: "2021-02-23T08:45:04.356856Z"
    - state: PENDING
      date: "2021-02-23T08:45:10.163754Z"
    - state: RUNNING
      date: "2021-02-23T08:45:19.822354Z"
  duration: 6
  jobUrl: "http://0d916855-1cd4-4b66-8803-b4782bc13902.job.gra.ai.cloud.ovh.net"
  sshUrl: "ssh://0d916855-1cd4-4b66-8803-b4782bc13902@gra.ai.cloud.ovh.net"
  monitoringUrl: "http://monitoring.gra.ai.cloud.ovh.net/d/job/job-monitoring?var-job=0d916855-1cd4-4b66-8803-b4782bc13902&from=1614069913000"
```

Then you can connect to it with a terminal:

```console
ssh 0d916855-1cd4-4b66-8803-b4782bc13902@gra.ai.cloud.ovh.net -i ~/.ssh/id_ed25519
```

### Manage registries

You can list available registries with:

```console
ovhai registry list
```

By default, you have access to public registries, and a shared registry scoped to your project.

:::warning
This shared registry can help you perform your tests, but should not be used in production, as we reserve the right to delete its content if deemed necessary. The images pushed to this registry are for AI Tools workloads only, and will not be accessible for external uses.
:::

This is why it can be interesting to add and manage other registries. To add a private registry, use:

```console
ovhai registry add `<url>`
```

You will be asked to type your credentials.

More information about adding and managing public & private registries can be found [here](/fr/guides/public-cloud/ai-machine-learning/ai-manage-registries.md).

### Switch region in the CLI

The regions available to install and use the `ovhai` CLI are `GRA` and `BHS`. If you want to change the region in the CLI, you can use the following commands.

You can list the **Names** and **URLs** of the available regions with:

```console
ovhai config list
```

:::info
The region in **green** is the one you are currently in.
:::

To change the region, use:

```console
ovhai config set <region>
```

:::info
`<region>` is the new region name (`GRA` or `BHS`), in which you want to be placed.
:::

If you need training or technical assistance to implement our solutions, contact your sales representative or click on [this link](https://www.ovhcloud.com/fr/professional-services/) to get a quote and ask our Professional Services experts for a custom analysis of your project.

## Feedback

Please send us your questions, feedback and suggestions to improve the service:

- On the OVHcloud [Discord server](https://discord.gg/ovhcloud)
