Auto-managed chat history
The Conversations API automatically manages multi-turn context across devices and sessions. Use it with the Responses API to inject historical context without manual synchronization.
Get an API key and export it as an environment variable. When using the OpenAI SDK, install the SDK.
Pass the
Prerequisites
Get an API key and export it as an environment variable. When using the OpenAI SDK, install the SDK.
Service endpoints
base_url for the SDK: https://dashscope-intl.aliyuncs.com/api/v2/apps/protocols/compatible-mode/v1
HTTP base endpoint: https://dashscope-intl.aliyuncs.com/api/v2/apps/protocols/compatible-mode/v1/conversations
Endpoints
| Endpoint | Description |
|---|---|
| Create conversation | Create a conversation with optional initial message items |
| Retrieve conversation | Retrieve a conversation by ID |
| Update conversation | Update a conversation's metadata |
| Delete conversation | Delete a conversation |
| Create items | Add message items to a conversation |
| List items | List message items in a conversation |
| Retrieve item | Retrieve a message item by ID |
| Delete item | Delete a message item |
Use conversations in the Responses API
Pass the conversation parameter to the Responses API to maintain context across turns.
Do not pass both
previous_response_id and conversation. They are mutually exclusive.- Python
- Node.js
Limitations
- Maximum 20 items per
itemsarray in create and add operations. - Maximum 16 metadata key-value pairs (keys: max 64 chars, values: max 512 chars).