요구 사항#
Python 3.11 이상. 추가 패키지 불필요. WEIGHTSAPI_API_KEY를 자신의 키로 설정하세요. AI 접근에는 로그인, 최소 100 USD의 확인된 충전 1회, 승인된 API 키, 요청에 충분한 사용 가능 크레딧이 필요합니다. 이후 각 충전도 최소 100 USD이며, 요청을 충당할 때 더 적은 잔액도 계속 사용할 수 있습니다. 크레딧은 거래 검증이 필요합니다. 트래픽을 보내기 전에 모델 가용성은 서비스 상태를 확인하세요.
레시피 실행#
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.")