快速开始
通过以下步骤,快速集成文章君开放平台 API。
1
注册账号并获取 API Key
首先,您需要注册一个账号。新用户注册后将获得 5 元体验金。
2
发起 API 请求
所有 API 请求需要在 Header 中携带您的 API Key:
cURL
curl -X POST https://api.wenzhang.jun/open/v1/draft/generate \
-H "Content-Type: application/json" \
-H "X-API-Key: ak_xxx.sk_xxx" \
-d '{
"title": "人工智能在教育领域的应用研究",
"major": "计算机科学与技术",
"requirements": "包含案例分析",
"word_count": 8000
}'Python
import requests
api_key = "ak_xxx.sk_xxx"
url = "https://api.wenzhang.jun/open/v1/draft/generate"
headers = {
"Content-Type": "application/json",
"X-API-Key": api_key
}
data = {
"title": "人工智能在教育领域的应用研究",
"major": "计算机科学与技术",
"requirements": "包含案例分析",
"word_count": 8000
}
response = requests.post(url, json=data, headers=headers)
result = response.json()
print(result)Node.js
const axios = require('axios');
const apiKey = 'ak_xxx.sk_xxx';
const url = 'https://api.wenzhang.jun/open/v1/draft/generate';
const data = {
title: '人工智能在教育领域的应用研究',
major: '计算机科学与技术',
requirements: '包含案例分析',
word_count: 8000
};
axios.post(url, data, {
headers: {
'Content-Type': 'application/json',
'X-API-Key': apiKey
}
}).then(response => {
console.log(response.data);
}).catch(error => {
console.error(error.response.data);
});3
处理响应
成功的请求会返回以下格式的 JSON 响应:
{
"code": 0,
"message": "ok",
"data": {
"request_id": "req_abc123",
"content": "生成的论文内容...",
"word_count": 8234,
"cost": 12.35,
"balance": 87.65,
"created_at": "2024-01-15T10:30:00Z"
}
}如果请求失败,会返回错误信息:
{
"code": 402,
"message": "账户余额不足,请充值后重试",
"data": null
}注意事项
- API Key 创建后,Secret Key 只会显示一次,请妥善保管
- 每个用户最多创建 100 个 API Key
- 同一服务的并发请求默认限制为 6 个,如需提升请联系客服
- 请求前会冻结预估费用,请确保账户余额充足