UIUIAPI聚合平台API通用代码教程

API站点使用教程1.1API接口地址填写请勿将APIKey泄露给他人,一旦泄露,请立即删除并创建新的APIKey修改原则:修改应用BASE_URL为其中一个中转接口调用地址接口即可,例如:修改原则https://api.openai.com↓https://api1.uiuiapi.com(如果原来接口地址需要加/v1的话我们的接口地址也需要在后面加/v1)出现回复缓慢的情况,请检查API调用日志,若日志正常,则自行调整网络。BaseUrl不同客户端适配的接口地址格式不同,通常为以下三种:https://api1.uiuiapi.comhttps://api1.uiuiapi.com/v1https://api1.uiuiapi.com/v1/chat/completions1.2Python接入示例所有对话模型均使用OpenAI格式,替换AI模型即可˂aclass="reference-link"name="Python流式"˃Python流式fromopenaiimportOpenAIapi_key="sk-HTdmSI6B2cNt************************************"api_base="https://api1.uiuiapi.com/v1"client=OpenAI(api_key=api_key,base_url=api_base)completion=client.chat.completions.create(model="claude-3-opus-20240229",stream:True,messages=[{"role":"system","content":"Youareahelpfulassistant."},{"role":"user","content":"Hello!"}])forchunkincompletion:print(chunk.choices[0].delta)˂aclass="reference-link"name="Python非流"˃Python非流fromopenaiimportOpenAIapi_key="sk-HTdmSI6B2cNt************************************"api_base="https://api1.uiuiapi.com/v1"client=OpenAI(api_key=api_key,base_url=api_base)completion=client.chat.completions.create(model="claude-3-opus-20240229",stream:False,messages=[{"role":"system","content":"Youareahelpfulassistant."},{"role":"user","content":"Hello!"}])print(completion.choices[0].message)˂aclass="reference-link"name="PythonWhisper语音转文字"˃PythonWhisper语音转文字fromopenaiimportOpenAIfrompathlibimportPath#设置你的基础URL和API密钥base_url="https://api1.uiuiapi.com/v1"key="sk-HTdmSI6B2cNt************************************"#初始化OpenAI客户端client=OpenAI(api_key=key,base_url=base_url)#音频文件的路径audio_file_path="C:/speech.mp3"#打开音频文件withopen(audio_file_path,"rb")asaudio_file:#创建转录transcription=client.audio.transcriptions.create(model="whisper-1",file=audio_file)#打印转录文本print(transcription.text)˂aclass="reference-link"name="PythonTTS文字转语音"˃PythonTTS文字转语音fromopenaiimportOpenAIfrompathlibimportPathdeftest_text_speech(model="tts-1"):print(f"Testing{model}-texttospeech")speech_file_path=Path(__file__).parent/"speech1.mp3"response=client.audio.speech.create(model=model,voice="alloy",#可选alloy,echo,fable,onyx,nova,shimmerinput="示例文本",)response.stream_to_file(speech_file_path)base_url="https://api1.uiuiapi.com/v1"key="sk-HTdmSI6B2cNt************************************"client=OpenAI(base_url=base_url,api_key=key)test_text_speech()1.3Curl接入示例˂aclass="reference-link"name="Curl流式"˃Curl流式curlhttps://api1.uiuiapi.com/v1/chat/completions\-H"Content-Type:application/json"\-H"Authorization:Bearersk-HTdmSI6B2cNt************************************"\-d'{"model":"claude-3-opus-20240229","stream":true,"messages":[{"role":"user","content":"say1"}]}'˂aclass="reference-link"name="Curl非流"˃Curl非流curlhttps://api1.uiuiapi.com/v1/chat/completions\-H"Content-Type:application/json"\-H"Authorization:Bearersk-HTdmSI6B2cNt************************************"\-d'{"model":"claude-3-opus-20240229","stream":false,"messages":[{"role":"user","content":"say1"}]}'1.4Node.js接入示例˂aclass="reference-link"name="Node.js流式"˃Node.js流式importOpenAIfrom"openai";constopenai=newOpenAI("https://api1.uiuiapi.com/v1");asyncfunctionmain(){constcompletion=awaitopenai.chat.completions.create({stream:true,messages:[{role:"system",content:"Youareahelpfulassistant."}],model:"claude-3-opus-20240229",});console.log(completion.choices[0]);}main();˂aclass="reference-link"name="Node.js非流"˃Node.js非流importOpenAIfrom"openai";constopenai=newOpenAI("https://api1.uiuiapi.com/v1");asyncfunctionmain(){constcompletion=awaitopenai.chat.completions.create({stream:false,messages:[{role:"system",content:"Youareahelpfulassistant."}],model:"claude-3-opus-20240229",});console.log(completion.choices[0]);}main();1.5Python使用Claude、gpt-4o识别图片˂aclass="reference-link"name="识别链接格式图片"˃识别链接格式图片fromopenaiimportOpenAIclient=OpenAI(base_url="https://api1.uiuiapi.com/v1",api_key=key)response=client.chat.completions.create(model="gpt-4o",messages=[{"role":"user","content":[{"type":"text","text":"What’sinthisimage?"},{"type":"image_url","image_url":{"url":"https://upload.wikimedia.org/wikipedia/commons/thumb/d/dd/Gfp-wisconsin-madison-the-nature-boardwalk.jpg/2560px-Gfp-wisconsin-madison-the-nature-boardwalk.jpg",},},],}],max_tokens=300,)print(response.choices[0])˂aclass="reference-link"name="识别Base64格式图片"˃识别Base64格式图片```importbase64importtimefromopenaiimportOpenAIimportopenaikey=‘sk-xxxx’client=OpenAI(base_url=”https://api1.uiuiapi.com/v1“,api_key=key)defencode_image(image_path):withopen(image_path,“rb”)asimage_file:returnbase64.b64encode(image_file.read()).decode(‘utf-8’)image_path=“图片.jpg”base64_image=encode_image(image_path)whileTrue:response=client.chat.completions.create(model=”claude-3-5-sonnet-20240620”,messages=[{“role”:“user”,“content”:[{“type”:“text”,“text”:“这张图片里有什么?请详细描述。”},{“type”:“image_url”,“image_url”:{“url”:f”data:image/jpeg;base64,{base64_image}”<!--autointro-->

UIUIChat在线助手使用教程

一、首先先获取APIKEY1、APIKEY获取:前往(uiuiapi.com)获取秘钥2、快速上手:快速使用,点击令牌后面的"聊天",即可一键导入使用。

宝塔面板Docker一键安装:部署GPTAcademic,开发私有GPT学术优化工具

使用宝塔Docker-compose,5分钟内在海外服务器上搭建gpt_academic。这篇文章讲解如何使用宝塔面板的Docker服务搭建GPT学术优化(GPTAcademic)。在人工智能的浪潮中,GPT模型因其强大的自然语言处理能力备受瞩目。然而,为了更好地应用于学术领域,许多人希望能部署自己私有的GPT学术优化工具。本文将详细介绍如何通过宝塔面板和Docker一键安装gptacademic,并将其部署到服务器上,从而开发出专属于自己的GPT学术优化工具。

中转API 部署ChatGPT应用Python开发调用请求代码示例

Python调用:发出请求方法一importopenaiopenai.api_base=“https://uiuiapi.com/v1"方法二(方法一不起作用用这个)修改环境变量OPENAI\_API\_BASE,各个系统怎么改环境变量请自行搜索,修改环境变量后不起作用请重启系统。OPENAI\_API\_BASE=https://uiuiapi.com/v1往下查看接入文档您可以将下面的命令粘贴到您的终端中以运行您的第一个API请求。确保替换YOUR_API_KEY为您

AIPRM for ChatGPT:ChatGPT 的强大助手

AIPRM是一款专为ChatGPT用户设计的强大谷歌浏览器插件。它功能丰富,让ChatGPT的使用更加便捷高效。插件地址:https://chrome.google.com/webstore/detail/aiprm-for-chatgpt/ojnbohmppadfgpejeebfnmnknjdlckgj

ChatGPT提问经常报错怎么办?一个插件可搞定

最近几天,相信大家都发现了ChatGPT一个问题,就是官网报错越来越频繁了。免费版的通病还有可能也是梯子节点网络环境不佳导致。当你需用ChatGPT来处理一些比较琐碎的任务时,一旦你离开页面时间比较久,再度返回跟它进行对话,就会出现如下报错:

ChatGPT访问报错 “Sorry You Have Been Blocked“解决办法

ChatGPT访问报错Sorry,youhavebeenblocked什么问题,怎么解决呢?看起来你在尝试访问一个特定的系统或应用,但遇到了报错,提示你被阻止了。答:最有效的解决方法是换过IP地址节点, Sorry,youhavebeenblocked很多都是你的IP地址被封锁。

目录[+]