Create an API key once to pre-fill a runnable submit + poll script.
#!/bin/bash
# Usage: chmod +x midjourney-v7-kinovi.sh && ./midjourney-v7-kinovi.sh
KINOVI_API_KEY="${KINOVI_API_KEY:?Set your API key: export KINOVI_API_KEY=your-api-key}"
# Submit task
RESPONSE=$(curl -s -X POST "https://kinovi.ai/api/v1/jobs/createTask" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $KINOVI_API_KEY" \
-d '{
"model": "midjourney-v7",
"inputs": {}
}')
TASK_ID=$(echo "$RESPONSE" | grep -o '"taskId":"[^"]*"' | cut -d'"' -f4)
echo "Task created: $TASK_ID"
# Poll until complete
while true; do
RESULT=$(curl -s "https://kinovi.ai/api/v1/jobs/recordInfo?taskId=$TASK_ID" \
-H "Authorization: Bearer $KINOVI_API_KEY")
STATUS=$(echo "$RESULT" | grep -o '"status":"[^"]*"' | head -1 | cut -d'"' -f4)
case "$STATUS" in
success) echo "Done!" && echo "$RESULT" | python3 -m json.tool 2>/dev/null || echo "$RESULT"; break ;;
fail) echo "Failed: $RESULT"; exit 1 ;;
*) echo "Status: $STATUS — waiting..." && sleep 2 ;;
esac
done
// midjourney-v7-kinovi.mjs — Usage: node midjourney-v7-kinovi.mjs
const API_KEY = process.env.KINOVI_API_KEY ?? "your-api-key";
// 1. Submit task
const { taskId } = await fetch("https://kinovi.ai/api/v1/jobs/createTask", {
method: "POST",
headers: { "Content-Type": "application/json", Authorization: `Bearer ${API_KEY}` },
body: JSON.stringify({
"model": "midjourney-v7",
"inputs": {}
}),
}).then((r) => r.json());
console.log("Task created:", taskId);
// 2. Poll until complete
while (true) {
const data = await fetch(
`https://kinovi.ai/api/v1/jobs/recordInfo?taskId=${taskId}`,
{ headers: { Authorization: `Bearer ${API_KEY}` } },
).then((r) => r.json());
if (data.status === "success") {
console.log("Done!", JSON.stringify(data.output, null, 2));
break;
}
if (data.status === "fail") {
console.error("Failed:", data.error);
process.exit(1);
}
process.stdout.write(`Status: ${data.status} — waiting...\r`);
await new Promise((r) => setTimeout(r, 2000));
}
# midjourney-v7-kinovi.py — Usage: python midjourney-v7-kinovi.py
import os
import time
import requests
API_KEY = os.environ.get("KINOVI_API_KEY", "your-api-key")
HEADERS = {"Authorization": f"Bearer {API_KEY}"}
# 1. Submit task
task_id = requests.post(
"https://kinovi.ai/api/v1/jobs/createTask",
headers=HEADERS,
json={
"model": "midjourney-v7",
"inputs": {}
},
).json()["taskId"]
print(f"Task created: {task_id}")
# 2. Poll until complete
while True:
data = requests.get(
"https://kinovi.ai/api/v1/jobs/recordInfo",
params={"taskId": task_id},
headers=HEADERS,
).json()
if data["status"] == "success":
print("Done!", data["output"])
break
if data["status"] == "fail":
raise SystemExit(f"Failed: {data['error']}")
print(f"Status: {data['status']} — waiting...", end="\r")
time.sleep(2)