要求#
Python 3.11 或更高版本。无需额外包。将 WEIGHTSAPI_API_KEY 设置为您的密钥。AI 访问需要登录、一次至少 100 美元的确认充值、一个已授权的 API 密钥以及足够的可用余额。每次后续充值的最低金额也为 100 美元;较小的剩余余额在足以支付请求时仍可使用。余额需要交易验证。发送流量前请查看服务状态 了解模型可用性。
运行配方#
import os, json, time, urllib.request
BASE = os.environ.get("WEIGHTSAPI_BASE_URL", "https://weightsapi.com/v1")
KEY = os.environ["WEIGHTSAPI_API_KEY"]
# Confirm batch-service availability before attempting upload or submission.
with open("batch.jsonl", "w", encoding="utf-8") as f:
for i in range(100_000):
f.write(json.dumps({"custom_id":str(i),"method":"POST","url":"/v1/chat/completions",
"body":{"model":"Qwen/Qwen3-32B","messages":[{"role":"user","content":"Summarize document "+str(i)}],"max_tokens":64}})+"\n")
print("Wrote 100,000 independent requests to batch.jsonl.")
print("Upload with the provider's batch adapter, then submit /v1/batches with completion_window=24h.")
print("Do not send this file to the synchronous endpoint: the batch discount applies only to batch jobs.")