# Why can't I access my input to my model in the chat completion API?

**URL:** <https://community.openai.com/t/why-cant-i-access-my-input-to-my-model-in-the-chat-completion-api/1271725>\
**Category:** API\
**Tags:** bug, api, assistants-api\
**Created:** [May 28, 2025, 8:05pm UTC](https://community.openai.com/t/why-cant-i-access-my-input-to-my-model-in-the-chat-completion-api/1271725 "2025-05-28T20:05:29Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![sitanshu](https://sea2.discourse-cdn.com/openai1/user_avatar/community.openai.com/sitanshu/32/511238_2.png) [@sitanshu](https://community.openai.com/u/sitanshu)\
**Post date:** [May 28, 2025, 8:05pm UTC](https://community.openai.com/t/why-cant-i-access-my-input-to-my-model-in-the-chat-completion-api/1271725/1 "2025-05-28T20:05:29Z")

</div>

When I pull all my chat completions from here: [https://api.openai.com/v1/chat/completions](https://api.openai.com/v1/chat/completions)

the standard response only contains the choices, nothing related to the input that was given.

For context I am trying to produce a jsonl file using my chat completions for fine-tuning of my models.

Any help on this would be appreciated, also maybe I’m missing something but a chat completion api without the input feels kind of incomplete

---

<div class="post-metadata">

**Author:** ![aprendendo.next](https://sea2.discourse-cdn.com/openai1/user_avatar/community.openai.com/aprendendo.next/32/721758_2.png) [@aprendendo.next](https://community.openai.com/u/aprendendo.next)\
**Post date:** [May 28, 2025, 10:19pm UTC](https://community.openai.com/t/why-cant-i-access-my-input-to-my-model-in-the-chat-completion-api/1271725/3 "2025-05-28T22:19:25Z")

</div>

You need to retrieve the [chat messages](https://platform.openai.com/docs/api-reference/chat/getMessages) with an additional step.

The python example in there has a little mistake, the array of messages is in completions.data. Here is a fixed example:

```python
from openai import OpenAI
client = OpenAI()

completions = client.chat.completions.list()
first_id = completions.data[0].id
first_completion = client.chat.completions.retrieve(completion_id=first_id)
messages = client.chat.completions.messages.list(completion_id=first_id)
print(messages)

```

---

<div class="post-metadata">

**Author:** ![\_j](https://sea2.discourse-cdn.com/openai1/user_avatar/community.openai.com/_j/32/766292_2.png) [@\_j](https://community.openai.com/u/_j)\
**Post date:** [May 28, 2025, 10:31pm UTC](https://community.openai.com/t/why-cant-i-access-my-input-to-my-model-in-the-chat-completion-api/1271725/4 "2025-05-28T22:31:26Z")

</div>

> [@sitanshu](#):
>
> a chat completion api without the input feels kind of incomplete

Having an API that sends thousands of words that you sent right back at you would seem silly, don’t you think?

Here’s producing a JSONL file using chat completions. I was going to show how simple it was, but then I told an AI to make in robust and harder to break and fixed what it broke.

### A function for making a training example line

```python
from openai import OpenAI
client = OpenAI(timeout=90)

import json

def make_jsonl_entry(input_messages, api_response, tools):
    # Get the assistant message object
    msg = api_response.choices[0].message
    # Use model_dump() if available, else fallback to __dict__
    msg_dict = msg.model_dump() if hasattr(msg, "model_dump") else msg. __dict__
    # Only keep the keys you want, and handle tool_calls/content being optional
    entry = {
        "role": msg_dict["role"],
    }
    if "content" in msg_dict and msg_dict["content"] is not None:
        entry["content"] = msg_dict["content"]
    if "tool_calls" in msg_dict and msg_dict["tool_calls"]:
        entry["tool_calls"] = msg_dict["tool_calls"]
    # If you always want tool_calls present (even if empty), uncomment:
    # entry["tool_calls"] = msg_dict.get("tool_calls", [])

    return json.dumps({
        "messages": input_messages + [entry],
        "parallel_tool_calls": False,
        "tools": tools,
    })

```

### Carry on with your normal usage:

```python
input = [
    {"role": "system", "content": "You are a helpful language assistant."},
    {"role": "user", "content": "Say 'banana' 10 times!"},
]
tools = []
api_response = client.chat.completions.create(
  model="gpt-4-turbo-2024-04-09", max_tokens=5, messages=input, tools=tools,
)
print(f"AI said:\n{api_response.choices[0].message.content}")

jsonl_chat_to_save = make_jsonl_entry(input, api_response, tools)

print(f"\n\nYour training file line:\n{jsonl_chat_to_save}")

```

* * *

If you simply must get what you just sent from an API, you’ve got the Responses endpoint. The data return is not your friend, though (nor is an API that makes you pay for more than the desired output length.)

```auto

r_input = [
    {
        "role": "system",
        "content": [
            {"type": "input_text", "text": "You are a helpful language assistant."}
        ]
    },
    {
        "role": "user",
        "content": [
            {"type": "input_text", "text": "Say 'banana' 10 times!"}
        ]
    }
]
response = client.responses.create(
  model="gpt-4-turbo-2024-04-09",
  input=r_input,
  max_output_tokens=16,
)
print(json.dumps(response.model_dump(),indent=2)) # can't trust index 0
input_get = client.responses.input_items.list(response.id, order="asc")
print(f"retrieved inputs: {input_get.model_dump()}") # not chatC items

```

---

<div class="post-metadata">

**Author:** ![sitanshu](https://sea2.discourse-cdn.com/openai1/user_avatar/community.openai.com/sitanshu/32/511238_2.png) [@sitanshu](https://community.openai.com/u/sitanshu)\
**Post date:** [May 28, 2025, 10:43pm UTC](https://community.openai.com/t/why-cant-i-access-my-input-to-my-model-in-the-chat-completion-api/1271725/5 "2025-05-28T22:43:09Z")

</div>

@_j maybe I didn’t explain my use case better, I am using a multi agent system from the oAI libraries so I am not making these create api calls myself but rather just storing the chat completions. In that case having the input also would be super beneficial, thank you for your help.

@aprendendo.next that API call works perfectly! thanks so much!

---

<div class="post-metadata">

**Author:** ![sitanshu](https://sea2.discourse-cdn.com/openai1/user_avatar/community.openai.com/sitanshu/32/511238_2.png) [@sitanshu](https://community.openai.com/u/sitanshu)\
**Post date:** [June 1, 2025, 11:44pm UTC](https://community.openai.com/t/why-cant-i-access-my-input-to-my-model-in-the-chat-completion-api/1271725/6 "2025-06-01T23:44:23Z")

</div>

@aprendendo.next I’m facing another issue where when I get the messages from that api I can’t see the tool/function calls made in some cases

im getting this in the messages body:

```auto
{
			"id": "id123",
			"role": "tool",
			"content": "None",
			"content_parts": null,
			"name": null
		}

```

content, name everything is null, it just says tool

---

<div class="post-metadata">

**Author:** ![aprendendo.next](https://sea2.discourse-cdn.com/openai1/user_avatar/community.openai.com/aprendendo.next/32/721758_2.png) [@aprendendo.next](https://community.openai.com/u/aprendendo.next)\
**Post date:** [June 2, 2025, 12:18am UTC](https://community.openai.com/t/why-cant-i-access-my-input-to-my-model-in-the-chat-completion-api/1271725/7 "2025-06-02T00:18:49Z")

</div>

@sitanshu I’ve just tried here with a function call and it seems to be a limitation of the API.

Unfortunately that’s all it returns, as of now I don’t know if there is another way to retrieve the exact inputs.

This works for text, but as you’ve noticed it has some limitations for other input types.

---

<div class="post-metadata">

**Author:** ![sitanshu](https://sea2.discourse-cdn.com/openai1/user_avatar/community.openai.com/sitanshu/32/511238_2.png) [@sitanshu](https://community.openai.com/u/sitanshu)\
**Post date:** [June 2, 2025, 3:18pm UTC](https://community.openai.com/t/why-cant-i-access-my-input-to-my-model-in-the-chat-completion-api/1271725/8 "2025-06-02T15:18:09Z")

</div>

made a post about it here: [Trying to access my chat completion input in a multi agent architecture](https://community.openai.com/t/trying-to-access-my-chat-completion-input-in-a-multi-agent-architecture/1275450)
