Skip to main content
Mynth is task-based. Even when you use the SDK in sync mode, the SDK is still polling an async task under the hood.

Use sync mode when

  • your request can wait for completion
  • you are on the server
  • you want the simplest API
const task = await mynth.generate({
  prompt: "Minimal product shot of a matte black espresso grinder",
  model: "google/gemini-3.1-flash-image",
});

Use async mode when

  • you need to respond quickly
  • you want browser progress updates
  • you are orchestrating background work
const task = await mynth.generate(
  {
    prompt: "Minimal product shot of a matte black espresso grinder",
    model: "google/gemini-3.1-flash-image",
  },
  { mode: "async" },
);

console.log(task.id);
console.log(task.access.publicAccessToken);

Poll the status endpoint

curl https://api.mynth.io/tasks/$TASK_ID/status \
  -H "Authorization: Bearer $PUBLIC_ACCESS_TOKEN"
Response:
{ "status": "pending" }

Fetch final results

curl https://api.mynth.io/tasks/$TASK_ID/results \
  -H "Authorization: Bearer $PUBLIC_ACCESS_TOKEN"

Owner-only task details

Use GET /tasks/:id when you need the full task object, including the original request and full result payload. This endpoint requires your Mynth API key and is not available through the public access token.
curl https://api.mynth.io/tasks/$TASK_ID \
  -H "Authorization: Bearer $MYNTH_API_KEY"
See Tasks reference for the response shape.

SDK polling behavior

TaskAsync.toTask() polls until the task is completed or failed. The SDK:
  • polls quickly at first, then more slowly
  • times out after five minutes
  • retries transient fetch failures
  • throws dedicated task and polling error classes
Read SDK tasks for the exact behavior.