POST/chat/completions/{completion_id}

Update chat completion metadata

Updates the metadata on a stored chat completion. The completion must have been created with store set to true, and metadata is the only supported modification. Use this operation to attach or replace structured key-value metadata on the completion.

  • IdempotentThe SDK sends Idempotency-Key, so a retried request is only applied once.

1 parameter · 1 body field
completion_idstringrequired
The unique identifier of the stored chat completion to update.

Metadata to attach to the stored chat completion. The metadata field is required.

metadataobjectrequired
A set of up to 16 key-value pairs, or null. Keys must be strings no longer than 64 characters, and values must be strings.

5 status codes
200Returns the updated chat completion object, including its identifier, choices, creation time, model, and metadata.
idstringrequired
A unique identifier for the chat completion.
choicesarray<object>required
A list of chat completion choices. Can be more than one if `n` is greater than 1.
createdintegerrequired
The Unix timestamp (in seconds) of when the chat completion was created.
modelstringrequired
The model used for the chat completion.
metadataobjectoptional
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.
service_tierstringoptional
Specifies the processing type used for serving the request. - If set to 'auto', then the request will be processed with the service tier configured in the Project settings. Unless otherwise configured, the Project will use 'default'. - If set to 'default', then the request will be processed with the standard pricing and performance for the selected model. - If set to '[flex](https://developers.openai.com/api/docs/guides/flex-processing)', then the request will be processed with the Flex Processing service tier. - To opt-in to [Fast mode](https://developers.openai.com/api/docs/guides/fast-mode) at the request level, include the `service_tier=fast` or `service_tier=priority` parameter for Responses or Chat Completions. The response will show `service_tier=priority` regardless of if you specify `service_tier=fast` or `priority` in your request. - When not set, the default behavior is 'auto'. When the `service_tier` parameter is set, the response body will include the `service_tier` value based on the processing mode actually used to serve the request. This response value may be different from the value set in the parameter.
Allowed:autodefaultflexscalepriorityfastDefault:auto
system_fingerprintstringdeprecatedoptional
This fingerprint represents the backend configuration that the model runs with. Can be used in conjunction with the `seed` request parameter to understand when backend changes have been made that might impact determinism.
objectstringrequired
The object type, which is always `chat.completion`.
Allowed:chat.completion
usageobjectoptional
Usage statistics for the completion request.
moderationobjectoptional
Moderation results for the request input and generated output, if moderated completions were requested.
400Returned when the metadata update is invalid.
errorobjectrequired
404Returned when no stored chat completion is found with the specified ID.
errorobjectrequired
429Returned when the request exceeds a rate limit.
errorobjectrequired
500Returned when an internal error prevents the request from being completed.
errorobjectrequired

Error handling

A 400 is returned for an invalid metadata update, and a 404 is returned when no stored chat completion matches the requested ID. A 429 is returned when the request exceeds a rate limit, and a 500 when an internal error prevents completion. The completion_id path parameter must identify a chat completion created with store set to true.