{"record":{"id":"2d5c7e9a4fa41704","repo":"vercel/ai","slug":"no-output-generated","errorCode":null,"errorMessage":"No output generated.","messagePattern":"No output generated\\.","errorType":"exception","errorClass":"NoOutputGeneratedError","httpStatus":null,"severity":"error","filePath":"packages/ai/src/generate-text/generate-text.ts","lineNumber":1747,"sourceCode":"\n  get responseMessages() {\n    return [\n      ...this.initialResponseMessages,\n      ...this.steps.flatMap(step => step.response.messages),\n    ];\n  }\n\n  get request() {\n    return this.finalStep.request;\n  }\n\n  get usage() {\n    return this.totalUsage;\n  }\n\n  get output() {\n    if (this._output == null) {\n      throw new NoOutputGeneratedError();\n    }\n\n    return this._output;\n  }\n}\n","sourceCodeStart":1729,"sourceCodeEnd":1753,"githubUrl":"https://github.com/vercel/ai/blob/69428b1f8b037e4d118fb4853428d5c4e620493c/packages/ai/src/generate-text/generate-text.ts#L1729-L1753","documentation":"NoOutputGeneratedError thrown by the result object's `output` getter when generateText was called with an output specification (experimental_output) but the model finished without producing any usable output. The SDK guards the accessor so consumers get a clear error instead of undefined.","triggerScenarios":"Accessing `result.output` after generateText with `experimental_output`/output spec when the step produced no text content or the output was never assigned (e.g. finishReason was tool-calls, content-filter, or the model returned an empty response).","commonSituations":"Model refused or returned empty completion; finishReason is 'tool-calls' so no text output was generated; content filter blocked the response; prompt asked for tool use while an output schema was also expected.","solutions":["Check `result.finishReason` before reading `result.output`; handle non-text finish reasons separately.","Ensure the prompt instructs the model to produce the final structured output rather than calling tools.","Wrap the `result.output` access in try/catch for NoOutputGeneratedError and fall back to raw text.","Check for content-filter/empty responses from the provider and retry with an adjusted prompt.","Update packages — some empty-output handling was fixed in newer releases."],"exampleFix":"// before\nconst data = result.output;\n// after\nlet data;\nif (result.finishReason === 'stop') {\n  data = result.output; // may still throw; see catch below\n} else {\n  data = fallbackForFinishReason(result.finishReason);\n}\ntry { data = result.output; } catch (e) { if (NoOutputGeneratedError.isInstance(e)) data = null; else throw e; }","handlingStrategy":"try-catch","validationCode":"// guard before accessing output\nfunction hasOutput(result) {\n  return result.finishReason === 'stop' && typeof result.text === 'string' && result.text.length > 0;\n}","typeGuard":"import { NoOutputGeneratedError } from 'ai';\nfunction isNoOutputGenerated(e): e is NoOutputGeneratedError {\n  return NoOutputGeneratedError.isInstance(e);\n}","tryCatchPattern":"let output;\ntry {\n  output = result.output;\n} catch (e) {\n  if (NoOutputGeneratedError.isInstance(e)) {\n    output = null; // handle empty generation, e.g. retry or fall back to result.text\n  } else throw e;\n}","preventionTips":["Check result.finishReason before reading result.output.","Raise maxOutputTokens to avoid truncated/empty generations.","Handle tool-call and content-filter finish reasons explicitly.","Retry on empty responses before giving up."],"tags":["no-output","empty-response","generate-text"],"backgroundTag":"no-output-generated","analyzedSha":"69428b1f8b037e4d118fb4853428d5c4e620493c","analyzedAt":"2026-08-30T12:32:21.016Z","schemaVersion":2},"datasetVersion":"2026-08-30T13:17:10.514Z"}