Skip to content
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/app/api/openrouter/[...path]/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -592,6 +592,8 @@ export async function POST(request: NextRequest): Promise<NextResponseType<unkno
request: requestBodyParsed,
response,
isUserByok: !!userByok,
feature,
balance: (await balanceAndSettingsPromise).balance,
});
if (errorResponse) {
return errorResponse;
Expand Down
15 changes: 15 additions & 0 deletions src/lib/llm-proxy-helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -142,11 +142,15 @@ export async function makeErrorReadable({
request,
response,
isUserByok,
feature,
balance,
}: {
requestedModel: string;
request: GatewayRequest;
response: Response;
isUserByok: boolean;
feature: FeatureValue | null;
balance: number;
}) {
if (response.status < 400) {
return undefined;
Expand All @@ -161,6 +165,17 @@ export async function makeErrorReadable({
{ status: response.status }
);
}

}

if (response.status === 404) {
Comment thread
chrarnoldus marked this conversation as resolved.
const recommendedModel = balance <= 0 ? KILO_AUTO_FREE_MODEL : KILO_AUTO_BALANCED_MODEL;
Comment thread
chrarnoldus marked this conversation as resolved.
const recommendation =
feature === 'kiloclaw' || feature === 'openclaw'
? `The model "${requestedModel}" does not exist or is no longer available. We recommend switching to ${recommendedModel.name}: /model kilocode/${recommendedModel.id}`
: `The model "${requestedModel}" does not exist or is no longer available. We recommend switching to ${recommendedModel.id}.`;
warnExceptInTest(`Responding with 404 ${recommendation}`);
return NextResponse.json({ error: recommendation, message: recommendation }, { status: 404 });
}

// Sometimes we get generic or nonsensical errors when the context length is exceeded
Expand Down
Loading