# Different parameters between JSON inference and Inference API

**URL:** <https://discuss.huggingface.co/t/different-parameters-between-json-inference-and-inference-api/15539>\
**Category:** 🤗Hub\
**Created:** [March 9, 2022, 4:37pm UTC](https://discuss.huggingface.co/t/different-parameters-between-json-inference-and-inference-api/15539 "2022-03-09T16:37:08Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![pierreguillou](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/pierreguillou/32/19626_2.png) [@pierreguillou](https://discuss.huggingface.co/u/pierreguillou)\
**Post date:** [March 9, 2022, 4:37pm UTC](https://discuss.huggingface.co/t/different-parameters-between-json-inference-and-inference-api/15539/1 "2022-03-09T16:37:08Z")

</div>

Hi.

I’m doing inferences with a T5 model ([Text2text-generation task](https://api-inference.huggingface.co/docs/python/html/detailed_parameters.html#text-generation-task)) through JSON inference and Inference API.

I noticed that I have the possibility to use the parameters `num_beams` and `max_length` within JSON inference, but not within Inference API (here, the Inference API parameters for [Text-generation task](https://api-inference.huggingface.co/docs/python/html/detailed_parameters.html#text-generation-task) that are the same as for [Text2text-generation task](https://api-inference.huggingface.co/docs/python/html/detailed_parameters.html#text2text-generation-task)). Strange…

Am I right? If yes, there will be an actualization of the Inference API parameters?

### JSON inference

(I can use the parameters `num_beams` and `max_length`)

```auto
import json
import requests

API_URL = "https://api-inference.huggingface.co/models/" + model_name
headers = {"Authorization": f"Bearer {API_TOKEN}"}

def query(payload):
    data = json.dumps(payload)
    response = requests.request("POST", API_URL, headers=headers, data=data)
    return json.loads(response.content.decode("utf-8")), response.headers.get('x-compute-type')

# get inference
data, x_compute_type = query(
    {
        "inputs": input_text,
        "parameters": {
            "num_beams": num_beams,
            "num_return_sequences": num_return_sequences,
            "max_length": max_target_length,
            },
    }
)

```

### Inference API

(I can not use the parameters `num_beams` and `max_length`)

```auto
!pip install huggingface_hub

from huggingface_hub.inference_api import InferenceApi
inference = InferenceApi(repo_id=model_name, token=API_TOKEN)

params = {
    # "num_beams": num_beams,
    "num_return_sequences": num_return_sequences,
    #"max_length" : max_target_length,
    }

inference(input_text, params)

```
