Sharing a Long-Term Memory Across Conversations

You can use the memory_subject_id metadata parameter to share long-term memory information across conversations.

The memory_subject_id is metqadata parameter is a project-scoped unique identifier for memory. All conversations created with the same memory_subject_id share the same long term memory space.

Example code:

# first conversation
conversation1 = client.conversations.create(
    metadata={ "memory_subject_id": "user_123456" },
)

# a turn on first conversation
response = client.responses.create(
    model="openai.gpt-4.1",
    input="I like Fish. I don't like Shrimp.",
    conversation=conversation1.id
)
print(response.output_text)

# delay for long-term memory processing
time.sleep(10)

# second conversation
conversation2 = client.conversations.create(
    metadata={ "memory_subject_id": "user_123456" },
)

# a turn on second conversation
response = client.responses.create(
    model="openai.gpt-4.1",
    input="What do I like",
    conversation=conversation2.id
)

print(response.output_text)