Python
Conversations
Create conversation
Create a conversation with optional initial message items.
Python
Copy
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(
metadata={"topic": "demo"},
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."}
]
)
print(conversation)Copy
{
"created_at": 1771316949128,
"id": "conv_xxx",
"metadata": {
"topic": "demo"
},
"object": "conversation"
}