Never stop coding. Free MIT AI gateway: one endpoint, 375 providers (150+ free), 1,400+ models Kimi, Claude, GPT, Gemini, GLM, DeepSeek, MiniMax. Works with Claude Code, Codex, Cursor, OpenCode, Cline & Copilot. Quota-aware auto-fallback, RTK+Caveman compression saves 15-95% tokens, MCP/A2A, Desktop/PWA. Built by 900+ contributors
TypeScript a2aai-agentsai-gatewayanthropicclaudeclaude-codeclinecodexcopilotcursordeepseekfree-aigeminikimillm-gatewaymcpopenaiopenai-proxyqwentoken-saver
// src/shared/schemas/playground.ts
import { z } from "zod";
import { partialWithoutDefaults } from "@/shared/validation/partialWithoutDefaults";
/** Row da tabela playground_presets. */
export const PlaygroundPresetRowSchema = z.object({
id: z.string().uuid(),
name: z.string().min(1).max(100),
endpoint: z.string().min(1),
model: z.string().min(1),
system: z.string().max(50_000).nullable(),
params_json: z.string(), // JSON serializado (parsed na rota)
created_at: z.string().datetime(),
});
/** Body de POST /api/playground/presets. */
export const PlaygroundPresetCreateSchema = z.object({
name: z.string().min(1).max(100),
endpoint: z.string().min(1),
model: z.string().min(1),
system: z.string().max(50_000).nullable().optional(),
params: z.record(z.string(), z.any()).default({}),
});
/** Body de PUT /api/playground/presets/[id]. */
export const PlaygroundPresetUpdateSchema = partialWithoutDefaults(PlaygroundPresetCreateSchema);
export const PlaygroundPresetListItemSchema = z.object({
id: z.string().uuid(),
name: z.string(),
endpoint: z.string(),
model: z.string(),
system: z.string().nullable(),
params: z.record(z.string(), z.any()),
created_at: z.string().datetime(),
});
export type PlaygroundPresetListItem = z.infer<typeof PlaygroundPresetListItemSchema>;
/** Tool definition aceito pelo Build tab. Validação client-side. */
export const ToolDefinitionSchema = z.object({
type: z.literal("function"),
function: z.object({
name: z.string().min(1).max(64),
description: z.string().max(1024).optional(),
parameters: z.record(z.string(), z.any()),
}),
});
/** JSON schema do response_format (Structured Output). Validação client-side. */
export const StructuredOutputSchema = z.object({
type: z.literal("json_schema"),
json_schema: z.object({
name: z.string().min(1).max(64),
schema: z.record(z.string(), z.any()),
strict: z.boolean().optional(),
}),
});
/** Stream metrics — uma medição por coluna/mensagem. */
export const StreamMetricsSchema = z.object({
ttftMs: z.number().nonnegative().nullable(), // null = não chegou primeiro chunk ainda
totalMs: z.number().nonnegative().nullable(),
tokensOut: z.number().int().nonnegative(),
tokensIn: z.number().int().nonnegative(),
tps: z.number().nonnegative().nullable(), // tokens/segundo (out/totalSec)
costUsd: z.number().nonnegative().nullable(),
});
export type StreamMetrics = z.infer<typeof StreamMetricsSchema>;