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

# Parameter Annotations

> Attaching annotations to your function's input and output types.

```py icon="python" focus={6-13} theme={null}
from muna import compile, Parameter
from typing import Annotated

@compile(...)
def area(
    radius: Annotated[
        float,
        Parameter.Generic(description="Radius of the circle.")
    ]
) -> Annotated[
    float,
    Parameter.Generic(description="Area of the circle.")
]:
    ...
```

These annotations serve multiple important purposes:

* They help users know what input data to provide to the compiled model and how to use output data from the compiled model, via the parameter `description`.
* They help users search for compiled models using highly detailed queries (e.g. MCP clients).
* They help the Muna client automatically provide familiar interfaces around your compiled function, e.g. with the [OpenAI interface](/sdk/openai).
* They help the Muna website automatically create interactive [`visualizers`](https://github.com/muna-ai/visualizers) for
  your compiled function.

<Tip>
  While not required, we highly recommend using parameter annotations on your compiled functions.
</Tip>

Below are currently supported annotations:

<AccordionGroup>
  <Accordion title="Generic Annotation" icon="binary">
    Use the `Parameter.Generic` annotation to provide information about a general input or output parameters:

    ```py model.py icon="python" focus={6-9} theme={null}
    from muna import compile, Parameter
    from typing import Annotated

    @compile(...)
    def area(
        radius: Annotated[
            float,
            Parameter.Generic(description="Radius of the circle.")
        ]
    ) -> float:
        ...
    ```

    Below is the full `Parameter.Generic` annotation definition:

    ```py icon="python" theme={null}
    @classmethod
    def Generic(
        cls,
        *,
        description: str  # Parameter description.
    ) -> Parameter: ...
    ```
  </Accordion>

  <Accordion title="Numeric Annotation" icon="hundred-points">
    Use the `Parameter.Numeric` annotation to specify numeric input or output parameters:

    ```py calculate_area.py icon="python" focus={6-13} theme={null}
    from muna import compile, Parameter
    from typing import Annotated

    @compile(...)
    def area(
        radius: Annotated[
            float,
            Parameter.Numeric(
                description="Circle radius.",
                min=1.,
                max=12.
            )
        ]
    ) -> float:
        ...
    ```

    Below is the full `Parameter.Numeric` annotation definition:

    ```py icon="python" theme={null}
    @classmethod
    def Numeric(
        cls,
        *,
        description: str,         # Parameter description.
        min: float | None=None,   # Minimum value.
        max: float | None=None    # Maximum value.
    ) -> Parameter: ...
    ```
  </Accordion>

  <Accordion title="Audio Annotation" icon="volume">
    Use the `Parameter.Audio` annotation to specify audio parameters:

    ```py transcribe_audio.py icon="python" focus={7-13} theme={null}
    from muna import compile, Parameter
    from numpy import ndarray
    from typing import Annotated

    @compile(...)
    def transcribe_audio(
        audio: Annotated[
            ndarray,
            Parameter.Audio(
                description="Input audio.",
                sample_rate=24_000
            )
        ]
    ) -> str:
        ...
    ```

    <Tip>
      The `Parameter.Audio` annotation allows the compiled model to be used by our
      [OpenAI speech client](/sdk/openai#creating-speech).
    </Tip>

    Below is the full `Parameter.Audio` annotation definition:

    ```py icon="python" theme={null}
    @classmethod
    def Audio(
        cls,
        *,
        description: str, # Parameter description.
        sample_rate: int  # Audio sample rate in Hertz.
    ) -> Parameter: ...
    ```
  </Accordion>

  <Accordion title="Audio Speed Annotation" icon="gauge-max">
    Use the `Parameter.AudioSpeed` annotation to specify audio speed parameters in audio generation models:

    ```py generate_speech.py icon="python" focus={8-15} theme={null}
    from muna import compile, Parameter
    from numpy import ndarray
    from typing import Annotated

    @compile(...)
    def generate_speech(
        text: str,
        speed: Annotated[
            float,
            Parameter.AudioSpeed(
                description="The speed of the generated audio.",
                min=0.25,
                max=4.0
            )
        ] = 1.0
    ) -> ndarray:
        ...
    ```

    Below is the full `Parameter.AudioSpeed` annotation definition:

    ```py icon="python" theme={null}
    @classmethod
    def AudioSpeed(
        cls,
        *,
        description: str,       # Parameter description.
        min: float | None=None, # Minimum audio speed.
        max: float | None=None  # Maximum audio speed.
    ) -> Parameter: ...
    ```
  </Accordion>

  <Accordion title="Audio Voice Annotation" icon="phone-volume" iconType="solid">
    Use the `Parameter.AudioVoice` annotation to specify audio voice parameters in audio generation models:

    ```py generate_speech.py icon="python" focus={10-13} theme={null}
    from muna import compile, Parameter
    from numpy import ndarray
    from typing import Annotated, Literal

    Voice = Literal["almas", "parv", "rhea", "sam"]

    @compile(...)
    def generate_speech(
        text: str,
        voice: Annotated[
            Voice,
            Parameter.AudioVoice(description="Voice to use when generating audio.")
        ],
        speed: float=1.0
    ) -> ndarray:
        ...
    ```

    Below is the full `Parameter.AudioVoice` annotation definition:

    ```py icon="python" theme={null}
    @classmethod
    def AudioVoice(
        cls,
        *,
        description: str    # Parameter description.
    ) -> Parameter: ...
    ```
  </Accordion>

  <Accordion title="Bounding Box Annotation" icon="rectangle-wide">
    Use the `Parameter.BoundingBox` or `Parameter.BoundingBoxes` annotations to specify
    bounding box parameters in object detection models:

    <CodeGroup>
      ```py Single icon="rectangle-wide" focus={8-11} theme={null}
      from muna import compile, Parameter
      from PIL import Image
      from typing import Annotated, Literal

      @compile(...)
      def detect_object(
          image: Image.Image
      ) -> Annotated[
          Detection,
          Parameter.BoundingBox(description="Detected object.")
      ]:
          ...
      ```

      ```py Multiple icon="rectangles-mixed" focus={8-11} theme={null}
      from muna import compile, Parameter
      from PIL import Image
      from typing import Annotated, Literal

      @compile(...)
      def detect_objects(
          image: Image.Image
      ) -> Annotated[
          list[Detection],
          Parameter.BoundingBoxes(description="Detected objects.")
      ]:
          ...
      ```
    </CodeGroup>

    Below is the full `Parameter.BoundingBox` annotation definition:

    <CodeGroup>
      ```py Single icon="rectangle-wide" theme={null}
      @classmethod
      def BoundingBox(
          cls,
          *,
          description: str    # Parameter description.
      ) -> Parameter: ...
      ```

      ```py Multiple icon="rectangles-mixed" theme={null}
      @classmethod
      def BoundingBoxes(
          cls,
          *,
          description: str    # Parameter description.
      ) -> Parameter: ...
      ```
    </CodeGroup>
  </Accordion>

  <Accordion title="Depth Map Annotation" icon="camera" iconType="solid">
    Use the `Parameter.DepthMap` annotation to specify depth map parameters in depth estimation models:

    ```py estimate_depth.py icon="python" focus={9-12} theme={null}
    from muna import compile, Parameter
    from numpy import ndarray
    from PIL import Image
    from typing import Annotated

    @compile(...)
    def estimate_depth(
        image: Image.Image
    ) -> Annotated[
        ndarray,
        Parameter.DepthMap(description="Metric depth tensor.")
    ]:
        ...
    ```

    Below is the full `Parameter.DepthMap` annotation definition:

    ```py icon="python" theme={null}
    @classmethod
    def DepthMap(
        cls,
        *,
        description: str    # Parameter description.
    ) -> Parameter: ...
    ```
  </Accordion>

  <Accordion title="Embedding Annotation" icon="wand-sparkles" iconType="solid">
    Use the `Parameter.Embedding` annotation to specify vector embedding parameters in embedding models:

    ```py embed_text.py icon="python" focus={8-11} theme={null}
    from muna import compile, Parameter
    from numpy import ndarray
    from typing import Annotated

    @compile(...)
    def embed_text(
        text: str
    ) -> Annotated[
        ndarray,
        Parameter.Embedding(description="Embedding vector.")
    ]:
        ...
    ```

    <Tip>
      The `Parameter.Embedding` annotation allows the compiled model to be used by our\
      [OpenAI embedding client](/sdk/openai#creating-embeddings).
    </Tip>

    Below is the full `Parameter.Embedding` annotation definition:

    ```py icon="python" theme={null}
    @classmethod
    def Embedding(
        cls,
        *,
        description: str  # Parameter description.
    ) -> Parameter: ...
    ```
  </Accordion>

  <Accordion title="Embedding Dimensions Annotation" icon="chart-scatter-3d" iconType="solid">
    Use the `Parameter.EmbeddingDims` annotation to specify an embedding
    Matryoshka dimension parameter in embedding models:

    ```py embed_text.py icon="python" focus={8-11} theme={null}
    from muna import compile, Parameter
    from numpy import ndarray
    from typing import Annotated

    @compile(...)
    def embed_text(
        text: str,
        dims: Annotated[
            int,
            Parameter.EmbeddingDims(description="Embedding dimensions.")
        ]
    ) -> ndarray:
        ...
    ```

    Below is the full `Parameter.EmbeddingDims` annotation definition:

    ```py icon="python" theme={null}
    @classmethod
    def EmbeddingDims(
        cls,
        *,
        description: str,       # Parameter description.
        min: int | None=None,   # Minimum embedding dimensions.
        max: int | None=None    # Maximum embedding dimensions.
    ) -> Parameter: ...
    ```
  </Accordion>
</AccordionGroup>


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.