# Gender Swap AI for agents

Read this before using the video API. Human entry: /for-agents (English) or /zh-CN/for-agents (简体中文).
Use the SAME origin that served this document as GSA_BASE. Preview credentials and tasks are scoped to Preview.

## What this service provides

Free character references, AI gijinka context, and fanwork inspiration:

- /ai-gijinka/deepseek: DeepSeek whale girl / 大肥鱼 character context and visual references.
- /ai-gijinka: AI gijinka character directory.
- /ai-gijinka/fanworks: community fanworks and source attribution.
- /ai-gijinka/inspiration: ideas for character scenes.
  Resolve links against GSA_BASE; follow the page's language links if needed. Reference artwork is inspiration, not a transfer of reuse rights. Keep source attribution and check permission before reusing an artist's work.

Use the user's existing image tool to prepare character art, comics or first frames. This service adds paid Seedance video generation through HTTP. You control the prompt; the site does not add a preset prompt. An MCP installation is not required.

## Reference map and image downloads

Use the links above as a map. The linked pages maintain character facts, visual references, creators and source works; do not treat a general image prompt as the character's definition.

For a request about 大肥鱼, start at /ai-gijinka/deepseek. Read the aliases and appearance, then use the **three-views** section for a front, side and back reference. Other character profiles follow /ai-gijinka/{slug}; discover them in the directory rather than guessing a slug.

1. Read the character page and find its three-view section, `#three-views`.
2. Follow its `a[download]` link to the original PNG. Resolve the actual href against GSA_BASE. Do not substitute the rendered thumbnail or a Next image-optimizer URL.
3. Download the file and inspect the image. A browser agent can click "Download three-view PNG" / "下载三视图 PNG" instead. Preserve the adjacent creator, source and licensing details in the user's reference notes.
4. Use the downloaded file with the user's existing image tool. To animate that result, upload the local image through the video upload flow below, or use a public HTTPS image URL that the provider can access.

The DeepSeek profile currently links to /images/ai-gijinka-turnarounds/deepseek.png. Prefer the page's current download link over constructing image filenames. Not every artwork on a reference page has a downloadable original; follow the available source links for those works.

A protected Preview may require a separate deployment share session before pages or images can be read. An API key does not unlock Vercel deployment protection. A protected image URL is not a public provider input: download it in the authorized session and upload the local file instead. Check that an image download returns an image, not a login HTML page.

## Authentication

The human signs in at /for-agents#connect, creates a key, and stores it in their agent's secret configuration as GSA_API_KEY.
The full key is shown once. The database stores its digest. Rotation immediately invalidates the previous key; revocation disables access.
Never place keys in URLs, prompts, source control, screenshots, or logs. Never ask for the user's GPT or provider key.
Send Authorization: Bearer $GSA_API_KEY to this site's API only. Upload URLs already contain scoped authorization: NEVER send the account key to the upload host.

## Safe working sequence

1. Establish the user's character, scene, motion, aspect ratio and desired duration.
2. Read free reference pages as needed; prepare images with the user's own image tool.
3. GET /api/agent/v1/models for current model IDs, resolutions and rates.
4. GET /api/agent/v1/balance for available PAID site credits. Free image credits do not fund video.
5. Upload local media if needed, then POST /api/agent/v1/quote with the complete generation body.
6. Obtain the user's spending approval or use their already approved budget. A quote does not reserve credits.
7. POST /api/agent/v1/generations with the IDENTICAL body, a stable Idempotency-Key, and X-Expected-Credits set to the quoted credits.
8. Poll GET /api/agent/v1/generations/{id} every 10 seconds. When succeeded, download the returned video asset using the same Bearer key. Resolve relative asset URLs against GSA_BASE.
9. Save the video locally and give it to the user. Publishing or sending to social platforms requires the user's instruction.

## Model and input contract

GET /api/agent/v1/models is public and returns {models:[...]}. Current provider: seeapi.
Models: seedance-2, seedance-2-fast, seedance-2-mini, seedance-2-5.
Endpoints: text-to-video, image-to-video, reference-to-video.
The top-level request uses native {model, endpoint, provider, input}. No prompt rewrite occurs.

Accepted input fields:

- prompt: required for text-to-video, optional with media. Maximum 20,000 characters (30,000 for Seedance 2.5).
- duration_seconds: integer, 4–15 for Seedance 2.0 / Fast / Mini; 4–30 for Seedance 2.5. Default 5. Automatic duration (-1) is unavailable because a fixed quote is required.
- resolution: 480p, 720p; also 1080p for standard / 2.5 and 4k for standard. Default 480p.
- aspect_ratio: 16:9, 9:16, 1:1, 4:3, 3:4, 21:9, adaptive. Seedance 2.5 with first/end frames requires adaptive.
- first_frame_image: HTTPS image URL, required for image-to-video.
- last_frame_image: optional HTTPS final-frame URL with image-to-video.
- reference_images, reference_video, reference_audio: arrays for reference-to-video only.
- generate_audio, camera_fixed, web_search, nsfw_checker: optional booleans passed unchanged to the provider.
- seed: integer >= -1, passed unchanged.
- output_format: mp4 only. return_last_frame: false only. This version delivers one MP4, without callbacks or last-frame images.

Reference limits: 9 images / 3 videos / 3 audio for standard, Fast and Mini; 30 / 10 / 10 for Seedance 2.5.
Audio-only references require Seedance 2.5. Other models need an image or video alongside audio.
For video/audio references, upload through this API first so duration and ownership can be verified. Each clip must be at least 2 seconds; total video duration and total audio duration are each <=15 seconds (30 for Seedance 2.5).
Video maximum size is 50 MiB (200 MiB for 2.5), audio 15 MiB, uploaded images 10 MiB. Images may also use accessible public HTTPS URLs.
Provider validation may reject unsupported combinations. Do not silently change the user's creative inputs after a rejection.

## Uploading a local file

POST /api/agent/v1/uploads with JSON {"kind":"image"} (or "video" / "audio"), authenticated.
Response contains upload_url, asset_url, method:"PUT", expires_at, allowed_content_types, maximum_bytes.
PUT the raw file bytes to upload_url with its correct Content-Type. No Bearer key on this PUT.
Upload authorization expires after one hour. Use asset_url in the native request. Keep signed URLs private.
Uploaded source links are temporary. Submit promptly; do not use them as permanent storage.

## Example (shell)

Set GSA_BASE to this document's origin and GSA_API_KEY through your secret manager.
Save the following JSON in request.json:

```json
{
  "model": "seedance-2-mini",
  "endpoint": "text-to-video",
  "provider": "seeapi",
  "input": {
    "prompt": "A blue-haired whale girl waves beside the ocean, gentle camera movement.",
    "duration_seconds": 5,
    "resolution": "480p",
    "aspect_ratio": "9:16"
  }
}
```

```sh
curl --fail-with-body "$GSA_BASE/api/agent/v1/balance" \
  -H "Authorization: Bearer $GSA_API_KEY"
curl --fail-with-body "$GSA_BASE/api/agent/v1/quote" \
  -H "Authorization: Bearer $GSA_API_KEY" \
  -H "Content-Type: application/json" --data-binary @request.json
# After spending approval, set QUOTED_CREDITS to the returned credits.
curl --fail-with-body "$GSA_BASE/api/agent/v1/generations" \
  -H "Authorization: Bearer $GSA_API_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: your-unique-operation-id" \
  -H "X-Expected-Credits: $QUOTED_CREDITS" --data-binary @request.json
```

## Responses, payment, and recovery

POST /quote returns {credits, pricing_version}. Rates use SITE credits, not upstream credits or USD. Buy paid credit packs through /for-agents#models with the same account. /pricing lists the other site plans.
Reference video changes the quote: billing includes its inspected duration as well as output duration. Always quote the actual body rather than estimate from the table.
POST /generations returns HTTP 202 with {generation, idempotent}. GET /generations returns this account's latest 20 tasks in this environment.
Generation fields: id, created_at, credits, status, error. On success, result.assets contains the MP4 download URL.
Statuses: queued, submitting, processing, saving, succeeded, failed, review. "review" needs support reconciliation; do not automatically create a replacement paid job.
Credits are reserved when processing starts, committed after successful archival, and released on confirmed failure. Concurrent requests can consume the balance after the initial balance check.
Keep the same Idempotency-Key when retrying the same body after a network failure. Changing the body with an existing key returns 409. Use a new key only for an intentionally new paid job.
Download before the 30-day retention window expires; results require account authorization. Rotation does not change ownership.

Error JSON: {error:"code"} (validation errors may include issues).

- 400 invalid_request / unsupported_configuration / invalid_media_inputs: fix the input; upload_media_first means use the upload flow.
- 401 invalid_api_key: the human must configure, rotate or create their key.
- 402 insufficient_credits: ask the human to fund the account at /for-agents#models.
- 404 video_task_not_found: wrong account, environment, ID or expired task.
- 409 idempotency_conflict / quote_changed: use the original body or obtain a new quote and spending approval.
- 503 video_unavailable / service_unavailable: retain the operation ID and retry later. Do not start additional paid jobs to hide the failure.
