How can I make an animation curve Keyframe "Auto" in code?

I'm creating an animation curve from scratch in code. I would like to set the keyframes to "Auto" like you can in the editor (as I wish to modify the keyframes themselves in the code)... at the moment my code is this:

var shoulderCurve : AnimationCurve;
var ks : Keyframe[];
ks = new Keyframe[2];
ks[0] = Keyframe(-1, 39);
ks[1] = Keyframe(1, -20);
shoulderCurve = new AnimationCurve(ks);

But that gives me keyframes with flat tangents. During runtime I can change the keyframes to Auto in the editor, and then I get the result I want - but I can't find any way of setting them as Auto to begin with, in code. I know I can set tangents manually, but that's not the same as having keyframes set to Auto.

hi,

AnimationCurve.SmoothTangents(key index, 0) does the thing.
So after creating the curve you can “Auto” it like this:

for(int i=0; i<shoulderCurve.keys.length; ++i)
{
  shoulderCurve.SmoothTangent(i, 0); //zero weight means average
}

When I did:

Keyframe[] ks;
ks = new Keyframe[2];
ks[0] = new Keyframe(0f, 0f);
ks[1] = new Keyframe(1f, 10f);		
		
AnimationCurve curve = new  AnimationCurve(ks);

this worked for me and I was able to get the curve i need and it showed up in the editor just fine when i use:

curve = EditorGUILayout.CurveField("Seed", curve);

Did you solved that?