keras-team/keras · error · NotImplementedError

_backend_add_endpoint() must be implemented in backend…

Error message

_backend_add_endpoint() must be implemented in backend subclasses.

What it means

Internal API-contract error: ExportArchive.add_endpoint() delegates the actual endpoint registration to _backend_add_endpoint(), which every backend-specific subclass must override. Hitting this means a backend subclass failed to implement the required abstract-style hook, not a user-input problem.

Solutions

  1. If you subclass ExportArchive for a custom backend, implement _backend_add_endpoint(name, fn, input_signature, **kwargs)
  2. Use the shipped backend ExportArchive class for your installed backend instead of a bare/incomplete subclass
  3. Report the missing implementation upstream if it comes from a Keras-distributed backend class
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at keras/src/export/saved_model_export_archive.py:158 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of keras-team/keras@7a34a03db6 (2026-08-25). Data as JSON: /api/errors/3fddc38d32967365. Report an issue: GitHub.

Appendix: source

Thrown at keras/src/export/saved_model_export_archive.py:158

                    ")"
                )
            setattr(self._tf_trackable, name, decorated_fn)
            self._endpoint_names.append(name)
            return decorated_fn

        input_signature = tree.map_structure(
            make_tf_tensor_spec, input_signature
        )
        decorated_fn = self._backend_add_endpoint(
            name, fn, input_signature, **kwargs
        )
        self._endpoint_signatures[name] = input_signature
        setattr(self._tf_trackable, name, decorated_fn)
        self._endpoint_names.append(name)
        return decorated_fn

    def _backend_add_endpoint(self, name, fn, input_signature, **kwargs):
        raise NotImplementedError(
            "_backend_add_endpoint() must be implemented in backend subclasses."
        )

    def track_and_add_endpoint(self, name, resource, input_signature, **kwargs):
        """Track the variables and register a new serving endpoint.

        This function combines the functionality of `track` and `add_endpoint`.
        It tracks the variables of the `resource` (either a layer or a model)
        and registers a serving endpoint using `resource.__call__`.

        Args:
            name: `str`. The name of the endpoint.
            resource: A trackable Keras resource, such as a layer or model.
            input_signature: Optional. Specifies the shape and dtype of `fn`.
                Can be a structure of `keras.InputSpec`, `tf.TensorSpec`,
                `backend.KerasTensor`, or backend tensor (see below for an
                example showing a `Functional` model with 2 input arguments). If
                not provided, `fn` must be a `tf.function` that has been called

View on GitHub (pinned to 7a34a03db6)