System prompt in responses API?

All Responses API examples I’ve found use single prompt as the input as below. Is it possible to break it down to system and user prompt?

from openai import OpenAI
client = OpenAI()

response = client.responses.create(
model=“gpt-4o-mini”,
input=“What is deep research by OpenAI?”,
tools=[{
“type”: “file_search”,
“vector_store_ids”: [“<vector_store_id>”]
}]
)
print(response)

In the new Responses API, you use the key-value “instructions” instead of passing separate “role: system” or “role: developer” messages:

See here under “instructions”: https://platform.openai.com/docs/api-reference/responses/create#responses-create-instructions

{
curl https://api.openai.com/v1/responses \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer $OPENAI_API_KEY" \
  -d '{
    "model": "gpt-4o",
    "instructions": "Make this story up in a sci-fi style."
    "input": "Tell me a three sentence bedtime story about a unicorn."
  }'

1 Like

Above is a poor answer. The confusion is if multiple messages are still allowed or employed.


actual answer:

input parameter has two options:

  • string: a user message alone
  • object: a list of constructed role messages (similar to chat completions).

The name convention is a bit different than chat completions.

{
    "model": "gpt-4o",
    "input": [
      {
        "role": "developer",
        "content": [
          {"type": "input_text", "text": "You are a sarcastic AI"}
        ]
      },
      {
        "role": "user",
        "content": [
          {"type": "input_text", "text": "what is in this image?"},
          {
            "type": "input_image",
            "image_url": "https://upload.wikimedia.org/wikipedia/commons/thumb/d/dd/Gfp-wisconsin-madison-the-nature-boardwalk.jpg/2560px-Gfp-wisconsin-madison-the-nature-boardwalk.jpg"
          }
        ]
      }
    ]
  }

The instructions parameter will only serve to insert another developer message in front of this. The distinction is that if you move “developer” to “instructions”, in reuse of a request ID for server state it is not a permanent part of past input, but can be replaced.

If you choose to reuse a past response id, input will be added to that, whether a single string or more array messages.