Browse Source

fix(02-02): remove multiple category params causing 400 error

fal.ai API only accepts a single category parameter, but we were
sending multiple categories. Now we fetch all active models and
filter client-side using the existing isRelevantModel() function.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
handoff-20260429-1057
shrimbly 6 months ago
parent
commit
2fe312db43
  1. 12
      src/app/api/providers/fal/models/route.ts
  2. 17
      src/lib/providers/fal.ts

12
src/app/api/providers/fal/models/route.ts

@ -80,13 +80,6 @@ function mapToProviderModel(model: FalModel): ProviderModel {
}; };
} }
/**
* Build category filter query string for relevant categories
*/
function buildCategoryFilter(): string {
return RELEVANT_CATEGORIES.map((cat) => `category=${encodeURIComponent(cat)}`).join("&");
}
interface ModelsSuccessResponse { interface ModelsSuccessResponse {
success: true; success: true;
models: ProviderModel[]; models: ProviderModel[];
@ -126,8 +119,9 @@ export async function GET(
); );
try { try {
// Build URL with category filter and optional search // Build URL - fetch all active models, filter client-side
let url = `${FAL_API_BASE}/models?${buildCategoryFilter()}&status=active`; // Note: fal.ai API only accepts single category param, so we fetch all and filter
let url = `${FAL_API_BASE}/models?status=active`;
if (searchQuery) { if (searchQuery) {
url += `&q=${encodeURIComponent(searchQuery)}`; url += `&q=${encodeURIComponent(searchQuery)}`;

17
src/lib/providers/fal.ts

@ -137,13 +137,6 @@ function buildHeaders(apiKey: string | null): HeadersInit {
return headers; return headers;
} }
/**
* Build category filter query string for relevant categories
*/
function buildCategoryFilter(): string {
return RELEVANT_CATEGORIES.map((cat) => `category=${encodeURIComponent(cat)}`).join("&");
}
/** /**
* fal.ai provider implementation * fal.ai provider implementation
*/ */
@ -155,8 +148,9 @@ const falProvider: ProviderInterface = {
const apiKey = getApiKeyFromStorage(); const apiKey = getApiKeyFromStorage();
try { try {
// Fetch models with category filter for relevant types // Fetch all active models, filter client-side
const url = `${FAL_API_BASE}/models?${buildCategoryFilter()}&status=active`; // Note: fal.ai API only accepts single category param, so we fetch all and filter
const url = `${FAL_API_BASE}/models?status=active`;
const response = await fetch(url, { const response = await fetch(url, {
headers: buildHeaders(apiKey), headers: buildHeaders(apiKey),
}); });
@ -179,8 +173,9 @@ const falProvider: ProviderInterface = {
const apiKey = getApiKeyFromStorage(); const apiKey = getApiKeyFromStorage();
try { try {
// Search with query and category filter // Search with query, filter client-side
const url = `${FAL_API_BASE}/models?q=${encodeURIComponent(query)}&${buildCategoryFilter()}&status=active`; // Note: fal.ai API only accepts single category param, so we fetch all and filter
const url = `${FAL_API_BASE}/models?q=${encodeURIComponent(query)}&status=active`;
const response = await fetch(url, { const response = await fetch(url, {
headers: buildHeaders(apiKey), headers: buildHeaders(apiKey),
}); });

Loading…
Cancel
Save