下载文件内容
先调用「上传文件」,用返回的文件 ID 替换示例文件 ID。
GET
/anthropic/v1/files/{file_id}/content● 支持请求参数
file_idstring必填path:
返回
400
只有代码执行工具生成的文件可以下载;你自己上传的文件(用途为 user_data)下载会返回 400 invalid_request_error,这与 Anthropic 官方的行为一致。
错误按 Anthropic 格式返回,参见 错误码
请求示例
curl
# 先调用「上传文件」,用返回的文件 ID 替换示例文件 ID。
curl https://api.deepraxis.com/anthropic/v1/files/file_123/content \
-H "x-api-key: $PRAXIS_API_KEY" \
-H "anthropic-version: 2023-06-01"Python
# 先调用「上传文件」,用返回的文件 ID 替换示例文件 ID。
from anthropic import Anthropic
client = Anthropic(
base_url="https://api.deepraxis.com/anthropic",
api_key="$PRAXIS_API_KEY",
)
content = client.files.download("file_123")TypeScript
// 先调用「上传文件」,用返回的文件 ID 替换示例文件 ID。
import Anthropic from "@anthropic-ai/sdk";
const client = new Anthropic({
baseURL: "https://api.deepraxis.com/anthropic",
apiKey: "$PRAXIS_API_KEY",
});
const content = await client.files.download("file_123");响应示例 400
{
"type": "error",
"error": {
"type": "invalid_request_error",
"message": "Uploaded user_data files are not downloadable through the Anthropic Files API."
}
}响应
HTTP 200
Binary content
未声明响应体。