# What is the correct format conversational models in the inference api

**URL:** <https://discuss.huggingface.co/t/what-is-the-correct-format-conversational-models-in-the-inference-api/100304>\
**Category:** Beginners\
**Created:** [July 31, 2024, 5:21pm UTC](https://discuss.huggingface.co/t/what-is-the-correct-format-conversational-models-in-the-inference-api/100304 "2024-07-31T17:21:31Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![steve-b](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/steve-b/32/29639_2.png) [@steve-b](https://discuss.huggingface.co/u/steve-b)\
**Post date:** [July 31, 2024, 5:21pm UTC](https://discuss.huggingface.co/t/what-is-the-correct-format-conversational-models-in-the-inference-api/100304/1 "2024-07-31T17:21:32Z")

</div>

Hi All,  
I am having some trouble understanding how to use conversational models with the HF inference api.

The [documentation](https://huggingface.co/docs/api-inference/en/detailed_parameters?code=curl#conversational-task) gives a curl example as:

```auto
curl https://api-inference.huggingface.co/models/microsoft/DialoGPT-large \
        -X POST \
        -d '{"inputs": {"past_user_inputs": ["Which movie is the best ?"], "generated_responses": ["It is Die Hard for sure."], "text":"Can you explain why ?"}}' \
        -H "Authorization: Bearer ${HF_API_TOKEN}"

```

however running this command gives the output:

```auto
curl -s -H 'Content-Type: application/json' https://api-inference.huggingface.co/models/microsoft/DialoGPT-large -X POST -d '{"inputs": {"past_user_inputs": ["Which movie is
 the best ?"], "generated_responses": ["It is Die Hard for sure."], "text":"Can you explain why ?"}}' -H "Authorization: ${HUGGINGFACE_AUTH_HEADER}"

Failed to deserialize the JSON body into the target type: inputs: invalid type: map, expected a string at line 1 column 11

```

the docs state that three key value pairs are needed for the input:

```auto
inputs (required) 	
text (required) The last input from the user in the conversation.
generated_responses A list of strings corresponding to the earlier replies from the model.
past_user_inputs A list of strings corresponding to the earlier replies from the user. Should be of the same length of generated_responses.

```

However it seems that what is required is:  
inputs = (some string)

I have tried the inputs = map approach with some of the other conversational models and they all reply saying that inputs must be a string and not a map.

```auto
curl -H 'Content-Type: application/json' https://api-inference.huggingface.co/models/facebook/blenderbot-400M-distill -X POST -d '{"inputs": {"past_user_inputs": ["Which mov
ie is the best ?"], "generated_responses": ["It is Die Hard for sure."], "text":"Can you explain why ?"}}' -H "Authorization: ${HUGGINGFACE_AUTH_HEADER}"
{"error":" `args[0]`: {'past_user_inputs': ['Which movie is the best ?'], 'generated_responses': ['It is Die Hard for sure.'], 'text': 'Can you explain why ?'} have the wrong format. The
should be either of type `str` or type `list`","warnings":["There was an inference error: `args[0]`: {'past_user_inputs': ['Which movie is the best ?'], 'generated_responses': ['It is Di
e Hard for sure.'], 'text': 'Can you explain why ?'} have the wrong format. The should be either of type `str` or type `list`"]}

```

```auto
 curl -H 'Content-Type: application/json' https://api-inference.huggingface.co/models/meta-llama/Llama-2-7b-chat-hf -X POST -d '{"inputs": {"past_user_inputs": ["Which movie
is the best ?"], "generated_responses": ["It is Die Hard for sure."], "text":"Can you explain why ?"}}' -H "Authorization: ${HUGGINGFACE_AUTH_HEADER}"
Failed to deserialize the JSON body into the target type: inputs: invalid type: map, expected a string at line 1 column 11

```

can anyone explain to me how this inference api for conversational models is meant to work?

another source of confusion is if I go to a conversational models page in Huggingface, I can see the chat bot option, and if I initiate a conversation I can capture the POST requests to the model in the developer tools.

When I did this I noticed it uses a different endpoint to the one detailed in the inference API docs,  
instead of:  
[https://api-inference.huggingface.co/models/microsoft/DialoGPT-large](https://api-inference.huggingface.co/models/microsoft/DialoGPT-large)  
it uses:  
[https://api-inference.huggingface.co/models/microsoft/DialoGPT-large/v1/chat/completions](https://api-inference.huggingface.co/models/microsoft/DialoGPT-large/v1/chat/completions)

and instead of a request structured like this:  
{“inputs”: {“past\_user\_inputs”: [“Which movie is the best ?”], “generated\_responses”: [“It is Die Hard for sure.”], “text”:“Can you explain why ?”}}

it uses one like this:  
{“messages”:[{“role”:“user”,“content”:“Which movie is the best”},{“role”:“assistant”,“content”:“Boondock s sequel?”},{“role”:“user”,“content”:“Can you explain why ?”}],"

can anyone shed some light on what is the correct / official way to consumer a conversational model with the inference api
