API 文档

兼容 OpenAI。你的代码要是已经在用 OpenAI SDK,改两行就完事。下面先是 5 分钟上手,然后是全部细节。

快速上手

  1. 打开 API 控制台,建一把密钥。把 cgw-sk-... 那串复制走 —— 只显示一次。
  2. 充值 USDT 余额,入口在 账单页。1 美元够你试上一阵了。
  3. 发一次请求:
cURL
curl https://cloudgpu.app/v1/chat/completions \ -H "Content-Type: application/json" \ -H "Authorization: Bearer $CGW_API_KEY" \ -d '{ "model": "deepseek-v4-flash", "messages": [ {"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Say hi in one sentence."} ] }'

鉴权

每一次请求 /v1/* requires an Authorization: Bearer cgw-sk-<your_key> header. Keys are scoped to your CloudGPU account. Revoke any key any time from the console; revocation takes effect immediately.

The raw key is shown exactly once at creation time. We store only a sha256 hash; we cannot recover it if you lose it. Create a new key if that happens.

接口

方法路径用途
POST/v1/chat/completionsOpenAI 格式的对话补全。请求和响应的结构跟 OpenAI 一样。
GET/v1/models列出可用模型,以及当前每 token 的价格。

向量、函数调用、视觉、图像生成 —— 在计划里,v0 还没有。

流式输出

在请求体里带上 "stream": true。响应是 OpenAI 格式的 Server-Sent Events。OpenAI SDK 会自己处理好。

Python (streaming)
# Streaming — same client, stream=True for chunk in client.chat.completions.create( model="deepseek-v4-flash", messages=[{"role": "user", "content": "Count to 5."}], stream=True, ): delta = chunk.choices[0].delta.content if delta: print(delta, end="", flush=True)

SDK

我们不做自己的 SDK —— OpenAI SDK 原样就能用,只要改 base_url 覆盖。

Python
# pip install openai>=1.0 from openai import OpenAI client = OpenAI( api_key="cgw-sk-...", # from /api/console base_url="https://cloudgpu.app/v1", ) resp = client.chat.completions.create( model="deepseek-v4-flash", messages=[{"role": "user", "content": "Say hi."}], ) print(resp.choices[0].message.content) print(f"Used {resp.usage.total_tokens} tokens")
Node.js
// npm install openai import OpenAI from "openai"; const client = new OpenAI({ apiKey: process.env.CGW_API_KEY, baseURL: "https://cloudgpu.app/v1", }); const resp = await client.chat.completions.create({ model: "deepseek-v4-flash", messages: [{ role: "user", content: "Say hi." }], }); console.log(resp.choices[0].message.content);

价格与计费

Every model is priced 比它自家官网便宜 for the same model — see the 价目表. You pay per token, per image, per character or per second of audio depending on the model; nothing is metered by the hour and there is no monthly minimum.

Each request deducts from your prepaid balance. Successful calls show in your 控制台 within ~1 second with full token counts and dollar cost.

完整的分模型价目表在介绍页.

限流

每把密钥每分钟100 次请求
每个账号每天10000 次请求

这些默认值是公测期防滥用用的。需要提额就找我们 —— 只要是真实业务都可以提,说一下用途就行。

错误码

报错的结构和 OpenAI 一样:HTTP 状态码加上 JSON 正文 { error: { type, code, message } }.

状态什么时候会出现
401missing_authorization没有带 Authorization 请求头。
401invalid_api_key密钥不存在或已被吊销。
400model_not_found模型 id 不在目录里。看 GET /v1/models。
402insufficient_balanceUSDT 余额低于 $0.01。请充值。
429rate_limit_exceeded撞到每分钟或每天的限额了。
503upstream_not_configured网关正在开通 —— 几个小时内会好。

准备好了?

领取 API 密钥