//GPT请求
String result = "";
void CHATGPT()
{
    WiFiClientSecure httpsClient;
    HTTPClient http;
    String message = "{\"model\": \"gpt-4-0613\", \"messages\": [{\"role\": \"user\", \"content\": \"" + result + "\"}]}";
    httpsClient.setInsecure();
    http.begin(httpsClient,"https://newapi02.sharkchat.cn/v1/chat/completions");
    http.addHeader("Content-Type", "application/json");
    http.addHeader("Accept", "application/json");
    http.addHeader("Authorization", "sk-VRmlEr8n5eBdEHvCA05627B27cB84b3b8a72B9C7C20d051f");
    int httpResponseCode = http.POST(message);
    if (httpResponseCode>0) {
      String response = http.getString();
      Serial.println(httpResponseCode);
      Serial.println(response);
    }
    else {
      Serial.print("Error on sending POST: ");
      Serial.println(httpResponseCode);
    }
    http.end();
}
Logo

Agent 垂直技术社区,欢迎活跃、内容共建。

更多推荐