接口地址:https://api.scnet.cn/api/llm/v1 |
---|
返回格式:json |
请求方式:post |
请求示例:https://api.scnet.cn/api/llm/v1 |
名称 | 类型 | 必填 | 说明 |
---|---|---|---|
- | - | - | - |
名称 | 类型 | 说明 |
---|---|---|
- | - | - |
{}
错误码 | 说明 |
---|---|
- | - |
# Please install OpenAI SDK first: `pip3 install openai`
from openai import OpenAI
client = OpenAI(api_key="<API Key>", base_url="https://api.scnet.cn/api/llm/v1")
response = client.chat.completions.create(
model="DeepSeek-R1-Distill-Qwen-7B",
messages=[
{"role": "system", "content": "You are a helpful assistant"},
{"role": "user", "content": "Hello"},
],
stream=False
)
print(response.choices[0].message.content)
package main
import (
"fmt"
"io/ioutil"
"net/http"
"strings"
)
func main() {
url := "https://api.scnet.cn/api/llm/v1/chat/completions"
method := "POST"
payload := strings.NewReader(`{
"messages": [
{
"content": "You are a helpful assistant",
"role": "system"
},
{
"content": "Hi",
"role": "user"
}
],
"model": "DeepSeek-R1-Distill-Qwen-7B",
"stream": false
}`)
client := &http.Client{}
req, err := http.NewRequest(method, url, payload)
if err != nil {
fmt.Println(err)
return
}
req.Header.Add("Content-Type", "application/json")
req.Header.Add("Authorization", "Bearer <API Key>")
res, err := client.Do(req)
if err != nil {
fmt.Println(err)
return
}
defer res.Body.Close()
body, err := ioutil.ReadAll(res.Body)
if err != nil {
fmt.Println(err)
return
}
fmt.Println(string(body))
}