和的子和子. (NordRouter)
举个例子:一个包的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']);在公共Flutter应用程序中,不要编入一个通用API密钥.用户要么输入自己的密钥,要么请求通过你的服务器.