Enabling Short-Term Memory

In the Conversations API, you can enable short-term memory compaction by setting the short_term_memory_optimization metadata parameter to true.

You can enable short-term memory compaction at the project level when you create a project. If you did not enable it during project creation, you can enable it later by editing the project.

You can also enable it for a specific conversation by setting the metadata.short_term_memory_optimization parameter to true when you create the conversation.

If you don't set short_term_memory_optimization in the conversation metadata, the system uses the project default settings.

For details on which model is used for compaction, see 2.1 Short-Term Memory Compaction (Conversation History Compaction).

Example:

conversation1 = client.conversations.create(
	metadata={"topic": "demo", "short_term_memory_optimization": "True"},
	items=[{"type": "message", "role": "user", "content": "Tell me a joke."}],
)