DeepSeek模型调用-专业版 PHP 注意 php版本要求8.3.13以上; 安装composer组件; 运行以下命令: composer require openaiphp/client composer dumpautoload 同步调用 php withApiKey($appkey) >withBaseUri($baseUrl) >make(); $response $client>chat()>create([ 'model' > $modelId, 'messages' > [ ['role' > 'user', 'content' > $prompt], ], ]); foreach ($response>choices as $result) { echo $result>message>content; } 流式调用 php withApiKey($appKey) >withBaseUri($baseUrl) >make(); $stream $client>chat()>createStreamed([ 'model' > $modelId, 'messages' > [ ['role' > 'user', 'content' > $prompt], ], ]); foreach($stream as $response){ $data$response>choices[0]; echo jsonencode($data, JSONUNESCAPEDUNICODE,JSONPRETTYPRINT).PHPEOL; }