Genace

generation API empty prompt: Separate string length from useful intent

A generation API empty prompt can fail at a simple string boundary long before any model interprets it. The current provider schemas require prompt to be a string with a minimum length of one. They do not trim whitespace, assess meaning, or verify that the request describes a useful visual task.

Know what the validator sees

An omitted prompt is not a string and fails. Null also fails. An empty string has length zero and fails. A string containing a single space has positive length and can pass this particular schema check. A JSON object placed directly in prompt is not a string, even if its fields look like a well-structured creative brief.

The public routes copy body.prompt into the provider parameters. They do not transform a structured prompt object into text. If your application writes a structured brief, serialize it deliberately into the string you want sent, or compile it into a plain-language prompt.

The job service validates provider parameters before reserving credits and creating the job. This establishes a local ordering boundary, not a promise that every request passing the string check will succeed upstream.

Add an application policy

For a simple prompt text area, trim leading and trailing whitespace when deciding whether the user supplied content. If the trimmed result is empty, show a local message before submission. Decide separately whether to submit the trimmed version or preserve intentional formatting in the actual prompt.

For multiline creative briefs, internal whitespace can carry useful organization. Avoid collapsing all spaces and newlines indiscriminately. A better policy checks for at least one non-whitespace character while preserving the reviewed content.

Use a draft status in your own application so a saved unfinished prompt is not mistaken for an approved generation task. Saving a draft and submitting a paid request are separate actions with different acceptance requirements.

Make the failure actionable

A client error should name the prompt field and preserve the user’s draft. Do not immediately resend the same empty input. If an agent assembled the request, retain the missing source field or failed template expansion that produced it so the author can correct the input.

A common failure is a template that contains only punctuation and labels after optional fields are removed. It may pass a nonempty string test but still lack a subject or action. Add a domain-specific brief review for that scenario without claiming the gateway performs semantic validation.

Offline acceptance

Test an empty string, whitespace only, a normal sentence, a multiline brief, null, a missing property, and an object. Confirm your local policy and the provider schema outcomes separately. Document any normalization that changes the submitted string.

Approve the workflow when drafts remain editable, whitespace-only submissions are stopped locally, and structured briefs become explicit strings. Continue with JSON prompting, input validation, and prompt revision review when moving from a valid string to an approved creative request.

Continue with models and parameters

Where these facts come from

  • codebase: src/app/api/v1/images/generations/route.ts
  • codebase: src/app/api/v1/video/generations/route.ts
  • codebase: src/ai/jobs/service.ts
  • codebase: src/ai/providers/nano-banana.ts
  • codebase: src/ai/providers/seedance.ts
  • codebase: src/ai/providers/kling.ts
  • codebase: src/ai/providers/veo3.ts
  • Editorial keyword hypothesis; search volume not measured