UNPKG

@mastra/core

Version:
30 lines • 1.53 kB
/** * Diagnostic fields of a provider HTTP failure (AI SDK `APICallError`). * * When a provider's error body doesn't match the shape the AI SDK expects, the * error `message` falls back to the HTTP status text ("Bad Request"), and the * real explanation is only in `responseBody`. These helpers pull out the fields * worth keeping without trusting the error object: getters may throw, fields * may be any type, and bodies may be huge. */ export declare const MAX_PERSISTED_RESPONSE_BODY_LENGTH = 2000; export declare function capPersistedText(text: string): string; export type ProviderErrorDetails = { statusCode?: number; responseBody?: string; requestId?: string; modelId?: string; }; export declare function readRequestId(headers: unknown): string | undefined; export declare function readRequestedModel(requestBody: unknown): string | undefined; export declare function readProviderErrorDetails(error: unknown): ProviderErrorDetails; /** * Human-readable one-liner for a provider HTTP failure, at most `maxLength` * characters, or undefined when the error carries no HTTP details. Example: * `Bad Request (HTTP 400): prompt is too long (request id req_123)`. * * The explanation is parsed from the full body (a truncated JSON body would not * parse), and the request id is always kept when the text has to be shortened. */ export declare function describeProviderError(message: string, error: unknown, maxLength: number): string | undefined; //# sourceMappingURL=provider-error-details.d.ts.map