Skip to main content

Class: NoObjectGeneratedError

Defined in: node_modules/.pnpm/ai@7.0.113_zod@4.3.6/node_modules/ai/dist/index.d.ts:7433

Thrown when no object could be generated. This can have several causes:

  • The model failed to generate a response.
  • The model generated a response that could not be parsed.
  • The model generated a response that could not be validated against the schema.

The error contains the following properties:

  • text: The text that was generated by the model. This can be the raw text or the tool call text, depending on the model.

Extends​

  • AISDKError

Constructors​

Constructor​

new NoObjectGeneratedError(__namedParameters): NoObjectGeneratedError

Defined in: node_modules/.pnpm/ai@7.0.113_zod@4.3.6/node_modules/ai/dist/index.d.ts:7451

Parameters​

__namedParameters​
cause?​

Error

finishReason​

FinishReason

message?​

string

response​

Omit<LanguageModelResponseMetadata, "messages">

text?​

string

usage​

LanguageModelUsage

Returns​

NoObjectGeneratedError

Overrides​

AISDKError.constructor

Properties​

cause?​

readonly optional cause?: unknown

Defined in: node_modules/.pnpm/@ai-sdk+provider@4.0.18/node_modules/@ai-sdk/provider/dist/index.d.ts:1994

The underlying cause of the error, if any.

Inherited from​

AISDKError.cause


finishReason​

readonly finishReason: FinishReason | undefined

Defined in: node_modules/.pnpm/ai@7.0.113_zod@4.3.6/node_modules/ai/dist/index.d.ts:7450

Reason why the model finished generating a response.


message​

message: string

Defined in: node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es5.d.ts:1077

Inherited from​

AISDKError.message


name​

name: string

Defined in: node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es5.d.ts:1076

Inherited from​

AISDKError.name


response​

readonly response: Omit<LanguageModelResponseMetadata, "messages"> | undefined

Defined in: node_modules/.pnpm/ai@7.0.113_zod@4.3.6/node_modules/ai/dist/index.d.ts:7442

The response metadata.


stack?​

optional stack?: string

Defined in: node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es5.d.ts:1078

Inherited from​

AISDKError.stack


text​

readonly text: string | undefined

Defined in: node_modules/.pnpm/ai@7.0.113_zod@4.3.6/node_modules/ai/dist/index.d.ts:7438

The text that was generated by the model. This can be the raw text or the tool call text, depending on the model.


usage​

readonly usage: LanguageModelUsage | undefined

Defined in: node_modules/.pnpm/ai@7.0.113_zod@4.3.6/node_modules/ai/dist/index.d.ts:7446

The usage of the model.


stackTraceLimit​

static stackTraceLimit: number

Defined in: node_modules/.pnpm/@types+node@22.19.7/node_modules/@types/node/globals.d.ts:68

The Error.stackTraceLimit property specifies the number of stack frames collected by a stack trace (whether generated by new Error().stack or Error.captureStackTrace(obj)).

The default value is 10 but may be set to any valid JavaScript number. Changes will affect any stack trace captured after the value has been changed.

If set to a non-number value, or set to a negative number, stack traces will not capture any frames.

Inherited from​

AISDKError.stackTraceLimit

Methods​

captureStackTrace()​

static captureStackTrace(targetObject, constructorOpt?): void

Defined in: node_modules/.pnpm/@types+node@22.19.7/node_modules/@types/node/globals.d.ts:52

Creates a .stack property on targetObject, which when accessed returns a string representing the location in the code at which Error.captureStackTrace() was called.

const myObject = {};
Error.captureStackTrace(myObject);
myObject.stack; // Similar to `new Error().stack`

The first line of the trace will be prefixed with ${myObject.name}: ${myObject.message}.

The optional constructorOpt argument accepts a function. If given, all frames above constructorOpt, including constructorOpt, will be omitted from the generated stack trace.

The constructorOpt argument is useful for hiding implementation details of error generation from the user. For instance:

function a() {
b();
}

function b() {
c();
}

function c() {
// Create an error without stack trace to avoid calculating the stack trace twice.
const { stackTraceLimit } = Error;
Error.stackTraceLimit = 0;
const error = new Error();
Error.stackTraceLimit = stackTraceLimit;

// Capture the stack trace above function b
Error.captureStackTrace(error, b); // Neither function c, nor b is included in the stack trace
throw error;
}

a();

Parameters​

targetObject​

object

constructorOpt?​

Function

Returns​

void

Inherited from​

AISDKError.captureStackTrace


hasMarker()​

protected static hasMarker(error, marker): boolean

Defined in: node_modules/.pnpm/@ai-sdk+provider@4.0.18/node_modules/@ai-sdk/provider/dist/index.d.ts:2014

Parameters​

error​

unknown

marker​

string

Returns​

boolean

Inherited from​

AISDKError.hasMarker


isError()​

static isError(error): error is Error

Defined in: node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.esnext.error.d.ts:23

Indicates whether the argument provided is a built-in Error instance or not.

Parameters​

error​

unknown

Returns​

error is Error

Inherited from​

AISDKError.isError


isInstance()​

static isInstance(error): error is NoObjectGeneratedError

Defined in: node_modules/.pnpm/ai@7.0.113_zod@4.3.6/node_modules/ai/dist/index.d.ts:7459

Checks if the given error is an AI SDK Error.

Parameters​

error​

unknown

The error to check.

Returns​

error is NoObjectGeneratedError

True if the error is an AI SDK Error, false otherwise.

Overrides​

AISDKError.isInstance


prepareStackTrace()​

static prepareStackTrace(err, stackTraces): any

Defined in: node_modules/.pnpm/@types+node@22.19.7/node_modules/@types/node/globals.d.ts:56

Parameters​

err​

Error

stackTraces​

CallSite[]

Returns​

any

See​

https://v8.dev/docs/stack-trace-api#customizing-stack-traces

Inherited from​

AISDKError.prepareStackTrace