开发者文档

接入黑云 API Hub,快速集成主流 AI 模型。

快速开始

1. 注册账号

访问 https://2685336309.icu 注册黑云账户。新用户注册即获赠 100,000 Token 免费额度,无需信用卡,开箱即用。

2. 创建 API Key

登录 黑云控制台,在「API 密钥」页面创建一个新的密钥。请妥善保管 API Key,创建后仅显示一次。

💡 提示:每个账户最多可创建 5 个 API Key,建议为不同应用分配不同的 Key 以便管理。

3. 发起首次 API 请求

获得 API Key 后,使用以下命令进行首次调用:

cURL
curl https://2685336309.icu/v1/chat/completions \
  -H "Authorization: Bearer sk-your-api-key" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "deepseek-chat",
    "messages": [{"role": "user", "content": "你好,请介绍一下自己"}]
  }'

📌 API 基础地址:所有请求均使用 https://2685336309.icu/v1 作为基础 URL。

认证方式

Bearer Token 认证

黑云 API 采用标准的 Bearer Token 认证方式。所有请求必须在 HTTP Header 中包含 Authorization 字段:

HTTP Header
Authorization: Bearer sk-你的API密钥

安全建议

⚠️ 注意:如果 API Key 泄露,请立即在控制台删除并重新生成。

模型列表

黑云支持多个渠道的 AI 模型。每个模型有独立的定价和上下文长度限制。以下为完整价格表。

DeepSeek

模型输入 (¥/1K tokens)输出 (¥/1K tokens)上下文
deepseek-chat0.000140.0002864K
deepseek-coder0.000140.0002816K

Kimi Moonshot

模型输入 (¥/1K tokens)输出 (¥/1K tokens)上下文
moonshot-v1-8k0.001700.001708K
moonshot-v1-32k0.003410.0034132K
moonshot-v1-128k0.008520.00852128K

通义千问 Alibaba Qwen

模型输入 (¥/1K tokens)输出 (¥/1K tokens)上下文
qwen-turbo0.002860.002861M
qwen-plus0.002860.00286128K
qwen-max0.002860.0028632K
qwen-long0.002860.0028610M
qwen2.5-7b-instruct0.002860.0028632K
qwen2.5-14b-instruct0.002860.0028632K
qwen2.5-32b-instruct0.002860.0028632K
qwen2.5-72b-instruct0.002860.0028632K

智谱 ChatGLM

模型输入 (¥/1K tokens)输出 (¥/1K tokens)上下文
glm-40.007100.00710128K
glm-4-plus0.007100.00710128K
glm-4-air0.000070.00007128K
glm-4-flash免费 🆓免费 🆓128K
glm-4-long0.000140.000141M
glm-4-05200.007100.00710128K
glm-4v0.007100.00710128K

SiliconFlow

模型输入 (¥/1K tokens)输出 (¥/1K tokens)上下文
Pro/deepseek-ai/DeepSeek-V30.001330.00133128K
Pro/deepseek-ai/DeepSeek-R10.0040.01664K
Qwen/Qwen2.5-72B-Instruct0.0040.004128K
Qwen/QwQ-32B0.0010.00132K
internlm/internlm3-8b-instruct0.000720.0007232K
deepseek-ai/DeepSeek-V2.50.000720.00072128K

MXAPI-AI

模型输入 (¥/1K tokens)输出 (¥/1K tokens)上下文
gpt-40.030000.060008K
gpt-4o0.005000.02000128K
gpt-4o-mini0.000150.00060128K
gpt-3.5-turbo0.000500.0015016K
deepseek-chat0.001000.0020064K
claude-3-5-sonnet0.003000.01500200K

API 参考 — 聊天补全

黑云 API 完全兼容 OpenAI 的 Chat Completions 接口格式,主流 SDK 无需额外适配即可使用。

📌 兼容性:支持 openai Python 库、openai Node.js 库等主流 OpenAI SDK。

POST /v1/chat/completions

创建一个聊天补全请求。

请求参数

参数类型说明必填
modelstring模型名称,如 deepseek-chat
messagesarray消息列表,包含 rolecontent
max_tokensinteger最大生成 Token 数,默认 4096
temperaturenumber采样温度 (0–2),默认 1.0
top_pnumber核采样参数 (0–1),默认 1.0
streamboolean是否流式返回,默认 false
stopstring/array停止序列
frequency_penaltynumber频率惩罚 (-2–2)
presence_penaltynumber存在惩罚 (-2–2)

请求示例

cURL

Bash
curl https://2685336309.icu/v1/chat/completions \
  -H "Authorization: Bearer sk-your-api-key" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "deepseek-chat",
    "messages": [
      {"role": "system", "content": "你是一位助手"},
      {"role": "user", "content": "介绍一下大模型的基本原理"}
    ],
    "max_tokens": 1024,
    "temperature": 0.7
  }'

Python

Python
from openai import OpenAI

client = OpenAI(
    base_url="https://2685336309.icu/v1",
    api_key="sk-your-api-key"
)

response = client.chat.completions.create(
    model="deepseek-chat",
    messages=[
        {"role": "system", "content": "你是一位助手"},
        {"role": "user", "content": "介绍一下大模型的基本原理"}
    ],
    max_tokens=1024,
    temperature=0.7
)

print(response.choices[0].message.content)

Node.js

Node.js
import OpenAI from 'openai';

const client = new OpenAI({
    baseURL: 'https://2685336309.icu/v1',
    apiKey: 'sk-your-api-key'
});

const response = await client.chat.completions.create({
    model: 'deepseek-chat',
    messages: [
        {role: 'system', content: '你是一位助手'},
        {role: 'user', content: '介绍一下大模型的基本原理'}
    ],
    max_tokens: 1024,
    temperature: 0.7
});

console.log(response.choices[0].message.content);

Java (OkHttp)

Java
// Maven 依赖:
// com.squareup.okhttp3:okhttp:4.12.0
// com.google.code.gson:gson:2.10.1

import okhttp3.*;
import com.google.gson.JsonObject;
import java.io.IOException;

public class ChatCompletionExample {
    public static void main(String[] args) throws IOException {
        OkHttpClient client = new OkHttpClient();

        JsonObject body = new JsonObject();
        body.addProperty("model", "deepseek-chat");

        JsonObject msg = new JsonObject();
        msg.addProperty("role", "user");
        msg.addProperty("content", "介绍一下大模型的基本原理");
        body.add("messages", new com.google.gson.JsonArray());
        body.getAsJsonArray("messages").add(msg);

        Request request = new Request.Builder()
            .url("https://2685336309.icu/v1/chat/completions")
            .addHeader("Authorization", "Bearer sk-your-api-key")
            .addHeader("Content-Type", "application/json")
            .post(RequestBody.create(
                MediaType.parse("application/json"),
                body.toString()
            ))
            .build();

        try (Response response = client.newCall(request).execute()) {
            System.out.println(response.body().string());
        }
    }
}

Go

Go
package main

import (
    "bytes"
    "encoding/json"
    "fmt"
    "io"
    "net/http"
)

func main() {
    requestBody, _ := json.Marshal(map[string]interface{}{
        "model": "deepseek-chat",
        "messages": []map[string]string{
            {"role": "user", "content": "介绍一下大模型的基本原理"},
        },
        "max_tokens":  1024,
        "temperature": 0.7,
    })

    req, _ := http.NewRequest(
        "POST",
        "https://2685336309.icu/v1/chat/completions",
        bytes.NewBuffer(requestBody),
    )
    req.Header.Set("Authorization", "Bearer sk-your-api-key")
    req.Header.Set("Content-Type", "application/json")

    client := &http.Client{}
    resp, err := client.Do(req)
    if err != nil {
        fmt.Println("Error:", err)
        return
    }
    defer resp.Body.Close()

    body, _ := io.ReadAll(resp.Body)
    fmt.Println(string(body))
}

响应格式

JSON
{
  "id": "chatcmpl-abc123",
  "object": "chat.completion",
  "created": 1680000000,
  "model": "deepseek-chat",
  "choices": [
    {
      "index": 0,
      "message": {
        "role": "assistant",
        "content": "大模型..."
      },
      "finish_reason": "stop"
    }
  ],
  "usage": {
    "prompt_tokens": 15,
    "completion_tokens": 200,
    "total_tokens": 215
  }
}

流式响应

设置 stream: true 即可启用流式响应,API 会以 Server-Sent Events (SSE) 格式逐块返回数据。每个数据块包含一个 delta 字段而非 message

SSE 示例
data: {"id":"chatcmpl-xxx","object":"chat.completion.chunk","choices":[{"index":0,"delta":{"content":"大"},"finish_reason":null}]}

data: {"id":"chatcmpl-xxx","object":"chat.completion.chunk","choices":[{"index":0,"delta":{"content":"模型"},"finish_reason":null}]}

data: {"id":"chatcmpl-xxx","object":"chat.completion.chunk","choices":[{"index":0,"delta":{},"finish_reason":"stop"}]}

data: [DONE]

API 参考 — 图像生成

通过图像生成 API,可以将文本描述转换为图像。兼容 OpenAI DALL-E 接口风格。

POST /v1/images/generations

参数类型说明必填
modelstring图像生成模型名称
promptstring文本描述,最多 1000 字符
ninteger生成数量 (1–4),默认 1
sizestring图像尺寸,如 1024x1024
qualitystring图像质量,standardhd
Bash
curl https://2685336309.icu/v1/images/generations \
  -H "Authorization: Bearer sk-your-api-key" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "dall-e-3",
    "prompt": "一只橘猫坐在服务器机房里,科技感,数字艺术",
    "n": 1,
    "size": "1024x1024"
  }'

多语言 SDK 示例

以下为各语言的完整可运行示例。只需替换 your-api-key 为真实 API Key 即可。

Python

使用 OpenAI 官方 Python SDK:

Python
from openai import OpenAI

client = OpenAI(
    base_url="https://2685336309.icu/v1",
    api_key="your-api-key"
)

response = client.chat.completions.create(
    model="deepseek-chat",
    messages=[{"role": "user", "content": "你好"}]
)

print(response.choices[0].message.content)

Node.js

使用 OpenAI 官方 Node.js SDK:

Node.js
import OpenAI from 'openai';

const client = new OpenAI({
    baseURL: 'https://2685336309.icu/v1',
    apiKey: 'your-api-key'
});

const response = await client.chat.completions.create({
    model: 'deepseek-chat',
    messages: [{role: 'user', content: '你好'}]
});

console.log(response.choices[0].message.content);

cURL

Bash
curl https://2685336309.icu/v1/chat/completions \
  -H "Authorization: Bearer your-api-key" \
  -H "Content-Type: application/json" \
  -d '{"model":"deepseek-chat","messages":[{"role":"user","content":"你好"}]}'

Java (OkHttp)

pom.xml 中添加依赖:

Maven
<dependency>
    <groupId>com.squareup.okhttp3</groupId>
    <artifactId>okhttp</artifactId>
    <version>4.12.0</version>
</dependency>
<dependency>
    <groupId>com.google.code.gson</groupId>
    <artifactId>gson</artifactId>
    <version>2.10.1</version>
</dependency>

Java 源代码:

Java
import okhttp3.*;
import com.google.gson.JsonObject;
import com.google.gson.JsonArray;
import java.io.IOException;

public class BlackCloudChat {
    public static void main(String[] args) throws IOException {
        OkHttpClient client = new OkHttpClient();

        JsonObject msg = new JsonObject();
        msg.addProperty("role", "user");
        msg.addProperty("content", "你好");

        JsonArray messages = new JsonArray();
        messages.add(msg);

        JsonObject body = new JsonObject();
        body.addProperty("model", "deepseek-chat");
        body.add("messages", messages);

        Request request = new Request.Builder()
            .url("https://2685336309.icu/v1/chat/completions")
            .addHeader("Authorization", "Bearer your-api-key")
            .addHeader("Content-Type", "application/json")
            .post(RequestBody.create(
                MediaType.parse("application/json"),
                body.toString()
            ))
            .build();

        try (Response response = client.newCall(request).execute()) {
            System.out.println(response.body().string());
        }
    }
}

Go

Go
package main

import (
    "bytes"
    "encoding/json"
    "fmt"
    "io"
    "net/http"
)

func main() {
    body := map[string]interface{}{
        "model": "deepseek-chat",
        "messages": []map[string]string{
            {"role": "user", "content": "你好"},
        },
    }

    jsonData, _ := json.Marshal(body)

    req, _ := http.NewRequest(
        "POST",
        "https://2685336309.icu/v1/chat/completions",
        bytes.NewBuffer(jsonData),
    )
    req.Header.Set("Authorization", "Bearer your-api-key")
    req.Header.Set("Content-Type", "application/json")

    client := &http.Client{}
    resp, err := client.Do(req)
    if err != nil {
        fmt.Println("请求失败:", err)
        return
    }
    defer resp.Body.Close()

    respBody, _ := io.ReadAll(resp.Body)
    fmt.Println(string(respBody))
}

错误码说明

HTTP 状态码错误类型说明解决方案
401invalid_api_key API Key 无效或未提供 检查请求头中是否包含正确的 Authorization: Bearer
402insufficient_quota 账户余额/额度不足 前往控制台 充值 或等待免费额度重置
404model_not_found 请求的模型不存在或未启用 检查 model 参数是否正确,参考模型列表
429rate_limit_exceeded 请求频率超出限制 降低请求频率,稍后重试
500upstream_error 上游模型服务异常 请稍后重试,如持续失败请联系客服
503service_unavailable 服务维护中 请稍后重试,关注控制台维护公告

📌 所有错误响应均包含:{"error": {"message": "...", "type": "...", "code": 401}}

使用限制

频率限制

为保障服务稳定性,API 接口有以下频率限制:

上下文长度

不同模型的上下文长度不同,详见上方 模型列表。超出上下文长度的请求会被截断或拒绝。

额度计算

费用按实际消耗的 Token 数量进行计费。Token 是模型处理文本的基本单位,一般约 750 个汉字 ≈ 1000 tokens。

💡 计算公式:
总费用 = 输入 Token 数 × 输入单价 + 输出 Token 数 × 输出单价
例如:调用 deepseek-chat,输入 500 tokens、输出 300 tokens:
500 × 0.00014 + 300 × 0.00028 = 0.154 元

最佳实践