Client Examples
CheapAI currently ships HTTP/client examples rather than an official SDK package. The snippets below use the current task-based voice and image API.
🐍 Python
Install
pip install requestsPython
import requests
API_KEY = "sk_your_api_key"
BASE = "https://api.cheapaiapi.com"
# Create a TTS task
create_res = requests.post(
f"{BASE}/v1/text-to-speech/21m00Tcm4TlvDq8ikWAM?output_format=mp3_44100_128",
headers={
"Authorization": f"Bearer {API_KEY}",
"Content-Type": "application/json",
},
json={
"text": "The first move is what sets everything in motion.",
"model_id": "eleven_multilingual_v2",
},
)
task = create_res.json()
print(task)
# Poll task result
task_id = task["task_id"]
result = requests.get(
f"{BASE}/v1/task/{task_id}",
headers={"Authorization": f"Bearer {API_KEY}"},
)
print(result.json())🟢 Node.js / TypeScript
Install
npm install undiciNode.js / TypeScript
const API_KEY = 'sk_your_api_key';
const BASE = 'https://api.cheapaiapi.com';
const createRes = await fetch(
`${BASE}/v1e/task/text-to-speech`,
{
method: 'POST',
headers: {
Authorization: `Bearer ${API_KEY}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({
text: 'Hello, this is a test.',
voice: 'en-US-AriaNeural',
with_transcript: true,
}),
}
);
const task = await createRes.json();
console.log(task);
const resultRes = await fetch(`${BASE}/v1e/task/${task.task_id}`, {
headers: { Authorization: `Bearer ${API_KEY}` },
});
console.log(await resultRes.json());📟 cURL
cURL
# Get balance
curl https://api.cheapaiapi.com/v1/credits \
-H "Authorization: Bearer sk_your_api_key" \
-H "Content-Type: application/json"
# Generate image
curl -X POST https://api.cheapaiapi.com/v1i/task/generate-image \
-H "Authorization: Bearer sk_your_api_key" \
-H "Content-Type: application/json" \
-d '{
"prompt": "A sunset over mountains",
"model_id": "bytedance-seedream-4.5",
"generations_count": 1,
"model_parameters": { "aspect_ratio": "16:9", "resolution": "2K" }
}'
# Manage API keys
curl https://api.cheapaiapi.com/v1/api-keys \
-H "Authorization: Bearer sk_your_api_key" \
-H "Content-Type: application/json"Integration Notes
For the current product shape, most teams build with a thin service wrapper around fetch or requests:
- → Use bearer auth with
Authorization: Bearer sk_... - → Expect async tasks for most generation endpoints
- → Poll task routes or use webhook callbacks where supported
- → Use separate keys for prod, staging, and experiments