Skip to main content
Conversations

Create conversation

Create a conversation with optional initial message items.

POST
/conversations
Python
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)
{
  "created_at": 1771316949128,
  "id": "conv_xxx",
  "metadata": {
    "topic": "demo"
  },
  "object": "conversation"
}

Authorizations

string
header
required

Qwen Cloud API Key. Create one in the console.

Body

application/json
object[]

Up to 20 initial message items.

items <= 20
object

Conversation metadata. Up to 16 key-value pairs (keys: max 64 chars, values: max 512 chars).

Response

200-application/json
integer

Unix timestamp (milliseconds) when the conversation was created.

1771316949128
string

The conversation ID.

conv_xxx
object

Metadata key-value pairs. Up to 16 pairs (keys: max 64 chars, values: max 512 chars).

enum<string>

Always conversation.

conversation