一文走进GpuGeek | 模型调用
在GpuGeek云平台,您可以使用界面体验区和 API 两种方式调用模型。
GpuGeek-弹性|便捷|划算,您的专属AI云
模型体验
每个模型均有自己的体验区界面,通过 Web 表单的形式填写模型请求参数,并通过界面展示输出结果。首次运行模型即可通过体验的方式查看模型的效果,并在后续稳定使用 API 方式调用。体验模型同 API 调用均会根据每次调用量(如 Tokens 数)或该次请求运行时长扣费。

API 调用
您可通过多种方式请求每个模型的 API,包括 HTTP、Node.js、Python,针对文本对话类的官方 API,支持 OpenAI 格式兼容。API 调用需要使用 API Token,您可在 API Token 页面查看并管理您的 API Token。
使用 HTTP 方式调用 API
curl -X POST "https://api.gpugeek.com/predictions" \
      -H "Authorization: Bearer your_api_key" \
      -H "Content-Type: application/json" \
      -H "Stream: true" \
      -d "{\"model\": \"GpuGeek/DeepSeek-R1-671B\", \"input\": {
       \"frequency_penalty\": 0,
       \"max_tokens\": 8192,
       \"prompt\": \"\",
       \"temperature\": 0.6,
       \"top_p\": 0.7
 }}"
使用 Python 客户端调用 API
导入requests模块
API_KEY = "your_api_key"
设置请求url
url = 'https://api.gpugeek.com/predictions';
设置请求头
headers = {
    "Authorization": f"Bearer {API_KEY}",
     "Content-Type": "application/json",
     "Stream": "true"
 }
设置请求参数
data = {
      "model": "GpuGeek/DeepSeek-R1-671B",  # 替换成你的模型名称
     #  替换成实际的入参
     "input": {
       "frequency_penalty": 0,
       "max_tokens": 8192,
       "prompt": "",
       "temperature": 0.6,
       "top_p": 0.7
 }
 }
发送 POST 请求
response = requests.post(url, headers=headers, json=data)
检查响应状态码并打印响应内容
if response.status_code == 200:
     for line in response.iter_lines():
         if line:
             print(line.decode("utf-8"))
 else:
     print("Error:", response.status_code, response.text)
使用 Node.js 客户端调用 API
导入 axios 模块和 stream 模块
const axios = require('axios');
 const { Readable } = require('stream');
设置 API_KEY 变量
const API_KEY = 'your_gpugeek_api_token';
设置请求 URL
const url = 'https://api.gpugeek.com/predictions';
设置请求头
const headers = {
     "Authorization": "Bearer API_KEY",
     "Content-Type": "application/json",
     "Stream": "true"
 };
请求体数据
const data = {
      "model": "GpuGeek/DeepSeek-R1-671B",  // 替换成你的模型名称
     // 替换成实际的入参
     input: {
       "frequency_penalty": 0,
       "max_tokens": 8192,
       "prompt": "",
       "temperature": 0.6,
       "top_p": 0.7
 },
 };
发送 POST 请求
axios.post(url, data, {
     headers: headers,
     responseType: 'stream'  // 设置响应类型为流
 })
 .then(response => {
     const readableStream = Readable.from(response.data);
    readableStream.on('data', (chunk) => {
         console.log(chunk.toString('utf-8'));
     });
    readableStream.on('error', (err) => {
         console.error('Stream error:', err.message);
     });
 })
 .catch(error => {
     if (error.response) {
         console.error("Error:", error.response.status, error.response.statusText);
     } else {
         console.error("Error:", error.message);
     }
 });
OpenAI 兼容模式
安装 OpenAI
pip install openai==1.63.2
导入 OpenAI 模块
from openai import OpenAI
初始化 OpenAI 客户端
client = OpenAI(
     api_key="your_api_key",  # your api token
     base_url="https://api.gpugeek.com/v1",  # endpoint
 )
发送请求
stream = client.chat.completions.create(
     model="GpuGeek/DeepSeek-R1-671B",
     stream=True,
     frequency_penalty=0,
     max_tokens=8192,
     messages=[
         {
             "role": "user",
             "content": "",
         }
     ],
     temperature=0.6,
     top_p=0.7,
)
for chunk in stream:
     print(chunk.choices[0].delta.content)
GpuGeek-弹性|便捷|划算,您的专属AI云
