Why am I getting a 400 error trying to hit the OpenAI API endpoint?

I’m trying to create a fairly rudimentary program to test the API out. But I’m getting a 400 response back. ChatGPT has been helpful in getting me to this point, but isn’t seeing what’s wrong with what I’m doing.

I’m coding this in C#. Can anyone tell me what’s wrong with this code?

#region Static CTor
static ChatGPT() {
	//TODO: Uh, that's not secure.
	_apiKey = "sk-TRUST_ME_BRO_ITS_LEGIT!";
	
	//Endpoint URI (duh).
	_endpointUri = new("https://api.openai.com/v1/completions");

	//Setup the Client.
	_gptClient = new HttpClient();

	
	_gptClient.DefaultRequestHeaders.Authorization = new("Bearer", _apiKey);
	_gptClient.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
}
#endregion
#region Methods and Functions
public static async Task<string> SendMessageAsync(string message) {
	//Serialize anonymous object containing our stuff into a JSON string.
	//Then stuff it into a StringContent object. God I've missed C# :-/
	var json = JsonSerializer.Serialize(new {
		model = "gpt-3.5-turbo",
		messages = new[ ] { new{
				role = "user",
				content = message
			} },
		temperature = Temperature,
		top_p = TopPercent,
		stream = true,
		max_tokens = MaxTokens,
		presence_penalty = PresencePenalty,
		frequency_penalty = FrequencyPenalty,
		user = "Me"
	});

	var content = new StringContent(json, Encoding.UTF8, "application/json");
	var response = await _gptClient.PostAsync(_endpointUri, content);
	return string.Empty;
}
#endregion

When debugging, I set a line on ‘var response = …’, which is where I’m seeing the 400 error being returned by the API.

EDIT: May have figured it out. I hit the list models endpoint directly and found this -
image

They updated the name of the model. That’s… kind of annoying. But I guess it means I can’t hardocde the model name. Which is fine.

Annoying but fine - guess I’ll be hitting the ‘list’ end point first, and taking the id of index = 2.

I’ll leave this here, hoping it helps someone.