> ## 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](https://docs.muna.ai/sdk/openai.md).
* 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.

Below are currently supported annotations:

> [accordion] Generic Annotation
>
> 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] Numeric Annotation
>
> 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] Audio Annotation
>
> 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](https://docs.muna.ai/sdk/openai.md#creating-speech).
>
> 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] Audio Speed Annotation
>
> 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] Audio Voice Annotation
>
> 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] Bounding Box Annotation
>
> Use the `Parameter.BoundingBox` or `Parameter.BoundingBoxes` annotations to specify
> bounding box parameters in object detection models:
>
> ```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.")
> ]:
>     ...
> ```
>
> Below is the full `Parameter.BoundingBox` annotation definition:
>
> ```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: ...
> ```

> [accordion] Depth Map Annotation
>
> 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] Embedding Annotation
>
> 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](https://docs.muna.ai/sdk/openai.md#creating-embeddings).
>
> Below is the full `Parameter.Embedding` annotation definition:
>
> ```py icon="python" theme={null}
> @classmethod
> def Embedding(
>     cls,
>     *,
>     description: str  # Parameter description.
> ) -> Parameter: ...
> ```

> [accordion] Embedding Dimensions Annotation
>
> 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: ...
> ```


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