> ## Documentation Index
> Fetch the complete documentation index at: https://wb-21fd5541-feat-cli-docs-generator.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

> Update an existing Artifact inside and outside of a W&B Run.

# Update an artifact

Pass desired values to update the `description`, `metadata`, and `alias` of an artifact. Call the `save()` method to update the artifact on the W\&B servers. You can update an artifact during a W\&B Run or outside of a Run.

<Note>
  **When to use Artifact.save() or wandb.Run.log\_artifact()**

  * Use `Artifact.save()` to update an existing artifact without creating a new run.
  * Use `wandb.Run.log_artifact()` to create a new artifact and associate it with a specific run.
</Note>

Use the W\&B Public API ([`wandb.Api`](/models/ref/python/public-api/api)) to update an artifact outside of a run. Use the Artifact API ([`wandb.Artifact`](/models/ref/python/experiments/artifact)) to update an artifact during a run.

<Warning>
  You can not update the alias of artifact linked to a model in Model Registry.
</Warning>

<Tabs>
  <Tab title="During a run">
    The following code example demonstrates how to update the description of an artifact using the [`wandb.Artifact`](/models/ref/python/experiments/artifact) API:

    ```python theme={null}
    import wandb

    with wandb.init(project="<example>") as run:
        artifact = run.use_artifact("<artifact-name>:<alias>")
        artifact.description = "<description>"
        artifact.save()
    ```
  </Tab>

  <Tab title="Outside of a run">
    The following code example demonstrates how to update the description of an artifact using the `wandb.Api` API:

    ```python theme={null}
    import wandb

    api = wandb.Api()

    artifact = api.artifact("entity/project/artifact:alias")

    # Update the description
    artifact.description = "My new description"

    # Selectively update metadata keys
    artifact.metadata["oldKey"] = "new value"

    # Replace the metadata entirely
    artifact.metadata = {"newKey": "new value"}

    # Add an alias
    artifact.aliases.append("best")

    # Remove an alias
    artifact.aliases.remove("latest")

    # Completely replace the aliases
    artifact.aliases = ["replaced"]

    # Persist all artifact modifications
    artifact.save()
    ```

    For more information, see the Weights and Biases [Artifact API](/models/ref/python/experiments/artifact).
  </Tab>

  <Tab title="With collections">
    You can also update an Artifact collection in the same way as a singular artifact:

    ```python theme={null}
    import wandb
    with wandb.init(project="<example>") as run:
        api = wandb.Api()
        artifact = api.artifact_collection(type="<type-name>", collection="<collection-name>")
        artifact.name = "<new-collection-name>"
        artifact.description = "<This is where you'd describe the purpose of your collection.>"
        artifact.save()
    ```

    For more information, see the [Artifacts Collection](/models/ref/python/public-api/api) reference.
  </Tab>
</Tabs>
