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 {
success: true;
models: ProviderModel[];
@ -126,8 +119,9 @@ export async function GET(
);
try {
// Build URL with category filter and optional search
let url = `${FAL_API_BASE}/models?${buildCategoryFilter()}&status=active`;
// Build URL - fetch all active models, filter client-side
// 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) {
url += `&q=${encodeURIComponent(searchQuery)}`;

17
src/lib/providers/fal.ts

@ -137,13 +137,6 @@ function buildHeaders(apiKey: string | null): HeadersInit {
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
*/
@ -155,8 +148,9 @@ const falProvider: ProviderInterface = {
const apiKey = getApiKeyFromStorage();
try {
// Fetch models with category filter for relevant types
const url = `${FAL_API_BASE}/models?${buildCategoryFilter()}&status=active`;
// Fetch all active models, filter client-side
// 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, {
headers: buildHeaders(apiKey),
});
@ -179,8 +173,9 @@ const falProvider: ProviderInterface = {
const apiKey = getApiKeyFromStorage();
try {
// Search with query and category filter
const url = `${FAL_API_BASE}/models?q=${encodeURIComponent(query)}&${buildCategoryFilter()}&status=active`;
// Search with query, filter client-side
// 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, {
headers: buildHeaders(apiKey),
});

Loading…
Cancel
Save