Create, submit, monitor, and retrieve asynchronous batch AI inference jobs via the Doubleword API using JSONL files for large or cost-sensitive workloads.
数据来源:ClawHub。 在 ClawSkills 查看
选择你使用的 Agent
方法一:命令行安装(推荐)
推荐(无需提前安装 clawhub)
npx clawhub@latest --dir ~/.claude/skills install doubleword-api或使用 clawhub CLI(需提前安装)
clawhub --dir ~/.claude/skills install doubleword-api⚠️ 需要 Node.js 18+,没有 Node?请使用下方方法二直接下载 ZIP。 安装 Node.js →
方法二:手动下载安装(无需 Node)
下载 ZIP,解压后将文件夹放到以下路径,重启 Agent 即可:
安装路径
~/.claude/skills/doubleword-api/💡解压后将文件夹放到上方路径,重启 Agent 即可生效
--- name: doubleword-batches description: Create and manage batch inference jobs using the Doubleword API (api.doubleword.ai). Use when users want to: (1) Process multiple AI requests in batch mode, (2) Submit JSONL batch files for async inference, (3) Monitor batch job progress and retrieve results, (4) Work with OpenAI-compatible batch endpoints, (5) Handle large-scale inference workloads that don't require immediate responses. ---
Process multiple AI inference requests asynchronously using the Doubleword batch API.
Batches are ideal for:
Basic workflow for any batch job:
Create a .jsonl file where each line contains a single request:
{"custom_id": "req-1", "method": "POST", "url": "/v1/chat/completions", "body": {"model": "anthropic/claude-3-5-sonnet", "messages": [{"role": "user", "content": "What is 2+2?"}]}}
{"custom_id": "req-2", "method": "POST", "url": "/v1/chat/completions", "body": {"model": "anthropic/claude-3-5-sonnet", "messages": [{"role": "user", "content": "What is the capital of France?"}]}}
Required fields per line:
custom_id: Unique identifier (max 64 chars) - use descriptive IDs like "user-123-question-5" for easier result mappingmethod: Always "POST"url: Always "/v1/chat/completions"body: Standard API request with model and messagesOptional body parameters:
temperature: 0-2 (default: 1.0)max_tokens: Maximum response tokenstop_p: Nucleus sampling parameterstop: Stop sequencesFile limits:
Helper script: Use scripts/create_batch_file.py to generate JSONL files programmatically:
python scripts/create_batch_file.py output.jsonl
Modify the script's requests list to generate your specific batch requests.
Upload the JSONL file:
curl https://api.doubleword.ai/v1/files \
-H "Authorization: Bearer $DOUBLEWORD_API_KEY" \
-F purpose="batch" \
-F file="@batch_requests.jsonl"
Response contains id field - save this file ID for next step.
Create the batch job using the file ID:
curl https://api.doubleword.ai/v1/batches \
-H "Authorization: Bearer $DOUBLEWORD_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"input_file_id": "file-abc123",
"endpoint": "/v1/chat/completions",
"completion_window": "24h"
}'
Parameters:
input_file_id: File ID from upload stependpoint: Always "/v1/chat/completions"completion_window: Choose "24h" (better pricing) or "1h" (50% premium, faster results)Response contains batch id - save this for status polling.
Check batch progress:
curl https://api.doubleword.ai/v1/batches/batch-xyz789 \
-H "Authorization: Bearer $DOUBLEWORD_API_KEY"
Status progression:
validating - Checking input file formatin_progress - Processing requestscompleted - All requests finishedOther statuses:
failed - Batch failed (check error_file_id)expired - Batch timed outcancelling/cancelled - Batch cancelledResponse includes:
output_file_id - Download results hereerror_file_id - Failed requests (if any)request_counts - Total/completed/failed countsPolling frequency: Check every 30-60 seconds during processing.
Early access: Results available via output_file_id before batch fully completes - check X-Incomplete header.
Download completed results:
curl https://api.doubleword.ai/v1/files/file-output123/content \
-H "Authorization: Bearer $DOUBLEWORD_API_KEY" \
> results.jsonl
Response headers:
X-Incomplete: true - Batch still processing, more results comingX-Last-Line: 45 - Resume point for partial downloadsOutput format (each line):
{
"id": "batch-req-abc",
"custom_id": "request-1",
"response": {
"status_code": 200,
"body": {
"id": "chatcmpl-xyz",
"choices": [{
"message": {
"role": "assistant",
"content": "The answer is 4."
}
}]
}
}
}
Download errors (if any):
curl https://api.doubleword.ai/v1/files/file-error123/content \
-H "Authorization: Bearer $DOUBLEWORD_API_KEY" \
> errors.jsonl
Error format (each line):
{
"id": "batch-req-def",
"custom_id": "request-2",
"error": {
"code": "invalid_request",
"message": "Missing required parameter"
}
}
curl https://api.doubleword.ai/v1/batches?limit=10 \
-H "Authorization: Bearer $DOUBLEWORD_API_KEY"
curl https://api.doubleword.ai/v1/batches/batch-xyz789/cancel \
-X POST \
-H "Authorization: Bearer $DOUBLEWORD_API_KEY"
Notes:
Parse JSONL output line-by-line:
import json
with open('results.jsonl') as f:
for line in f:
result = json.loads(line)
custom_id = result['custom_id']
content = result['response']['body']['choices'][0]['message']['content']
print(f"{custom_id}: {content}")
Check for incomplete batches and resume:
import requests
response = requests.get(
'https://api.doubleword.ai/v1/files/file-output123/content',
headers={'Authorization': f'Bearer {api_key}'}
)
if response.headers.get('X-Incomplete') == 'true':
last_line = int(response.headers.get('X-Last-Line', 0))
print(f"Batch incomplete. Processed {last_line} requests so far.")
# Continue polling and download again later
Extract failed requests from error file and resubmit:
import json
failed_ids = []
with open('errors.jsonl') as f:
for line in f:
error = json.loads(line)
failed_ids.append(error['custom_id'])
print(f"Failed requests: {failed_ids}")
# Create new batch with only failed requests
- Good: "user-123-question-5" - Bad: "1", "req1"
24h for cost savings, 1h only when time-sensitiveerror_file_id and retry failed requestscompleted/total ratioFor complete API details including authentication, rate limits, and advanced parameters, see:
references/api_reference.md - Full endpoint documentation and schemas安装 Doubleword API 后,可以对 AI 说这些话来触发它
Help me get started with Doubleword API
Explains what Doubleword API does, walks through the setup, and runs a quick demo based on your current project
Use Doubleword API to create, submit, monitor, and retrieve asynchronous batch AI inferen...
Invokes Doubleword API with the right parameters and returns the result directly in the conversation
What can I do with Doubleword API in my marketing & growth workflow?
Lists the top use cases for Doubleword API, with example commands for each scenario
将技能文件夹放到 ~/.claude/skills/doubleword-api/ 目录(个人级,所有项目可用),或 .claude/skills/doubleword-api/(项目级)。重启 AI 客户端后,用 /doubleword-api 主动调用,或让 AI 根据上下文自动发现并使用。
Doubleword API 支持 Claude、Cursor、OpenClaw,可与这些 AI 平台无缝集成,扩展其能力。
Doubleword API 可免费安装使用。请查阅仓库了解许可证信息。
Create, submit, monitor, and retrieve asynchronous batch AI inference jobs via the Doubleword API using JSONL files for large or cost-sensitive workloads.
Doubleword API 属于「Marketing & Growth」分类,该分类的技能帮助 AI 智能体在此领域执行专业任务。
Automate my marketing & growth tasks using Doubleword API
Identifies repetitive steps in your workflow and sets up Doubleword API to handle them automatically