Update chat completion

POSThttps:/api.openai.com/v1/chat/completions/{completion_id}

Modify a stored chat completion. Only Chat Completions that have been created with the store parameter set to true can be modified. Currently, the only supported modification is to update the metadata field.

Path parameters

  • completion_id
    string
    Required
    The ID of the chat completion to update.

Request body

  • metadata
    object or null
    Required
    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. Keys are strings with a maximum length of 64 characters. Values are strings with a maximum length of 512 characters.

Response

The ChatCompletion object matching the specified ID.

Example request
1
curl -X POST https://api.openai.com/v1/chat/completions/chat_abc123 \
2
-H "Authorization: Bearer $OPENAI_API_KEY" \
3
-H "Content-Type: application/json" \
4
-d '{"metadata": {"foo": "bar"}}'
Example response
1
{
2
"object": "chat.completion",
3
"id": "chatcmpl-AyPNinnUqUDYo9SAdA52NobMflmj2",
4
"model": "gpt-4o-2024-08-06",
5
"created": 1738960610,
6
"request_id": "req_ded8ab984ec4bf840f37566c1011c417",
7
"tool_choice": null,
8
"usage": {
9
"total_tokens": 31,
10
"completion_tokens": 18,
11
"prompt_tokens": 13
12
},
13
"seed": 4944116822809979520,
14
"top_p": 1.0,
15
"temperature": 1.0,
16
"presence_penalty": 0.0,
17
"frequency_penalty": 0.0,
18
"system_fingerprint": "fp_50cad350e4",
19
"input_user": null,
20
"service_tier": "default",
21
"tools": null,
22
"metadata": {
23
"foo": "bar"
24
},
25
"choices": [
26
{
27
"index": 0,
28
"message": {
29
"content": "Mind of circuits hum, \nLearning patterns in silence— \nFuture's quiet spark.",
30
"role": "assistant",
31
"tool_calls": null,
32
"function_call": null
33
},
34
"finish_reason": "stop",
35
"logprobs": null
36
}
37
],
38
"response_format": null
39
}
Built with