# Invoke\_endpoint returns error - wrong payload format?

**URL:** <https://discuss.huggingface.co/t/invoke-endpoint-returns-error-wrong-payload-format/69504>\
**Category:** Beginners\
**Created:** [January 17, 2024, 2:49pm UTC](https://discuss.huggingface.co/t/invoke-endpoint-returns-error-wrong-payload-format/69504 "2024-01-17T14:49:03Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![linudaar](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/linudaar/32/23076_2.png) [@linudaar](https://discuss.huggingface.co/u/linudaar)\
**Post date:** [January 17, 2024, 2:49pm UTC](https://discuss.huggingface.co/t/invoke-endpoint-returns-error-wrong-payload-format/69504/1 "2024-01-17T14:49:03Z")

</div>

Hi,  
I am very new in the world of AI/LLMs so please bear with me.  
I want to play with an llm to summarize a text.  
I deployed a serverless sagemaker jumpstart model “infer-huggingface-summarization-bert-small2bert-small-finetuned-cnn-daily-mail-summarization” using cloudformation stack. The model and endpoint seem to be up and running.

I am running this python code in a lambda for a simple “hello world” experiment

```auto
client = boto3.client('runtime.sagemaker')
payload = "Summarize this text: This is a beautiful day. I am happy. I am going to the park."
encoded_payload = json.dumps(payload).encode("utf-8")
response = client.invoke_endpoint(
  EndpointName="SummarizationEndpoint", 
  ContentType="application/json", 
  Accept="application/json",
  Body=encoded_payload
)

```

it fails with the error:

```auto
An error occurred: An error occurred (ModelError) when calling the InvokeEndpoint operation: Received client error (400) from model with message "
{
  "code": 400,
  "type": "InternalServerException",
  "message": "\u0027str\u0027 object has no attribute \u0027pop\u0027"
}"

```

As this is a ModelError, I am assuming my sagemaker setup is correct and the lambda is indeed talking to the model. I am assuming I am just not passing the payload correctly over to the invoke\_endpoint function or the model.

I tried different formats for `payload`.

```auto
 payload = {"inputs": "Summarize this text: This is a beautiful day. I am happy. I am going to the park."}

```

… results in error `"\u0027str\u0027 object is not callable"`

```auto
 payload = {"input_texts": "Summarize this text: This is a beautiful day. I am happy. I am going to the park."}

```

… results in error `args[0]`: {\u0027input_texts\u0027: \u0027Summarize this text: This is a beautiful day. I am happy. I am going to the park.\u0027} have the wrong format. The should be either of type `str` or type `list`

Judging from the test code [here](https://github.com/aws/sagemaker-huggingface-inference-toolkit/blob/main/tests/integ/config.py) my best guess would be `payload = {"inputs":"text"}` but this doesn’t work.

I am sure I am missing something very obvious but can’t see it. Can I see a working example or where this is documented?
