Rerank takes any modelID but always sends a cohereRerankRequest, which always carries api_version: 2 (rerank.go:44-49, :138-143). The Amazon rerank schema rejects that key, so every call fails:
ValidationException: Malformed input request: extraneous key [api_version] is not permitted, please reformat your input and try again.
Repro (needs a region that offers the model, e.g. us-west-2; it is not in us-east-1):
resp, err := bedrock.Rerank(ctx, g, "amazon.rerank-v1:0", &ai.RerankerRequest{
Query: ai.DocumentFromText("What is the capital of France?", nil),
Documents: []*ai.Document{ai.DocumentFromText("Paris is the capital of France.", nil)},
})
The two families are otherwise identical: same query/documents/top_n body over InvokeModel, same {"results": [{"index", "relevance_score"}]} response, so buildRerankResponse already handles Amazon unchanged. The only incompatible field is api_version, and Cohere requires it (omitting it fails with required key [api_version] not found), while Amazon forbids it. Both errors are from live ValidationException responses in us-west-2.
If Cohere-only is deliberate, the fix is a clear error instead: reject non-Cohere IDs in Rerank rather than sending a body the service will refuse.
Reranktakes anymodelIDbut always sends acohereRerankRequest, which always carriesapi_version: 2(rerank.go:44-49,:138-143). The Amazon rerank schema rejects that key, so every call fails:Repro (needs a region that offers the model, e.g.
us-west-2; it is not inus-east-1):The two families are otherwise identical: same
query/documents/top_nbody overInvokeModel, same{"results": [{"index", "relevance_score"}]}response, sobuildRerankResponsealready handles Amazon unchanged. The only incompatible field isapi_version, and Cohere requires it (omitting it fails withrequired key [api_version] not found), while Amazon forbids it. Both errors are from liveValidationExceptionresponses inus-west-2.If Cohere-only is deliberate, the fix is a clear error instead: reject non-Cohere IDs in
Rerankrather than sending a body the service will refuse.