본문 바로가기
C.W.K.
Stream
Lesson 03 of 07 · published

Input Format — string vs message list

~22 min · input, messages, multimodal

Level 0Tokenizer
0 XP0/54 lessons0/10 achievements
0/120 XP to next level120 XP to go0% complete

Responses 의 input 은 두 가지 형태를 받아. 단순한 문자열을 보낼 수도 있고, type 이 붙은 content part 를 담은 message 목록을 보낼 수도 있어. 한 번 묻고 끝나는 텍스트 요청에는 문자열을, multimodal 또는 여러 turn 에 걸친 요청에는 목록을 써.

문자열이면 충분한 경우

이미지도 대화 기록도 없는 단일 user prompt 라면 input="What is 2+2?" 만으로 충분해. 불필요한 구조 없이 의도가 바로 보여.

message 목록에는 content type 을 밝혀

이미지, 파일, 여러 turn, 세분화된 role 이 필요하면 message 목록을 사용해. input_text, input_image, input_file 로 각 content part 의 type 을 명시하므로 multimodal 요청 구조가 분명해져.

system 성격의 지시는 instructions= 로

input 목록에 system role 메시지를 넣어도 기존 호환 동작이 남아 있을 수 있지만, Responses 의 새 구조는 최상위 instructions= parameter 를 사용해. 새 코드에서는 지시와 입력을 분리해.

작업에 맞는 input 형태를 골라

단순한 질문에 긴 message 구조를 강제할 이유도 없고, multimodal 입력을 문자열 하나에 욱여넣을 수도 없어. 두 형태 중 필요한 표현력을 가장 간단하게 주는 쪽을 선택해.

Code

Plain string input·python
response = client.responses.create(
    model="gpt-5.4",
    input="Explain quantum entanglement in simple terms."
)
print(response.output_text)
Message-list input with input_text and input_image·python
response = client.responses.create(
    model="gpt-5.4",
    input=[
        {"role": "developer", "content": "You are a helpful assistant."},
        {"role": "user", "content": "What is 2 + 2?"},
    ]
)
Example 3·python
response = client.responses.create(
    model="gpt-4.1",
    input=[{
        "role": "user",
        "content": [
            {"type": "input_text", "text": "Describe this image:"},
            {"type": "input_image", "image_url": "https://example.com/img.jpg", "detail": "high"},
            {"type": "input_file", "file_id": "file-abc123"},
        ]
    }]
)

External links

Exercise

같은 지시를 (1) 최상위 instructions=, (2) developer role 메시지, (3) user 메시지 앞부분에 넣는 세 방식으로 보내. assistant 출력을 비교하고 어느 방식이 가장 안정적으로 지시를 따르는지 확인해.

Progress

Progress is local-only — sign in to sync across devices.
이 페이지에서 버그를 발견하셨거나 피드백이 있으세요?문제 신고

댓글 0

🔔 답글 알림 (로그인 필요)
로그인댓글을 남기려면 로그인해 주세요.

아직 댓글이 없어요. 첫 댓글을 남겨보세요.