メイン コンテンツにスキップ

このブラウザーはサポートされなくなりました。

Microsoft Edge にアップグレードすると、最新の機能、セキュリティ更新プログラム、およびテクニカル サポートを利用できます。

Microsoft Edge をダウンロードする Internet Explorer と 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.

パス パラメーター

response_id string 必須

The ID of the response to cancel.

ヘッダー パラメーター

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.

応答

The request has succeeded.

ヘッダー

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.

本文

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.

次のいずれか:
json_schema OpenAI.TextResponseFormatJsonSchema

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

type enum 必須

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 必須

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 必須

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 必須

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 必須

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
次のいずれか:
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
次のいずれか:
function OpenAI.ToolChoiceFunction

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

type enum 必須

For function calling, the type is always function.

function
name string 必須

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 必須

For MCP tools, the type is always mcp.

mcp
server_label string 必須

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 必須

Allowed tool configuration type. Always allowed_tools.

allowed_tools
mode enum 必須

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[] 必須

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 必須

For custom tool calling, the type is always custom.

custom
name string 必須

The name of the custom tool to call.

programmatic_tool_calling OpenAI.SpecificProgrammaticToolCallingParam
type enum 必須

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 必須

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 必須

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 必須
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 必須
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 必須
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 必須
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 必須
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 必須
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 必須
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 必須
computer_use
prompt OpenAI.Prompt

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

id string 必須

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
次のいずれか:
string
type enum 必須

The type of the input item. Always input_text.

input_text
text string 必須

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 必須

The breakpoint mode. Always explicit.

explicit
type enum 必須

The type of the input item. Always input_image.

input_image
image_url string | null
file_id string | null
detail enum 必須
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 必須

The breakpoint mode. Always explicit.

explicit
type enum 必須

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 必須

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 必須

Unique identifier for this Response.

object enum 必須

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 必須
cyber enum 必須
standarddaybreak_bluedaybreak_red
created_at integer 必須

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

completed_at integer | null
error OpenAI.ResponseError | null 必須

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 必須

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 必須

A human-readable description of the error.

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.

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

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
次のいずれか:
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.

次のいずれか:
string
enum
noneminimallowmediumhighxhighmax
summary enum
autoconcisedetailed
context enum
autocurrent_turnall_turns
generate_summary enum
autoconcisedetailed
instructions string | OpenAI.InputItem[] | null 必須
次のいずれか:
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 必須
input_tokens_details OpenAI.ResponseUsageInputTokensDetails 必須
cached_tokens integer 必須
cache_write_tokens integer 必須
output_tokens integer 必須
output_tokens_details OpenAI.ResponseUsageOutputTokensDetails 必須
reasoning_tokens integer 必須
total_tokens integer 必須
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 必須
30m
mode enum 必須
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.

次のいずれか:
cache_miss OpenAI.PromptCacheMissDiagnosticsBody
type enum 必須
cache_miss
reason enum 必須
model_changedprompt_cache_key_changedtools_changedtext_format_changedreasoning_effort_changedverbosity_changedcontext_compactedinput_changedservice_tier_changed
cache_missed_tokens integer 必須
comparison_reusable_tokens integer
cache_hit OpenAI.PromptCacheHitDiagnosticsBody
type enum 必須
cache_hit
comparison_response_not_found OpenAI.PromptCacheComparisonResponseNotFoundDiagnosticsBody
type enum 必須
comparison_response_not_found
unavailable OpenAI.PromptCacheUnavailableDiagnosticsBody
type enum 必須
unavailable
moderation OpenAI.Moderation | null

Moderation results or errors for the response input and output.

input error | moderation_result 必須

Moderation results or an error for a response moderation check.

次のいずれか:
error OpenAI.ModerationErrorBody

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

type enum 必須

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

error
code string 必須

The error code.

message string 必須

The error message.

moderation_result OpenAI.ModerationResultBody

A moderation result produced for the response input or output.

type enum 必須

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

moderation_result
model string 必須

The moderation model that produced this result.

flagged boolean 必須

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

categories object 必須

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

[key: string] boolean
category_scores object 必須

A dictionary of moderation categories to scores.

[key: string] number
category_applied_input_types object 必須

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

[key: string] enum[]
output error | moderation_result 必須

Moderation results or an error for a response moderation check.

次のいずれか:
error OpenAI.ModerationErrorBody

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

type enum 必須

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

error
code string 必須

The error code.

message string 必須

The error message.

moderation_result OpenAI.ModerationResultBody

A moderation result produced for the response input or output.

type enum 必須

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

moderation_result
model string 必須

The moderation model that produced this result.

flagged boolean 必須

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

categories object 必須

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

[key: string] boolean
category_scores object 必須

A dictionary of moderation categories to scores.

[key: string] number
category_applied_input_types object 必須

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

[key: string] enum[]
parallel_tool_calls boolean 必須

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 必須

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

max_output_tokens integer | null
agent_reference AgentReference | null 必須

The agent used for this response

type enum 必須
agent_reference
name string 必須

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 必須

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.

content_filters ContentFilterResult[]

The content filter evaluation results.

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/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)

回答

{
  "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": {}
}
ja-jp
プライバシーの選択
  • AI 免責事項
  • 以前のバージョン
  • ブログ
  • 投稿
  • プライバシー
  • コンシューマーの健康に関するプライバシー
  • 利用条件
  • 商標
  • © Microsoft 2026