Execution gate

Prepare every model call before relay.

Use readiness and prepare helpers to resolve model access, return blocked or denied responses early, and keep relay credentials short-lived.

Prepare execution

prepareExecutionWithResponse() is the default path for web route handlers. It combines delegation status lookup, requested model resolution, authorization, non-allow response creation, relay config, and report helpers.

blocked: setup issue deny: policy issue allow: relay ready
Readiness check without authorization
import { createVelaClientFromEnvironment, createVelaErrorResponse, createVelaIntegration, createVelaIntegrationReadinessResponse } from "@vela/sdk";

export async function GET(req: Request) {
  try {
    const executionScope = await resolveExecutionScopeForRequest(req);

    if (!executionScope) {
      return Response.json({ ready: false, error: "Vela execution scope is not configured." }, { status: 400 });
    }

    const client = createVelaClientFromEnvironment({ env: process.env });
    const vela = createVelaIntegration({ client, executionScope });

    return createVelaIntegrationReadinessResponse(await vela.checkReadiness());
  } catch (error) {
    return createVelaErrorResponse(error, {
      body: { ready: false },
      fallbackMessage: "Unexpected Vela readiness error.",
    });
  }
}
Bind the app-chosen scope once
import { createVelaClientFromEnvironment, createVelaIntegration } from "@vela/sdk";

const client = createVelaClientFromEnvironment({ env: process.env });

const vela = createVelaIntegration({
  client,
  executionScope: {
    customerTenantId,
    delegationId,
    requestedModel,
  },
});

const prepared = await vela.prepareExecutionWithResponse({
  estimatedCostUsd: 0.05,
  zeroDataRetentionCapable: true,
});

if (prepared.outcome !== "allow") {
  return prepared.response;
}

When not using Web Response

Use prepareExecutionWithFailure() and createPreparedExecutionFailureHttpResponse() in runtimes that need a framework-neutral { status, body } descriptor instead of a Web Response.