Clef Flash
快速返回判断概率、分类和评分,支持 24K 上下文。
模型 ID(请求中的 model 字段)
clef-flash快速开始#
- 创建 API Key
在控制台 我的 Key 创建通用 API Key(明文只显示一次),并确认账户余额充足。
- 设置环境变量
export TOKENTOSEA_API_KEY="sk-relay_…",示例从环境变量读取密钥。 - 发送请求
以下为 System One · JSON 示例;其他接口见全部调用示例。
export TOKENTOSEA_API_KEY="你的主站通用 API Key"
REQUEST_KEY="$(uuidgen)"
curl https://api.tokentosea.com/v1/systemone \
-H "Authorization: Bearer $TOKENTOSEA_API_KEY" \
-H "Idempotency-Key: $REQUEST_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "clef-flash",
"state": "Checkout has been failing for every customer for the last hour.",
"questions": {
"urgent": {
"type": "noul",
"instructions": "Is this an urgent service outage?"
}
}
}'
# 查询原请求;异步任务未结束时稍后继续查询,不要重复提交。
curl "https://api.tokentosea.com/v1/results/$REQUEST_KEY" \
-H "Authorization: Bearer $TOKENTOSEA_API_KEY"
# 返回 asset_id 后,获取短期有效的 COS 下载链接。
# curl "https://api.tokentosea.com/v1/assets/ASSET_ID/download-url" \
# -H "Authorization: Bearer $TOKENTOSEA_API_KEY"# pip install requests
# export TOKENTOSEA_API_KEY="你的主站通用 API Key"
import json
import os
import time
import uuid
import requests
API_BASE = "https://api.tokentosea.com"
API_KEY = os.environ["TOKENTOSEA_API_KEY"] # 控制台「我的 Key」创建的通用 API Key
REQUEST_KEY = str(uuid.uuid4()) # Idempotency-Key:重试或查询结果时复用同一个值
AUTH = {"Authorization": f"Bearer {API_KEY}"}
PENDING = {"planned", "sending", "streaming", "upstream_pending", "billing", "archiving"}
payload = {
"model": "clef-flash",
"state": "Checkout has been failing for every customer for the last hour.",
"questions": {
"urgent": {"type": "noul", "instructions": "Is this an urgent service outage?"},
},
}
def show(data):
print(json.dumps(data, ensure_ascii=False, indent=2))
def wait_for_result():
"""查询原请求;异步任务未结束时稍后继续查询,不要重复提交。"""
while True:
result = requests.get(f"{API_BASE}/v1/results/{REQUEST_KEY}", headers=AUTH, timeout=30).json()
if result.get("status") not in PENDING:
return result
time.sleep(5)
try:
response = requests.post(
f"{API_BASE}/v1/systemone",
headers={**AUTH, "Idempotency-Key": REQUEST_KEY},
json=payload,
timeout=1300,
)
print(response.status_code, response.headers.get("X-Request-Id"))
show(response.json())
except requests.RequestException as error:
# 连接中断时请求可能已被受理:用同一个 REQUEST_KEY 查询结果,不要重新提交。
print("\n请求中断:", error)
result = wait_for_result()
print("结果:", result.get("status"), "结算:", result.get("billing_status"), result.get("error") or "")// Node.js 18+,无需额外依赖。保存为 example.mjs 后运行:node example.mjs
// export TOKENTOSEA_API_KEY="你的主站通用 API Key"
import { randomUUID } from 'node:crypto';
const API_BASE = 'https://api.tokentosea.com';
const API_KEY = process.env.TOKENTOSEA_API_KEY; // 控制台「我的 Key」创建的通用 API Key
const REQUEST_KEY = randomUUID(); // Idempotency-Key:重试或查询结果时复用同一个值
const auth = { Authorization: `Bearer ${API_KEY}` };
const PENDING = new Set(['planned', 'sending', 'streaming', 'upstream_pending', 'billing', 'archiving']);
const payload = {
model: 'clef-flash',
state: 'Checkout has been failing for every customer for the last hour.',
questions: {
urgent: { type: 'noul', instructions: 'Is this an urgent service outage?' },
},
};
const show = data => console.log(JSON.stringify(data, null, 2));
// 查询原请求;异步任务未结束时稍后继续查询,不要重复提交。
async function waitForResult() {
for (;;) {
const result = await fetch(`${API_BASE}/v1/results/${REQUEST_KEY}`, { headers: auth }).then(r => r.json());
if (!PENDING.has(result.status)) return result;
await new Promise(resolve => setTimeout(resolve, 5000));
}
}
try {
const response = await fetch(`${API_BASE}/v1/systemone`, {
method: 'POST',
headers: { ...auth, 'Idempotency-Key': REQUEST_KEY, 'Content-Type': 'application/json' },
body: JSON.stringify(payload),
});
console.log(response.status, response.headers.get('x-request-id'));
show(await response.json());
} catch (error) {
// 连接中断时请求可能已被受理:用同一个 REQUEST_KEY 查询结果,不要重新提交。
console.error('\n请求中断:', error.message);
}
const result = await waitForResult();
console.log('结果:', result.status, '结算:', result.billing_status, result.error ?? '');能力与接口#
结构化判断 概率判断 分类选择 分级评分 图像判断
下表只列出已在该型号上完成验收的接口、响应方式与输入类型;其他组合会返回 422(如 endpoint_not_verified、response_mode_not_verified、input_modality_not_verified)。
| 接口 | JSON | SSE 流式 | WebSocket | 已验证输入 |
|---|---|---|---|---|
System One/v1/systemone | 支持 | 不支持 | 不支持 | 文本、图片 |
支持的判断原语:noul、choice、score。详见 System One 指南。
价格#
官方价格以美元(USD)公布,核对日期 2026-10-21。TokenToSea 按官方价格计费、不加价;调用从账户余额(美元)扣除,美元价格直接扣费,金额保留 6 位小数并向上取整。
| 计费项 | 单价 | 计量单位 |
|---|---|---|
| 输入 token | $0.038 | 每百万 token |
- 官方原价,仅按供应商 usage.input_tokens 计费;不使用字符估算,输出免费。
- 模型页旧价格与现行账户目录不一致;采用账户 API 与 2026-10-09 官方公告一致的 USD 0.038 / 百万输入 token、24576 token 上限。
每次请求先按可能的最高用量预留金额,完成后按供应商返回的实际用量结算并退回差额。计费方式详见计费与结算。
官方价格来源
- developers.cloudflare.com/workers-ai/models/clef-flash/
- developers.cloudflare.com/changelog/post/2026-10-09-clef-omni-workers-ai/
限制#
| 项目 | 取值 | 说明 |
|---|---|---|
| 上下文窗口 | 24,576 token | 厂商文档 |
| 单次输入上限 | 24,576 token | 平台校验,超出返回错误 |
响应方式:JSON。
- 同一账户最多同时进行 8 个已预留或执行中的调用(平台规则)。
- 请求体不超过 32 MiB(gzip / zstd 压缩的请求按解压后大小计算),按紧凑 JSON 计算不超过 13 MiB。
- 最多 64 个问题、4 张图片(单张 4 MiB、合计 8 MiB);媒体使用 data URI 或
{content_type, base64}。
全部调用示例#
每个示例都包含 cURL、Python 与 Node.js 三种写法,发送完全相同的请求体,并用同一个 Idempotency-Key 查询结果。
System One · JSON#
POST /v1/systemone 接口参考
export TOKENTOSEA_API_KEY="你的主站通用 API Key"
REQUEST_KEY="$(uuidgen)"
curl https://api.tokentosea.com/v1/systemone \
-H "Authorization: Bearer $TOKENTOSEA_API_KEY" \
-H "Idempotency-Key: $REQUEST_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "clef-flash",
"state": "Checkout has been failing for every customer for the last hour.",
"questions": {
"urgent": {
"type": "noul",
"instructions": "Is this an urgent service outage?"
}
}
}'
# 查询原请求;异步任务未结束时稍后继续查询,不要重复提交。
curl "https://api.tokentosea.com/v1/results/$REQUEST_KEY" \
-H "Authorization: Bearer $TOKENTOSEA_API_KEY"
# 返回 asset_id 后,获取短期有效的 COS 下载链接。
# curl "https://api.tokentosea.com/v1/assets/ASSET_ID/download-url" \
# -H "Authorization: Bearer $TOKENTOSEA_API_KEY"# pip install requests
# export TOKENTOSEA_API_KEY="你的主站通用 API Key"
import json
import os
import time
import uuid
import requests
API_BASE = "https://api.tokentosea.com"
API_KEY = os.environ["TOKENTOSEA_API_KEY"] # 控制台「我的 Key」创建的通用 API Key
REQUEST_KEY = str(uuid.uuid4()) # Idempotency-Key:重试或查询结果时复用同一个值
AUTH = {"Authorization": f"Bearer {API_KEY}"}
PENDING = {"planned", "sending", "streaming", "upstream_pending", "billing", "archiving"}
payload = {
"model": "clef-flash",
"state": "Checkout has been failing for every customer for the last hour.",
"questions": {
"urgent": {"type": "noul", "instructions": "Is this an urgent service outage?"},
},
}
def show(data):
print(json.dumps(data, ensure_ascii=False, indent=2))
def wait_for_result():
"""查询原请求;异步任务未结束时稍后继续查询,不要重复提交。"""
while True:
result = requests.get(f"{API_BASE}/v1/results/{REQUEST_KEY}", headers=AUTH, timeout=30).json()
if result.get("status") not in PENDING:
return result
time.sleep(5)
try:
response = requests.post(
f"{API_BASE}/v1/systemone",
headers={**AUTH, "Idempotency-Key": REQUEST_KEY},
json=payload,
timeout=1300,
)
print(response.status_code, response.headers.get("X-Request-Id"))
show(response.json())
except requests.RequestException as error:
# 连接中断时请求可能已被受理:用同一个 REQUEST_KEY 查询结果,不要重新提交。
print("\n请求中断:", error)
result = wait_for_result()
print("结果:", result.get("status"), "结算:", result.get("billing_status"), result.get("error") or "")// Node.js 18+,无需额外依赖。保存为 example.mjs 后运行:node example.mjs
// export TOKENTOSEA_API_KEY="你的主站通用 API Key"
import { randomUUID } from 'node:crypto';
const API_BASE = 'https://api.tokentosea.com';
const API_KEY = process.env.TOKENTOSEA_API_KEY; // 控制台「我的 Key」创建的通用 API Key
const REQUEST_KEY = randomUUID(); // Idempotency-Key:重试或查询结果时复用同一个值
const auth = { Authorization: `Bearer ${API_KEY}` };
const PENDING = new Set(['planned', 'sending', 'streaming', 'upstream_pending', 'billing', 'archiving']);
const payload = {
model: 'clef-flash',
state: 'Checkout has been failing for every customer for the last hour.',
questions: {
urgent: { type: 'noul', instructions: 'Is this an urgent service outage?' },
},
};
const show = data => console.log(JSON.stringify(data, null, 2));
// 查询原请求;异步任务未结束时稍后继续查询,不要重复提交。
async function waitForResult() {
for (;;) {
const result = await fetch(`${API_BASE}/v1/results/${REQUEST_KEY}`, { headers: auth }).then(r => r.json());
if (!PENDING.has(result.status)) return result;
await new Promise(resolve => setTimeout(resolve, 5000));
}
}
try {
const response = await fetch(`${API_BASE}/v1/systemone`, {
method: 'POST',
headers: { ...auth, 'Idempotency-Key': REQUEST_KEY, 'Content-Type': 'application/json' },
body: JSON.stringify(payload),
});
console.log(response.status, response.headers.get('x-request-id'));
show(await response.json());
} catch (error) {
// 连接中断时请求可能已被受理:用同一个 REQUEST_KEY 查询结果,不要重新提交。
console.error('\n请求中断:', error.message);
}
const result = await waitForResult();
console.log('结果:', result.status, '结算:', result.billing_status, result.error ?? '');相关文档#
在控制台测试#
登录后可在 模型测试 页面直接调用 clef-flash,查看返回结果、token 用量与实际扣费。网页调用同样从账户余额扣费。