Builds a validation failure. The SDK does this itself before it performs a request.
What was wrong with the call, such as 'Message cannot be empty'.
Optionalkey: string
Name of the field the failure is about. The SDK's own validations leave it unset.
Optional ReadonlykeyName of the field the failure is about.
The SDK does not populate it — every validation it raises passes the message alone — so it
is only set on a ValidationError an application constructed itself. It is also left out
of toJson(), so a serialized validation error carries only its
kind and message.
ReadonlykindAlways 'ValidationError'. Branch on it to tell this failure from the other SDK errors.
Optional ReadonlyoriginalThe error or value that caused this one, when the SDK was wrapping something else.
For a NetworkError this is the browser's own fetch rejection. It is not
serialized as-is: toJson() takes only an Error cause's
message.
Serializes the error into the JSON-safe ErrorJson payload for logging or reporting.
The payload always carries kind and the message. The cause's message
is added only when originalError is an Error and says
something the message does not, truncated to 256 characters; any other cause is dropped.
Subclasses extend the payload with the fields listed on their own pages.
The error as plain, JSON-serializable data.
A method was called with arguments, or in a state, that the SDK will not send to the Agents API.
This is one of the two SDK errors that only ever reach the caller and are never delivered to onError (the other is ChatCreationFailed): it is the direct answer to the call you just made, and every method that raises it rejects the promise it returned, so
awaitthe call inside atry/catchor attach a.catch(). The SDK raises it from chat() when the message is empty or 2000 characters or longer, when the session's ChatMode has chat disabled or is in maintenance, and when the chat or the stream has not been initialized yet; from speak() when it is called before connect(); and from rate(), deleteRate() and submitFeedback() when no chat has started, plus, forrate()alone, when no message with the given id is in the transcript. It is also raised from createAgentManager and changeMode() when an Expressive (V4) agent is asked for ChatMode.Off or ChatMode.DirectPlayback, which only Talks (V2) and Clips (V3) agents support. The five Expressive-only media methods — publishMicrophoneStream(), replaceMicrophoneTrack(), publishCameraStream(), setSttLanguage() and sendDataChannelMessage() — raise it the other way round: when the session is a Talks (V2) or Clips (V3) one, or connect() has not run yet.Nothing was sent to the Agents API when this is raised, so the session stays usable: fix the argument or wait for 'connected' and call again. kind is
'ValidationError'.