跳转到主要内容

Documentation Index

Fetch the complete documentation index at: https://docs.qoder.com/llms.txt

Use this file to discover all available pages before exploring further.

POST /v1/sessions/{session_id}/resources 为 Session 添加文件资源。添加后,Agent 在处理消息时可以访问这些文件。 此功能为 M3 门控特性,需要先通过 Files API 上传文件获取 file_id

请求头

头部必选说明
AuthorizationBearer <PAT>
Content-Typeapplication/json

路径参数

参数类型必选说明
session_idstringSession ID(sess_ 前缀)

请求体

字段类型必选说明
resourcesarray资源对象数组
resources[].typestring固定值 "file"
resources[].file_idstring文件 ID(通过 Files API 上传后获得)

示例请求

curl -X POST "https://openapi.qoder.sh/api/v1/cloud/sessions/sess_019e392c0d1e74e095d21ea4c6b41def/resources" \
  -H "Authorization: Bearer $QODER_PAT" \
  -H "Content-Type: application/json" \
  -d '{
    "resources": [
      {"type": "file", "file_id": "file_abc123def456"}
    ]
  }'

示例响应

HTTP 200 OK 返回更新后的 Session 对象(含新的 resources 列表)。

错误码

HTTPtype触发条件
400invalid_request_error请求格式错误(如 type 不为 "file" 或缺少 file_id
401authentication_errorPAT 无效或过期
404not_found_errorSession 或文件不存在
错误响应示例:
{
  "type": "error",
  "error": {
    "type": "invalid_request_error",
    "message": "resources[0]: field 'type' must be 'file'."
  }
}
{
  "type": "error",
  "error": {
    "type": "not_found_error",
    "message": "File 'file_fake_test_id' was not found."
  }
}
完整错误信封说明详见 错误参考