post method

Future<Response> post(
  1. String path, {
  2. required Map<String, dynamic> data,
})

Posts a request to the OpenAI API.

Implementation

Future<http.Response> post(
  String path, {
  required Map<String, dynamic> data,
}) async {
  final url = Uri.parse('$endpoint$path/?api-version=2024-08-01-preview');
  print(url);
  final headers = {
    'Content-Type': 'application/json',
    'api-key': apiKey,
  };
  final body = jsonEncode(data);

  final response = await http.post(url, headers: headers, body: body);
  _checkResponse(response);
  return response;
}