并行智算云MaaS平台作为一站式大模型服务平台,整合了DeepSeek、GLM、Qwen等热门大模型,为开发者提供了便捷高效的API调用方式。本文将详细介绍从注册认证、API密钥获取到Python和cURL调用的完整流程,并针对DeepSeek-R1等热门模型提供实际应用示例。
一、平台注册与API密钥获取
1. 注册并行智算云账号
访问并行智算云官方注册网站(https://ai.paratera.com),填写手机号码、验证码等必要信息完成注册。建议用户名简洁易记,密码设置为包含字母、数字和特殊字符的高强度组合。
2. 获取API密钥
登录后进入控制台,按照以下步骤获取API密钥:
-
在控制台中找到"MaaS平台"选项
-
点击"创建API KEY"按钮生成专属密钥1
-
密钥由AccessKey和SecretAccessKey组成,代表账号身份,等同于登录密码,必须妥善保管
重要提示:API密钥一旦泄露可能导致权限被滥用,如已泄露请立即禁用该密钥对。平台支持密钥的查看、禁用、启用和删除操作,可在【个人中心】->【我的密钥】中进行管理。
3. 多种API接入形式
支持2种使用方式:本地客户端接入、代码接入
3.1 本地客户端接入
支持三种主流工具:Chatbox、Cherry Studio、AnythingLLM
3.1.1 Chatbox接入
(1) 本地下载安装Chatbox
(2) 选择模型提供方为OpenAI API
(3) 输入API密钥(API KEY)、API 域名(API URL)、模型名
注:如果首次进入chatbox时,忘记选择【使用自己的模型】,可在对话窗口左下角【设置】里修改模型。
(4) 开启对话等功能使用
3.1.2 Cherry Studio接入
(1) 本地下载安装Cherry Studio
(2) 选择模型提供方为OpenAI
(3) 输入API密钥(API KEY)、API 地址(API URL)、模型名
注:如果首次进入Cherry Studio时,忘记选择【使用自己的模型】,可在对话窗口左下角【齿轮】里修改模型。
(4) 开启对话等功能使用
3.1.3 AnythingLLM接入
(1) 本地下载安装AnythingLLM
(2) 首次安装设置界面,选择Generic OpenAI,输入API KEY、API URL、模型名
(3) 更改设置,选择左下角第四个图标
(4) 开启对话等功能使用
3.2 代码接入
支持curl、python、golang、java、nodejs等
3.2.1 curl接入
查询所有可用模型
curl --request GET \ --url [hostname]/v1/models \ --header 'authorization: Bearer 申请到的key' \ --header 'content-type: application/json'
推理
curl --request POST \ --url [hostname]/chat/completions \ --header 'authorization: Bearer 申请到的key' \ --header 'content-type: application/json' \ --data '{ "model": "模型ID", "messages": [ { "role": "user", "content": "Hello World" } ]}'
3.2.2 python接入
import openai client = openai.OpenAI( api_key="申请到的key", base_url="[hostname]/v1/") response = client.chat.completions.create( model="模型ID", # model to send to the proxy messages=[{"role": "user", "content": "Hello World"}],)print(response)
3.2.3 golang接入
package mainimport ( "bytes" "encoding/json" "fmt" "io/ioutil" "net/http") func main() { url := "[hostname]/v1/chat/completions" // Define and marshal the payload payload, _ := json.Marshal(map[string]interface{}{ "model": "模型ID", "messages": []map[string]string{{ "role": "user", "content": "Hello World", }}, "stream": false, "max_tokens": 512, "temperature": 0.6, }) // Create and send the request req, _ := http.NewRequest("POST", url, bytes.NewBuffer(payload)) req.Header.Set("Authorization", "Bearer 申请的api-key") req.Header.Set("Content-Type", "application/json") res, err := http.DefaultClient.Do(req) if err != nil { fmt.Println("Error:", err) return } defer res.Body.Close() // Read and print the response body, _ := ioutil.ReadAll(res.Body) fmt.Println("Response:", string(body))}
3.2.4 java 接入
import com.mashape.unirest.http.HttpResponse;import com.mashape.unirest.http.Unirest;import org.json.JSONObject;import org.json.JSONArray; public class Test { public static void main(String[] args) throws Exception{ JSONObject body = new JSONObject() .put("model", "模型ID") .put("messages", new JSONArray().put(new JSONObject().put("role", "user").put("content", "Hello World"))) .put("stream", false) .put("max_tokens", 512) .put("temperature", 0.6); HttpResponse<String> response = Unirest.post("[hostname]/v1/chat/completions") .header("Authorization", "Bearer 申请的api-key") .header("Content-Type", "application/json") .body(body.()) .asString(); System.out.println(response.getBody()); }}
3.2.5 nodejs 接入
const axios = require('axios'); const url = '[hostname]/v1/chat/completions'; const payload = { model: '模型ID', messages: [ { role: 'user', content: 'Hello world', }, ], stream: false, max_tokens: 512, temperature: 0.6,}; axios .post(url, payload, { headers: { Authorization: 'Bearer 申请的api-key', 'Content-Type': 'application/json', }, }) .then((response) => { console.log('Response Status:', response.status); console.log('Response Body:', response.data.choices[0].message.content ); }) .catch((err) => { console.error('Error:', err); });
六、优化与最佳实践
-
Token管理:平台按Token计费,注意优化提示词减少不必要消耗
-
错误处理:实现重试机制应对网络波动或模型加载失败
-
性能优化:对于批量请求,考虑使用异步调用提高效率
-
安全实践:定期轮换API密钥,遵循最小权限原则分配访问权限
七、平台优势与资源
并行智算云MaaS平台的核心优势包括:
-
丰富模型选择:集成DeepSeek、GLM、Qwen等热门模型
-
高性价比:依托海量算力基础,提供充足GPU资源
-
专业技术支持:7×24小时响应团队
-
免费资源:新用户可领取免费Token额度体验服务
平台还支持模型的一键启动、部署和在线微调,助力打造专属AI应用。对于企业级需求,可考虑商用级API服务,获得更高并发和SLA保障。