一、接口信息
接口地址:https://www.1bit.asia/openai/api/ask
类型:POST
参数:{
"prompt": "写一个修仙小说目录",
"userName":"apiuser002",
"token":"链接页面获取"
}
说明:userName参数和token需要对应。同一时间多人调用会产生理解混乱,多组不同账号token请查看。
userName----token--------------------------------
apiuser001 ea7cd815-628d-4ad6-bf8c-365ed9192dff
apiuser002 da510ca1-63ff-4771-8375-fc34c977ca8f
apiuser003 b97a0ca3-2f30-4a15-809a-f27126ded0e0
apiuser004 5cedb043-120a-43ae-9db8-535cf4c333a6
apiuser005 3c6e8535-45e9-4000-ae86-ed03d6ed9600
apiuser006 da510ca1-63ff-4771-8375-fc34c977ca81
apiuser007 da510ca1-63ff-4771-8375-fc34c977ca82
apiuser008 da510ca1-63ff-4771-8375-fc34c977ca83
apiuser009 da510ca1-63ff-4771-8375-fc34c977ca84
apiuser010 da510ca1-63ff-4771-8375-fc34c977ca85
apiuser011 da510ca1-63ff-4771-8375-fc34c977ca86
apiuser012 da510ca1-63ff-4771-8375-fc34c977ca87
apiuser013 da510ca1-63ff-4771-8375-fc34c977ca88
apiuser014 da510ca1-63ff-4771-8375-fc34c977ca89
apiuser015 da510ca1-63ff-4771-8375-fc34c977caaa
apiuser016 da510ca1-63ff-4771-8375-fc34c977cabb
apiuser017 da510ca1-63ff-4771-8375-fc34c977cavv
apiuser018 da510ca1-63ff-4771-8375-fc34c977cacc
apiuser019 da510ca1-63ff-4771-8375-fc34c977cass
二、Java调用方式
private static String getQuestionInfo(String question) { try { URL url = new URL("https://www.1bit.asia/openai/api/ask"); HttpURLConnection con = (HttpURLConnection) url.openConnection(); con.setRequestMethod("POST"); // 设置请求头 con.setRequestProperty("Content-Type", "application/json"); // 设置请求体 String requestBody = "{\"prompt\":\""+ question +"\",\"token\":\"链接页面获取\",\"userName\":\"apiuser002\"}"; con.setDoOutput(true); con.setDoInput(true); OutputStream os = con.getOutputStream(); os.write(requestBody.getBytes()); os.flush(); os.close(); BufferedReader in = new BufferedReader(new InputStreamReader(con.getInputStream())); String inputLine; StringBuffer content = new StringBuffer(); while ((inputLine = in.readLine()) != null) { content.append(inputLine); } in.close(); String questionInfo = content.toString(); return questionInfo; } catch (IOException e) { e.printStackTrace(); return "请求异常"; } }
运行效果:
三、python 调用方式
# coding=gbk import requests import json prompt = input('请输入问题:') url = 'https://www.1bit.asia/openai/api/ask' data = {'prompt': prompt, 'token': '链接页面获取', 'userName':'apiuser002'} headers = {'Content-Type':'application/json'} response = requests.post(url, data= json.dumps(data), headers=headers) print('答:'+response.text)
运行效果
访问接口域名部分去掉/openai及之后的也可以进行页面使用。