Skip to content

Supercharge your AI agents with data from the web and beyond. Building the library for superintelligence. 🔥

Nick: fix json valdiation

Nicolas044bc33aae54
diff --git a/apps/js-sdk/firecrawl/src/v2/types.ts b/apps/js-sdk/firecrawl/src/v2/types.ts
index 026389a6a..42b1a7208 100644
--- a/apps/js-sdk/firecrawl/src/v2/types.ts
+++ b/apps/js-sdk/firecrawl/src/v2/types.ts
@@ -22,8 +22,8 @@ export interface Format {
export interface JsonFormat extends Format {
type: "json";
- prompt: string;
- schema: Record<string, unknown> | ZodTypeAny;
+ prompt?: string;
+ schema?: Record<string, unknown> | ZodTypeAny;
}
export interface ScreenshotFormat {
diff --git a/apps/js-sdk/firecrawl/src/v2/utils/validation.ts b/apps/js-sdk/firecrawl/src/v2/utils/validation.ts
index 82c97ee35..1461e500c 100644
--- a/apps/js-sdk/firecrawl/src/v2/utils/validation.ts
+++ b/apps/js-sdk/firecrawl/src/v2/utils/validation.ts
@@ -12,8 +12,8 @@ export function ensureValidFormats(formats?: FormatOption[]): void {
}
if ((fmt as JsonFormat).type === "json") {
const j = fmt as JsonFormat;
- if (!j.prompt || !j.schema) {
- throw new Error("json format requires 'prompt' and 'schema'");
+ if (!j.prompt && !j.schema) {
+ throw new Error("json format requires either 'prompt' or 'schema' (or both)");
}
// Flexibility: allow passing a Zod schema. Convert to JSON schema internally.
const maybeSchema: any = j.schema as any;