|
|
| |
|
delphi7调用AI大模型 | |
| 阅读 77 次 更新时间:2025/2/28 | |
|
procedure TForm1.Button1Click(Sender: TObject); var XMLHttp: OleVariant; apiKey, url, requestBody, response: string; begin // 初始化XMLHttp对象 XMLHttp := CreateOleObject('MSXML2.XMLHTTP'); // 设置API密钥和URL apiKey := 'sk-hhnu'; url := 'https://api.siliconflow.cn/v1/chat/completions'; // 设置请求体 requestBody := '{"model": "Pro/deepseek-ai/DeepSeek-V3", "messages": [{"role": "user", "content": "你好,DeepSeek!"}]}'; // 发送POST请求 XMLHttp.Open('POST', url, False); XMLHttp.SetRequestHeader('Authorization', 'Bearer ' + apiKey); XMLHttp.SetRequestHeader('Content-Type', 'application/json'); XMLHttp.Send(requestBody); // 获取响应 response := XMLHttp.ResponseText; memo2.Text :=response; end; | |
|
|
|