Giky API / Docs
DEVELOPER DOCUMENTATION

Giky API JavaScript Quickstart

Use built-in fetch from a Node.js server. No browser-side key or unofficial SDK is required.

On this pageRun the exampleRecovery

Run the example

Set AI_API_KEY, save as generate.mjs and run node generate.mjs. This submits a paid request. Persist requestId and payload before sending in your production application.

// Node.js 22+. Save as generate.mjs; no SDK dependency required.
import { randomUUID } from 'node:crypto';
const base = (process.env.AI_API_BASE_URL || 'https://gikyapi.com').replace(/\/$/, '');
const key = process.env.AI_API_KEY;
if (!key) throw new Error('Set AI_API_KEY on your server');
const requestId = randomUUID();
const payload = {
  "model": "seedream-5-flash",
  "operation": "text-to-image",
  "input": {
    "prompt": "A blue ceramic cup beside an orange, soft morning light",
    "resolution": "2K",
    "aspect_ratio": "1:1"
  }
};
console.log('Request ID:', requestId); // Persist with payload before submitting.
async function read(path, options = {}) {
  const response = await fetch(base + path, {
    ...options, signal: AbortSignal.timeout(35000),
    headers: { Authorization: 'Bearer ' + key, ...options.headers }
  });
  const data = await response.json();
  if (!response.ok) throw new Error(JSON.stringify(data));
  return data;
}
let task = await read('/v1/tasks', {
  method: 'POST',
  headers: { 'Content-Type': 'application/json', 'Idempotency-Key': requestId },
  body: JSON.stringify(payload)
});
console.log('Task ID:', task.id);
for (let attempt = 0; attempt < 120; attempt++) {
  await new Promise(resolve => setTimeout(resolve, 5000));
  task = await read('/v1/tasks/' + task.id);
  if (task.status === 'succeeded') { console.log(task.outputs); break; }
  if (['failed', 'needs_review'].includes(task.status)) {
    throw new Error('Inspect task ' + task.id + ': ' + task.status);
  }
}
// If still running, save task.id and query it later. Never submit again just to poll.

Recovery

The request timeout and the generation lifetime are different. A timeout is not a refund or cancellation. Reuse the same idempotency key for uncertain submission recovery; resume polling a known task without submitting it again.