> ## Documentation Index
> Fetch the complete documentation index at: https://docs.baseten.co/llms.txt
> Use this file to discover all available pages before exploring further.

# Label deployments

> Add labels when you push a deployment, then view them in the console, the Baseten CLI, or the Management API.

Labels are a JSON object stored with a deployment. Use them to record metadata
such as the owning team, source commit, or CI run.

Published deployment labels remain fixed after creation. To change them,
create another deployment with new labels. For a development deployment,
passing labels on a later push replaces its current labels. Omitting labels
preserves them.

A label object can be up to 2 KB after JSON serialization. Label keys and
string values can contain printable ASCII characters except spaces.

## Set labels

<Tabs>
  <Tab title="Baseten CLI">
    **To label a deployment**:

    ```bash theme={"system"}
    baseten model push --labels '{"team": "ml-platform", "env": "staging"}'
    ```

    For more information, see [`baseten model push`](/reference/cli/baseten/model).
  </Tab>

  <Tab title="Truss CLI">
    **To label a deployment**:

    ```bash theme={"system"}
    truss push --labels '{"team": "ml-platform", "env": "staging"}'
    ```

    For more information, see [`truss push`](/reference/cli/truss/push).
  </Tab>

  <Tab title="Python SDK">
    **To label a deployment**:

    ```python theme={"system"}
    import truss

    truss.push("./my-model", labels={"team": "ml-platform", "env": "staging"})
    ```

    For more information, see [`truss.push()`](/reference/sdk/truss/push).
  </Tab>

  <Tab title="REST API">
    **To label a deployment**:

    Add `labels` to the `deployment` object in both the prepare and create
    requests:

    ```json theme={"system"}
    {
      "labels": {
        "team": "ml-platform",
        "env": "staging"
      }
    }
    ```

    For the complete prepare, upload, and create sequence, see
    [Create a model with the REST API](/examples/create-a-model-with-rest).
  </Tab>

  <Tab title="CI/CD">
    **To label a deployment**:

    ```yaml theme={"system"}
    - uses: basetenlabs/action-truss-push@v0.1
      with:
        truss-directory: "./my-model"
        baseten-api-key: ${{ secrets.BASETEN_API_KEY }}
        labels: '{"team": "ml-platform", "triggered-by": "ci"}'
    ```

    For more information, see the
    [deploy GitHub Action](/reference/ci/github-action) and
    [Deploy with labels](/deployment/ci-cd#deploy-with-labels).
  </Tab>
</Tabs>

## View labels

After you push the deployment, view its labels in the console, the Baseten CLI,
or the Management API:

<Tabs>
  <Tab title="UI">
    **To view a deployment's labels**:

    1. Sign in to your workspace at
       [app.baseten.co](https://app.baseten.co) and choose **Dedicated Inference** in the
       sidebar.
    2. Select your model.
    3. Select the deployment under **Deployments**.
    4. Find **Labels** in the deployment details, below **Truss config**.
  </Tab>

  <Tab title="Baseten CLI">
    **To view a deployment's labels**:

    JSON output includes labels. The text summary omits them.

    Print the whole deployment record with `--output json`:

    <CodeGroup>
      ```bash Command theme={"system"}
      baseten model deployment describe --model-id abc123 --deployment-id def456 --output json
      ```

      ```json Output theme={"system"}
      {
        "id": "def456",
        "name": "deployment-1",
        "model_id": "abc123",
        "status": "ACTIVE",
        "instance_type_name": "1x2 - 1 vCPU, 2 GiB RAM",
        "labels": {
          "env": "staging",
          "team": "ml-platform"
        },
        ...
      }
      ```
    </CodeGroup>

    Print just the labels with `--jq`:

    <CodeGroup>
      ```bash Command theme={"system"}
      baseten model deployment describe --model-id abc123 --deployment-id def456 --jq '.labels'
      ```

      ```json Output theme={"system"}
      {
        "env": "staging",
        "team": "ml-platform"
      }
      ```
    </CodeGroup>

    For more information, see
    [`baseten model deployment describe`](/reference/cli/baseten/model-deployment).
  </Tab>

  <Tab title="REST API">
    **To view a deployment's labels**:

    <CodeGroup>
      ```bash Request theme={"system"}
      curl "https://api.baseten.co/v1/models/{model_id}/deployments/{deployment_id}" \
        -H "Authorization: Bearer $BASETEN_API_KEY"
      ```

      ```json Response theme={"system"}
      {
        "id": "def456",
        "name": "deployment-1",
        "model_id": "abc123",
        "status": "ACTIVE",
        "labels": {
          "team": "ml-platform",
          "env": "staging"
        },
        ...
      }
      ```
    </CodeGroup>

    For more information, see
    [Get a model's deployment by ID](/reference/management-api/deployments/gets-a-models-deployment-by-id).
  </Tab>
</Tabs>

## Next steps

Use labels in CI/CD to compare the deployment running on Baseten with the
commit or workflow run that created it.

* [Manage the deployment lifecycle](/deployment/manage/lifecycle) to promote or
  retire a labeled deployment.
* [CI/CD](/deployment/ci-cd) to attach labels automatically from GitHub Actions.
* [Deployments](/deployment/deployments) for how deployments, environments, and
  promotion fit together.
