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

# Tagging

> Assign custom tags to a video

## What is Tagging?

Tagging applies custom and automated tags to a video.

The path to use tagging:

```
core/tagging
```

## Running Tagging

The basic use of tagging to get AI generated tags:

<CodeGroup>
  ```python python theme={null}
  resp = moonshine.run(
      flow="core/tagging",
      index="your-index",
      video_id="[file_id].mp4",
  )
  ```
</CodeGroup>

Tagging only runs on **one video at a time**. It will have to be run multiple times to tag multiple videos.

### Custom Tags

To use custom tags, add a the `tags` parameter:

<CodeGroup>
  ```python python theme={null}
  resp = moonshine.run(
      flow="core/tagging",
      index="your-index",
      video_id="[file_id].mp4",
      tags=["basketball", "baseball", "soccer"],

  )
  ```
</CodeGroup>

### Multiple Tags

By default, tagging will assign multiple tags to a video. To set the number of tags use `num_tags`:

<CodeGroup>
  ```python python theme={null}
  resp = moonshine.run(
      flow="core/tagging",
      index="your-index",
      video_id="[file_id].mp4",
      tags=["basketball", "baseball", "soccer"],
      num_tags = 2
  )
  ```
</CodeGroup>

Note that `num_tags` is the maximum number of tags that will be assigned to the video and can be lower.

## Tagging Response Format

Tagging returns a json with the following structure:

<Tabs>
  <Tab title="output">
    <ParamField path="[output]" type="List[str]">
      List of tags assigned to the video
    </ParamField>
  </Tab>

  <Tab title="status">
    <ParamField path="[status]" type="string">
      Completion status of the tagging operation
    </ParamField>
  </Tab>

  <Tab title="video_id">
    <ParamField path="[video_id]" type="string">
      Video ID of the tagged video
    </ParamField>
  </Tab>
</Tabs>

Example:

```json theme={null}
{
    "output": ["basketball"],
    "status": "complete",
    "video_id": "[file_id].mp4"
}
```

## Tagging Complete Example

A complete example that runs tagging over an entire index:

<CodeGroup>
  ```python python theme={null}
  import moonshine

  moonshine.configure("YOUR-TOKEN-HERE")
  index = "my-sports-videos"

  items = moonshine.items(index=index)
  tags_to_use = ["basketball", "baseball", "soccer"]

  for item in items:
      file_id = item["file_id"]
      file_name = item["file_name"]
      print(f"Tagging video: {file_name} (ID: {file_id})")
      resp = moonshine.run(
          flow="core/tagging",
          index=index,
          video_id=file_id,
          tags=tags_to_use,
          num_tags=1
      )
      print(f"Tagging results for {file_name}: {resp}")
  ```
</CodeGroup>

## Tagging JSON

Workflows are in a private beta. Please contact us at [team@usemoonshine.com](mailto:team@usemoonshine.com) to request access.

***

<Accordion title=".run(flow='core/tagging', ...) params" icon="code-simple">
  <ParamField path="index" type="string" required>
    Name/ID of the parent index of the video being processed.
  </ParamField>

  <ParamField path="video_id" type="string" required>
    ID of the video being processed.
  </ParamField>

  <ParamField path="tags" type="List[str]">
    List of tags to assign to the video.
  </ParamField>

  <ParamField path="num_tags" type="int">
    maximum number of tags that will be assigned to the video and can be lower.
  </ParamField>
</Accordion>
