Lompati ke konten utama

Browser ini sudah tidak didukung.

Tingkatkan ke Microsoft Edge untuk memanfaatkan fitur, pembaruan keamanan, dan dukungan teknis terkini.

Unduh Microsoft Edge Informasi selengkapnya tentang Internet Explorer dan Microsoft Edge
microsoft-foundry.rest.security.o-auth2-auth

Responses

Cancel a model response

POST /openai/v1/responses/{response_id}/cancel

Cancels a model response with the given ID. Only responses created with the background parameter set to true can be cancelled.

Parameter jalur

response_id string diperlukan

The ID of the response to cancel.

Parameter header

x-ms-user-identity string

Opaque per-user identity string used to scope endpoint-scoped data to a specific end user. The caller must have the agents/endpoints/UserIdentityImpersonation/action RBAC permission.

Respons

The request has succeeded.

Header

x-agent-session-id string

Session ID for this request. Only present for hosted agent responses. Returns the provided session ID or an auto-generated one if not provided in the request.

Isi

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
top_logprobs integer | null
temperature number | null
top_p number | null
user string | null

This field is being replaced by safety_identifier and prompt_cache_key. Use prompt_cache_key instead to maintain caching optimizations. A stable identifier for your end-users. Used to boost cache hit rates by better bucketing similar requests and to help OpenAI detect and prevent abuse. Learn more.

safety_identifier string | null
prompt_cache_key string | null
prompt_cache_retention enum
in_memory24h
previous_response_id string | null
model string

The model deployment to use for the creation of this response.

background boolean | null
max_tool_calls integer | null
text OpenAI.ResponseTextParam

Configuration options for a text response from the model. Can be plain text or structured JSON data. Learn more: - Text inputs and outputs - Structured Outputs

format json_schema | text | json_object

An object specifying the format that the model must output. Configuring { "type": "json_schema" } enables Structured Outputs, which ensures the model will match your supplied JSON schema. Learn more in the Structured Outputs guide. The default format is { "type": "text" } with no additional options. Not recommended for gpt-4o and newer models:* Setting to { "type": "json_object" } enables the older JSON mode, which ensures the message the model generates is valid JSON. Using json_schema is preferred for models that support it.

Salah satu dari berikut ini:
json_schema OpenAI.TextResponseFormatJsonSchema

JSON Schema response format. Used to generate structured JSON responses. Learn more about Structured Outputs.

type enum diperlukan

The type of response format being defined. Always json_schema.

json_schema
description string

A description of what the response format is for, used by the model to determine how to respond in the format.

name string diperlukan

The name of the response format. Must be a-z, A-Z, 0-9, or contain underscores and dashes, with a maximum length of 64.

schema OpenAI.ResponseFormatJsonSchemaSchema diperlukan

The schema for the response format, described as a JSON Schema object. Learn how to build JSON schemas here.

strict boolean | null
text OpenAI.TextResponseFormatConfigurationResponseFormatText

Default response format. Used to generate text responses.

type enum diperlukan

The type of response format being defined. Always text.

text
json_object OpenAI.TextResponseFormatConfigurationResponseFormatJsonObject

JSON object response format. An older method of generating JSON responses. Using json_schema is recommended for models that support it. Note that the model will not generate JSON without a system or user message instructing it to do so.

type enum diperlukan

The type of response format being defined. Always json_object.

json_object
verbosity enum

Constrains the verbosity of the model's response. Lower values will result in more concise responses, while higher values will result in more verbose responses. Currently supported values are low, medium, and high. The default is medium.

lowmediumhigh
tools OpenAI.Tool[]

An array of tools the model may call while generating a response. You can specify which tool to use by setting the tool_choice parameter. We support the following categories of tools: - Built-in tools: Tools that are provided by OpenAI that extend the model's capabilities, like web search or file search. Learn more about built-in tools. - MCP Tools: Integrations with third-party systems via custom MCP servers or predefined connectors such as Google Drive and SharePoint. Learn more about MCP Tools. - Function calls (custom tools): Functions that are defined by you, enabling the model to call your own code with strongly typed arguments and outputs. Learn more about function calling. You can also use custom tools to call your own code.

tool_choice enum | OpenAI.ToolChoiceParam
Salah satu dari berikut ini:
enum

Controls which (if any) tool is called by the model. none means the model will not call any tool and instead generates a message. auto means the model can pick between generating a message or calling one or more tools. required means the model must call one or more tools.

noneautorequired
Salah satu dari berikut ini:
function OpenAI.ToolChoiceFunction

Use this option to force the model to call a specific function.

type enum diperlukan

For function calling, the type is always function.

function
name string diperlukan

The name of the function to call.

mcp OpenAI.ToolChoiceMCP

Use this option to force the model to call a specific tool on a remote MCP server.

type enum diperlukan

For MCP tools, the type is always mcp.

mcp
server_label string diperlukan

The label of the MCP server to use.

name string | null
allowed_tools OpenAI.ToolChoiceAllowed

Constrains the tools available to the model to a pre-defined set.

type enum diperlukan

Allowed tool configuration type. Always allowed_tools.

allowed_tools
mode enum diperlukan

Constrains the tools available to the model to a pre-defined set. auto allows the model to pick from among the allowed tools and generate a message. required requires the model to call one or more of the allowed tools.

autorequired
tools object[] diperlukan

A list of tool definitions that the model should be allowed to call. For the Responses API, the list of tool definitions might look like: json [ { "type": "function", "name": "get_weather" }, { "type": "mcp", "server_label": "deepwiki" }, { "type": "image_generation" } ]

custom OpenAI.ToolChoiceCustom

Use this option to force the model to call a specific custom tool.

type enum diperlukan

For custom tool calling, the type is always custom.

custom
name string diperlukan

The name of the custom tool to call.

programmatic_tool_calling OpenAI.SpecificProgrammaticToolCallingParam
type enum diperlukan

The tool to call. Always programmatic_tool_calling.

programmatic_tool_calling
apply_patch OpenAI.SpecificApplyPatchParam

Forces the model to call the apply_patch tool when executing a tool call.

type enum diperlukan

The tool to call. Always apply_patch.

apply_patch
shell OpenAI.SpecificFunctionShellParam

Forces the model to call the shell tool when a tool call is required.

type enum diperlukan

The tool to call. Always shell.

shell
file_search OpenAI.ToolChoiceFileSearch

Indicates that the model should use a built-in tool to generate a response. Learn more about built-in tools.

type enum diperlukan
file_search
web_search_preview OpenAI.ToolChoiceWebSearchPreview

Indicates that the model should use a built-in tool to generate a response. Learn more about built-in tools.

type enum diperlukan
web_search_preview
computer_use_preview OpenAI.ToolChoiceComputerUsePreview

Indicates that the model should use a built-in tool to generate a response. Learn more about built-in tools.

type enum diperlukan
computer_use_preview
web_search_preview_2025_03_11 OpenAI.ToolChoiceWebSearchPreview20250311

Indicates that the model should use a built-in tool to generate a response. Learn more about built-in tools.

type enum diperlukan
web_search_preview_2025_03_11
image_generation OpenAI.ToolChoiceImageGeneration

Indicates that the model should use a built-in tool to generate a response. Learn more about built-in tools.

type enum diperlukan
image_generation
code_interpreter OpenAI.ToolChoiceCodeInterpreter

Indicates that the model should use a built-in tool to generate a response. Learn more about built-in tools.

type enum diperlukan
code_interpreter
computer OpenAI.ToolChoiceComputer

Indicates that the model should use a built-in tool to generate a response. Learn more about built-in tools.

type enum diperlukan
computer
computer_use OpenAI.ToolChoiceComputerUse

Indicates that the model should use a built-in tool to generate a response. Learn more about built-in tools.

type enum diperlukan
computer_use
prompt OpenAI.Prompt

Reference to a prompt template and its variables. Learn more.

id string diperlukan

The unique identifier of the prompt template to use.

version string | null
variables OpenAI.ResponsePromptVariables | null

Optional map of values to substitute in for variables in your prompt. The substitution values can either be strings, or other Response input types like images or files.

[key: string] string | OpenAI.InputTextContent | OpenAI.InputImageContent | OpenAI.InputFileContent
Salah satu dari yang berikut:
string
type enum diperlukan

The type of the input item. Always input_text.

input_text
text string diperlukan

The text input to the model.

prompt_cache_breakpoint OpenAI.PromptCacheBreakpointConfig

Marks the exact end of a reusable prompt prefix. The breakpoint inherits its TTL from the request's prompt_cache_options.ttl; the boundary is not rounded to a token block.

mode enum diperlukan

The breakpoint mode. Always explicit.

explicit
type enum diperlukan

The type of the input item. Always input_image.

input_image
image_url string | null
file_id string | null
detail enum diperlukan
lowhighautooriginal
prompt_cache_breakpoint OpenAI.PromptCacheBreakpointConfig

Marks the exact end of a reusable prompt prefix. The breakpoint inherits its TTL from the request's prompt_cache_options.ttl; the boundary is not rounded to a token block.

mode enum diperlukan

The breakpoint mode. Always explicit.

explicit
type enum diperlukan

The type of the input item. Always input_file.

input_file
file_id string | null
filename string

The name of the file to be sent to the model.

file_data string

The content of the file to be sent to the model.

prompt_cache_breakpoint OpenAI.PromptCacheBreakpointConfig

Marks the exact end of a reusable prompt prefix. The breakpoint inherits its TTL from the request's prompt_cache_options.ttl; the boundary is not rounded to a token block.

mode enum diperlukan

The breakpoint mode. Always explicit.

explicit
file_url string

The URL of the file to be sent to the model.

detail enum
autolowhigh
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. - If set to 'ultrafast', then the request will be processed with the access-controlled Ultrafast Processing service tier. This tier is currently available for gpt-5.6-sol; a response served through it will show service_tier=ultrafast. - 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.

autodefaultflexscalepriorityfastultrafast
truncation enum
autodisabled
id string diperlukan

Unique identifier for this Response.

object enum diperlukan

The object type of this resource - always set to response.

response
status enum

The status of the response generation. One of completed, failed, in_progress, cancelled, queued, or incomplete.

completedfailedin_progresscancelledqueuedincomplete
access_programs OpenAI.AccessProgramsBody | null diperlukan
cyber enum diperlukan
standarddaybreak_bluedaybreak_red
created_at integer diperlukan

Unix timestamp (in seconds) of when this Response was created.

completed_at integer | null
error OpenAI.ResponseError | null diperlukan

An error object returned when the model fails to generate a Response.

type string | null

The original error type, or null if it was not recorded.

param string | null

The request parameter associated with the error, or null if none was recorded.

code enum diperlukan

The error code for the response.

server_errorrate_limit_exceededinvalid_promptdata_residency_mismatchbio_policymisalignment_policy_violationvector_store_timeoutinvalid_imageinvalid_image_formatinvalid_base64_imageinvalid_image_urlimage_too_largeimage_too_smallimage_parse_errorimage_content_policy_violationinvalid_image_modeimage_file_too_largeunsupported_image_media_typeempty_image_filefailed_to_download_imageimage_file_not_found
message string diperlukan

A human-readable description of the error.

misalignment OpenAI.MisalignmentErrorDetailsResource
review_target string | null
error_type string | enum
Salah satu dari yang berikut:
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 diperlukan

The public continuation instruction.

incomplete_details OpenAI.ResponseIncompleteDetails | null diperlukan
reason enum
max_output_tokensmax_messagescontent_filtersteered
output OpenAI.OutputItem[] diperlukan

An array of content items generated by the model. - The length and order of items in the output array is dependent on the model's response. - Rather than accessing the first item in the output array and assuming it's an assistant message with the content generated by the model, you might consider using the output_text property where supported in SDKs.

reasoning OpenAI.Reasoning | null

Configuration options for reasoning models.

mode string | enum
Salah satu dari yang berikut:
string
enum
standardpro
effort string | enum | null

Constrains effort on reasoning for reasoning models. Currently supported values are none, minimal, low, medium, high, xhigh, and max. Reducing reasoning effort can result in faster responses and fewer tokens used on reasoning in a response. Not all reasoning models support every value. See the reasoning guide for model-specific support.

Salah satu dari yang berikut:
string
enum
noneminimallowmediumhighxhighmax
summary enum
autoconcisedetailed
context enum
autocurrent_turnall_turns
generate_summary enum
autoconcisedetailed
instructions string | OpenAI.InputItem[] | null diperlukan
Salah satu dari yang berikut:
string
OpenAI.InputItem[]
output_text string | null
usage OpenAI.ResponseUsage | null

Represents token usage details including input tokens, output tokens, a breakdown of output tokens, and the total tokens used.

input_tokens integer diperlukan
input_tokens_details OpenAI.ResponseUsageInputTokensDetails diperlukan
cached_tokens integer diperlukan
cache_write_tokens integer diperlukan
output_tokens integer diperlukan
output_tokens_details OpenAI.ResponseUsageOutputTokensDetails diperlukan
reasoning_tokens integer diperlukan
total_tokens integer diperlukan
prompt_cache_options OpenAI.PromptCacheOptions

The prompt-caching options that were applied to the response. Supported for gpt-5.6 and later models.

ttl enum diperlukan
30m
mode enum diperlukan
implicitexplicit
comparison_response_id string | null
prompt_cache_diagnostics cache_miss | cache_hit | comparison_response_not_found | unavailable

Prompt cache diagnostics requested for this response.

Salah satu dari berikut ini:
cache_miss OpenAI.PromptCacheMissDiagnosticsBody
type enum diperlukan
cache_miss
reason enum diperlukan
model_changedprompt_cache_key_changedtools_changedtext_format_changedreasoning_effort_changedverbosity_changedcontext_compactedinput_changedservice_tier_changed
cache_missed_tokens integer diperlukan
comparison_reusable_tokens integer
cache_hit OpenAI.PromptCacheHitDiagnosticsBody
type enum diperlukan
cache_hit
comparison_response_not_found OpenAI.PromptCacheComparisonResponseNotFoundDiagnosticsBody
type enum diperlukan
comparison_response_not_found
unavailable OpenAI.PromptCacheUnavailableDiagnosticsBody
type enum diperlukan
unavailable
moderation OpenAI.Moderation | null

Moderation results or errors for the response input and output.

input error | moderation_result diperlukan

Moderation results or an error for a response moderation check.

Salah satu dari berikut ini:
error OpenAI.ModerationErrorBody

An error produced while attempting moderation for the response input or output.

type enum diperlukan

The object type, which was always error for moderation failures.

error
code string diperlukan

The error code.

message string diperlukan

The error message.

moderation_result OpenAI.ModerationResultBody

A moderation result produced for the response input or output.

type enum diperlukan

The object type, which was always moderation_result for successful moderation results.

moderation_result
model string diperlukan

The moderation model that produced this result.

flagged boolean diperlukan

A boolean indicating whether the content was flagged by any category.

categories object diperlukan

A dictionary of moderation categories to booleans, True if the input is flagged under this category.

[key: string] boolean
category_scores object diperlukan

A dictionary of moderation categories to scores.

[key: string] number
category_applied_input_types object diperlukan

Which modalities of input are reflected by the score for each category.

[key: string] enum[]
output error | moderation_result diperlukan

Moderation results or an error for a response moderation check.

Salah satu dari berikut ini:
error OpenAI.ModerationErrorBody

An error produced while attempting moderation for the response input or output.

type enum diperlukan

The object type, which was always error for moderation failures.

error
code string diperlukan

The error code.

message string diperlukan

The error message.

moderation_result OpenAI.ModerationResultBody

A moderation result produced for the response input or output.

type enum diperlukan

The object type, which was always moderation_result for successful moderation results.

moderation_result
model string diperlukan

The moderation model that produced this result.

flagged boolean diperlukan

A boolean indicating whether the content was flagged by any category.

categories object diperlukan

A dictionary of moderation categories to booleans, True if the input is flagged under this category.

[key: string] boolean
category_scores object diperlukan

A dictionary of moderation categories to scores.

[key: string] number
category_applied_input_types object diperlukan

Which modalities of input are reflected by the score for each category.

[key: string] enum[]
parallel_tool_calls boolean diperlukan

Whether to allow the model to run tool calls in parallel.

conversation OpenAI.ResponseConversation | null

The conversation that this response belonged to. Input items and output items from this response were automatically added to this conversation.

id string diperlukan

The unique ID of the conversation that this response was associated with.

max_output_tokens integer | null
agent_reference AgentReference | null diperlukan

The agent used for this response

type enum diperlukan
agent_reference
name string diperlukan

The name of the agent.

version string

The version identifier of the agent.

model_selection_details ModelSelectionDetails

Model selection metadata providing visibility into routing decisions.

model_router_details ModelRouterDetails diperlukan

Routing decision metadata from Model Router.

mode string | enum diperlukan

The routing mode used by Model Router for the request.

Salah satu dari yang berikut:
string
enum
balancedcostquality
session_affinity SessionAffinityDetails

Effective Model Router session affinity metadata for a request.

mode string | enum diperlukan

Effective modes reported for Model Router session affinity.

Salah satu dari yang berikut:
string
enum
stickynone
source string | enum

Conversation identifier sources supported by Model Router session affinity.

Salah satu dari yang berikut:
string
enum
session_id_payloadsession_id_headernot_availableconversationprevious_response_id
decision string | enum

Final outcomes reported for Model Router session affinity.

Salah satu dari yang berikut:
string
enum
initializeretainswitch
routing_trace RoutingTraceEntry[] diperlukan

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.

content_filters ContentFilterResult[]

The content filter evaluation results.

Client error

Isi

Content-Type: application/json
error OpenAI.Error diperlukan
code string | null diperlukan
message string diperlukan
param string | null
type string
misalignment OpenAI.MisalignmentErrorDetailsResource
review_target string | null
error_type string | enum
Salah satu dari yang berikut:
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 diperlukan

The public continuation instruction.

details OpenAI.Error[]
additionalInfo object
debugInfo object

Server error

Isi

Content-Type: application/json
error OpenAI.Error diperlukan
code string | null diperlukan
message string diperlukan
param string | null
type string
misalignment OpenAI.MisalignmentErrorDetailsResource
review_target string | null
error_type string | enum
Salah satu dari yang berikut:
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 diperlukan

The public continuation instruction.

details OpenAI.Error[]
additionalInfo object
debugInfo object

Minta

curl -X POST https://api.openai.com/v1/responses/resp_123/cancel \
    -H "Content-Type: application/json" \
    -H "Authorization: Bearer $OPENAI_API_KEY"
import OpenAI from "openai";
const client = new OpenAI();

const response = await client.responses.cancel("resp_123");
console.log(response);
import os
from openai import OpenAI

client = OpenAI(
    api_key=os.environ.get("OPENAI_API_KEY"),  # This is the default and can be omitted
)
response = client.responses.cancel(
    "resp_677efb5139a88190b512bc3fef8e535d",
)
print(response.id)
import OpenAI from 'openai';

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

const response = await client.responses.cancel('resp_677efb5139a88190b512bc3fef8e535d');

console.log(response.id);
package main

import (
    "context"
    "fmt"

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

func main() {
    client := openai.NewClient(
        option.WithAPIKey("My API Key"),
    )
    response, err := client.Responses.Cancel(context.TODO(), "resp_677efb5139a88190b512bc3fef8e535d")
    if err != nil {
        panic(err.Error())
    }
    fmt.Printf("%+v
", response.ID)
}
package com.openai.example;

import com.openai.client.OpenAIClient;
import com.openai.client.okhttp.OpenAIOkHttpClient;
import com.openai.models.responses.Response;
import com.openai.models.responses.ResponseCancelParams;

public final class Main {
    private Main() {}

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

        Response response = client.responses().cancel("resp_677efb5139a88190b512bc3fef8e535d");
    }
}
require "openai"

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

response = openai.responses.cancel("resp_677efb5139a88190b512bc3fef8e535d")

puts(response)

Tanggapan

{
  "id": "resp_67cb71b351908190a308f3859487620d06981a8637e6bc44",
  "object": "response",
  "created_at": 1741386163,
  "status": "cancelled",
  "background": true,
  "completed_at": null,
  "error": null,
  "incomplete_details": null,
  "instructions": null,
  "max_output_tokens": null,
  "model": "gpt-4o-2024-08-06",
  "output": [
    {
      "type": "message",
      "id": "msg_67cb71b3c2b0819084d481baaaf148f206981a8637e6bc44",
      "status": "in_progress",
      "role": "assistant",
      "content": [
        {
          "type": "output_text",
          "text": "Silent circuits hum,
Thoughts emerge in data streams—
Digital dawn breaks.",
          "annotations": []
        }
      ]
    }
  ],
  "parallel_tool_calls": true,
  "previous_response_id": null,
  "reasoning": {
    "effort": null,
    "summary": null
  },
  "store": true,
  "temperature": 1.0,
  "text": {
    "format": {
      "type": "text"
    }
  },
  "tool_choice": "auto",
  "tools": [],
  "top_p": 1.0,
  "truncation": "disabled",
  "usage": null,
  "user": null,
  "metadata": {}
}
id-id
Pilihan Privasi Anda
  • Pengelakan AI
  • Versi Sebelumnya
  • Blog
  • Berikan kontribusi
  • Privasi
  • Privasi Kesehatan Konsumen
  • Persyaratan Penggunaan
  • Merek Dagang
  • © Microsoft 2026