I am using the invoke_model function of boto3 library for AWS bedrock for Claude sonnet 3.5 v2. I am trying to use prompt caching by using the InvokeModel API of bedrock for claude, according to the following documentation PROMPT Caching using bedrock, invoke_model must be accepting the parameter explicitPromptCaching, but upon using the latest version of boto3: 1.36.3 at this time, I am getting this error:
botocore.exceptions.ParamValidationError: Parameter validation failed: Unknown parameter in input: "explicitPromptCaching", must be one of: body, contentType, accept, modelId, trace, guardrailIdentifier, guardrailVersion, performanceConfigLatency
Here is the function call:
response = self.client.invoke_model(body=body, modelId=self.modelId,explicitPromptCaching = 'enabled')
Also according to another documentation of boto3 in python: boto3 docs, invoke_model is not supposed to be accepting the parameter in question.
Also upon going through the docs of InvokeModel API, there is nothing about this parameter.
To use prompt caching the only option that I may have is ConverseAPI, but my backend is already written using InvokeModel, the advantage of using InvokeModel over ConverseAPI is that the latter uses a unified format of request and response for all the models, this might seem a good use but for me it is not. InvokeAPI is specific to the model vendor you are using, this way you can follow the extensive docs of the vendor model, but for the latter you will have to cope with the incomplete and bizarre docs of aws bedrock and be on their mercy when something goes wrong.
What am I doing wrong? Help is appreciated.