To the best of my knowledge, the only way to keep the AI from attacking you is to ensure they are too weak, or that they are otherwise occupied.

Use of agents is key. Sabotaged castles do not produce troops; keep the AI repairing castles. Rebellions keep the AI occupied; use monks to create rebellions wherever possible. Sure, help the AI expand but never allow it to become strong. Never trust anyone you share a border with.

For an excellent example of how this works, read: https://forums.totalwar.org/vb/showt...tion-V5445)-10