ForLoop Media integration guide
ForLoop core service · docs
v1.4.0
llms.txtOpen console

ForLoop core service

ForLoop Media integration guide

Generate images, transform stored images, read images as text, and synthesize speech through asynchronous, billable media jobs.

Quickstart

Create an app-subject connection to this service, then exchange the app credential for an assertion.

curl -X POST https://media.app.forloop.cc/api/opencode/a2a/connections/<connectionId>/assertion \
  -H "x-api-token: $FLC_APP_CREDENTIAL" \
  -H "content-type: application/json" \
  -d '{"scopes":["media.jobs:write"],"contractVersion":"1.4.0"}'

The assertion is valid for 300 seconds. Send it as Authorization: Bearer <assertion> on every /v1 call.

  1. Submit an image, vision, or speech job with POST /v1/images, /v1/vision, or /v1/speech.
  2. Poll GET /v1/jobs/{id} until the job reaches a terminal status.
  3. Read the stored asset through the returned signed URL or export endpoint.
  4. Inspect GET /v1/usage for charged assets and wallet state.

Authentication and tenancy

The service trusts only a verified app assertion. It checks iss, aud, sub=app:<callerSprintId>, appPublicId, env, scopes, and the pinned contractVersion.

Scopes

API reference

MethodPathAccessSuccessToolPurpose
POST/v1/imageswrite202Generate imageCreate an image job from a natural-language prompt. Returns 202 immediately with a jobId; the provider call, moderation, object-storage write, and charge happen asynchronously. One request may ask for up to 4 images (n); each stored image is charged separately. Requires an Idempotency-Key header.
POST/v1/speechwrite202Generate speechCreate a text-to-speech job. Returns 202 immediately with a jobId; synthesis, subtitle sidecar, object-storage write, and charge happen asynchronously. Text up to 10,000 characters is synthesized inline; longer text (up to 50,000 inline, or 1,000,000 via textFileId) requires asyncTask and is polled until the provider task completes. Billing is per 1,000 provider-reported characters. Requires an Idempotency-Key header.
POST/v1/musicwrite202Generate musicCreate a music job. Returns 202 immediately with a jobId; synthesis, object-storage write, and charge happen asynchronously. Supports instrumental tracks from a prompt, lyrical songs from structured lyrics, and cover generation from audio this app already stored. One song per request, charged per stored song. Requires an Idempotency-Key header.
GET/v1/jobs/{id}read200Get jobRead one job, including fresh short-lived signed URLs for every stored image. This is the 'load the image back' call: render assets[].url directly, and call again when a URL expires.
GET/v1/jobsread200List jobsCursor-paginated list of the caller app's jobs in this environment, newest first. List responses never include signed URLs.
POST/v1/jobs/{id}/cancelwrite202Cancel jobCancel a job that is still queued. The reservation is released, so a canceled job is free. Requires an Idempotency-Key header.
POST/v1/jobs/{id}/exportwrite200Export jobMint longer-lived download URLs (default 1 hour) so the app can copy the image bytes into its own storage before the 30-day retention window closes. Requires an Idempotency-Key header.
POST/v1/jobs/{id}/retainwrite200Retain jobExtend retention by a number of days, or retain indefinitely with days=0, so the images are not deleted at expiresAt. Requires an Idempotency-Key header.
GET/v1/jobs/{id}/assets/{index}/contentread302Redirect to assetStable per-asset endpoint that 302-redirects to a freshly signed URL, so an app can use one URL in an <img src> without minting it first.
DELETE/v1/jobs/{id}write204Delete jobDelete the stored images and the job record immediately. Requires an Idempotency-Key header.
GET/v1/usageread200Get usageUsage summary for a time window: job counts by status, images stored, stored bytes, charged FLC, and the app's live wallet balance and spend cap.
POST/v1/voiceswrite201Clone voiceClone a voice from audio this app already stored, subject to an explicit consent attestation. Returns 201 with a voiceId usable as voiceId on POST /v1/speech. Cloning is biometric processing, so it requires the separate media.voices:write scope and is disabled by default. Requires an Idempotency-Key header.
GET/v1/voicesread200List voicesList this app's voices in the environment. Returns ids, kind, status and the consent attestor and timestamp; the attestation text and any audio are never returned.
GET/v1/voices/{id}read200Get voiceFetch one voice by id.
DELETE/v1/voices/{id}write204Delete voiceDelete a cloned voice locally and ask the provider to delete its model. The local record is marked deleted first, so a provider failure cannot leave the caller believing a voice still exists. Requires an Idempotency-Key header.
POST/v1/visionwrite202Image to textDescribe or answer questions about one or more stored images using DeepSeek vision. Returns 202 with a job; poll get_job until status is succeeded and read job.text. Each stored image is charged once (media.vision, 2 FLC/image); failed descriptions are free.

Generate image

POST /v1/images · write · success 202

Create an image job from a natural-language prompt. Returns 202 immediately with a jobId; the provider call, moderation, object-storage write, and charge happen asynchronously. One request may ask for up to 4 images (n); each stored image is charged separately. Requires an Idempotency-Key header.

Example

POST /v1/images
Idempotency-Key: avatar-user-42-v1
Authorization: Bearer <assertion>
{"prompt":"A cat in a spacesuit, studio lighting","aspectRatio":"1:1"}

202
{"job":{"jobId":"job_6f1c...","status":"queued","params":{"model":"image-01","requestedCount":1,"aspectRatio":"1:1"},"assets":[],"billing":{"state":"reserved","quotedAmountFLC":50,"unitAmountFLC":50},"expiresAt":"2026-11-28T09:00:00.000Z"}}

Output fields: job

Generate speech

POST /v1/speech · write · success 202

Create a text-to-speech job. Returns 202 immediately with a jobId; synthesis, subtitle sidecar, object-storage write, and charge happen asynchronously. Text up to 10,000 characters is synthesized inline; longer text (up to 50,000 inline, or 1,000,000 via textFileId) requires asyncTask and is polled until the provider task completes. Billing is per 1,000 provider-reported characters. Requires an Idempotency-Key header.

Example

POST /v1/speech
Idempotency-Key: narration-ch3-v1
Authorization: Bearer <assertion>
{"text":"Welcome to ForLoop.","voiceId":"male-qn-qingse","format":"mp3"}

202
{"job":{"jobId":"job_9a2c...","modality":"speech","status":"queued","params":{"model":"speech-2.8-hd","requestedCount":1,"format":"mp3","sampleRate":32000},"assets":[],"billing":{"state":"reserved","quotedAmountFLC":2,"unitAmountFLC":2},"expiresAt":"2026-12-03T09:00:00.000Z"}}

Output fields: job

Generate music

POST /v1/music · write · success 202

Create a music job. Returns 202 immediately with a jobId; synthesis, object-storage write, and charge happen asynchronously. Supports instrumental tracks from a prompt, lyrical songs from structured lyrics, and cover generation from audio this app already stored. One song per request, charged per stored song. Requires an Idempotency-Key header.

Example

POST /v1/music
Idempotency-Key: lobby-theme-v1
Authorization: Bearer <assertion>
{"prompt":"uplifting synthwave, driving bass, 80s","isInstrumental":true}

202
{"job":{"jobId":"job_4d1e...","modality":"music","status":"queued","params":{"model":"music-3.0","requestedCount":1,"isInstrumental":true},"assets":[],"billing":{"state":"reserved","quotedAmountFLC":200,"unitAmountFLC":200},"expiresAt":"2026-12-03T09:00:00.000Z"}}

Output fields: job

Get job

GET /v1/jobs/{id} · read · success 200

Read one job, including fresh short-lived signed URLs for every stored image. This is the 'load the image back' call: render assets[].url directly, and call again when a URL expires.

Example

GET /v1/jobs/job_6f1c...
Authorization: Bearer <assertion>

200
{"job":{"jobId":"job_6f1c...","status":"succeeded","assets":[{"index":0,"contentType":"image/png","bytes":812345,"width":1024,"height":1024,"url":"https://s3...","urlExpiresAt":"2026-10-29T10:15:00.000Z"}],"billing":{"state":"charged","chargedAmountFLC":50}}}

Output fields: job

List jobs

GET /v1/jobs · read · success 200

Cursor-paginated list of the caller app's jobs in this environment, newest first. List responses never include signed URLs.

Example

GET /v1/jobs?status=succeeded&limit=20

200
{"jobs":[{"jobId":"job_6f1c...","status":"succeeded","assets":[{"index":0,"contentType":"image/png","bytes":812345}],"expiresAt":"2026-11-28T09:00:00.000Z"}],"nextCursor":"..."}

Output fields: jobs, nextCursor

Cancel job

POST /v1/jobs/{id}/cancel · write · success 202

Cancel a job that is still queued. The reservation is released, so a canceled job is free. Requires an Idempotency-Key header.

Example

POST /v1/jobs/job_6f1c.../cancel
Idempotency-Key: cancel-job_6f1c

202
{"job":{"jobId":"job_6f1c...","status":"canceled","billing":{"state":"released"}}}

Output fields: job

Export job

POST /v1/jobs/{id}/export · write · success 200

Mint longer-lived download URLs (default 1 hour) so the app can copy the image bytes into its own storage before the 30-day retention window closes. Requires an Idempotency-Key header.

Example

POST /v1/jobs/job_6f1c.../export
Idempotency-Key: export-job_6f1c

200
{"jobId":"job_6f1c...","assets":[{"index":0,"contentType":"image/png","bytes":812345,"url":"https://s3..."}],"urlExpiresAt":"2026-10-29T11:00:00.000Z","expiresAt":"2026-11-28T09:00:00.000Z"}

Output fields: jobId, assets, urlExpiresAt, expiresAt

Retain job

POST /v1/jobs/{id}/retain · write · success 200

Extend retention by a number of days, or retain indefinitely with days=0, so the images are not deleted at expiresAt. Requires an Idempotency-Key header.

Example

POST /v1/jobs/job_6f1c.../retain
Idempotency-Key: retain-job_6f1c
{"days":90}

200
{"job":{"jobId":"job_6f1c...","expiresAt":"2027-01-27T09:00:00.000Z","retained":false}}

Output fields: job

Redirect to asset

GET /v1/jobs/{id}/assets/{index}/content · read · success 302

Stable per-asset endpoint that 302-redirects to a freshly signed URL, so an app can use one URL in an <img src> without minting it first.

Example

GET /v1/jobs/job_6f1c.../assets/0/content

302
location: https://s3.ap-southeast-1.amazonaws.com/...?X-Amz-Signature=...

Output fields:

Delete job

DELETE /v1/jobs/{id} · write · success 204

Delete the stored images and the job record immediately. Requires an Idempotency-Key header.

Example

DELETE /v1/jobs/job_6f1c...
Idempotency-Key: delete-job_6f1c

204

Output fields:

Get usage

GET /v1/usage · read · success 200

Usage summary for a time window: job counts by status, images stored, stored bytes, charged FLC, and the app's live wallet balance and spend cap.

Example

GET /v1/usage?from=2026-10-01T00:00:00Z&to=2026-10-29T00:00:00Z

200
{"usage":{"total":12,"succeeded":11,"images":14,"storedBytes":9345211,"chargedFLC":700,"counts":{"succeeded":11,"content_filtered":1},"wallet":{"available":4300,"spent":700,"spendCap":10000,"currency":"FLC"}}}

Output fields: usage

Clone voice

POST /v1/voices · write · success 201

Clone a voice from audio this app already stored, subject to an explicit consent attestation. Returns 201 with a voiceId usable as voiceId on POST /v1/speech. Cloning is biometric processing, so it requires the separate media.voices:write scope and is disabled by default. Requires an Idempotency-Key header.

Example

POST /v1/voices
Idempotency-Key: clone-user-42-v1
Authorization: Bearer <assertion with media.voices:write>
{"source":{"jobId":"job_9a2c...","index":0},"label":" narrator","consent":{"attested":true,"attestedBy":"user_42","statement":"I confirm the person whose voice is used has given informed consent for this voice to be cloned and used by this application."}}

201
{"voice":{"voiceId":"voice_7f3...","kind":"cloned","status":"active","consent":{"attested":true,"attestedBy":"user_42","attestedAt":"2026-11-03T09:00:00.000Z"},"expiresAt":"2026-11-10T09:00:00.000Z"}}

Output fields: voice

List voices

GET /v1/voices · read · success 200

List this app's voices in the environment. Returns ids, kind, status and the consent attestor and timestamp; the attestation text and any audio are never returned.

Example

GET /v1/voices?limit=50

200
{"voices":[{"voiceId":"voice_7f3...","kind":"cloned","status":"active"}]}

Output fields: voices, nextCursor

Get voice

GET /v1/voices/{id} · read · success 200

Fetch one voice by id.

Example

GET /v1/voices/voice_7f3...

200
{"voice":{"voiceId":"voice_7f3...","status":"active"}}

Output fields: voice

Delete voice

DELETE /v1/voices/{id} · write · success 204

Delete a cloned voice locally and ask the provider to delete its model. The local record is marked deleted first, so a provider failure cannot leave the caller believing a voice still exists. Requires an Idempotency-Key header.

Example

DELETE /v1/voices/voice_7f3...
Idempotency-Key: withdraw-consent-42

204

Output fields:

Image to text

POST /v1/vision · write · success 202

Describe or answer questions about one or more stored images using DeepSeek vision. Returns 202 with a job; poll get_job until status is succeeded and read job.text. Each stored image is charged once (media.vision, 2 FLC/image); failed descriptions are free.

Example

POST /v1/vision
Idempotency-Key: alt-text-42
Authorization: Bearer <assertion>
{"images":[{"jobId":"job_6f1c...","index":0}],"prompt":"Describe this image in one sentence."}

202
{"job":{"jobId":"job_9a2c...","modality":"vision","status":"queued","params":{"model":"deepseek-flash","images":[{"jobId":"job_6f1c...","index":0}]},"assets":[],"billing":{"state":"reserved","quotedAmountFLC":2},"expiresAt":"2026-12-03T09:00:00.000Z"}}

Output fields: job

Errors and retries

CodeMeaningRetry?
invalid_assertion / expiredThe assertion is missing, invalid, or expired.No; exchange a fresh assertion.
insufficient_scopeThe assertion does not carry a required scope.No; update the connection grant.
env_mismatch / audience_mismatchWrong platform environment or target.No; fix the connection.
invalid_requestThe request body or parameters are invalid.No.
not_foundThe resource is absent or belongs to another app.No.
conflictVersion, state, or idempotency conflict.No; read the current state first.
quota_exceeded / rate_limitedPer-app quota or rate limit reached.Yes, after the indicated delay.
internal_error / provider_transportTransient platform or provider failure.Yes, with backoff and the same idempotency key.

Billing

undefined FLC per 1 unit (ceil). Payer: APP:<appPublicId>. Failures are free.

The service reserves before billable work and commits only after the success condition in its contract. A failed, filtered, or canceled unit is free. A successful unit that cannot settle is retried durably and is never silently released.

Limits and retention

AI-agent checklist

  1. Discover the target agent card and pin its exact contract version.
  2. Exchange the app credential for a fresh assertion immediately before the call.
  3. Use the generated client types; never hand-write a response type.
  4. Send Idempotency-Key on every write and reuse it only for the same logical request.
  5. Never infer the payer or app ID from a request body; use the verified assertion.
  6. Treat 4xx errors as terminal unless the contract explicitly says otherwise; retry only transient 5xx/transport errors with backoff.
  7. Read the returned job/delivery state before presenting success to a user.