_model_kwargs = self.model_kwargs or {}
        # Prepare the payload JSON
        parameter_payload = {"inputs": prompt, "parameters": _model_kwargs}
        try:
            # Initialize the OctoAI client
            from octoai import client
            octoai_client = client.Client(token=self.octoai_api_token)
            # Send the request using the OctoAI client
            resp_json = octoai_client.infer(self.endpoint_url, parameter_payload)
            text = resp_json["generated_text"]
        except Exception as e:
            # Handle any errors raised by the inference endpoint
            raise ValueError(f"Error raised by the inference endpoint: {e}") from e
        if stop is not None:
            # Apply stop tokens when making calls to OctoAI
            text = enforce_stop_tokens(text, stop)
        return text