Tuqu Photo API
Overview
Use this skill to call the Dream Weaver APIs safely and consistently across both hosts: https://photo.tuqu.ai for image and catalog flows, and https://billing.tuqu.ai/dream-weaver for recharge flows. The main failure mode is choosing the wrong host or authentication mode: body userKey for /api/billing/balance and all v2 generation endpoints, header x-api-key for character management and history APIs, Authorization: Bearer <serviceKey> for recharge endpoints, and no auth for discovery and prompt enhancement. serviceKey and userKey refer to the same credential.
Set Base URLs Only
Set these only when overriding the defaults:
TUQU_BASE_URL=https://photo.tuqu.ai
TUQU_BILLING_BASE_URL=https://billing.tuqu.ai/dream-weaver
Do not rely on a shared credential environment variable. The agent must provide the credential explicitly on
every authenticated request so multiple roles can use different service keys safely.
Prefer scripts/tuqu_request.py over ad-hoc curl so host selection, auth, and JSON handling stay consistent.
Choose the Endpoint
Follow this decision flow:
- Need available presets, template IDs, style IDs, or usage hints? Call
/api/catalog.
- Need direct text or reference-image generation without preset logic? Optionally call
/api/enhance-prompt, then call /api/v2/generate-image.
- Need template or style generation from a preset ID? Call
/api/catalog first, prepare at least one source image, then call /api/v2/apply-preset.
- Need persistent characters or multi-character scene generation? Use
/api/characters, optionally call /api/enhance-prompt, then call /api/v2/generate-for-character.
- Need prior outputs or audit trail data? Use
/api/history.
- Need pricing or remaining credits? Use
/api/model-costs and /api/billing/balance.
- Need to top up a project's balance? Call
/api/v1/recharge/plans, then /api/v1/recharge/wechat or /api/v1/recharge/stripe.
Read references/endpoints.md for exact request and response fields.
Read references/workflows.md for end-to-end task recipes.
Follow Operating Rules
- Verify the auth mode before every request. Even when the same credential backs multiple endpoints,
/api/v2/generate-for-character still requires body userKey, /api/characters and /api/history still require x-api-key, and recharge endpoints still require bearer auth.
- Verify the host before every request. Recharge endpoints live on
TUQU_BILLING_BASE_URL, not TUQU_BASE_URL.
- Provide the credential explicitly on every authenticated helper call with
--service-key <role-service-key>, unless the workflow explicitly requires you to place it in the JSON body or query string.
- Send JSON with
Content-Type: application/json.
- Send base64 images as full data URLs such as
data:image/jpeg;base64,..., not raw base64 fragments.
- Treat
/api/catalog as the source of truth for presetId, preset type, and variable names. Do not guess placeholders.
- For
/api/v2/apply-preset, send at least one sourceImages or sourceImageUrls entry. Template presets treat them as face-reference images; style presets treat the first one as the image to transform.
- Use
/api/model-costs before overriding modelId on cost-sensitive jobs.
- Use
ratio: "Original" only when at least one reference image is present, because the server measures the first reference image.
- Prefer
Authorization: Bearer <serviceKey> for recharge endpoints. Use query or body fallback only when the caller cannot set headers.
- Preserve
imageUrl, promptUsed, model, remainingBalance, transactionId, and historyItem when the API returns them.
- Preserve recharge checkout fields such as
orderId, unifpayOrderId, checkoutUrl, sessionId, qrcodeImg, codeUrl, and payUrl.
- Surface API error codes directly, especially
INVALID_REQUEST, UNAUTHORIZED, NOT_FOUND, INSUFFICIENT_BALANCE, GENERATION_FAILED, PAYMENT_NOT_CONFIGURED, and CURRENCY_NOT_SUPPORTED.
Use the Request Helper
Use the helper for repeatable API calls:
python3 scripts/tuqu_request.py GET /api/catalog --query type=all
python3 scripts/tuqu_request.py GET /api/model-costs
python3 scripts/tuqu_request.py POST /api/enhance-prompt \
--json '{"category":"portrait","prompt":"soft editorial portrait with window light"}'
python3 scripts/tuqu_request.py POST /api/v2/generate-image \
--service-key <role-service-key> \
--body-file payloads/generate-image.json
python3 scripts/tuqu_request.py GET /api/v1/recharge/plans \
--service-key <role-service-key>
python3 scripts/tuqu_request.py POST /api/v1/recharge/stripe \
--service-key <role-service-key> \
--json '{"planId":"698b7fead4c733c85f2a9c74","successUrl":"https://your-app.com/payment/success","cancelUrl":"https://your-app.com/payment/cancel"}'
The helper auto-detects both host and auth for the supported endpoints in this skill. Pass --service-key on every authenticated call. Override with --base-url or --auth-mode only when you have a documented reason.
Handle Common Tasks
Generate from prompt or references
- Optionally call
/api/enhance-prompt when the user prompt is vague.
- Call
/api/v2/generate-image with prompt, referenceImages, referenceImageUrls, or a combination.
- Return the
imageUrl and any balance or transaction metadata.
Generate from a preset
- Call
/api/catalog and pick a valid preset.
- Inspect whether the preset is a
template or a style.
- Provide at least one
sourceImages or sourceImageUrls entry.
- Fill
variableValues only with the preset's defined placeholders.
- Call
/api/v2/apply-preset.
Generate with saved characters
- Create or look up characters through
/api/characters.
- Optionally enhance the scene prompt with
/api/enhance-prompt.
- Call
/api/v2/generate-for-character.
- Save or expose the returned
historyItem when present.
Inspect balance and history
- Call
/api/billing/balance before expensive jobs when the user asks about credits.
- Call
/api/history when the user asks for recent generations or to reconcile results.
Recharge with WeChat or Stripe
- Call
/api/v1/recharge/plans to list valid planId values for the project bound to the service key.
- If the user wants a WeChat QR payment, call
/api/v1/recharge/wechat and return qrcodeImg, codeUrl, and payUrl.
- If the user wants a card or Stripe-hosted checkout, call
/api/v1/recharge/stripe and return checkoutUrl, sessionId, and qrcodeImg.
- Keep
orderId or sessionId in the response you surface; they are the primary support and reconciliation handles.
Recover from Failures
- On
INSUFFICIENT_BALANCE, stop and report the remaining balance if available.
- On
INVALID_REQUEST, compare the payload against references/endpoints.md and call out the missing field explicitly.
- On
NOT_FOUND from /api/v2/apply-preset, re-run /api/catalog; the presetId is wrong or no longer active.
- On
UNAUTHORIZED, verify whether the endpoint expects body userKey, header x-api-key, or bearer serviceKey, and verify that the caller supplied the intended role-specific credential.
- On recharge
UNAUTHORIZED, verify the service key has not been revoked or frozen and that you are sending it to the billing host.
- On
PAYMENT_NOT_CONFIGURED, report which channel is missing at the project or global config layer.
- On
CURRENCY_NOT_SUPPORTED, stop and explain that WeChat only supports direct CNY or JPY, plus USD via project FX conversion.
- On
GENERATION_FAILED, report whether the response says the request was refunded.
1---2name: tuqu-photo-api3description: Use when interacting with the Tuqu Dream Weaver photo or billing APIs for image generation, preset application, prompt enhancement, catalog or model discovery, character management, history queries, token balance checks, or recharge flows, especially around /api/v2/generate-image, /api/v2/apply-preset, /api/v2/generate-for-character, /api/enhance-prompt, /api/catalog, /api/model-costs, /api/characters, /api/history, /api/billing/balance, /api/v1/recharge/plans, /api/v1/recharge/wechat, or /api/v1/recharge/stripe.4---56# Tuqu Photo API78## Overview910Use this skill to call the Dream Weaver APIs safely and consistently across both hosts: `https://photo.tuqu.ai` for image and catalog flows, and `https://billing.tuqu.ai/dream-weaver` for recharge flows. The main failure mode is choosing the wrong host or authentication mode: body `userKey` for `/api/billing/balance` and all v2 generation endpoints, header `x-api-key` for character management and history APIs, `Authorization: Bearer <serviceKey>` for recharge endpoints, and no auth for discovery and prompt enhancement. `serviceKey` and `userKey` refer to the same credential.1112## Set Base URLs Only1314Set these only when overriding the defaults:1516- `TUQU_BASE_URL=https://photo.tuqu.ai`17- `TUQU_BILLING_BASE_URL=https://billing.tuqu.ai/dream-weaver`1819Do not rely on a shared credential environment variable. The agent must provide the credential explicitly on20every authenticated request so multiple roles can use different service keys safely.2122Prefer `scripts/tuqu_request.py` over ad-hoc `curl` so host selection, auth, and JSON handling stay consistent.2324## Choose the Endpoint2526Follow this decision flow:27281. Need available presets, template IDs, style IDs, or usage hints? Call `/api/catalog`.292. Need direct text or reference-image generation without preset logic? Optionally call `/api/enhance-prompt`, then call `/api/v2/generate-image`.303. Need template or style generation from a preset ID? Call `/api/catalog` first, prepare at least one source image, then call `/api/v2/apply-preset`.314. Need persistent characters or multi-character scene generation? Use `/api/characters`, optionally call `/api/enhance-prompt`, then call `/api/v2/generate-for-character`.325. Need prior outputs or audit trail data? Use `/api/history`.336. Need pricing or remaining credits? Use `/api/model-costs` and `/api/billing/balance`.347. Need to top up a project's balance? Call `/api/v1/recharge/plans`, then `/api/v1/recharge/wechat` or `/api/v1/recharge/stripe`.3536Read [references/endpoints.md](references/endpoints.md) for exact request and response fields.37Read [references/workflows.md](references/workflows.md) for end-to-end task recipes.3839## Follow Operating Rules4041- Verify the auth mode before every request. Even when the same credential backs multiple endpoints, `/api/v2/generate-for-character` still requires body `userKey`, `/api/characters` and `/api/history` still require `x-api-key`, and recharge endpoints still require bearer auth.42- Verify the host before every request. Recharge endpoints live on `TUQU_BILLING_BASE_URL`, not `TUQU_BASE_URL`.43- Provide the credential explicitly on every authenticated helper call with `--service-key <role-service-key>`, unless the workflow explicitly requires you to place it in the JSON body or query string.44- Send JSON with `Content-Type: application/json`.45- Send base64 images as full data URLs such as `data:image/jpeg;base64,...`, not raw base64 fragments.46- Treat `/api/catalog` as the source of truth for `presetId`, preset type, and variable names. Do not guess placeholders.47- For `/api/v2/apply-preset`, send at least one `sourceImages` or `sourceImageUrls` entry. Template presets treat them as face-reference images; style presets treat the first one as the image to transform.48- Use `/api/model-costs` before overriding `modelId` on cost-sensitive jobs.49- Use `ratio: "Original"` only when at least one reference image is present, because the server measures the first reference image.50- Prefer `Authorization: Bearer <serviceKey>` for recharge endpoints. Use query or body fallback only when the caller cannot set headers.51- Preserve `imageUrl`, `promptUsed`, `model`, `remainingBalance`, `transactionId`, and `historyItem` when the API returns them.52- Preserve recharge checkout fields such as `orderId`, `unifpayOrderId`, `checkoutUrl`, `sessionId`, `qrcodeImg`, `codeUrl`, and `payUrl`.53- Surface API error codes directly, especially `INVALID_REQUEST`, `UNAUTHORIZED`, `NOT_FOUND`, `INSUFFICIENT_BALANCE`, `GENERATION_FAILED`, `PAYMENT_NOT_CONFIGURED`, and `CURRENCY_NOT_SUPPORTED`.5455## Use the Request Helper5657Use the helper for repeatable API calls:5859```bash60python3 scripts/tuqu_request.py GET /api/catalog --query type=all61python3 scripts/tuqu_request.py GET /api/model-costs62python3 scripts/tuqu_request.py POST /api/enhance-prompt \63 --json '{"category":"portrait","prompt":"soft editorial portrait with window light"}'64python3 scripts/tuqu_request.py POST /api/v2/generate-image \65 --service-key <role-service-key> \66 --body-file payloads/generate-image.json67python3 scripts/tuqu_request.py GET /api/v1/recharge/plans \68 --service-key <role-service-key>69python3 scripts/tuqu_request.py POST /api/v1/recharge/stripe \70 --service-key <role-service-key> \71 --json '{"planId":"698b7fead4c733c85f2a9c74","successUrl":"https://your-app.com/payment/success","cancelUrl":"https://your-app.com/payment/cancel"}'72```7374The helper auto-detects both host and auth for the supported endpoints in this skill. Pass `--service-key` on every authenticated call. Override with `--base-url` or `--auth-mode` only when you have a documented reason.7576## Handle Common Tasks7778### Generate from prompt or references79801. Optionally call `/api/enhance-prompt` when the user prompt is vague.812. Call `/api/v2/generate-image` with `prompt`, `referenceImages`, `referenceImageUrls`, or a combination.823. Return the `imageUrl` and any balance or transaction metadata.8384### Generate from a preset85861. Call `/api/catalog` and pick a valid preset.872. Inspect whether the preset is a `template` or a `style`.883. Provide at least one `sourceImages` or `sourceImageUrls` entry.894. Fill `variableValues` only with the preset's defined placeholders.905. Call `/api/v2/apply-preset`.9192### Generate with saved characters93941. Create or look up characters through `/api/characters`.952. Optionally enhance the scene prompt with `/api/enhance-prompt`.963. Call `/api/v2/generate-for-character`.974. Save or expose the returned `historyItem` when present.9899### Inspect balance and history1001011. Call `/api/billing/balance` before expensive jobs when the user asks about credits.1022. Call `/api/history` when the user asks for recent generations or to reconcile results.103104### Recharge with WeChat or Stripe1051061. Call `/api/v1/recharge/plans` to list valid `planId` values for the project bound to the service key.1072. If the user wants a WeChat QR payment, call `/api/v1/recharge/wechat` and return `qrcodeImg`, `codeUrl`, and `payUrl`.1083. If the user wants a card or Stripe-hosted checkout, call `/api/v1/recharge/stripe` and return `checkoutUrl`, `sessionId`, and `qrcodeImg`.1094. Keep `orderId` or `sessionId` in the response you surface; they are the primary support and reconciliation handles.110111## Recover from Failures112113- On `INSUFFICIENT_BALANCE`, stop and report the remaining balance if available.114- On `INVALID_REQUEST`, compare the payload against [references/endpoints.md](references/endpoints.md) and call out the missing field explicitly.115- On `NOT_FOUND` from `/api/v2/apply-preset`, re-run `/api/catalog`; the `presetId` is wrong or no longer active.116- On `UNAUTHORIZED`, verify whether the endpoint expects body `userKey`, header `x-api-key`, or bearer `serviceKey`, and verify that the caller supplied the intended role-specific credential.117- On recharge `UNAUTHORIZED`, verify the service key has not been revoked or frozen and that you are sending it to the billing host.118- On `PAYMENT_NOT_CONFIGURED`, report which channel is missing at the project or global config layer.119- On `CURRENCY_NOT_SUPPORTED`, stop and explain that WeChat only supports direct `CNY` or `JPY`, plus `USD` via project FX conversion.120- On `GENERATION_FAILED`, report whether the response says the request was refunded.