Add Animation Key Frame to Clip In Code

I am trying to add keyframes to a clip in code at “Editor Time”.I have heard that I can’t do this at runtime which is fine, but I have not seen any examples of doing it at editor time.

I saw AnimationUtility but I don’t see any functions that could help me. Thanks.

AddingKeyframes

Also if you want it to happen in the editor
ExecuteInEditMode