# Error code 400 when running llama2 on sagemaker endpoint

**URL:** <https://discuss.huggingface.co/t/error-code-400-when-running-llama2-on-sagemaker-endpoint/47615>\
**Category:** Amazon SageMaker\
**Created:** [July 21, 2023, 12:57pm UTC](https://discuss.huggingface.co/t/error-code-400-when-running-llama2-on-sagemaker-endpoint/47615 "2023-07-21T12:57:02Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![admangan4400](https://avatars.discourse-cdn.com/v4/letter/a/35a633/32.png) [@admangan4400](https://discuss.huggingface.co/u/admangan4400)\
**Post date:** [July 21, 2023, 12:57pm UTC](https://discuss.huggingface.co/t/error-code-400-when-running-llama2-on-sagemaker-endpoint/47615/1 "2023-07-21T12:57:02Z")

</div>

Followed @philschmid blog on finetuning and then deployed the model to the endpoint with the below code and it returned the following error:

```auto
ModelError: An error occurred (ModelError) when calling the InvokeEndpoint operation: Received client error (400) from primary with message "{
  "code": 400,
  "type": "InternalServerException",
  "message": "\u0027llama\u0027"
}

```

Deployment Code:

```auto
from sagemaker.huggingface import HuggingFaceModel

# create Hugging Face Model Class
huggingface_model = HuggingFaceModel(
   model_data=model_s3, # Change to your model path
   role=role,
   transformers_version="4.26",
   pytorch_version="1.13",
   py_version="py39",
   model_server_workers=1
)

predictor = huggingface_model.deploy(
   initial_instance_count=1,
   instance_type= "ml.g5.2xlarge",
    endpoint_name='llama2-7b-1'
)

```

---

<div class="post-metadata">

**Author:** ![philschmid](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/philschmid/32/38022_2.png) [@philschmid](https://discuss.huggingface.co/u/philschmid)\
**Post date:** [July 24, 2023, 7:19am UTC](https://discuss.huggingface.co/t/error-code-400-when-running-llama2-on-sagemaker-endpoint/47615/2 "2023-07-24T07:19:10Z")

</div>

To deploy llama you should use the new LLM container: [Introducing the Hugging Face LLM Inference Container for Amazon SageMaker](https://huggingface.co/blog/sagemaker-huggingface-llm)
