python/resources/conversations/methods/retrieve/index.md +0 −81 deleted
File Deleted View Diff
1## Retrieve a conversation
2
3`conversations.retrieve(strconversation_id) -> Conversation`
4
5**get** `/conversations/{conversation_id}`
6
7Get a conversation
8
9### Parameters
10
11- `conversation_id: str`
12
13### Returns
14
15- `class Conversation: …`
16
17 - `id: str`
18
19 The unique ID of the conversation.
20
21 - `created_at: int`
22
23 The time at which the conversation was created, measured in seconds since the Unix epoch.
24
25 - `metadata: object`
26
27 Set of 16 key-value pairs that can be attached to an object. This can be useful for storing additional information about the object in a structured format, and querying for objects via API or the dashboard.
28 Keys are strings with a maximum length of 64 characters. Values are strings with a maximum length of 512 characters.
29
30 - `object: Literal["conversation"]`
31
32 The object type, which is always `conversation`.
33
34 - `"conversation"`
35
36### Example
37
38```python
39import os
40from openai import OpenAI
41
42client = OpenAI(
43 api_key=os.environ.get("OPENAI_API_KEY"), # This is the default and can be omitted
44)
45conversation = client.conversations.retrieve(
46 "conv_123",
47)
48print(conversation.id)
49```
50
51#### Response
52
53```json
54{
55 "id": "id",
56 "created_at": 0,
57 "metadata": {},
58 "object": "conversation"
59}
60```
61
62### Example
63
64```python
65from openai import OpenAI
66client = OpenAI()
67
68conversation = client.conversations.retrieve("conv_123")
69print(conversation)
70```
71
72#### Response
73
74```json
75{
76 "id": "conv_123",
77 "object": "conversation",
78 "created_at": 1741900000,
79 "metadata": {"topic": "demo"}
80}
81```