Пропустить и перейти к основному содержимому

Этот браузер больше не поддерживается.

Выполните обновление до Microsoft Edge, чтобы воспользоваться новейшими функциями, обновлениями для системы безопасности и технической поддержкой.

Скачать Microsoft Edge Дополнительные сведения об Internet Explorer и Microsoft Edge
microsoft-foundry.rest.security.o-auth2-auth

Chat

Update a chat completion

POST /openai/v1/chat/completions/{completion_id}

Updates a chat completion with the supplied changes.

Параметры пути

completion_id string обязательно

The ID of the chat completion to update.

Текст запроса

The request body.

Content-Type: application/json
metadata OpenAI.Metadata | null обязательно

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.

[key: string] string

Ответы

The request has succeeded.

Текст

Content-Type: application/json
id string обязательно

A unique identifier for the chat completion.

choices OpenAI.CreateChatCompletionResponseChoices[] обязательно

A list of chat completion choices. Can be more than one if n is greater than 1.

created integer обязательно

The Unix timestamp (in seconds) of when the chat completion was created.

model string обязательно

The model deployment used for the creation of this chat completion.

metadata OpenAI.Metadata | null

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.

[key: string] string
service_tier enum

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', then the request will be processed with the Flex Processing service tier. - To opt-in to 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.

autodefaultflexscalepriorityfast
system_fingerprint string

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.

object enum обязательно

The object type, which is always chat.completion.

chat.completion
usage OpenAI.CompletionUsage

Usage statistics for the completion request.

completion_tokens integer обязательно
prompt_tokens integer обязательно
total_tokens integer обязательно
completion_tokens_details OpenAI.CompletionUsageCompletionTokensDetails
accepted_prediction_tokens integer
audio_tokens integer
reasoning_tokens integer
text_tokens integer
rejected_prediction_tokens integer
prompt_tokens_details OpenAI.CompletionUsagePromptTokensDetails
audio_tokens integer
cached_tokens integer
text_tokens integer
image_tokens integer
cache_write_tokens integer
moderation OpenAI.ChatCompletionModeration | null

Moderation results or errors for the request input and generated output.

input moderation_results | error обязательно

Moderation results or an error for a chat completion moderation check.

Один из следующих:
moderation_results OpenAI.ChatCompletionModerationResults

Successful moderation results for the request input or generated output.

type enum обязательно

The object type, which is always moderation_results.

moderation_results
model string обязательно

The moderation model used to generate the results.

results OpenAI.ModerationResultBody[] обязательно

A list of moderation results.

error OpenAI.ChatCompletionModerationError

An error produced while attempting moderation.

type enum обязательно

The object type, which is always error.

error
code string обязательно

The error code.

message string обязательно

The error message.

output moderation_results | error обязательно

Moderation results or an error for a chat completion moderation check.

Один из следующих:
moderation_results OpenAI.ChatCompletionModerationResults

Successful moderation results for the request input or generated output.

type enum обязательно

The object type, which is always moderation_results.

moderation_results
model string обязательно

The moderation model used to generate the results.

results OpenAI.ModerationResultBody[] обязательно

A list of moderation results.

error OpenAI.ChatCompletionModerationError

An error produced while attempting moderation.

type enum обязательно

The object type, which is always error.

error
code string обязательно

The error code.

message string обязательно

The error message.

model_selection_details ModelSelectionDetails

Model selection metadata providing visibility into routing decisions.

model_router_details ModelRouterDetails обязательно

Routing decision metadata from Model Router.

mode string | enum обязательно

The routing mode used by Model Router for the request.

Любое из следующих:
string
enum
balancedcostquality
session_affinity SessionAffinityDetails

Effective Model Router session affinity metadata for a request.

mode string | enum обязательно

Effective modes reported for Model Router session affinity.

Любое из следующих:
string
enum
stickynone
source string | enum

Conversation identifier sources supported by Model Router session affinity.

Любое из следующих:
string
enum
session_id_payloadsession_id_headernot_availableconversationprevious_response_id
decision string | enum

Final outcomes reported for Model Router session affinity.

Любое из следующих:
string
enum
initializeretainswitch
routing_trace RoutingTraceEntry[] обязательно

Ordered trace of routing decisions. Contains one entry for Chat Completions, and may contain multiple entries for Responses API or agent scenarios where multiple inference turns occur.

Client error

Текст

Content-Type: application/json
error OpenAI.Error обязательно
code string | null обязательно
message string обязательно
param string | null
type string
misalignment OpenAI.MisalignmentErrorDetailsResource
review_target string | null
error_type string | enum
Любое из следующих:
string
enum
potentially_unintended_data_transferpotentially_unintended_data_accesspotentially_unintended_destructive_activityother
detailed_explanation string

The public explanation for this block.

steer OpenAI._MisalignmentSteer
message string обязательно

The public continuation instruction.

details OpenAI.Error[]
additionalInfo object
debugInfo object

Server error

Текст

Content-Type: application/json
error OpenAI.Error обязательно
code string | null обязательно
message string обязательно
param string | null
type string
misalignment OpenAI.MisalignmentErrorDetailsResource
review_target string | null
error_type string | enum
Любое из следующих:
string
enum
potentially_unintended_data_transferpotentially_unintended_data_accesspotentially_unintended_destructive_activityother
detailed_explanation string

The public explanation for this block.

steer OpenAI._MisalignmentSteer
message string обязательно

The public continuation instruction.

details OpenAI.Error[]
additionalInfo object
debugInfo object

Запрос

curl -X POST https://api.openai.com/v1/chat/completions/chat_abc123 \
  -H "Authorization: Bearer $OPENAI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"metadata": {"foo": "bar"}}'
import os
from openai import OpenAI

client = OpenAI(
    api_key=os.environ.get("OPENAI_API_KEY"),  # This is the default and can be omitted
)
chat_completion = client.chat.completions.update(
    completion_id="completion_id",
    metadata={
        "foo": "string"
    },
)
print(chat_completion.id)
import OpenAI from 'openai';

const client = new OpenAI({
  apiKey: process.env['OPENAI_API_KEY'], // This is the default and can be omitted
});

const chatCompletion = await client.chat.completions.update('completion_id', {
  metadata: { foo: 'string' },
});

console.log(chatCompletion.id);
package main

import (
    "context"
    "fmt"

    "github.com/openai/openai-go"
    "github.com/openai/openai-go/option"
    "github.com/openai/openai-go/shared"
)

func main() {
    client := openai.NewClient(
        option.WithAPIKey("My API Key"),
    )
    chatCompletion, err := client.Chat.Completions.Update(
        context.TODO(),
        "completion_id",
        openai.ChatCompletionUpdateParams{
            Metadata: shared.Metadata{
                "foo": "string",
            },
        },
    )
    if err != nil {
        panic(err.Error())
    }
    fmt.Printf("%+v
", chatCompletion.ID)
}
package com.openai.example;

import com.openai.client.OpenAIClient;
import com.openai.client.okhttp.OpenAIOkHttpClient;
import com.openai.core.JsonValue;
import com.openai.models.chat.completions.ChatCompletion;
import com.openai.models.chat.completions.ChatCompletionUpdateParams;

public final class Main {
    private Main() {}

    public static void main(String[] args) {
        OpenAIClient client = OpenAIOkHttpClient.fromEnv();

        ChatCompletionUpdateParams params = ChatCompletionUpdateParams.builder()
            .completionId("completion_id")
            .metadata(ChatCompletionUpdateParams.Metadata.builder()
                .putAdditionalProperty("foo", JsonValue.from("string"))
                .build())
            .build();
        ChatCompletion chatCompletion = client.chat().completions().update(params);
    }
}
require "openai"

openai = OpenAI::Client.new(api_key: "My API Key")

chat_completion = openai.chat.completions.update("completion_id", metadata: {foo: "string"})

puts(chat_completion)

Response

{
  "object": "chat.completion",
  "id": "chatcmpl-AyPNinnUqUDYo9SAdA52NobMflmj2",
  "model": "gpt-4o-2024-08-06",
  "created": 1738960610,
  "request_id": "req_ded8ab984ec4bf840f37566c1011c417",
  "tool_choice": null,
  "usage": {
    "total_tokens": 31,
    "completion_tokens": 18,
    "prompt_tokens": 13
  },
  "seed": 4944116822809979520,
  "top_p": 1.0,
  "temperature": 1.0,
  "presence_penalty": 0.0,
  "frequency_penalty": 0.0,
  "system_fingerprint": "fp_50cad350e4",
  "input_user": null,
  "service_tier": "default",
  "tools": null,
  "metadata": {
    "foo": "bar"
  },
  "choices": [
    {
      "index": 0,
      "message": {
        "content": "Mind of circuits hum,
Learning patterns in silence—
Future's quiet spark.",
        "role": "assistant",
        "tool_calls": null,
        "function_call": null
      },
      "finish_reason": "stop",
      "logprobs": null
    }
  ],
  "response_format": null
}
ru-ru
Ваши варианты выбора параметров конфиденциальности
  • Заявление об отказе ИИ
  • Предыдущие версии
  • Блог
  • Участие в доработке
  • Конфиденциальность
  • Конфиденциальность медицинских данных потребителей
  • Условия использования
  • Товарные знаки
  • © Microsoft 2026