Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DOCS-3537: Update ml-training-client.md #4154

Merged
merged 4 commits into from
Mar 28, 2025
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 41 additions & 3 deletions docs/dev/reference/apis/ml-training-client.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,19 @@ The ML training client API supports the following methods:

## Establish a connection

To use the Viam ML training client API, you first need to instantiate a [`ViamClient`](https://python.viam.dev/autoapi/viam/app/viam_client/index.html#viam.app.viam_client.ViamClient) and then instantiate an [`MLTrainingClient`](https://python.viam.dev/autoapi/viam/app/viam_client/index.html#viam.app.viam_client.ViamClient.ml_training_client).
See the following example for reference.
To use the Viam ML training client API, you first need to instantiate a `ViamClient` and then instantiate an `MLTrainingClient`.

You can create an [API key](/manage/manage/access/) on your settings page.
You will also need an API key and API key ID to authenticate your session.
Your API key needs to have [Org owner permissions](/manage/manage/rbac/#organization-settings-and-roles) to use the MLTraining client API.
To get an API key (and corresponding ID), you have two options:

- [Create an API key using the Viam app](/operate/control/api-keys/#add-an-api-key)
- [Create an API key using the Viam CLI](/dev/tools/cli/#create-an-organization-api-key)

The following example instantiates a `ViamClient`, authenticating with an API key, and then instantiates an `MLTrainingClient`:

{{< tabs >}}
{{% tab name="Python" %}}

```python {class="line-numbers linkable-line-numbers"}
import asyncio
Expand Down Expand Up @@ -66,6 +75,35 @@ if __name__ == '__main__':
asyncio.run(main())
```

{{% /tab %}}
{{% tab name="TypeScript" %}}

```ts {class="line-numbers linkable-line-numbers" data-line="5"}
async function connect(): Promise<VIAM.ViamClient> {
// Replace "<API-KEY-ID>" (including brackets) with your machine's
const API_KEY_ID = "<API-KEY-ID>";
// Replace "<API-KEY>" (including brackets) with your machine's API key
const API_KEY = "<API-KEY>";
const opts: VIAM.ViamClientOptions = {
serviceHost: "https://app.viam.com:443",
credentials: {
type: "api-key",
authEntity: API_KEY_ID,
payload: API_KEY,
},
};

const client = await VIAM.createViamClient(opts);
return client;
}

const appClient = await connect();
const mlTrainingClient = appClient.mlTrainingClient;
```

{{% /tab %}}
{{< /tabs >}}

Once you have instantiated an `MLTrainingClient`, you can run the following [API methods](#api) against the `MLTrainingClient` object (named `ml_training_client` in the examples).

## API
Expand Down
Loading