    def api(
        self,
        input: IODescriptor[IOType],
        output: IODescriptor[IOType],
        *,
        name: str | None = None,
        doc: str | None = None,
        route: str | None = None,
    ) -> _inference_api_wrapper[IOType]:
        """Decorator for adding InferenceAPI to this service"""

        def decorator(
            fn: _inference_api_wrapper[IOType],
        ) -> _inference_api_wrapper[IOType]:
            _api = InferenceAPI[IOType](
                name=first_not_none(name, default=fn.__name__),
                user_defined_callback=fn,
                input_descriptor=input,
                output_descriptor=output,
                doc=doc,
                route=route,
            )
            if _api.name in self.apis:
                raise BentoMLException(
                    f"API {_api.name} is already defined in Service {self.name}"
                )
            self.apis[_api.name] = _api
            return fn

        return t.cast("_inference_api_wrapper[IOType]", decorator)
Decorator for adding InferenceAPI to this service
src/bentoml/_internal/service/service.py