> ## Documentation Index
> Fetch the complete documentation index at: https://wb-21fd5541-style-guide-models-reports-20260604-104120.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Create a collection

> Create a collection of linked artifact versions within a W&B Registry and configure accepted artifact types.

This page explains how to create a collection within a W\&B Registry and configure the artifact types it accepts.

A *collection* is a set of linked artifact versions within a registry. Each collection represents a distinct task or use case.

For example, within a registry you might have multiple collections. Each collection contains a different dataset such as MNIST, CIFAR-10, or ImageNet.

As another example, you might have a registry called `chatbot` that contains a collection for model artifacts, another collection for dataset artifacts, and another collection for fine-tuned model artifacts.

How you organize a registry and their collections is up to you.

<Note>
  If you're familiar with W\&B Model Registry, you might know about registered models. The W\&B Registry now refers to registered models as *collections*.
</Note>

## Collection types

Each collection accepts one, and only one, *type* of artifact. The type you specify restricts which artifacts you, and other members of your organization, can link to that collection.

<Note>
  You can think of artifact types similar to data types in programming languages such as Python. In this analogy, a collection can store strings, integers, or floats but not a mix of these data types.
</Note>

For example, suppose you create a collection that accepts `dataset` artifact types. You can only link future artifact versions of type `dataset` to this collection. Similarly, you can only link artifacts of type `model` to a collection that accepts only model artifact types.

<Note>
  You specify an artifact's type when you create that artifact object. See the `type` field in `wandb.Artifact()`. Replace the bracketed placeholders with your own values:

  ```python theme={null}
  import wandb

  # Initialize a run
  with wandb.init(
    entity = "[TEAM-ENTITY]",
    project = "[PROJECT]"
    ) as run:

    # Create an artifact object
    artifact = wandb.Artifact(
        name="[ARTIFACT-NAME]",
        type="[ARTIFACT-TYPE]"
        )
  ```
</Note>

When you create a collection, you can select from a list of predefined artifact types. The artifact types available to you depend on the registry that the collection belongs to.

Before you link an artifact to a collection or create a new collection, [check which artifact types the collection accepts](#check-the-artifact-types-a-collection-accepts).

### Check the artifact types a collection accepts

Before you link to a collection, inspect the artifact type that the collection accepts. This helps you avoid link errors caused by mismatched artifact types. You can inspect the artifact types that a collection accepts programmatically with the W\&B Python SDK or interactively with the W\&B UI.

<Note>
  An error message appears if you try to link an artifact to a collection that doesn't accept that artifact type.
</Note>

<Tabs>
  <Tab title="W&B UI">
    You can find the accepted artifact types on the registry card on the homepage or within a registry's settings page.

    For both methods, first navigate to your W\&B Registry.

    Within the homepage of the W\&B Registry, you can view the accepted artifact types by scrolling to the registry card of that registry. The labels within the registry card list the artifact types that the registry accepts.

    <Frame>
      <img src="https://mintcdn.com/wb-21fd5541-style-guide-models-reports-20260604-104120/BZf2oO7lDKnugIUj/images/registry/artifact_types_model_card.png?fit=max&auto=format&n=BZf2oO7lDKnugIUj&q=85&s=9eba159c4e4630eb3e70f1db91263e5a" alt="Artifact types selection" width="3416" height="1622" data-path="images/registry/artifact_types_model_card.png" />
    </Frame>

    For example, the following image shows multiple registry cards on the W\&B Registry homepage. Within the **Model** registry card, you can see two artifact types: `model` and `model-new`.

    To view accepted artifact types within a registry's settings page:

    1. Click the registry card you want to view the settings for.
    2. Click the gear icon in the upper right corner.
    3. Scroll to the **Accepted artifact types** field.
  </Tab>

  <Tab title="Python SDK (Beta)">
    Programmatically view the artifact types that a registry accepts with the W\&B Python SDK:

    Replace `[REGISTRY-NAME]` with the name of your registry:

    ```python theme={null}
    import wandb

    registry_name = "[REGISTRY-NAME]"
    artifact_types = wandb.Api().project(name=f"wandb-registry-{registry_name}").artifact_types()
    for artifact_type in artifact_types:
        print(artifact_type.name)
    ```

    <Note>
      The following code snippet doesn't initialize a run. You don't need to create a run if you're only querying the W\&B API and not tracking an experiment, artifact, and so on.
    </Note>
  </Tab>
</Tabs>

Once you know what type of artifact a collection accepts, you can [create a collection](#create-a-collection).

## Create a collection

Interactively or programmatically create a collection within a registry. You can't change the type of artifact that a collection accepts after you create it.

### Create a collection programmatically

Use the `wandb.Run.link_artifact()` method to link an artifact to a collection. Specify both the collection and the registry to the `target_path` field as a path that takes the form of:

```python theme={null}
f"wandb-registry-{registry_name}/{collection_name}"
```

Where `registry_name` is the name of the registry and `collection_name` is the name of the collection. Append the prefix `wandb-registry-` to the registry name.

<Note>
  W\&B automatically creates a collection for you if you try to link an artifact to a collection that doesn't exist. If you specify a collection that exists, W\&B links the artifact to the existing collection.
</Note>

The following code snippet shows how to programmatically create a collection. Replace the bracketed placeholders with your own values:

```python theme={null}
import wandb

# Initialize a run
with wandb.init(entity = "[TEAM-ENTITY]", project = "[PROJECT]") as run:

  # Create an artifact object
  artifact = wandb.Artifact(
    name = "[ARTIFACT-NAME]",
    type = "[ARTIFACT-TYPE]"
    )

  registry_name = "[REGISTRY-NAME]"
  collection_name = "[COLLECTION-NAME]"
  target_path = f"wandb-registry-{registry_name}/{collection_name}"

  # Link the artifact to a collection
  run.link_artifact(artifact = artifact, target_path = target_path)
```

After this code runs, the artifact links to the specified collection, and W\&B creates the collection automatically if it doesn't already exist.

### Create a collection interactively

The following steps describe how to interactively create a collection using the W\&B Registry:

1. Navigate to the W\&B Registry at [https://wandb.ai/registry/](https://wandb.ai/registry/).
2. Select a registry.
3. Click the **Create collection** button in the upper-right corner.
4. Provide a name for your collection in the **Name** field.
5. Select a type from the **Type** dropdown. Or, if the registry enables custom artifact types, provide one or more artifact types that this collection accepts.
6. Optional: Provide a description of your collection in the **Description** field.
7. Optional: Add one or more tags in the **Tags** field.
8. Click **Link version**.
9. From the **Project** dropdown, select the project where your artifact is stored.
10. From the **Artifact** collection dropdown, select your artifact.
11. From the **Version** dropdown, select the artifact version you want to link to your collection.
12. Click the **Create collection** button.
