InputTextSensitiveContentDetected is an HTTP 400 that BytePlus Seedance returns when its input-text filter rejects your prompt. Same text, same verdict, so retrying it is pointless. The fix that works for us: match the code by prefix, take it out of the retry loop, fall back once to a second model endpoint, and only then ask the user to rephrase.

We hit this on a film-trailer generation platform that turns a script into a storyboard and renders each scene through Seedance 1.5 Pro image-to-video at 1080p. Light content went through fine. Then a test run on a WWII Holocaust drama in the vein of The Pianist failed scene after scene. Below is the real error, the sanitization bug that made our first fix a no-op, the fallback we shipped, and three more bugs we found in our own fallback code while writing this up.

What does the InputTextSensitiveContentDetected error actually look like?

It arrives as HTTP 400 Bad Request from the task-creation POST to /api/v3/contents/generations/tasks, before any video is rendered. The code sits in error.code. BytePlus documents the message as "The request failed because the input text may contain sensitive information", followed by a request ID. Nothing in the response says which words tripped it.

HTTP/1.1 400 Bad Request

{
  "error": {
    "code": "InputTextSensitiveContentDetected",
    "message": "The request failed because the input text may contain sensitive information.Request ID: {id}"
  }
}

Two details in the BytePlus ModelArk error-code reference matter for your handler. First, there is a suffixed sibling, InputTextSensitiveContentDetected.PolicyViolation, for text that "may be related to copyright restrictions". A trailer product that ingests film scripts is exactly where you'd see it. Our shipped check used ==, so that variant would have slipped through as a generic 400. Match by prefix.

Second, the filter also runs on output. OutputVideoSensitiveContentDetected shows up on the polled task, not on the POST, so a submit-time handler never sees it. If you poll tasks, route both paths to the same classifier.

Why does retrying InputTextSensitiveContentDetected never work?

The filter is a classifier run on your prompt text, not a transient fault. Resend the same bytes and you get the same 400. Our first version treated every 400 as retryable: 3 attempts, 10 seconds apart. Each flagged scene burned 20 seconds and three rejections, then failed with a generic "API failed after 3 attempts" message.

That retry policy wasn't wrong for every error. We added it after real 429s, and we use the same 3-attempts / 10-second shape on Flowise calls for clients whose lower-tier OpenAI accounts hit rate limits. The mistake was letting one status code stand for two very different failures. A 429 says "not now." A content-filter 400 says "not this text." Classify by error.code before you look at the status code.

We've seen this blind-retry pattern on LLM agents too. A failure signal with no actionable detail gets retried until the budget runs out. We wrote about the agent version in why our LLM agent retried a browser rehearsal 58 times on passed=false with an empty errors list.

Why did our prompt sanitization silently never run?

Our retry code sanitized payload['prompt'], but Seedance's video-task payload has no prompt key. The prompt lives in a content array, as a {"type": "text"} part next to the image_url part. The if 'prompt' in payload guard was always false, so sanitization was skipped and nothing was logged.

The bug came from copying the retry block across endpoints. Our Seedream image calls really do send a flat prompt field. The Seedance video call doesn't. This is what shipped first:

# BROKEN: Seedance video payloads have no 'prompt' key
if response.status_code == 400 and attempt == 2:
    if 'prompt' in payload:                       # always False
        original_prompt = payload['prompt']
        sanitized_prompt = re.sub(r"[^a-zA-Z0-9\s,.]", "", original_prompt)
        payload['prompt'] = sanitized_prompt

And this is the payload it was supposed to be cleaning:

payload = {
    'model': 'seedance-1-5-pro-251215',
    'content': [
        {'type': 'text', 'text': full_prompt},
        {'type': 'image_url', 'image_url': {'url': presigned_storyboard_url}}
    ],
    'resolution': '1080p',
    'duration': duration_seconds,     # clamped to 4..12
    'ratio': '16:9',
    'generate_audio': False           # Seedance 1.5 only
}

The fix walks the array and rewrites the text part in place:

if 'content' in payload and isinstance(payload['content'], list):
    for content_item in payload['content']:
        if content_item.get('type') == 'text' and 'text' in content_item:
            content_item['text'] = re.sub(r"[^a-zA-Z0-9\s,.]", "", content_item['text'])
            break

Does stripping punctuation get past the content filter?

No. The filter judges what the text means, and removing an em dash doesn't change that. Sanitization is worth keeping for the other kind of 400, such as stray control characters or odd quoting in LLM-written scene descriptions. It does nothing for InputTextSensitiveContentDetected. That's why we check for the filter code before the generic retry runs.

The ASCII-only regex we shipped also does damage. It strips every non-ASCII letter, so names in a Polish-set WWII script get mangled:

>>> re.sub(r"[^a-zA-Z0-9\s,.]", "", "Władysław's family — forced from Warsaw's ghetto, 1942")
'Wadysaws family  forced from Warsaws ghetto, 1942'

Use \w (Unicode-aware in Python 3) and keep apostrophes and hyphens. The complete version below does this.

How do you fall back to a second Seedance model when the filter rejects?

On InputTextSensitiveContentDetected, switch payload['model'] to a second model configured in SEEDANCE_VIDEO_FALLBACK_MODEL and resubmit the same text once. Strip any parameters the fallback doesn't support. For us that was generate_audio, which Seedance 1.0 rejects with its own 400. Fail with rephrasing guidance only if the fallback refuses too.

Our primary is seedance-1-5-pro-251215. The fallback is a ModelArk custom inference endpoint (an ep-… ID) serving a Seedance 1.0 model that accepted the historical scene descriptions the 1.5 endpoint rejected. This is the block we shipped:

if error_code == 'InputTextSensitiveContentDetected':
    fallback_model = os.getenv('SEEDANCE_VIDEO_FALLBACK_MODEL')
    if fallback_model and payload['model'] != fallback_model:
        logger.warning(f"Scene {scene_number}: Content filter triggered by primary model "
                       f"'{model}'. Switching to fallback model '{fallback_model}'.")
        payload['model'] = fallback_model
        if 'generate_audio' in payload and ('1-0' in fallback_model
                                            or 'seedance-1-0' in fallback_model.lower()):
            del payload['generate_audio']
        attempt = 0          # "reset" the retry counter (see below: it doesn't)
        continue
    raise Exception(f"Scene {scene_number} contains content flagged as sensitive ...")

We chose model fallback over automatically rewriting the prompt with an LLM. A silent rewrite changes the scene the user wrote, for example turning a specific historical event into something generic, and the user never finds out. Fallback keeps the text and changes the renderer. The cost is visual consistency: a 1.0 clip next to 1.5 clips in the same trailer can look different. We log every switch at WARNING so we can count how often it happens per film.

One non-technical caveat. Which endpoint accepts which text depends on the provider's configuration, and that can change without notice. Treat the fallback as a capability you re-verify. Make sure your use case and your provider agreement cover it, and don't build a product on the assumption that it will last.

What three latent bugs did we find in our own fallback code in 2026?

All three survived because the happy path still worked. Setting attempt = 0 inside a Python for loop doesn't reset anything. if response is False for every 4xx. And a '1-0' in model version check can't match an ep-… endpoint ID. Each one fails quietly instead of crashing.

1. attempt = 0 in a for loop is a no-op. The loop was for attempt in range(1, max_attempts + 1). Python's for statement rebinds the target from the iterator on every pass, so assigning to it inside the body has no effect on the next iteration. The fallback only got whatever attempts the primary hadn't used. If the filter fired on attempt 3 (say, after two 429s), continue ended the loop and the code went on to read result, which was never assigned. That's an UnboundLocalError instead of a fallback.

>>> seen = []
>>> for attempt in range(1, 4):
...     seen.append(attempt)
...     if attempt == 1:
...         attempt = 0; continue
>>> seen
[1, 2, 3]

2. requests.Response is falsy on errors. Our error logging used response.status_code if response else "unknown". requests defines Response.__bool__ as self.ok, which is False for any status of 400 or above. Inside an HTTPError handler the response is always an error, so the log said "HTTP unknown error" every time. Use response is not None.

3. Version-sniffing an endpoint ID. The generate_audio strip only fires if the fallback name contains 1-0. ModelArk custom endpoint IDs look like ep-2026MMDDhhmmss-xxxxx and contain no version string, so the strip can never trigger for them. If the fallback really is 1.0, the request goes out with a parameter 1.0 rejects. Declare model capabilities in config. Don't infer them from names.

What does the complete fix look like?

Each model gets its own retry budget. The filter code is matched by prefix and moves on to the next model instead of retrying. Sanitization targets the content array with a Unicode-aware regex. Model capabilities come from config. 429s and generic 400s keep the 3-attempt, 10-second policy, and the last generic-400 attempt sends a cleaned prompt.

import copy
import os
import re
import time

import requests

FILTER_PREFIX = "InputTextSensitiveContentDetected"   # also matches ".PolicyViolation"
RETRYABLE_STATUS = {400, 429}
MAX_ATTEMPTS = 3
RETRY_DELAY = 10


class ContentFilterRejected(Exception):
    """Non-retryable: the same text will be rejected again."""


def _error_code(response):
    try:
        body = response.json()
    except ValueError:
        return None
    if isinstance(body, dict) and isinstance(body.get("error"), dict):
        return body["error"].get("code")
    return None


def _sanitize_text_parts(payload):
    """Seedance puts the prompt in content[], not payload['prompt']."""
    changed = False
    for part in payload.get("content", []):
        if part.get("type") == "text" and part.get("text"):
            part["text"] = re.sub(r"[^\w\s,.'\-:]", "", part["text"])
            changed = True
    return changed


def _for_model(payload, model, supports_audio):
    p = copy.deepcopy(payload)
    p["model"] = model
    if not supports_audio:          # Seedance 1.0 rejects generate_audio with a 400
        p.pop("generate_audio", None)
    return p


def create_task(api_url, api_key, payload, scene):
    headers = {"Authorization": f"Bearer {api_key}", "Content-Type": "application/json"}
    # (model, supports_audio). Endpoint IDs like "ep-2026...-abcde" carry no version
    # string, so declare capabilities in config instead of sniffing the name.
    models = [(payload["model"], True)]
    fallback = os.getenv("SEEDANCE_VIDEO_FALLBACK_MODEL")
    if fallback and fallback != payload["model"]:
        audio_ok = os.getenv("SEEDANCE_VIDEO_FALLBACK_SUPPORTS_AUDIO", "false") == "true"
        models.append((fallback, audio_ok))

    filter_hit = None
    for model, supports_audio in models:       # each model gets a fresh attempt budget
        body = _for_model(payload, model, supports_audio)
        attempt = 0
        while attempt < MAX_ATTEMPTS:
            attempt += 1
            response = requests.post(api_url, json=body, headers=headers, timeout=120)
            if response.ok:
                return response.json()

            # NOTE: never `if response:` here. Response.__bool__ is False for 4xx/5xx.
            code = _error_code(response) or ""
            if code.startswith(FILTER_PREFIX):
                filter_hit = code
                break                          # same text = same verdict; try next model
            if response.status_code not in RETRYABLE_STATUS or attempt == MAX_ATTEMPTS:
                response.raise_for_status()
            time.sleep(RETRY_DELAY)
            if response.status_code == 400 and attempt == 2:
                _sanitize_text_parts(body)     # last attempt gets a cleaned prompt

    raise ContentFilterRejected(
        f"Scene {scene}: {filter_hit}. Rephrase the scene description: describe what is "
        f"on screen ('uniformed soldiers', 'restrictive notices on a wall'), not named "
        f"groups, decrees, or events."
    )

We tested five cases against a mocked requests.post. Primary filtered then fallback succeeds: 2 calls, generate_audio removed. Both models return .PolicyViolation: 2 calls, then ContentFilterRejected. Generic 400 twice then success: 3 calls, third with the cleaned text. 429 three times: raises after 3 calls. Two 429s, then a filter hit, then fallback: 4 calls and success. The old loop crashed on that last case.

What should the user see when every model refuses the prompt?

A specific, non-retryable error that says the scene text was flagged, names common triggers, and gives concrete rewrites. "API failed after 3 attempts" sends the user looking for an outage. "Scene 7 was flagged by the content filter, describe what's on screen rather than naming groups or decrees" tells them exactly what to change.

For historical drama, the rewrites we suggest in the error message describe what the camera sees instead of naming the history:

  • "Nazi soldiers in 1940s Berlin" becomes "uniformed soldiers in a historical city square"
  • Specific anti-Jewish decrees become "restrictive notices posted on a wall"
  • Named atrocities become the visual aftermath: empty streets, abandoned belongings, a closed gate

The film's meaning comes from the edit, the voiceover and the music, not from the per-shot prompt. The video model needs a filmable description, not historical context. If your storyboard prompts are LLM-written, pushing that rule upstream into the prompt-writing step prevents most rejections before they happen.

Seedance runs a separate image-side filter with its own codes and fixes. If your storyboard frames contain photoreal faces, see how we fixed InputImageSensitiveContentDetected.PrivacyInformation on AI-generated faces with YuNet grid-masking.

So how should you handle InputTextSensitiveContentDetected from Seedance?

Treat it as a verdict, not a fault. Match the code by prefix so .PolicyViolation is caught too. Never feed it to your generic 400/429 retry loop. Make sure your sanitizer edits the content array where Seedance actually keeps the prompt. Give one fallback model a fresh attempt budget, and when everything refuses, tell the user how to rephrase.

The bigger lesson from this incident is that every bug here was quiet. A guard that was never true, a counter reset that did nothing, a falsy response object, a version check that couldn't match. Retry and fallback code only runs when something has already gone wrong, so test it deliberately with mocked failures.