createChat method
https://api-docs.deepseek.com/api/create-chat-completion
model defaults to deepseek-chat
Implementation
Future<Completion> createChat({
required List<Message> messages,
String? model,
Map<String, dynamic>? options,
}) async {
final res = await http.post(
Uri.parse('$baseUrl/chat/completions'),
headers: _headers..['Content-Type'] = 'application/json',
body: jsonEncode({
'messages': messages.map((e) => e.toMap()).toList(),
'model': model ?? Models.chat.name,
...?options,
}),
);
if (res.statusCode != 200) {
throw DeepSeekException.fromBody(res.body, res.statusCode);
}
return Completion(utf8.decode(res.bodyBytes));
}