Guide · Amazon Bedrock · Model Distillation · Deployment
Bedrock Model Distillation Deployment — Provisioned Throughput, MCP tool handler, teacher/student routing
A Bedrock distilled model cannot be invoked on-demand — it requires Provisioned Throughput (PT) before any tool handler can call it, and the PT must be active before you retire the teacher model from production traffic. Four deployment pitfalls catch MCP server builders: the modelId in ConverseCommand must be the provisioned model ARN, not the custom model ARN — using the custom model ARN directly returns AccessDeniedException: Custom models require Provisioned Throughput; PT provisioning takes 10–30 minutes, so GetProvisionedModelThroughputCommand must be polled until status === "InService" before shifting traffic; PT is priced as a fixed monthly commitment regardless of token usage — the minimum commitment is OneMonth, so buying PT for a model you retire in two weeks wastes money; and one model unit supports a fixed request concurrency for the student model — if your MCP server handles bursts above that concurrency, requests queue inside Bedrock and increase latency. For the job creation API see distillation overview; for hyperparameters see customization job parameters.
TL;DR
After the distillation job reaches "Completed", call CreateProvisionedThroughputCommand with the outputModelArn and wait for the PT to reach "InService". Use the provisionedModelArn in ConverseCommand.modelId. Route traffic to the student only after verifying quality matches the teacher on a held-out eval set. Delete PT before the commitment period ends if the model performs below expectations — once the commitment renews, you're locked in for another cycle.
Creating Provisioned Throughput for the distilled model
Once the distillation job is Completed, outputModelArn from GetModelCustomizationJobCommand is the custom model ARN. Pass it to CreateProvisionedThroughputCommand:
import {
BedrockClient,
CreateProvisionedThroughputCommand,
GetProvisionedModelThroughputCommand,
} from "@aws-sdk/client-bedrock";
const bedrockClient = new BedrockClient({ region: "us-east-1" });
async function createProvisionedThroughput(params: {
customModelArn: string;
provisionedModelName: string;
modelUnits?: number;
}): Promise<string> {
const response = await bedrockClient.send(
new CreateProvisionedThroughputCommand({
// The custom model ARN from the completed distillation job
modelId: params.customModelArn,
// Unique name for this provisioned throughput resource
provisionedModelName: params.provisionedModelName,
// Number of model units (1 = minimum; determines max concurrency)
modelUnits: params.modelUnits ?? 1,
// Minimum commitment: "OneMonth" or "SixMonths"
// SixMonths is ~30-50% cheaper per unit but locks you in for 6 months
commitmentDuration: "OneMonth",
})
);
// provisionedModelArn is what you use in ConverseCommand.modelId
return response.provisionedModelArn!;
}
// Wait for PT to become InService
async function waitForProvisionedThroughput(
provisionedModelArn: string
): Promise<void> {
while (true) {
const pt = await bedrockClient.send(
new GetProvisionedModelThroughputCommand({
provisionedModelId: provisionedModelArn,
})
);
console.log(`PT status: ${pt.status}`);
if (pt.status === "InService") break;
if (pt.status === "Failed") {
throw new Error(`Provisioned Throughput failed: ${pt.failureMessage}`);
}
// "Creating" or "Updating" — wait and retry
await new Promise((r) => setTimeout(r, 30_000));
}
}
// Full deployment sequence:
const customModelArn = "arn:aws:bedrock:us-east-1:123456789012:custom-model/mcp-classifier-lite-v1";
const provisionedModelArn = await createProvisionedThroughput({
customModelArn,
provisionedModelName: "mcp-classifier-lite-pt-v1",
modelUnits: 1,
});
await waitForProvisionedThroughput(provisionedModelArn);
console.log("Ready to invoke:", provisionedModelArn);
The provisionedModelArn format is arn:aws:bedrock:REGION:ACCOUNT_ID:provisioned-model/RESOURCE_ID — it includes your account ID, unlike foundation model ARNs which have no account segment. Keep this ARN in an environment variable or AWS SSM Parameter Store so your MCP server can retrieve it at startup without hardcoding.
Invoking the distilled model in an MCP tool handler
At runtime, using the distilled model from a tool handler is identical to using any other Bedrock model — just replace the modelId with the provisioned model ARN:
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
import { z } from "zod";
import {
BedrockRuntimeClient,
ConverseCommand,
} from "@aws-sdk/client-bedrock-runtime";
// Runtime client for inference — separate from BedrockClient (control-plane)
const runtimeClient = new BedrockRuntimeClient({ region: "us-east-1" });
// Provisioned model ARN — load from environment, not hardcoded
const DISTILLED_MODEL_ID = process.env.DISTILLED_MODEL_ARN!;
// Falls back to teacher model if distilled model is not yet provisioned
const TEACHER_MODEL_ID = "anthropic.claude-3-sonnet-20240229-v1:0";
const server = new McpServer({ name: "support-server", version: "1.0.0" });
server.tool(
"classify_support_ticket",
{
ticket: z.string().describe("Support ticket text to classify"),
useTeacher: z.boolean().optional().describe("Force teacher model (for A/B comparison)"),
},
async ({ ticket, useTeacher }) => {
const modelId = useTeacher ? TEACHER_MODEL_ID : DISTILLED_MODEL_ID;
const response = await runtimeClient.send(
new ConverseCommand({
modelId,
messages: [
{
role: "user",
content: [
{
text: `Classify this support ticket into one of: billing, technical, account, general.\n\nTicket: ${ticket}\n\nCategory:`,
},
],
},
],
inferenceConfig: {
maxTokens: 20,
temperature: 0,
stopSequences: ["\n"],
},
})
);
const category =
response.output?.message?.content
?.filter((b) => b.text)
.map((b) => b.text)
.join("")
.trim() ?? "general";
return {
content: [{ type: "text", text: category }],
metadata: {
modelUsed: modelId.includes("provisioned-model") ? "distilled" : "teacher",
inputTokens: response.usage?.inputTokens,
outputTokens: response.usage?.outputTokens,
},
};
}
);
The optional useTeacher flag provides a quick A/B escape hatch — MCP clients can explicitly request the teacher model for high-stakes calls while the distilled model handles the bulk of routine classification. Remove this flag once the distilled model's production quality is validated.
Gradual traffic shift from teacher to student
Rather than switching all traffic at once, route a small percentage to the student model while monitoring quality. Increase the percentage as confidence builds:
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
import { z } from "zod";
import {
BedrockRuntimeClient,
ConverseCommand,
} from "@aws-sdk/client-bedrock-runtime";
const runtimeClient = new BedrockRuntimeClient({ region: "us-east-1" });
// Traffic split configuration — increase STUDENT_TRAFFIC_PERCENT over time
// 0 = all teacher, 100 = all student
const STUDENT_TRAFFIC_PERCENT = Number(process.env.STUDENT_TRAFFIC_PERCENT ?? "0");
const TEACHER_MODEL_ID = "anthropic.claude-3-sonnet-20240229-v1:0";
const STUDENT_MODEL_ARN = process.env.DISTILLED_MODEL_ARN!;
function selectModel(): { modelId: string; isStudent: boolean } {
if (!STUDENT_MODEL_ARN || STUDENT_TRAFFIC_PERCENT === 0) {
return { modelId: TEACHER_MODEL_ID, isStudent: false };
}
const useStudent = Math.random() * 100 < STUDENT_TRAFFIC_PERCENT;
return {
modelId: useStudent ? STUDENT_MODEL_ARN : TEACHER_MODEL_ID,
isStudent: useStudent,
};
}
const server = new McpServer({ name: "support-server", version: "1.0.0" });
server.tool(
"classify_ticket",
{ ticket: z.string() },
async ({ ticket }) => {
const { modelId, isStudent } = selectModel();
const start = Date.now();
const response = await runtimeClient.send(
new ConverseCommand({
modelId,
messages: [
{
role: "user",
content: [{ text: `Classify: ${ticket}` }],
},
],
inferenceConfig: { maxTokens: 20, temperature: 0 },
})
);
const latencyMs = Date.now() - start;
const result =
response.output?.message?.content
?.filter((b) => b.text)
.map((b) => b.text)
.join("") ?? "";
// Log for quality monitoring — compare student vs teacher labels
console.log(JSON.stringify({
model: isStudent ? "student" : "teacher",
latencyMs,
inputTokens: response.usage?.inputTokens,
outputTokens: response.usage?.outputTokens,
result: result.trim(),
ticket: ticket.slice(0, 100),
}));
return { content: [{ type: "text", text: result.trim() }] };
}
);
Recommended rollout schedule: start at 5% student traffic for 24 hours, compare labels between teacher and student on the same tickets (log both for the shadow period), increase to 25% if agreement rate is above 95%, then to 100% if 25% shows no degradation over 48 hours. If the student's label diverges from the teacher's on more than 5% of tickets in production, roll back by setting STUDENT_TRAFFIC_PERCENT=0 and re-evaluate the training data distribution.
Model units and concurrency planning
One model unit supports a specific maximum request concurrency. For small student models like Amazon Titan Text Lite, one model unit handles more concurrent requests than a large foundation model on the same unit count. Understand your MCP server's peak concurrent tool calls before choosing unit count:
// Concurrency estimation for Provisioned Throughput sizing
function estimateModelUnits(params: {
peakConcurrentToolCalls: number; // max simultaneous classify_ticket calls
avgLatencyMs: number; // expected distilled model latency per call
safetyMarginPercent: number; // extra capacity buffer (20-50%)
}): number {
// Throughput per model unit depends on the student model and task
// For Amazon Titan Text Lite on short classification tasks: ~10-20 req/s per unit
// Conservative estimate: 5 req/s per unit to account for variable latency
const requestsPerSecondPerUnit = 5;
// Peak calls per second from concurrency and average latency
const peakRequestsPerSecond =
params.peakConcurrentToolCalls / (params.avgLatencyMs / 1000);
const requiredUnits = peakRequestsPerSecond / requestsPerSecondPerUnit;
const withMargin = requiredUnits * (1 + params.safetyMarginPercent / 100);
return Math.max(1, Math.ceil(withMargin));
}
const units = estimateModelUnits({
peakConcurrentToolCalls: 50, // 50 simultaneous classify_ticket calls
avgLatencyMs: 300, // 300 ms expected latency
safetyMarginPercent: 50, // 50% safety margin
});
console.log(`Recommended model units: ${units}`);
// peak = 50 / 0.3 ≈ 167 req/s, needs 167/5 = 33 units × 1.5 ≈ 50 units
// At this scale, verify the per-unit pricing on the Bedrock pricing page
For MCP servers with moderate classification workloads (up to 10 concurrent tool calls), one model unit is typically sufficient. The Bedrock console shows request queue depth and throttle counts for a provisioned model — monitor these in the first week after going live and add units if the queue depth is consistently above zero during peak hours.
Benchmarking teacher vs student cost and latency
The core justification for distillation is cost and latency reduction. Measure both before committing to a one-month PT purchase:
async function benchmarkModels(params: {
prompts: string[];
teacherModelId: string;
studentModelArn: string;
iterations?: number;
}): Promise<void> {
const { prompts, teacherModelId, studentModelArn, iterations = 50 } = params;
async function runBatch(modelId: string, label: string) {
const latencies: number[] = [];
const tokenCounts: number[] = [];
for (let i = 0; i < iterations; i++) {
const prompt = prompts[i % prompts.length];
const start = Date.now();
const response = await runtimeClient.send(
new ConverseCommand({
modelId,
messages: [{ role: "user", content: [{ text: prompt }] }],
inferenceConfig: { maxTokens: 50, temperature: 0 },
})
);
latencies.push(Date.now() - start);
tokenCounts.push(
(response.usage?.inputTokens ?? 0) + (response.usage?.outputTokens ?? 0)
);
}
const avgLatency = latencies.reduce((a, b) => a + b, 0) / latencies.length;
const p95Latency = latencies.sort((a, b) => a - b)[Math.floor(latencies.length * 0.95)];
const avgTokens = tokenCounts.reduce((a, b) => a + b, 0) / tokenCounts.length;
console.log(`\n${label}:`);
console.log(` avg latency: ${avgLatency.toFixed(0)}ms`);
console.log(` p95 latency: ${p95Latency}ms`);
console.log(` avg tokens per call: ${avgTokens.toFixed(0)}`);
}
await runBatch(teacherModelId, "Teacher (Claude 3 Sonnet)");
await runBatch(studentModelArn, "Student (Distilled Titan Lite)");
}
// Run benchmark on representative prompts before full rollout
await benchmarkModels({
prompts: [
"Classify: I cannot reset my password.",
"Classify: Unexpected charge on my credit card.",
"Classify: API response is slower than expected.",
"Classify: How do I export my data?",
],
teacherModelId: "anthropic.claude-3-sonnet-20240229-v1:0",
studentModelArn: process.env.DISTILLED_MODEL_ARN!,
iterations: 100,
});
Deleting Provisioned Throughput before renewal
PT commitments renew automatically unless deleted before the end of the commitment period. If your distilled model's performance is below expectations, delete the PT resource before it renews to avoid another month of charges:
import { DeleteProvisionedModelThroughputCommand } from "@aws-sdk/client-bedrock";
async function deleteProvisionedThroughput(provisionedModelArn: string): Promise<void> {
// Before deleting: shift all traffic back to the teacher model
// (set STUDENT_TRAFFIC_PERCENT=0 in your MCP server env)
await bedrockClient.send(
new DeleteProvisionedModelThroughputCommand({
provisionedModelId: provisionedModelArn,
})
);
// Deletion is eventual — the resource moves to "Deleting" then disappears
// You are not billed for the remaining commitment period after deletion IF
// you are within the cancellation window (check current Bedrock pricing terms)
console.log("Provisioned Throughput deletion initiated:", provisionedModelArn);
}
// Check PT expiration date before deleting
async function checkProvisionedThroughputDetails(provisionedModelArn: string) {
const pt = await bedrockClient.send(
new GetProvisionedModelThroughputCommand({
provisionedModelId: provisionedModelArn,
})
);
console.log({
status: pt.status, // "InService" | "Creating" | "Updating" | "Failed"
creationTime: pt.creationTime,
lastModifiedTime: pt.lastModifiedTime,
commitmentDuration: pt.commitmentDuration, // "OneMonth" | "SixMonths"
commitmentExpirationTime: pt.commitmentExpirationTime, // when the current commitment ends
modelUnits: pt.modelUnits,
});
return pt;
}
Mark the commitmentExpirationTime in your team calendar. Bedrock does not send automatic expiration reminders — you must monitor it yourself. If you want to continue using the model, you can update the provisioned throughput (change unit count or extend commitment) via UpdateProvisionedThroughputCommand rather than deleting and re-creating.
MCP server startup check for distilled model readiness
Add a startup check to your MCP server that verifies the provisioned model is InService before accepting tool calls. This prevents silent failures where the server starts but every tool call returns errors because the PT resource is still being created:
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
import {
BedrockClient,
GetProvisionedModelThroughputCommand,
} from "@aws-sdk/client-bedrock";
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
const bedrockClient = new BedrockClient({ region: "us-east-1" });
async function checkDistilledModelReady(): Promise<boolean> {
const ptArn = process.env.DISTILLED_MODEL_ARN;
if (!ptArn) {
console.warn("DISTILLED_MODEL_ARN not set — using teacher model for all calls");
return false;
}
try {
const pt = await bedrockClient.send(
new GetProvisionedModelThroughputCommand({ provisionedModelId: ptArn })
);
if (pt.status === "InService") {
console.log("Distilled model is InService:", ptArn);
return true;
} else {
console.warn(`Distilled model status is ${pt.status} — falling back to teacher`);
return false;
}
} catch (err) {
console.error("Could not check distilled model status:", err);
return false;
}
}
// Check at startup — this is fast (single describe call, no inference)
const distilledModelReady = await checkDistilledModelReady();
const server = new McpServer({ name: "support-server", version: "1.0.0" });
// Register tools — they use distilledModelReady flag for model selection
// (omitted for brevity — see routing example above)
const transport = new StdioServerTransport();
await server.connect(transport);
Monitor your distilled model endpoint continuously
Provisioned Throughput has different failure modes than on-demand inference: the endpoint can become "Failed" due to AWS infrastructure issues, and your MCP tool handlers start returning errors that look like model timeouts until you check PT status. AliveMCP monitors your MCP server from outside your AWS account and alerts you within seconds when tool calls fail — giving you time to fall back to the teacher model before users notice the degradation.