How do you use prompts stored in prompt management with a single invocation of the model? I setup a prompt with a variable called myInput
but the docs don't specify how I can use this other than this example which implies I need to setup a flow just to use the prompt? Am I unable to use the prompt I created in prompt management directly with the InvokeModelCommand
?
Nothing in the docs I'm seeing explicitly calls tells you how to specify prompt variables even though the modelId
field states this in this doc:
If you use a prompt created through Prompt management, specify the ARN of the prompt.
import { BedrockRuntimeClient, InvokeModelCommand } from "@aws-sdk/client-bedrock-runtime";
...
const bedrockClient = new BedrockRuntimeClient({});
...
const command = new InvokeModelCommand({
modelId: "arn:aws:bedrock:us-east-1:12345678:prompt/ABCDEFG:2",
body: JSON.stringify({
promptVariables: {
myInput: myInputValue
}
})
});
const response = await bedrockClient.send(command);
Specifying the modelId is ok but gives an error because the prompt variables can't be passed.
ValidationException: Malformed request for promptVariablesreceived
Although the InvokeModelCommand
explicitly states you can specify the ARN of the prompt managed template, there appears to be no way to pass prompt variables as part of the request. The ConverseCommand
supports it but not the InvokeModelCommand
and the examples only show managed prompt templates being used in flows so for now I'm assuming those are the only two scenarios where they can be used unfortunately.