Guide · Amazon Bedrock · Model Distillation
MCP Server Amazon Bedrock Model Distillation — CreateModelCustomizationJob, teacher model, student base
Amazon Bedrock Model Distillation lets MCP server builders create small, fast, cost-efficient custom models by using a large "teacher" model's outputs as training targets for a smaller "student" model. The API is CreateModelCustomizationJobCommand from @aws-sdk/client-bedrock — the control-plane package, not bedrock-runtime — with customizationType: "DISTILLATION" and a required teacherModelConfig block that names the teacher. Four constraints catch MCP server authors off-guard: the job is asynchronous and takes hours, so you must poll GetModelCustomizationJobCommand until status is "Completed"; the student base model must come from a supported distillation base list — not every Bedrock foundation model can be a student; training data only needs prompts, not completions — Bedrock calls the teacher model automatically for each prompt during the job to generate golden outputs; and the finished custom model requires Provisioned Throughput before you can invoke it — on-demand inference is not available for custom models. For training data format details see distillation training data; for hyperparameter tuning see customization job parameters; for PT deployment see deploying distilled models.
TL;DR
Import CreateModelCustomizationJobCommand from @aws-sdk/client-bedrock. Set customizationType: "DISTILLATION", point trainingDataConfig.s3Uri at a JSONL of prompts (completions are auto-generated by the teacher), name your teacher in teacherModelConfig.teacherModelIdentifier, and pick a supported small base model in baseModelIdentifier. Poll GetModelCustomizationJobCommand until status === "Completed". Then create Provisioned Throughput with CreateProvisionedThroughputCommand to serve the distilled model in MCP tool handlers.
- Bedrock Model Distillation — training data format, prompt JSONL, synthetic completions
- Bedrock Model Distillation — customization job parameters, hyperparameters, IAM role
- Bedrock Model Distillation — deploying with Provisioned Throughput, MCP tool integration
- Bedrock Fine-Tuning — FINE_TUNING vs DISTILLATION comparison
- Bedrock Provisioned Throughput — model units, commitment duration, cost
What distillation is and why MCP server builders use it
Model distillation transfers knowledge from a large, expensive foundation model (the teacher) to a small, cheap custom model (the student). The student learns by seeing the teacher's outputs on a dataset of prompts that reflect your production workload. After training, the student model can produce responses similar to the teacher's on that workload while running 3–10× faster and costing significantly less per token.
For MCP server builders, distillation solves a specific problem: some tool handlers are called thousands of times per day on narrow, predictable tasks — classifying a support ticket, extracting a date range from a user query, reformatting a JSON object — that don't require the full reasoning power of a Claude 3 Sonnet or Amazon Nova Pro. Running a large model for every such call is expensive and adds latency. A distilled student model trained on teacher outputs for exactly those tasks can handle them at a fraction of the cost with similar accuracy.
Distillation differs from fine-tuning in a critical way: fine-tuning uses human-labeled training data, while distillation uses teacher-model outputs as training targets. This means you do not need expensive human annotation — you only need a set of representative prompts, and Bedrock invokes the teacher model for you during the distillation job to generate the golden completions.
Package and client setup
Distillation uses the Bedrock control-plane client, not the runtime client. These are separate packages that are easy to confuse:
# Control-plane (create/manage jobs, models, provisioned throughput)
npm install @aws-sdk/client-bedrock
# Runtime (invoke models, converse API — used AFTER the model is deployed)
npm install @aws-sdk/client-bedrock-runtime
Create the control-plane client once at module level and reuse it:
import { BedrockClient } from "@aws-sdk/client-bedrock";
// Control-plane client — for managing customization jobs and models
const bedrockClient = new BedrockClient({
region: process.env.AWS_REGION ?? "us-east-1",
});
The distillation API is not available in all AWS regions. As of late 2026 it is supported in us-east-1, us-west-2, and eu-west-1. If you receive an UnsupportedRegionException or the command is missing, switch to one of these regions.
Supported student base models
Not every Bedrock foundation model can serve as a distillation student. The student base model is the smaller model whose weights will be updated during training. Supported student base models include smaller Amazon and third-party models designated for customization. Common examples:
// Supported student base model identifiers (use exact string)
const STUDENT_BASES = {
// Amazon Titan Text Lite — small, fast, cost-effective
titanLite: "amazon.titan-text-lite-v1:0:4k",
// Amazon Titan Text Express — mid-size, strong on instruction following
titanExpress: "amazon.titan-text-express-v1:0:8k",
// Meta Llama 3 8B — if Bedrock grants access in your region
llama3_8b: "meta.llama3-8b-instruct-v1:0",
};
// Teacher models (must be a large foundation model Bedrock can call)
const TEACHER_MODELS = {
claude3Sonnet: "arn:aws:bedrock:us-east-1::foundation-model/anthropic.claude-3-sonnet-20240229-v1:0",
claude3Haiku: "arn:aws:bedrock:us-east-1::foundation-model/anthropic.claude-3-haiku-20240307-v1:0",
titanPremier: "arn:aws:bedrock:us-east-1::foundation-model/amazon.titan-text-premier-v1:0",
};
The teacher model and student model do not need to be from the same provider. You can use Claude 3 Sonnet as the teacher and Amazon Titan Lite as the student. The teacher only generates training targets; it is not part of the final deployed model at all. Use ListFoundationModels with the byCustomizationType: "DISTILLATION" filter to get the authoritative list of supported student bases for your account and region:
import { ListFoundationModelsCommand } from "@aws-sdk/client-bedrock";
const models = await bedrockClient.send(new ListFoundationModelsCommand({
byCustomizationType: "DISTILLATION",
}));
for (const m of models.modelSummaries ?? []) {
console.log(m.modelId, m.modelName, m.responseStreamingSupported);
}
Minimal distillation job
The minimum viable call to start a distillation job requires eight fields. The most common mistake is omitting teacherModelConfig — without it, Bedrock returns a ValidationException: teacherModelConfig is required for DISTILLATION:
import {
BedrockClient,
CreateModelCustomizationJobCommand,
} from "@aws-sdk/client-bedrock";
const bedrockClient = new BedrockClient({ region: "us-east-1" });
async function startDistillationJob(params: {
jobName: string;
customModelName: string;
s3TrainingUri: string;
s3OutputUri: string;
roleArn: string;
}): Promise<string> {
const response = await bedrockClient.send(
new CreateModelCustomizationJobCommand({
// Required for distillation
customizationType: "DISTILLATION",
// Job metadata
jobName: params.jobName,
customModelName: params.customModelName,
// The student base model — must be a supported distillation base
baseModelIdentifier: "amazon.titan-text-lite-v1:0:4k",
// The teacher model that generates golden completions from your prompts
teacherModelConfig: {
teacherModelIdentifier:
"arn:aws:bedrock:us-east-1::foundation-model/anthropic.claude-3-sonnet-20240229-v1:0",
// Max tokens the teacher generates per training prompt
maxResponseLengthForInference: 1024,
},
// Training data: JSONL of {"prompt": "..."} lines — no completions needed
trainingDataConfig: {
s3Uri: params.s3TrainingUri,
},
// Where to write training artifacts and final model weights
outputDataConfig: {
s3Uri: params.s3OutputUri,
},
// IAM role with bedrock:InvokeModel + s3 read/write
roleArn: params.roleArn,
})
);
// jobArn uniquely identifies the job for status polling
return response.jobArn!;
}
// Usage
const jobArn = await startDistillationJob({
jobName: "mcp-classifier-distill-2026-11",
customModelName: "mcp-classifier-lite-v1",
s3TrainingUri: "s3://my-bucket/distill-training/prompts.jsonl",
s3OutputUri: "s3://my-bucket/distill-output/mcp-classifier/",
roleArn: "arn:aws:iam::123456789012:role/BedrockCustomizationRole",
});
console.log("Job started:", jobArn);
Three naming constraints to watch: jobName must be unique within your account and region (reusing a name after the job completes is allowed; reusing it while a job is still running returns a ConflictException); customModelName must also be unique — it becomes the display name in the Bedrock console; both names accept only alphanumeric characters, hyphens, and underscores.
Polling job status
The job runs asynchronously. Total duration depends on dataset size and model, but expect 2–8 hours for a typical distillation job with 5,000–50,000 prompts. Poll with GetModelCustomizationJobCommand:
import {
GetModelCustomizationJobCommand,
ModelCustomizationJobStatus,
} from "@aws-sdk/client-bedrock";
async function waitForDistillationJob(
jobArn: string,
pollIntervalMs = 60_000
): Promise<string> {
while (true) {
const job = await bedrockClient.send(
new GetModelCustomizationJobCommand({ jobIdentifier: jobArn })
);
const status = job.status as ModelCustomizationJobStatus;
console.log(`[${new Date().toISOString()}] status=${status}`);
switch (status) {
case "Completed":
// customModelArn is only set after the job completes successfully
return job.outputModelArn!;
case "Failed":
throw new Error(`Distillation job failed: ${job.failureMessage}`);
case "Stopped":
throw new Error("Distillation job was stopped externally.");
// InProgress, Starting, Stopping — keep polling
default:
await new Promise((r) => setTimeout(r, pollIntervalMs));
}
}
}
// In an MCP tool that kicks off distillation and returns the job ARN,
// a background process or separate Lambda watches for completion:
const customModelArn = await waitForDistillationJob(jobArn);
console.log("Distilled model ARN:", customModelArn);
Do not poll more frequently than once per minute — the job status changes at most every few minutes during training, and excessive polling provides no benefit. If the job is "Failed", failureMessage contains the reason: common causes are invalid JSONL format, insufficient training examples (fewer than the minimum 1,000 prompts), or an IAM role missing the bedrock:InvokeModel permission on the teacher model.
IAM role requirements
The roleArn you pass to CreateModelCustomizationJobCommand must have permissions that cover three areas: invoking the teacher model, reading training data from S3, and writing the output model artifacts back to S3. Bedrock also needs to assume the role, so the trust policy must include bedrock.amazonaws.com:
// Trust policy (applied to the IAM role, not an inline policy)
{
"Version": "2012-10-17",
"Statement": [{
"Effect": "Allow",
"Principal": { "Service": "bedrock.amazonaws.com" },
"Action": "sts:AssumeRole",
"Condition": {
"StringEquals": { "aws:SourceAccount": "123456789012" },
"ArnEquals": { "aws:SourceArn": "arn:aws:bedrock:us-east-1:123456789012:model-customization-job/*" }
}
}]
}
// Permission policy (attached to the role)
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "InvokeTeacherModel",
"Effect": "Allow",
"Action": ["bedrock:InvokeModel"],
"Resource": [
"arn:aws:bedrock:us-east-1::foundation-model/anthropic.claude-3-sonnet-20240229-v1:0"
]
},
{
"Sid": "ReadTrainingData",
"Effect": "Allow",
"Action": ["s3:GetObject", "s3:ListBucket"],
"Resource": [
"arn:aws:s3:::my-bucket",
"arn:aws:s3:::my-bucket/distill-training/*"
]
},
{
"Sid": "WriteOutputModel",
"Effect": "Allow",
"Action": ["s3:PutObject", "s3:GetObject"],
"Resource": "arn:aws:s3:::my-bucket/distill-output/*"
}
]
}
The Condition block in the trust policy scopes the assume-role to Bedrock jobs in your account — without it, any Bedrock service in any account could assume your role, which is a security risk. The bedrock:InvokeModel permission is specifically on the teacher model ARN, not a wildcard — Bedrock calls the teacher during the distillation job to generate training targets, so it must be able to invoke it.
End-to-end distillation workflow for MCP servers
The full lifecycle of a distillation-powered MCP tool handler has four phases: data preparation, job creation, model deployment, and tool invocation. Here is the complete shape of each phase:
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
import { z } from "zod";
import {
BedrockClient,
CreateModelCustomizationJobCommand,
GetModelCustomizationJobCommand,
CreateProvisionedThroughputCommand,
} from "@aws-sdk/client-bedrock";
import {
BedrockRuntimeClient,
ConverseCommand,
} from "@aws-sdk/client-bedrock-runtime";
const bedrockClient = new BedrockClient({ region: "us-east-1" });
const runtimeClient = new BedrockRuntimeClient({ region: "us-east-1" });
// --- Phase 1: kick off distillation (run once, before the MCP server starts) ---
async function createDistillationJob(): Promise<string> {
const { jobArn } = await bedrockClient.send(
new CreateModelCustomizationJobCommand({
customizationType: "DISTILLATION",
jobName: "support-classifier-distill-v1",
customModelName: "support-classifier-lite-v1",
baseModelIdentifier: "amazon.titan-text-lite-v1:0:4k",
teacherModelConfig: {
teacherModelIdentifier:
"arn:aws:bedrock:us-east-1::foundation-model/anthropic.claude-3-sonnet-20240229-v1:0",
maxResponseLengthForInference: 256,
},
trainingDataConfig: { s3Uri: "s3://my-bucket/training/classifier-prompts.jsonl" },
outputDataConfig: { s3Uri: "s3://my-bucket/output/support-classifier/" },
roleArn: "arn:aws:iam::123456789012:role/BedrockCustomizationRole",
hyperParameters: { epochCount: "2", batchSize: "1" },
})
);
return jobArn!;
}
// --- Phase 2: wait for completion (long-running, run as a background job) ---
async function getModelArn(jobArn: string): Promise<string> {
const job = await bedrockClient.send(
new GetModelCustomizationJobCommand({ jobIdentifier: jobArn })
);
if (job.status !== "Completed") throw new Error("Job not complete");
return job.outputModelArn!;
}
// --- Phase 3: provision the model (run once after Completed) ---
async function provisionModel(customModelArn: string): Promise<string> {
const { provisionedModelArn } = await bedrockClient.send(
new CreateProvisionedThroughputCommand({
provisionedModelName: "support-classifier-pt-v1",
modelId: customModelArn,
modelUnits: 1,
commitmentDuration: "OneMonth",
})
);
return provisionedModelArn!;
}
// --- Phase 4: MCP server uses the distilled model at runtime ---
const server = new McpServer({ name: "support-server", version: "1.0.0" });
// Store the provisioned model ARN in env after provisioning
const DISTILLED_MODEL_ARN = process.env.DISTILLED_MODEL_ARN!;
server.tool(
"classify_support_ticket",
{
ticket: z.string().describe("Support ticket text to classify"),
},
async ({ ticket }) => {
const response = await runtimeClient.send(
new ConverseCommand({
modelId: DISTILLED_MODEL_ARN, // provisioned model ARN, not foundation model ID
messages: [
{
role: "user",
content: [
{
text: `Classify this support ticket into one of: billing, technical, account, general.\n\nTicket: ${ticket}`,
},
],
},
],
inferenceConfig: { maxTokens: 50, temperature: 0 },
})
);
const text =
response.output?.message?.content
?.filter((b) => b.text)
.map((b) => b.text)
.join("") ?? "";
return { content: [{ type: "text", text: text.trim() }] };
}
);
Pass the provisionedModelArn (not the customModelArn) to ConverseCommand.modelId. Using the custom model ARN directly returns AccessDeniedException: Custom models require Provisioned Throughput. The provisioned model ARN looks like arn:aws:bedrock:us-east-1:123456789012:provisioned-model/XXXXXXXXXX.
Key gotchas
- customizationType must be exact —
"DISTILLATION"(all-caps) is different from"FINE_TUNING"and"CONTINUED_PRE_TRAINING". Sending the wrong value runs a fine-tuning job without the teacher-model step, which requires you to provide your own completions in training data. - Training data needs only prompts — with
customizationType: "DISTILLATION", Bedrock calls the teacher for each prompt to generate golden outputs during the job. If your JSONL contains bothpromptandcompletionfields, the provided completion is used directly (Bedrock skips the teacher call), which lets you pre-generate or curate teacher outputs. Mixing prompt-only and prompt+completion lines in the same file is supported. - Minimum 1,000 prompts — jobs with fewer training examples return a
ValidationExceptionbefore the job starts. For meaningful distillation, 5,000–50,000 examples gives the student model enough signal to generalize; 1,000 is the floor, not the target. - Job names are account+region scoped — a
ConflictExceptionmeans a job with that name is currentlyInProgress. Use a timestamp suffix (-2026-11) to avoid collisions across runs. - Provisioned Throughput has a minimum commitment —
OneMonthis the shortest option. Budget for this before starting a distillation job. You cannot serve the distilled model without it. - No cross-region inference for distilled models — inference profiles that route across regions only work with foundation models. The provisioned model ARN must match the region where you created the provisioned throughput.
When to choose distillation over other Bedrock customization options
| Option | Training data | Use when | Cost driver |
|---|---|---|---|
| Distillation | Prompts only (teacher generates completions) | You have representative prompts but no labeled answers; you want teacher-quality behavior at student cost | Teacher invocations + compute for distillation job |
| Fine-tuning | Prompt + completion pairs (human-labeled) | You have expert-labeled examples or need highly specific output format | Compute for fine-tuning job only (no teacher invocations) |
| Prompt engineering | None | Behavior can be encoded in a system prompt; no deployment overhead needed | Per-token inference cost × volume |
| Provisioned Throughput (no custom) | None | High-volume on a standard foundation model; latency matters but no specialized behavior needed | Fixed PT cost regardless of token count |
Monitor your distilled MCP server in production
Once your distilled model is live in a tool handler, latency anomalies and unexpected inference errors are hard to catch without endpoint-level monitoring. AliveMCP tracks MCP server health, response time, and tool call error rates from an external vantage point — so you know the moment your distilled-model tool handler degrades, independent of CloudWatch metrics inside your AWS account.