Readiness Endpoint
Settings and onboarding screens sometimes need to show whether a delegation is usable before model execution. Use checkReadiness() instead of prepareExecution...() for that case. A readiness endpoint does not issue authorization or relay credentials.
App-Resolved Scope Route
Section titled “App-Resolved Scope Route”import { createVelaClientFromEnvironment, createVelaEnvironmentDiagnosticsResponse, createVelaErrorResponse, createVelaIntegration, createVelaIntegrationReadinessResponse, getVelaEnvironmentDiagnostics, resolveVelaExecutionScopeFromUrl,} from "@vel4ai/sdk";
declare const process: { env: Record<string, string | undefined> };
export async function GET(req: Request): Promise<Response> { const environment = getVelaEnvironmentDiagnostics({ env: process.env });
if (!environment.ok) { return createVelaEnvironmentDiagnosticsResponse(environment, { body: { ready: false }, }); }
const executionScope = resolveVelaExecutionScopeFromUrl(req.url);
if (!executionScope) { return Response.json({ ready: false, error: "Vela execution scope is missing." }, { status: 400 }); }
try { const vela = createVelaIntegration({ client: createVelaClientFromEnvironment({ env: process.env }), executionScope, });
return createVelaIntegrationReadinessResponse(await vela.checkReadiness()); } catch (error) { return createVelaErrorResponse(error, { body: { ready: false }, fallbackMessage: "Vela readiness check failed unexpectedly.", }); }}Env-Driven Demo Route
Section titled “Env-Driven Demo Route”Only local demos should use createVelaIntegrationReadinessResponseFromEnvironment() to resolve the client and scope together.
import { createVelaIntegrationReadinessResponseFromEnvironment } from "@vel4ai/sdk";
declare const process: { env: Record<string, string | undefined> };
export function GET(): Promise<Response> { return createVelaIntegrationReadinessResponseFromEnvironment({ env: process.env, });}Response Contents
Section titled “Response Contents”The readiness result returns ready, reasonCode, requestedModel, modelResolution, and statusSnapshot. A terminal delegation status can be used as a signal to clear saved scope.