The sustainability and safety of shipping are crucial for the environment and society. Digital twins have been used to optimize ship design and operations. However, it is challenging for the traditional format of ship digital twins to effectively monitor and enhance ship safety and efficiency. This is because physical model-based digital twins have limitations in accurately representing complex operational conditions. This project introduces an AI-based digital twin to address this challenge and promote safe and sustainable ship operations. The digital twin aims to capture and optimize the ship motion and energy systems in real operational conditions. The project presents an AI-based digital twin based on sea trial data streams. The digital twin incorporates the following elements: (I) Multi-sources data collection, (II) Bi-directional Long Short-Term Memory (Bi-LSTM) network with attention mechanisms predicting ship fuel consumption, (III)Optimal transformer neural network for ship motion analysis, and (IV) Operations optimization. The established AI-based digital twin can monitor, analyze, and predict 6-Degree of Freedom (6-DoF) ship motion and fuel consumption. By iteratively assessing various combined operation instructions, the optimal combination of operation instructions can be determined, enhancing safety and sustainability in real operational conditions. The study demonstrates that the AI-based digital twin can help avoid critical scenarios (collision, grounding, capsizing, etc.) and reduce greenhouse gas emissions during shipping. In the long term, this project could contribute to the development of a new generation of decision support systems for enhancing safety and decarbonization in waterborne transportation.