简单的对接 DeepSeek
public function callDeepSeekApi($userMessage=''):string{
$apiKey='你申请的 api';
$url='https://api.deepseek.com/chat/completions';
$headers=['Content-Type: application/json','Accept: application/json','Authorization: Bearer '.$apiKey];
$data=[
'model'=>'deepseek-chat',
'messages'=>[['role'=>'system','content'=>'You are a helpful assistant.'],['role'=>'user','content'=>$userMessage]],
'stream'=>false,
"frequency_penalty"=>0,
'response_format'=>['type'=>'text'
"max_tokens"=>2048,
"presence_penalty"=>0,
"stop"=>null,
"stream_options"=>,
=>,
=>,
=>,
=>,
=>,
=>
];
=();
=();
(,CURLOPT_URL,);
(,CURLOPT_CUSTOMREQUEST,);
(,CURLOPT_POSTFIELDS,);
(,CURLOPT_RETURNTRANSFER,);
(,CURLOPT_SSL_VERIFYPEER,);
(,CURLOPT_HTTPHEADER,);
=();
=();
(!){
=();
....PHP_EOL;
}
;
}