TokenLab

파일 및 배치

파일 업로드

배치 파일, 이미지 참조 또는 Anthropic 형식의 파일을 업로드합니다.

POST
/v1/files

파일 용도 (File Purposes)

  • 배치 파일: /v1/batches에 대해 purpose=batch를 사용하세요.
  • 이미지/참조 파일: 파일 기반 이미지 요청을 위해 purpose=user_data 또는 purpose=vision을 사용하세요.
  • Anthropic 파일: anthropic-beta: files-api-2025-04-14 헤더를 추가하세요.

예시

요청

cURL
curl -X POST "https://api.tokenlab.sh/v1/files" \
  -H "Authorization: Bearer sk-your-api-key" \
  -F "purpose=batch" \
  -F "file=@batch-input.jsonl;type=application/jsonl"

이미지 파일 입력

이 동일한 /v1/files 경로를 사용하여 /v1/images/edits를 위한 이미지 참조 파일을 업로드할 수 있습니다.

  • purpose=user_data 또는 purpose=vision을 사용하세요.
  • 선택적으로 model을 포함하여 이미지 편집 모델을 선택할 수 있습니다. 기본값은 gpt-image-2입니다.
  • 반환된 file_id는 선택한 이미지 편집 구성에 바인딩되며 images[].file_id에서 재사용할 수 있습니다.

Anthropic Files API 모드

  • Anthropic Files를 사용하려면 anthropic-beta: files-api-2025-04-14를 추가하세요.
  • Anthropic 모드에서는 원본 파일을 직접 업로드하며 purpose=batch를 전송하지 마세요.
  • 반환된 file_id는 현재 워크스페이스에서만 사용할 수 있으며 /v1/messages 요청에서 재사용할 수 있습니다.
  • 업로드된 파일을 Anthropic 메시지 콘텐츠에서 참조하려는 경우, Anthropic 네이티브 헤더(x-api-key, anthropic-version 및 필요한 경우 베타 헤더)를 계속 사용하세요.

응답 예시

응답

200 OK
{
  "id": "file_abc123",
  "object": "file",
  "bytes": 32768,
  "created_at": 1706000000,
  "filename": "batch-input.jsonl",
  "purpose": "batch"
}

주요 필드

idstring
파일 ID입니다.
purposestring
파일에 할당된 용도입니다. 업로드 시 batch, user_data 또는 vision을 사용할 수 있습니다.
bytesinteger
바이트 단위의 파일 크기입니다.

인증

BearerAuth
AuthorizationBearer <token>

API 키 인증입니다. Dashboard > API > API Keys에서 API 키를 생성하거나 관리하십시오.

위치: header

헤더

anthropic-beta?string

Anthropic Files API 모드를 사용하려면 files-api-2025-04-14를 포함하십시오.

요청 본문

multipart/form-data

응답

application/json

application/json

application/json

application/json