# How to set minimum length of generated text in hosted API

**URL:** </static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fhow-to-set-minimum-length-of-generated-text-in-hosted-api%2F3893%3E%5C
**Category:** Beginners\
**Created:** [February 23, 2021, 9:45pm UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fhow-to-set-minimum-length-of-generated-text-in-hosted-api%2F3893 "2021-02-23T21:45:42Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![benjismith](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/benjismith/32/17937_2.png) [@benjismith](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Fbenjismith)%5C
**Post date:** [February 23, 2021, 9:45pm UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fhow-to-set-minimum-length-of-generated-text-in-hosted-api%2F3893%2F1 "2021-02-23T21:45:42Z")

</div>

I’m using the hosted API to generate text from gpt2-xl, like this:

```auto
curl -X POST /static-proxy?url=https%3A%2F%2Fapi-inference.huggingface.co%2Fmodels%2Fgpt2-xl \
     -H "Authorization: Bearer api_org_AAAABBBBCCCCDDDD" \
     -H "Content-Type: application/json" \
     -d '{
          "inputs":"Once upon a time, there was a horrible witch who",
          "options":{"wait_for_model":true}
     }'

```

…which returns something like this:

```auto
[{"generated_text":"Once upon a time, there was a horrible witch who
had a cat named Chunky. She tortured and killed her cats and ate their
fur and meat with the help from a huge snake that her mother fed to her
with a spoon. The witch named"}]

```

Which is great.

Now I’d like to use a longer prompt (~1000 characters) and ask for a longer body of generated text in response (original length + ~1000 characters of new text).

But I don’t see any info [in the docs](/static-proxy?url=https%3A%2F%2Fapi-inference.huggingface.co%2Fdocs%2Fpython%2Fhtml%2Fdetailed_parameters.html%23text-generation-task) about how to ask for a longer body of generated text. And if I make my prompt longer, the amount of generated text appended to my prompt gets proportionally shorter, and the whole response is about the same size. Is this a fundamental limitation of the hosted APIs or is there some way to achieve this?

---

<div class="post-metadata">

**Author:** ![Narsil](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/narsil/32/40029_2.png) [@Narsil](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2FNarsil)%5C
**Post date:** [March 10, 2021, 9:31am UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fhow-to-set-minimum-length-of-generated-text-in-hosted-api%2F3893%2F2 "2021-03-10T09:31:09Z")

</div>

Hi @benjismith ,

Sorry for the late reply.  
Currently the only way you can do that is by using

```auto
 "inputs":"Once upon a time, there was a horrible witch who",
          "options":{"wait_for_model":true}
          "parameters": {"max_length": 10}

```

but that IS an issue because you need to know how many tokens your prompt is to be precise.  
We’re going to add a better parameter for this and document it.

---

<div class="post-metadata">

**Author:** ![benjismith](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/benjismith/32/17937_2.png) [@benjismith](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Fbenjismith)%5C
**Post date:** [March 10, 2021, 10:47pm UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fhow-to-set-minimum-length-of-generated-text-in-hosted-api%2F3893%2F3 "2021-03-10T22:47:51Z")

</div>

Perfect, thank you! Is there an ticket on github for this that I can follow?
