Skip to content

🪢 Open source agent evals & observability: Trace, evaluate, and improve LLM applications with one open platform.

trace api

Max Deichmannf7d2997e9ac2
diff --git a/src/pages/api/traces.ts b/src/pages/api/traces.ts
index c533d74fb6..01f7c21711 100644
--- a/src/pages/api/traces.ts
+++ b/src/pages/api/traces.ts
@@ -7,7 +7,7 @@ const prisma = new PrismaClient();
const TraceSchema = z.object({
name: z.string(),
attributes: z.record(z.string(), z.any()),
- status: z.string(),
+ status: z.literal("success").or(z.literal("error")).or(z.literal("running")),
statusMessage: z.string().optional(),
});
@@ -35,11 +35,15 @@ export default async function handler(
});
res.status(201).json({ trace: newTrace });
- } catch (error) {
- res.status(400).json({
- success: false,
- message: "Invalid request data",
- error: error.message,
- });
+ } catch (error: unknown) {
+ const errorMessage =
+ error instanceof Error ? error.message : "An unknown error occurred";
+ res
+ .status(400)
+ .json({
+ success: false,
+ message: "Invalid request data",
+ error: errorMessage,
+ });
}
}