Generate professional writing with Claude via HTTP. Requires a Business plan API key.
Authorization: Bearer sn_...https://your-domain.com
Locally: http://localhost:3000
Include your API key in every request:
Authorization: Bearer sn_your_api_key_here
sn_Stream an AI-generated response from your prompt.
| Header | Required | Description |
|---|---|---|
Authorization | Yes | Bearer sn_... |
Content-Type | Yes | application/json |
| Field | Type | Required | Description |
|---|---|---|---|
prompt | string | Yes | Full writing instruction (max 12,000 characters) |
toolId | string | No | Template ID for history (e.g. cover-letter) |
toolName | string | No | Human-readable label saved to history |
tone | string | No | Tone used (e.g. professional) |
{
"prompt": "Write a cover letter for Alex Johnson applying for Senior PM at Acme Corp...",
"toolId": "cover-letter",
"toolName": "Cover letter",
"tone": "professional"
}
Returns text/event-stream in Anthropic-compatible SSE format. Parse data: lines as JSON events. Text arrives in content_block_delta events:
data: {"type":"content_block_delta","delta":{"type":"text_delta","text":"Hello"}}
data: {"type":"message_stop"}
| Header | Description |
|---|---|
X-Plan-Tier | Your effective plan (business) |
X-Priority | true for priority processing |
curl -N -X POST https://your-domain.com/api/v1/generate \
-H "Authorization: Bearer sn_YOUR_KEY" \
-H "Content-Type: application/json" \
-d '{"prompt":"Write a professional cold email to a SaaS founder about partnership opportunities.","tone":"confident"}'
const res = await fetch('https://your-domain.com/api/v1/generate', {
method: 'POST',
headers: {
'Authorization': 'Bearer sn_YOUR_KEY',
'Content-Type': 'application/json',
},
body: JSON.stringify({
prompt: 'Write a LinkedIn bio for a fintech founder...',
toolId: 'linkedin-bio',
tone: 'professional',
}),
});
const reader = res.body.getReader();
const decoder = new TextDecoder();
let output = '';
while (true) {
const { done, value } = await reader.read();
if (done) break;
for (const line of decoder.decode(value).split('\n')) {
if (!line.startsWith('data: ')) continue;
try {
const event = JSON.parse(line.slice(6));
if (event.type === 'content_block_delta' && event.delta?.text) {
output += event.delta.text;
process.stdout.write(event.delta.text);
}
} catch {}
}
}
import requests, json
url = "https://your-domain.com/api/v1/generate"
headers = {
"Authorization": "Bearer sn_YOUR_KEY",
"Content-Type": "application/json",
}
payload = {"prompt": "Write ad copy for a fitness app...", "tone": "persuasive"}
with requests.post(url, headers=headers, json=payload, stream=True) as r:
r.raise_for_status()
for line in r.iter_lines():
if not line or not line.startswith(b"data: "):
continue
data = line[6:].decode()
try:
event = json.loads(data)
if event.get("type") == "content_block_delta":
print(event["delta"].get("text", ""), end="", flush=True)
except json.JSONDecodeError:
pass
| Status | Meaning |
|---|---|
400 | Missing or invalid prompt, or prompt too long |
401 | Invalid or missing API key |
403 | API access requires Business plan |
429 | Rate or usage limit reached |
502 | Upstream AI service error |
503 | AI service not configured on server |
JSON error shape:
{"error": "Invalid or missing API key. Use Authorization: Bearer sn_..."}
| Limit | Business plan |
|---|---|
| Generations | Unlimited |
| Max prompt length | 12,000 characters |
| Max output tokens | 2,000 per request |
| API keys per account | 3 |
| Rate limit (free-tier fallback) | Skipped for Business |
Generate and revoke keys from the web app: Account → API keys. Team members on a Business account inherit Business features but only the account owner can manage billing; API keys are tied to the user who creates them.
Business customers get priority support: hello@sparknous.com