Home → Help

Empty response with finish_reason content_filter

A moderation layer stopped generation. The request ran, so it is a normal response rather than an error, and any tokens produced before the stop are billed.

What you are seeing

Why it happens

Filtering can apply to the prompt or to the output as it is produced. A stop partway through means the output tripped it; an immediate empty response usually means the input did.

Thresholds differ by model and by provider, so the same text can pass on one and stop on another. That is why switching models appears to 'fix' it.

It is easy to confuse with truncation. The difference is in finish_reason: length means you ran out of tokens, content_filter means the content was refused.

How to fix it

  1. Branch on finish_reasonHandle content_filter as its own case with a message to the user. Retrying identical input produces the identical result and only costs money.
  2. Check which side trippedSend the prompt with a minimal max_tokens. If it still stops immediately, the input is the trigger, not the output.
  3. Rephrase rather than retryIf the task is legitimate, removing the specific phrasing that triggers it usually works. Quoted user content is a frequent cause.
A filtered response is a completed request, so the tokens generated before the stop appear in your APICLAN usage log and are charged. An empty completion with a nonzero output count is exactly this case.

Related

Unexpected token '<' when calling an OpenAI-compatible API401 invalid API key — when the key looks right but still fails

Last checked 2026-10-01. Written from problems diagnosed on a live OpenAI-compatible gateway, not collected from other sites.