Supercharge your AI agents with data from the web and beyond. Building the library for superintelligence. 🔥
TypeScript aiai-agentsai-crawlerai-scrapingai-searchcrawlerdata-extractionhtml-to-markdownllmmarkdownscraperscrapingweb-crawlerweb-dataweb-data-extractionweb-scraperweb-scrapingweb-searchwebscraping
feat(agent): default to spark-2 (#4360)
Rakshith Ramprakashcf1d31b75053
diff --git a/README.md b/README.mdindex 764cd5503..da7ee60a7 100644--- a/README.md+++ b/README.md@@ -384,11 +384,12 @@ result = app.agent(#### Model Selection-Choose between two models based on your needs:+Choose a model based on your needs:| Model | Cost | Best For ||-------|------|----------|-| `spark-1-mini` (default) | 60% cheaper | Most tasks |+| `spark-2` (default) | See [pricing](https://docs.firecrawl.dev/features/agent) | Most tasks |+| `spark-1-mini` | 60% cheaper than `spark-1-pro` | Cost-sensitive tasks || `spark-1-pro` | Standard | Complex research, critical data gathering |```pythonresult = app.agent(diff --git a/apps/api/src/controllers/v2/agent-schema.test.ts b/apps/api/src/controllers/v2/agent-schema.test.tsnew file mode 100644index 000000000..130800956--- /dev/null+++ b/apps/api/src/controllers/v2/agent-schema.test.ts@@ -0,0 +1,28 @@+import { describe, expect, it } from "vitest";+import { agentRequestSchema } from "./types";++describe("agentRequestSchema model", () => {+ it("defaults to spark-2 when no model is given", () => {+ expect(+ agentRequestSchema.parse({ prompt: "Find the pricing page" }).model,+ ).toBe("spark-2");+ });++ it("keeps an explicitly requested model", () => {+ for (const model of ["spark-1-pro", "spark-1-mini", "spark-2"] as const) {+ expect(+ agentRequestSchema.parse({ prompt: "Find the pricing page", model })+ .model,+ ).toBe(model);+ }+ });++ it("rejects an unknown model", () => {+ expect(() =>+ agentRequestSchema.parse({+ prompt: "Find the pricing page",+ model: "spark-3",+ }),+ ).toThrow();+ });+});diff --git a/apps/api/src/controllers/v2/agent-status.ts b/apps/api/src/controllers/v2/agent-status.tsindex dc82300b2..f73bff2cb 100644--- a/apps/api/src/controllers/v2/agent-status.ts+++ b/apps/api/src/controllers/v2/agent-status.ts@@ -25,6 +25,9 @@ export async function agentStatusController(const agent = await supabaseGetAgentByIdDirect(req.params.jobId);+ // Jobs whose stored options carry no model predate the model option and ran+ // on spark-1-pro, so the fallback here stays spark-1-pro even though the+ // agent request schema now defaults new jobs to spark-2.let model: "spark-1-pro" | "spark-1-mini" | "spark-2";if (agent) {model = (agent.options?.model ?? "spark-1-pro") as@@ -52,7 +55,7 @@ export async function agentStatusController(module: "api/v2",text: await optionsRequest.text(),});- model = "spark-1-pro"; // fall back to this value+ model = "spark-1-pro"; // fall back to the pre-model-option default} else {model = ((await optionsRequest.json()).model ?? "spark-1-pro") as| "spark-1-pro"@@ -66,7 +69,7 @@ export async function agentStatusController(module: "api/v2",extractId: req.params.jobId,});- model = "spark-1-pro"; // fall back to this value+ model = "spark-1-pro"; // fall back to the pre-model-option default}}diff --git a/apps/api/src/controllers/v2/types.ts b/apps/api/src/controllers/v2/types.tsindex 2dd98a199..89e9e78a7 100644--- a/apps/api/src/controllers/v2/types.ts+++ b/apps/api/src/controllers/v2/types.ts@@ -1005,9 +1005,7 @@ export const agentRequestSchema = z.strictObject({webhook: agentWebhookSchema.optional(),overrideWhitelist: z.string().optional(),- model: z- .enum(["spark-1-pro", "spark-1-mini", "spark-2"])- .default("spark-1-pro"),+ model: z.enum(["spark-1-pro", "spark-1-mini", "spark-2"]).default("spark-2"),threatProtection: threatProtectionOverrideSchema.optional(),auditMetadata: auditMetadataSchema.optional(),});