Dart dan Flutter dari NordRouter
Contoh dengan paket http:
dart
import 'dart:convert';
import 'package:http/http.dart' as http;
final response = await http.post(
Uri.parse('https://nordrouter.com/v1/chat/completions'),
headers: {
'Authorization': 'Bearer $apiKey',
'Content-Type': 'application/json',
},
body: jsonEncode({
'model': 'anthropic/claude-sonnet-4.6',
'messages': [{'role': 'user', 'content': 'Привет!'}],
}),
);
if (response.statusCode != 200) throw Exception(response.body);
print(jsonDecode(response.body)['choices'][0]['message']['content']);Di aplikasi Flutter publik, jangan sematkan kunci API bersama. Entah pengguna memasukkan kuncinya sendiri, atau permintaan melewati server Anda.