Prompted formatting is not a parser contract
An answer can contain Markdown fences, explanatory prose, missing fields or values outside your expected domain. A technically completed response can therefore fail your application's data requirements. Do not treat a successful HTTP status or a plausible-looking object as proof that the generated content is safe to execute.
What to do next
- 01
Define the expected shape
Write the required fields, value types and allowed ranges in your own schema. Request only the information needed, using a short clear instruction and bounded output length.
- 02
Validate before accepting
Parse the returned text without executing it, then run your schema checks. Keep the raw confirmed response privately for diagnosis while presenting a clear validation outcome to the user.
- 03
Handle failure deliberately
Use a controlled correction workflow or manual review when appropriate. A second model call is another potentially billable task, so do not hide unbounded repair loops behind a single action.
A concrete example
Illustrative task: a user requests three scene labels in JSON. The model returns a code-fenced object with four labels. The application rejects the shape instead of silently accepting it or repeatedly paying for repairs without a limit.
Before you call it ready
- No unsupported JSON-mode parameter is sent.
- Output is parsed and schema-checked.
- Correction attempts have explicit limits and approval.
When to stop or choose another method
If strict machine-readable guarantees are essential, choose a service with the required supported structured-output contract or add deterministic application logic. A prompt alone is insufficient assurance.
