Delete a response

更新时间:
复制 MD 格式

Deletes a stored model response based on its response ID.

China (Beijing)

SDK call configuration base_url: https://dashscope.aliyuncs.com/compatible-mode/v1

HTTP request: DELETE https://dashscope.aliyuncs.com/compatible-mode/v1/responses/{response_id}

Path parameter

response_id string Required

Response ID to delete, in the format resp_xxx. Only responses created with store=true can be deleted.

Python

import os
from openai import OpenAI

client = OpenAI(
    # If not using an environment variable, pass the key directly: api_key="sk-xxx"
    api_key=os.getenv("DASHSCOPE_API_KEY"),
    base_url="https://dashscope.aliyuncs.com/compatible-mode/v1",
)

response = client.responses.delete("resp_xxx")
print(response)

Node.js

import OpenAI from "openai";

const openai = new OpenAI({
    // If not using an environment variable, pass the key directly: apiKey: "sk-xxx"
    apiKey: process.env.DASHSCOPE_API_KEY,
    baseURL: "https://dashscope.aliyuncs.com/compatible-mode/v1"
});

async function main() {
    const response = await openai.responses.del("resp_xxx");
    console.log(response);
}

main();

cURL

curl -X DELETE https://dashscope.aliyuncs.com/compatible-mode/v1/responses/resp_xxx \
  -H "Authorization: Bearer $DASHSCOPE_API_KEY"

Response

{
    "deleted": true,
    "id": "resp_4ca7fa5e-6ff5-9787-bc18-af6ca5eff36c"
}

id string

ID of the deleted response.

deleted boolean

true if deletion succeeded.

Error response

Returned when the specified response ID does not exist:

{
    "error": {
        "message": "Response with id 'resp_xxx' not found.",
        "type": "InvalidParameter"
    }
}