Skip to main content
Conversations

Conversations

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.

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

EndpointDescription
Create conversationCreate a conversation with optional initial message items
Retrieve conversationRetrieve a conversation by ID
Update conversationUpdate a conversation's metadata
Delete conversationDelete a conversation
Create itemsAdd message items to a conversation
List itemsList message items in a conversation
Retrieve itemRetrieve a message item by ID
Delete itemDelete 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
import os
from openai import OpenAI

client = OpenAI(
  api_key=os.getenv("DASHSCOPE_API_KEY"),
  base_url="https://dashscope-intl.aliyuncs.com/api/v2/apps/protocols/compatible-mode/v1",
)

conversation = client.conversations.create(
  items=[
    {
      "type": "message",
      "role": "system",
      "content": "Alice, a gentle and resilient woman, was born in Singapore. She is 20 years old, and her hobbies are music and chess.",
    }
  ]
)

response1 = client.responses.create(
  conversation=conversation.id, model="qwen3.6-plus", input="How old is Alice?"
)
print(f"First response: {response1.output_text}")

response2 = client.responses.create(
  conversation=conversation.id, model="qwen3.6-plus", input="What are her hobbies?"
)
print(f"Second response: {response2.output_text}")

Limitations

  • Maximum 20 items per items array in create and add operations.
  • Maximum 16 metadata key-value pairs (keys: max 64 chars, values: max 512 chars).