# The Completions API doesn't \*really\* return completions

**URL:** <https://community.openai.com/t/the-completions-api-doesnt-really-return-completions/922833>\
**Category:** API\
**Tags:** prompt-engineering\
**Created:** [August 26, 2024, 5:55pm UTC](https://community.openai.com/t/the-completions-api-doesnt-really-return-completions/922833 "2024-08-26T17:55:26Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![coder0xff](https://sea2.discourse-cdn.com/openai1/user_avatar/community.openai.com/coder0xff/32/448420_2.png) [@coder0xff](https://community.openai.com/u/coder0xff)\
**Post date:** [August 26, 2024, 5:55pm UTC](https://community.openai.com/t/the-completions-api-doesnt-really-return-completions/922833/1 "2024-08-26T17:55:26Z")

</div>

If I send this prompt for completion:

"The following is the list of the descending positive integers starting from 9. The list is complete. 9 8 7 6 5 4 3 2 "

I believe the completion of this ought to be “1”, and nothing more. However, `AsyncOpenAI.chat.completions.create` is more interested in having a chat:

“The list you’ve provided is a sequence of descending positive integers starting from 9 and decrements by 1 each time. If the list is complete with respect to only including single-digit positive integers 9 down to 2, then the sequence you’ve given is accurate. However, if the sequence is meant to include all positive integers down to 1 in a descending order, then the number 1 is missing at the end of the list. It should be:\n\n9 8 7 6 5 4 3 2 1\n\nEach number in the sequence is one less than the number before it, and this sequence is typically known as a countdown. The integer 1 is the smallest positive integer and would complete the sequence of single-digit positive integers from 9 down to 1.”

Now to the LLM’s credit, it knows what the list should contain. but I would not describe its response as a completion of my input. Though my knowledge of LLMs is limited, I imagine the most likely predicted next token following my input is “1”, but whatever layers reside between my API call and the transformer are complicating things in undesirable ways for this use case. Is there a way to achieve a sort of “raw” mode? Thanks.

---

<div class="post-metadata">

**Author:** ![PaulBellow](https://sea2.discourse-cdn.com/openai1/user_avatar/community.openai.com/paulbellow/32/597962_2.png) [@PaulBellow](https://community.openai.com/u/PaulBellow)\
**Post date:** [August 26, 2024, 6:07pm UTC](https://community.openai.com/t/the-completions-api-doesnt-really-return-completions/922833/2 "2024-08-26T18:07:39Z")

</div>

Welcome to the community!

Are you using gpt-3.5-turbo-instruct?

Are you limiting max\_tokens? Might also ask for completion in the system prompt.

---

<div class="post-metadata">

**Author:** ![coder0xff](https://sea2.discourse-cdn.com/openai1/user_avatar/community.openai.com/coder0xff/32/448420_2.png) [@coder0xff](https://community.openai.com/u/coder0xff)\
**Post date:** [August 26, 2024, 6:13pm UTC](https://community.openai.com/t/the-completions-api-doesnt-really-return-completions/922833/3 "2024-08-26T18:13:28Z")

</div>

Hi Paul. Here’s my invocation.

```auto
task = _remote_client().chat.completions.create(
    model="gpt-4",
    messages=[{"role": "user", "content": content}],
    temperature=1,
    max_tokens=4096,
    top_p=1,
    frequency_penalty=0,
    presence_penalty=0,
)

```

> Might also ask for completion in the system prompt.

Sorry, would you elaborate? I don’t know what that is.

---

<div class="post-metadata">

**Author:** ![Diet](https://sea2.discourse-cdn.com/openai1/user_avatar/community.openai.com/diet/32/562749_2.png) [@Diet](https://community.openai.com/u/Diet)\
**Post date:** [August 26, 2024, 6:31pm UTC](https://community.openai.com/t/the-completions-api-doesnt-really-return-completions/922833/4 "2024-08-26T18:31:16Z")

</div>

> [@coder0xff](#):
>
> The following is the list of the descending positive integers starting from 9. The list is complete. 9 8 7 6 5 4 3 2

GPT-4 is unfortunately just a chat model

instruct are the actual completion models:

 ![The image shows a text snippet from a black-background interface labeled "Playground," stating a list of descending positive integers from 9 to 1. (Captioned by AI)](https://us1.discourse-cdn.com/openai1/original/4X/5/4/f/54ff4d0931ee1975ce9337ad677109d1be9261d7.png)

you can play with it here:

[https://platform.openai.com/playground/complete](https://platform.openai.com/playground/complete)

Is that what you meant?

---

<div class="post-metadata">

**Author:** ![bodeip1](https://sea2.discourse-cdn.com/openai1/user_avatar/community.openai.com/bodeip1/32/448515_2.png) [@bodeip1](https://community.openai.com/u/bodeip1)\
**Post date:** [August 26, 2024, 6:41pm UTC](https://community.openai.com/t/the-completions-api-doesnt-really-return-completions/922833/5 "2024-08-26T18:41:15Z")

</div>

You need to give it a few shots if you want an exact response like that, at least one or two. Look up few shot prompting.

---

<div class="post-metadata">

**Author:** ![coder0xff](https://sea2.discourse-cdn.com/openai1/user_avatar/community.openai.com/coder0xff/32/448420_2.png) [@coder0xff](https://community.openai.com/u/coder0xff)\
**Post date:** [August 26, 2024, 6:42pm UTC](https://community.openai.com/t/the-completions-api-doesnt-really-return-completions/922833/6 "2024-08-26T18:42:22Z")

</div>

I see. My example in the my original post is of course just a contrived toy example. What I’m really after is completion of Python code. I think I’ll be better off trying to programmatically cope with GPT-4’s difficult behavior in exchange for its superior ability.

---

<div class="post-metadata">

**Author:** ![coder0xff](https://sea2.discourse-cdn.com/openai1/user_avatar/community.openai.com/coder0xff/32/448420_2.png) [@coder0xff](https://community.openai.com/u/coder0xff)\
**Post date:** [August 26, 2024, 6:43pm UTC](https://community.openai.com/t/the-completions-api-doesnt-really-return-completions/922833/7 "2024-08-26T18:43:32Z")

</div>

> [@bodeip1](#):
>
> You need to give it a few shots if you want an exact response like that, at least one or two. Look up few shot prompting.

In my real use case (not the toy example I gave), I gave it 50 examples. xD

---

<div class="post-metadata">

**Author:** ![bodeip1](https://sea2.discourse-cdn.com/openai1/user_avatar/community.openai.com/bodeip1/32/448515_2.png) [@bodeip1](https://community.openai.com/u/bodeip1)\
**Post date:** [August 26, 2024, 6:53pm UTC](https://community.openai.com/t/the-completions-api-doesnt-really-return-completions/922833/8 "2024-08-26T18:53:11Z")

</div>

Not sure about 50 examples, I usually have the responses reduced down to a single number sequence with one shot. Also, I usually add in a line that says you will fail if you respond with anything except the single number.

---

<div class="post-metadata">

**Author:** ![PaulBellow](https://sea2.discourse-cdn.com/openai1/user_avatar/community.openai.com/paulbellow/32/597962_2.png) [@PaulBellow](https://community.openai.com/u/PaulBellow)\
**Post date:** [August 26, 2024, 7:17pm UTC](https://community.openai.com/t/the-completions-api-doesnt-really-return-completions/922833/9 "2024-08-26T19:17:00Z")

</div>

> [@coder0xff](#):
>
> ` model="gpt-4",`

Ah, yes, that’s a Chat Completion model, not Completion (Legacy)…

> | /v1/chat/completions | All GPT-4o, GPT-4o-mini, GPT-4, and GPT-3.5 Turbo models and their dated releases. chatgpt-4o-latest dynamic model. Fine-tuned versions of gpt-4o, gpt-4o-mini, gpt-4, and gpt-3.5-turbo. |
> | --- | --- |
> | /v1/completions (Legacy) | gpt-3.5-turbo-instruct, babbage-002, davinci-002 |

More info here…

[https://platform.openai.com/docs/models/model-endpoint-compatibility](https://platform.openai.com/docs/models/model-endpoint-compatibility)

---

<div class="post-metadata">

**Author:** ![fluxtah](https://sea2.discourse-cdn.com/openai1/user_avatar/community.openai.com/fluxtah/32/140390_2.png) [@fluxtah](https://community.openai.com/u/fluxtah)\
**Post date:** [August 26, 2024, 10:23pm UTC](https://community.openai.com/t/the-completions-api-doesnt-really-return-completions/922833/10 "2024-08-26T22:23:05Z")

</div>

Did you try adding “no prose” in your prompts.

Also try using user role instead of system.

Also maybe add a label such as

Output:

Right at the end of the prompt to indicate the output can force it to do the minimal without explanation (prose).

---

<div class="post-metadata">

**Author:** ![scottswigart](https://sea2.discourse-cdn.com/openai1/user_avatar/community.openai.com/scottswigart/32/283245_2.png) [@scottswigart](https://community.openai.com/u/scottswigart)\
**Post date:** [August 26, 2024, 10:39pm UTC](https://community.openai.com/t/the-completions-api-doesnt-really-return-completions/922833/11 "2024-08-26T22:39:49Z")

</div>

Try something like this:

predict the next number in this sequence. put the next number in a \<next\_number\> tag

9, 8, 7, 6, 5, 4, 3, 2
