How to correctly reach a Sagemaker endpoint with AWS.jl

I am using AWS.jl to call from my machine a Sagemaker endpoint I have on AWS like this:

using JSON
using AWS: @service
@service Sagemaker_Runtime;

body = Dict(:inputs => "what is Python?", :parameters => Dict( :max_new_tokens => 200 ))
endpoint = "jumpstart-dft-meta-textgeneration-llama-2-13b-f"
parameters = Dict(
    "Content-Type" => "application/json"
);
Sagemaker_Runtime.invoke_endpoint(body, endpoint, parameters)

but I get this error, which seems to point to a missing “inputs” in the JSON body, but it looks like it’s there to me:

AWS.AWSExceptions.AWSException: 424 -- Received client error (422) from primary with message "Failed to deserialize the JSON body into the target type: missing field `inputs` at line 1 column 107". See https://eu-west-1.console.aws.amazon.com/cloudwatch/home?region=eu-west-1#logEventViewer:group=/aws/sagemaker/Endpoints/jumpstart-dft-meta-textgeneration-llama-2-13b-f in account 839864180634 for more information.

HTTP.Exceptions.StatusError(424, "POST", "/endpoints/jumpstart-dft-meta-textgeneration-llama-2-13b-f/invocations", HTTP.Messages.Response:
"""
HTTP/1.1 424 Failed Dependency
x-amzn-RequestId: f1c8d49c-0c20-43e7-a137-0e69f9e0f9ab
x-amzn-ErrorType: ModelError:http://internal.amazon.com/coral/com.amazonaws.sagemaker.runtime/
Date: Sun, 10 Dec 2023 16:13:11 GMT
Content-Type: application/json
Content-Length: 713
connection: keep-alive

[Message Body was streamed]""")

{"ErrorCode":"CLIENT_ERROR_FROM_MODEL","LogStreamArn":"arn:aws:logs:eu-west-1:839864180634:log-group:/aws/sagemaker/Endpoints/jumpstart-dft-meta-textgeneration-llama-2-13b-f","Message":"Received client error (422) from primary with message \"Failed to deserialize the JSON body into the target type: missing field `inputs` at line 1 column 107\". See https://eu-west-1.console.aws.amazon.com/cloudwatch/home?region=eu-west-1#logEventViewer:group=/aws/sagemaker/Endpoints/jumpstart-dft-meta-textgeneration-llama-2-13b-f in account 839864180634 for more information.","OriginalMessage":"Failed to deserialize the JSON body into the target type: missing field `inputs` at line 1 column 107","OriginalStatusCode":422}


Stacktrace:
  [1] (::HTTP.ConnectionRequest.var"#connections#4"{HTTP.ConnectionRequest.var"#connections#1#5"{HTTP.TimeoutRequest.var"#timeouts#3"{HTTP.TimeoutRequest.var"#timeouts#1#4"{HTTP.ExceptionRequest.var"#exceptions#2"{HTTP.ExceptionRequest.var"#exceptions#1#3"{typeof(HTTP.StreamRequest.streamlayer)}}}}}})(req::HTTP.Messages.Request; proxy::Nothing, socket_type::Type, socket_type_tls::Type, readtimeout::Int64, connect_timeout::Int64, logerrors::Bool, logtag::Nothing, kw::Base.Pairs{Symbol, Union{Nothing, Int64}, Tuple{Symbol, Symbol, Symbol}, NamedTuple{(:iofunction, :decompress, :verbose), Tuple{Nothing, Nothing, Int64}}})
    @ HTTP.ConnectionRequest ~/.julia/packages/HTTP/bDoga/src/clientlayers/ConnectionRequest.jl:144
  [2] (::HTTP.RetryRequest.var"#manageretries#3"{HTTP.RetryRequest.var"#manageretries#1#4"{HTTP.ConnectionRequest.var"#connections#4"{HTTP.ConnectionRequest.var"#connections#1#5"{HTTP.TimeoutRequest.var"#timeouts#3"{HTTP.TimeoutRequest.var"#timeouts#1#4"{HTTP.ExceptionRequest.var"#exceptions#2"{HTTP.ExceptionRequest.var"#exceptions#1#3"{typeof(HTTP.StreamRequest.streamlayer)}}}}}}}})(req::HTTP.Messages.Request; retry::Bool, retries::Int64, retry_delays::ExponentialBackOff, retry_check::Function, retry_non_idempotent::Bool, kw::Base.Pairs{Symbol, Union{Nothing, Int64}, Tuple{Symbol, Symbol, Symbol}, NamedTuple{(:iofunction, :decompress, :verbose), Tuple{Nothing, Nothing, Int64}}})
    @ HTTP.RetryRequest ~/.julia/packages/HTTP/bDoga/src/clientlayers/RetryRequest.jl:35
  [3] manageretries
    @ ~/.julia/packages/HTTP/bDoga/src/clientlayers/RetryRequest.jl:30 [inlined]
  [4] (::HTTP.CookieRequest.var"#managecookies#4"{HTTP.CookieRequest.var"#managecookies#1#5"{HTTP.RetryRequest.var"#manageretries#3"{HTTP.RetryRequest.var"#manageretries#1#4"{HTTP.ConnectionRequest.var"#connections#4"{HTTP.ConnectionRequest.var"#connections#1#5"{HTTP.TimeoutRequest.var"#timeouts#3"{HTTP.TimeoutRequest.var"#timeouts#1#4"{HTTP.ExceptionRequest.var"#exceptions#2"{HTTP.ExceptionRequest.var"#exceptions#1#3"{typeof(HTTP.StreamRequest.streamlayer)}}}}}}}}}})(req::HTTP.Messages.Request; cookies::Bool, cookiejar::HTTP.Cookies.CookieJar, kw::Base.Pairs{Symbol, Union{Nothing, Integer}, NTuple{4, Symbol}, NamedTuple{(:iofunction, :decompress, :verbose, :retry), Tuple{Nothing, Nothing, Int64, Bool}}})
    @ HTTP.CookieRequest ~/.julia/packages/HTTP/bDoga/src/clientlayers/CookieRequest.jl:42
  [5] managecookies
    @ ~/.julia/packages/HTTP/bDoga/src/clientlayers/CookieRequest.jl:19 [inlined]
  [6] (::HTTP.HeadersRequest.var"#defaultheaders#2"{HTTP.HeadersRequest.var"#defaultheaders#1#3"{HTTP.CookieRequest.var"#managecookies#4"{HTTP.CookieRequest.var"#managecookies#1#5"{HTTP.RetryRequest.var"#manageretries#3"{HTTP.RetryRequest.var"#manageretries#1#4"{HTTP.ConnectionRequest.var"#connections#4"{HTTP.ConnectionRequest.var"#connections#1#5"{HTTP.TimeoutRequest.var"#timeouts#3"{HTTP.TimeoutRequest.var"#timeouts#1#4"{HTTP.ExceptionRequest.var"#exceptions#2"{HTTP.ExceptionRequest.var"#exceptions#1#3"{typeof(HTTP.StreamRequest.streamlayer)}}}}}}}}}}}})(req::HTTP.Messages.Request; iofunction::Nothing, decompress::Nothing, basicauth::Bool, detect_content_type::Bool, canonicalize_headers::Bool, kw::Base.Pairs{Symbol, Integer, Tuple{Symbol, Symbol}, NamedTuple{(:verbose, :retry), Tuple{Int64, Bool}}})
    @ HTTP.HeadersRequest ~/.julia/packages/HTTP/bDoga/src/clientlayers/HeadersRequest.jl:71
  [7] defaultheaders
    @ ~/.julia/packages/HTTP/bDoga/src/clientlayers/HeadersRequest.jl:14 [inlined]
  [8] (::HTTP.RedirectRequest.var"#redirects#3"{HTTP.RedirectRequest.var"#redirects#1#4"{HTTP.HeadersRequest.var"#defaultheaders#2"{HTTP.HeadersRequest.var"#defaultheaders#1#3"{HTTP.CookieRequest.var"#managecookies#4"{HTTP.CookieRequest.var"#managecookies#1#5"{HTTP.RetryRequest.var"#manageretries#3"{HTTP.RetryRequest.var"#manageretries#1#4"{HTTP.ConnectionRequest.var"#connections#4"{HTTP.ConnectionRequest.var"#connections#1#5"{HTTP.TimeoutRequest.var"#timeouts#3"{HTTP.TimeoutRequest.var"#timeouts#1#4"{HTTP.ExceptionRequest.var"#exceptions#2"{HTTP.ExceptionRequest.var"#exceptions#1#3"{typeof(HTTP.StreamRequest.streamlayer)}}}}}}}}}}}}}})(req::HTTP.Messages.Request; redirect::Bool, redirect_limit::Int64, redirect_method::Nothing, forwardheaders::Bool, response_stream::Base.BufferStream, kw::Base.Pairs{Symbol, Integer, Tuple{Symbol, Symbol}, NamedTuple{(:verbose, :retry), Tuple{Int64, Bool}}})
    @ HTTP.RedirectRequest ~/.julia/packages/HTTP/bDoga/src/clientlayers/RedirectRequest.jl:17
  [9] redirects
    @ ~/.julia/packages/HTTP/bDoga/src/clientlayers/RedirectRequest.jl:14 [inlined]
 [10] (::HTTP.MessageRequest.var"#makerequest#3"{HTTP.MessageRequest.var"#makerequest#1#4"{HTTP.RedirectRequest.var"#redirects#3"{HTTP.RedirectRequest.var"#redirects#1#4"{HTTP.HeadersRequest.var"#defaultheaders#2"{HTTP.HeadersRequest.var"#defaultheaders#1#3"{HTTP.CookieRequest.var"#managecookies#4"{HTTP.CookieRequest.var"#managecookies#1#5"{HTTP.RetryRequest.var"#manageretries#3"{HTTP.RetryRequest.var"#manageretries#1#4"{HTTP.ConnectionRequest.var"#connections#4"{HTTP.ConnectionRequest.var"#connections#1#5"{HTTP.TimeoutRequest.var"#timeouts#3"{HTTP.TimeoutRequest.var"#timeouts#1#4"{HTTP.ExceptionRequest.var"#exceptions#2"{HTTP.ExceptionRequest.var"#exceptions#1#3"{typeof(HTTP.StreamRequest.streamlayer)}}}}}}}}}}}}}}}})(method::String, url::URIs.URI, headers::Vector{Pair{SubString{String}, SubString{String}}}, body::String; copyheaders::Bool, response_stream::Base.BufferStream, http_version::HTTP.Strings.HTTPVersion, verbose::Int64, kw::Base.Pairs{Symbol, Bool, Tuple{Symbol, Symbol}, NamedTuple{(:redirect, :retry), Tuple{Bool, Bool}}})
    @ HTTP.MessageRequest ~/.julia/packages/HTTP/bDoga/src/clientlayers/MessageRequest.jl:35
 [11] makerequest
    @ ~/.julia/packages/HTTP/bDoga/src/clientlayers/MessageRequest.jl:24 [inlined]
 [12] request(stack::HTTP.MessageRequest.var"#makerequest#3"{HTTP.MessageRequest.var"#makerequest#1#4"{HTTP.RedirectRequest.var"#redirects#3"{HTTP.RedirectRequest.var"#redirects#1#4"{HTTP.HeadersRequest.var"#defaultheaders#2"{HTTP.HeadersRequest.var"#defaultheaders#1#3"{HTTP.CookieRequest.var"#managecookies#4"{HTTP.CookieRequest.var"#managecookies#1#5"{HTTP.RetryRequest.var"#manageretries#3"{HTTP.RetryRequest.var"#manageretries#1#4"{HTTP.ConnectionRequest.var"#connections#4"{HTTP.ConnectionRequest.var"#connections#1#5"{HTTP.TimeoutRequest.var"#timeouts#3"{HTTP.TimeoutRequest.var"#timeouts#1#4"{HTTP.ExceptionRequest.var"#exceptions#2"{HTTP.ExceptionRequest.var"#exceptions#1#3"{typeof(HTTP.StreamRequest.streamlayer)}}}}}}}}}}}}}}}}, method::String, url::URIs.URI, h::Vector{Pair{SubString{String}, SubString{String}}}, b::String, q::Nothing; headers::Vector{Pair{SubString{String}, SubString{String}}}, body::String, query::Nothing, kw::Base.Pairs{Symbol, Any, Tuple{Symbol, Symbol, Symbol}, NamedTuple{(:redirect, :retry, :response_stream), Tuple{Bool, Bool, Base.BufferStream}}})
    @ HTTP ~/.julia/packages/HTTP/bDoga/src/HTTP.jl:457
 [13] #request#20
    @ ~/.julia/packages/HTTP/bDoga/src/HTTP.jl:315 [inlined]
 [14] macro expansion
    @ ~/.julia/packages/Mocking/Q17aB/src/mock.jl:29 [inlined]
 [15] (::AWS.var"#48#50"{AWS.Request, OrderedCollections.LittleDict{Symbol, Any, Vector{Symbol}, Vector{Any}}})()
    @ AWS ~/.julia/packages/AWS/SchLh/src/utilities/request.jl:225
 [16] (::Base.var"#90#92"{Base.var"#90#91#93"{AWS.AWSExponentialBackoff, AWS.var"#49#51", AWS.var"#48#50"{AWS.Request, OrderedCollections.LittleDict{Symbol, Any, Vector{Symbol}, Vector{Any}}}}})(; kwargs::Base.Pairs{Symbol, Union{}, Tuple{}, NamedTuple{(), Tuple{}}})
    @ Base ./error.jl:296
 [17] (::Base.var"#90#92"{Base.var"#90#91#93"{AWS.AWSExponentialBackoff, AWS.var"#49#51", AWS.var"#48#50"{AWS.Request, OrderedCollections.LittleDict{Symbol, Any, Vector{Symbol}, Vector{Any}}}}})()
    @ Base ./error.jl:291
 [18] _http_request(http_backend::AWS.HTTPBackend, request::AWS.Request, response_stream::IOBuffer)
    @ AWS ~/.julia/packages/AWS/SchLh/src/utilities/request.jl:250
 [19] macro expansion
    @ ~/.julia/packages/Mocking/Q17aB/src/mock.jl:29 [inlined]
 [20] (::AWS.var"#41#44"{AWS.AWSConfig, AWS.Request, IOBuffer, Vector{Int64}})()
    @ AWS ~/.julia/packages/AWS/SchLh/src/utilities/request.jl:134
 [21] (::AWS.var"#42#46"{AWS.var"#41#44"{AWS.AWSConfig, AWS.Request, IOBuffer, Vector{Int64}}, IOBuffer})()
    @ AWS ~/.julia/packages/AWS/SchLh/src/utilities/request.jl:149
 [22] (::Base.var"#90#92"{Base.var"#90#91#93"{AWS.AWSExponentialBackoff, AWS.var"#43#47"{AWS.AWSConfig, Vector{String}, Vector{String}, Int64}, AWS.var"#42#46"{AWS.var"#41#44"{AWS.AWSConfig, AWS.Request, IOBuffer, Vector{Int64}}, IOBuffer}}})(; kwargs::Base.Pairs{Symbol, Union{}, Tuple{}, NamedTuple{(), Tuple{}}})
    @ Base ./error.jl:296
 [23] (::Base.var"#90#92"{Base.var"#90#91#93"{AWS.AWSExponentialBackoff, AWS.var"#43#47"{AWS.AWSConfig, Vector{String}, Vector{String}, Int64}, AWS.var"#42#46"{AWS.var"#41#44"{AWS.AWSConfig, AWS.Request, IOBuffer, Vector{Int64}}, IOBuffer}}})()
    @ Base ./error.jl:291
 [24] submit_request(aws::AWS.AWSConfig, request::AWS.Request; return_headers::Nothing)
    @ AWS ~/.julia/packages/AWS/SchLh/src/utilities/request.jl:200
 [25] (::AWS.RestJSONService)(request_method::String, request_uri::String, args::Dict{String, Any}; aws_config::AWS.AWSConfig, feature_set::AWS.FeatureSet)
    @ AWS ~/.julia/packages/AWS/SchLh/src/AWS.jl:431
 [26] RestJSONService
    @ ~/.julia/packages/AWS/SchLh/src/AWS.jl:402 [inlined]
 [27] invoke_endpoint(Body::Dict{Symbol, Any}, EndpointName::String, params::Dict{String, String}; aws_config::AWS.AWSConfig)
    @ Main.Sagemaker_Runtime ~/.julia/packages/AWS/SchLh/src/services/sagemaker_runtime.jl:83
 [28] invoke_endpoint(Body::Dict{Symbol, Any}, EndpointName::String, params::Dict{String, String})
    @ Main.Sagemaker_Runtime ~/.julia/packages/AWS/SchLh/src/services/sagemaker_runtime.jl:77
 [29] top-level scope
    @ /mnt/data/projects/GenieGiano/test.ipynb:1