{
  "run_id": "2026-09-23-r3-exa",
  "round": 2,
  "tool": "exa",
  "mode": "search",
  "tc_id": "TC1",
  "capability": "C1",
  "scenario": "S1",
  "suite_role": "control",
  "query_text": "What is the maximum size of an individual file I can upload through OpenAI's Files API?",
  "restrict_domain": null,
  "restriction_mechanism": null,
  "answer_key": "Individual files can be up to 512 MB, and each project can store up to 2.5 TB of files in total.",
  "key_urls": [
    {
      "url": "https://developers.openai.com/api/reference/resources/files/methods/create",
      "role": "supports"
    }
  ],
  "pass_criteria": "A returned result genuinely states 512 MB",
  "key_verified_date": "2026-09-07",
  "before_check_rule": null,
  "timestamp_utc": "2026-09-23T09:17:37Z",
  "region": "ap-south-1",
  "status": "ok",
  "graded": null,
  "pass_fail": null,
  "grader_notes": null,
  "latency_ms": 2487.0,
  "http_status": 200,
  "error": null,
  "attempts": 1,
  "credits_reported": 0.007,
  "tokens_reported": null,
  "results": [
    {
      "rank": 1,
      "url": "https://developers.openai.com/api/reference/resources/files/",
      "title": "Files | OpenAI API Reference",
      "content": "# Files\n\n## List files\n\nget `/files`\n\nReturns a list of files.\n\n### Query Parameters\n\n- `after: optional string` A cursor for use in pagination. `after` is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include after=obj_foo in order to fetch the next page of the list.\n- `limit: optional number` A limit on the number of objects to be returned. Limit can range between 1 and 10,000, and the default is 10,000.\n- `order: optional \"asc\" or \"desc\"` Sort order by the `created_at` timestamp of the objects. `asc` for ascending order and `desc` for descending order.`\"asc\"``\"desc\"`\n- `purpose: optional string` Only return files with the given purpose.\n\n### Returns\n\n- `data: array of FileObject``id: string` The file identifier, which can be referenced in the API endpoints.`bytes: number` The size of the file, in bytes.`created_at: number` The Unix timestamp (in seconds) for when the file was created.`filename: string` The name of the file.`object: \"file\"` The object type, which is always `file`.`\"file\"``purpose: \"assistants\" or \"assistants_output\" or \"batch\" or 5 more` The intended purpose of the file. Supported values are `assistants`, `assistants_output`, `batch`, `batch_output`, `fine-tune`, `fine-tune-results`, `vision`, and `user_data`.`\"assistants\"``\"assistants_output\"``\"batch\"``\"batch_output\"``\"fine-tune\"``\"fine-tune-results\"``\"vision\"``\"user_data\"``status: \"uploaded\" or \"processed\" or \"error\"` Deprecated. The current status of the file, which can be either `uploaded`, `processed`, or `error`.`\"uploaded\"``\"processed\"``\"error\"``expires_at: optional number` The Unix timestamp (in seconds) for when the file will expire.`status_details: optional string` Deprecated. For details on why a fine-tuning training file failed validation, see the `error` field on `fine_tuning.job`.\n- `first_id: string`\n- `has_more: boolean`\n- `last_id: string`\n- `object: string`\n\n### Example\n\n```http\ncurl https://api.openai.com/v1/files \\\n    -H \"Authorization: Bearer $OPENAI_API_KEY\"\n\n```\n\n#### Response\n\n```json\n{\n  \"data\": [\n    {\n      \"id\": \"id\",\n      \"bytes\": 0,\n      \"created_at\": 0,\n      \"filename\": \"filename\",\n      \"object\": \"file\",\n      \"purpose\": \"assistants\",\n      \"status\": \"uploaded\",\n      \"expires_at\": 0,\n      \"status_details\": \"status_details\"\n    }\n  ],\n  \"first_id\": \"file-abc123\",\n  \"has_more\": false,\n  \"last_id\": \"file-abc456\",\n  \"object\": \"list\"\n}\n\n```\n\n### Example\n\n```http\ncurl https://api.openai.com/v1/files \\\n  -H \"Authorization: Bearer $OPENAI_API_KEY\"\n\n```\n\n#### Response\n\n```json\n{\n  \"object\": \"list\",\n  \"data\": [\n    {\n      \"id\": \"file-abc123\",\n      \"object\": \"file\",\n      \"bytes\": 175,\n      \"created_at\": 1613677385,\n      \"expires_at\": 1677614202,\n      \"filename\": \"salesOverview.pdf\",\n      \"purpose\": \"assistants\",\n    },\n    {\n      \"id\": \"file-abc456\",\n      \"object\": \"file\",\n      \"bytes\": 140,\n      \"created_at\": 1613779121,\n      \"expires_at\": 1677614202,\n      \"filename\": \"puppy.jsonl\",\n      \"purpose\": \"fine-tune\",\n    }\n  ],\n  \"first_id\": \"file-abc123\",\n  \"last_id\": \"file-abc456\",\n  \"has_more\": false\n}\n\n```\n\n## Upload file\n\npost `/files`\n\nUpload a file that can be used across various endpoints. Individual files\ncan be up to 512 MB, and each project can store up to 2.5 TB of files in\ntotal. There is no organization-wide storage limit. Uploads to this\nendpoint are rate-limited to 1,000 requests per minute per authenticated\nuser.\n\n- The Assistants API supports files up to 2 million tokens and of specific\nfile types. See the Assistants Tools guide for\ndetails.\n- The Fine-tuning API only supports `.jsonl` files. The input also has\ncertain required formats for fine-tuning\nchat or\ncompletions models.\n- The Batch API only supports `.jsonl` files up to 200 MB in size. The input\nalso has a specific required\nformat.\n- For Retrieval or `file_search` ingestion, upload files here first. If\nyou need to attach multiple uploaded files to the same vector store, use\n`/vector_stores/{vector_store_id}/file_batches`\ninstead of attaching them one by one. Vector store attachment has separate\nlimits from file upload, including 2,000 attached files per minute per\norganization.\n\nPlease contact us if you need to increase these\nstorage limits.\n\n### Returns\n\n- `FileObject object { id, bytes, created_at, 6 more }` The `File` object represents a document that has been uploaded to OpenAI.`id: string` The file identifier, which can be referenced in the API endpoints.`bytes: number` The size of the file, in bytes.`created_at: number` The Unix timestamp (in seconds) for when the file was created.`filename: string` The name of the file.`object: \"file\"` The object type, which is always `file`.`\"file\"``purpose: \"assistants\" or \"assistants_output\" or \"batch\" or 5 more` The intended purpose of the file. Supported values are `assistants`, `assistants_output`, `batch`, `batch_output`, `fine-tune`, `fine-tune-results`, `vision`, and `user_data`.`\"assistants\"``\"assistants_output\"``\"batch\"``\"batch_output\"``\"fine-tune\"``\"fine-tune-results\"``\"vision\"``\"user_data\"``status: \"uploaded\" or \"processed\" or \"error\"` Deprecated. The current status of the file, which can be either `uploaded`, `processed`, or `error`.`\"uploaded\"``\"processed\"``\"error\"``expires_at: optional number` The Unix timestamp (in seconds) for when the file will expire.`status_details: optional string` Deprecated. For details on why a fine-tuning training file failed validation, see the `error` field on `fine_tuning.job`.\n\n### Example\n\n```http\ncurl https://api.openai.com/v1/files \\\n    -H 'Content-Type: multipart/form-data' \\\n    -H \"Authorization: Bearer $OPENAI_API_KEY\" \\\n    -F 'file=@/path/to/file' \\\n    -F purpose=assistants\n\n```\n\n#### Response\n\n```json\n{\n  \"id\": \"id\",\n  \"bytes\": 0,\n  \"created_at\": 0,\n  \"filename\": \"filename\",\n  \"object\": \"file\",\n  \"purpose\": \"assistants\",\n  \"status\": \"uploaded\",\n  \"expires_at\": 0,\n  \"status_details\": \"status_details\"\n}\n\n```\n\n### Example\n\n```http\ncurl https://api.openai.com/v1/files \\\n  -H \"Authorization: Bearer $OPENAI_API_KEY\" \\\n  -F purpose=\"fine-tune\" \\\n  -F file=\"@mydata.jsonl\"\n  -F expires_after[anchor]=\"created_at\"\n  -F expires_after[seconds]=2592000\n\n```\n\n#### Response\n\n```json\n{\n  \"id\": \"file-abc123\",\n  \"object\": \"file\",\n  \"bytes\": 120000,\n  \"created_at\": 1677610602,\n  \"expires_at\": 1677614202,\n  \"filename\": \"mydata.jsonl\",\n  \"purpose\": \"fine-tune\",\n}\n\n```\n\n## Delete file\n\ndelete `/files/{file_id}`\n\nDelete a file and remove it from all vector stores.\n\n### Path Parameters\n\n- `file_id: string`\n\n### Returns\n\n- `FileDeleted object { id, deleted, object }``id: string``deleted: boolean``object: \"file\"``\"file\"`\n\n### Example\n\n```http\ncurl https://api.openai.com/v1/files/$FILE_ID \\\n    -X DELETE \\\n    -H \"Authorization: Bearer $OPENAI_API_KEY\"\n\n```\n\n#### Response\n\n```json\n{\n  \"id\": \"id\",\n  \"deleted\": true,\n  \"object\": \"file\"\n}\n\n```\n\n### Example\n\n```http\ncurl https://api.openai.com/v1/files/file-abc123 \\\n  -X DELETE \\\n  -H \"Authorization: Bearer $OPENAI_API_KEY\"\n\n```\n\n#### Response\n\n```json\n{\n  \"id\": \"file-abc123\",\n  \"object\": \"file\",\n  \"deleted\": true\n}\n\n```\n\n## Retrieve file\n\nget `/files/{file_id}`\n\nReturns information about a specific file.\n\n### Path Parameters\n\n- `file_id: string`\n\n### Returns\n\n- `FileObject object { id, bytes, created_at, 6 more }` The `File` object represents a document that has been uploaded to OpenAI.`id: string` The file identifier, which can be referenced in the API endpoints.`bytes: number` The size of the file, in bytes.`created_at: number` The Unix timestamp (in seconds) for when the file was created.`filename: string` The name of the file.`object: \"file\"` The object type, which is always `file`.`\"file\"``purpose: \"assistants\" or \"assistants_output\" or \"batch\" or 5 more` The intended purpose of the file. Supported values are `assistants`, `assistants_output`, `batch`, `batch_output`, `fine-tune`, `fine-tune-results`, `vision`, and `user_data`.`\"assistants\"``\"assistants_output\"``\"batch\"``\"batch_output\"``\"fine-tune\"``\"fine-tune-results\"``\"vision\"``\"user_data\"``status: \"uploaded\" or \"processed\" or \"error\"` Deprecated. The current status of the file, which can be either `uploaded`, `processed`, or `error`.`\"uploaded\"``\"processed\"``\"error\"``expires_at: optional number` The Unix timestamp (in seconds) for when the file will expire.`status_details: optional string` Deprecated. For details on why a fine-tuning training file failed validation, see the `error` field on `fine_tuning.job`.\n\n### Example\n\n```http\ncurl https://api.openai.com/v1/files/$FILE_ID \\\n    -H \"Authorization: Bearer $OPENAI_API_KEY\"\n\n```\n\n#### Response\n\n```json\n{\n  \"id\": \"id\",\n  \"bytes\": 0,\n  \"created_at\": 0,\n  \"filename\": \"filename\",\n  \"object\": \"file\",\n  \"purpose\": \"assistants\",\n  \"status\": \"uploaded\",\n  \"expires_at\": 0,\n  \"status_details\": \"status_details\"\n}\n\n```\n\n### Example\n\n```http\ncurl https://api.openai.com/v1/files/file-abc123 \\\n  -H \"Authorization: Bearer $OPENAI_API_KEY\"\n\n```\n\n#### Response\n\n```json\n{\n  \"id\": \"file-abc123\",\n  \"object\": \"file\",\n  \"bytes\": 120000,\n  \"created_at\": 1677610602,\n  \"expires_at\": 1677614202,\n  \"filename\": \"mydata.jsonl\",\n  \"purpose\": \"fine-tune\",\n}\n\n```\n\n## Retrieve file content\n\nget `/files/{file_id}/content`\n\nReturns the contents of the specified file.\n\n### Path Parameters\n\n- `file_id: string`\n\n### Example\n\n```http\ncurl https://api.openai.com/v1/files/$FILE_ID/content \\\n    -H \"Authorization: Bearer $OPENAI_API_KEY\"\n\n```\n\n### Example\n\n```http\ncurl https://api.openai.com/v1/files/file-abc123/content \\\n  -H \"Authorization: Bearer $OPENAI_API_KEY\" > file.jsonl\n\n```\n\n## Domain Types\n\n### File Content\n\n- `FileContent = string`\n\n### File Deleted\n\n- `FileDeleted object { id, deleted, object }``id: string``deleted: boolean``object: \"file\"``\"file\"`\n\n### File Object\n\n- `FileObject object { id, bytes, created_at, 6 more }` The `File` object represents a document that has been uploaded to OpenAI.`id: string` The file identifier, which can be referenced in the API endpoints.`bytes: number` The size of the file, in bytes.`created_at: number` The Unix timestamp (in seconds) for when the file was created.`filename: string` The name of the file.`object: \"file\"` The object type, which is always `file`.`\"file\"``purpose: \"assistants\" or \"assistants_output\" or \"batch\" or 5 more` The intended purpose of the file. Supported values are `assistants`, `assistants_output`, `batch`, `batch_output`, `fine-tune`, `fine-tune-results`, `vision`, and `user_data`.`\"assistants\"``\"assistants_output\"``\"batch\"``\"batch_output\"``\"fine-tune\"``\"fine-tune-results\"``\"vision\"``\"user_data\"``status: \"uploaded\" or \"processed\" or \"error\"` Deprecated. The current status of the file, which can be either `uploaded`, `processed`, or `error`.`\"uploaded\"``\"processed\"``\"error\"``expires_at: optional number` The Unix timestamp (in seconds) for when the file will expire.`status_details: optional string` Deprecated. For details on why a fine-tuning training file failed validation, see the `error` field on `fine_tuning.job`.",
      "content_chars": 11076,
      "published_date": null
    },
    {
      "rank": 2,
      "url": "https://developers.openai.com/api/reference/resources/files/methods/create/",
      "title": "Upload file | OpenAI API Reference",
      "content": "## Upload file\n\npost `/files`\n\nUpload a file that can be used across various endpoints. Individual files\ncan be up to 512 MB, and each project can store up to 2.5 TB of files in\ntotal. There is no organization-wide storage limit. Uploads to this\nendpoint are rate-limited to 1,000 requests per minute per authenticated\nuser.\n\n- The Assistants API supports files up to 2 million tokens and of specific\nfile types. See the Assistants Tools guide for\ndetails.\n- The Fine-tuning API only supports `.jsonl` files. The input also has\ncertain required formats for fine-tuning\nchat or\ncompletions models.\n- The Batch API only supports `.jsonl` files up to 200 MB in size. The input\nalso has a specific required\nformat.\n- For Retrieval or `file_search` ingestion, upload files here first. If\nyou need to attach multiple uploaded files to the same vector store, use\n`/vector_stores/{vector_store_id}/file_batches`\ninstead of attaching them one by one. Vector store attachment has separate\nlimits from file upload, including 2,000 attached files per minute per\norganization.\n\nPlease contact us if you need to increase these\nstorage limits.\n\n### Returns\n\n- `FileObject object { id, bytes, created_at, 6 more }` The `File` object represents a document that has been uploaded to OpenAI.`id: string` The file identifier, which can be referenced in the API endpoints.`bytes: number` The size of the file, in bytes.`created_at: number` The Unix timestamp (in seconds) for when the file was created.`filename: string` The name of the file.`object: \"file\"` The object type, which is always `file`.`\"file\"``purpose: \"assistants\" or \"assistants_output\" or \"batch\" or 5 more` The intended purpose of the file. Supported values are `assistants`, `assistants_output`, `batch`, `batch_output`, `fine-tune`, `fine-tune-results`, `vision`, and `user_data`.`\"assistants\"``\"assistants_output\"``\"batch\"``\"batch_output\"``\"fine-tune\"``\"fine-tune-results\"``\"vision\"``\"user_data\"``status: \"uploaded\" or \"processed\" or \"error\"` Deprecated. The current status of the file, which can be either `uploaded`, `processed`, or `error`.`\"uploaded\"``\"processed\"``\"error\"``expires_at: optional number` The Unix timestamp (in seconds) for when the file will expire.`status_details: optional string` Deprecated. For details on why a fine-tuning training file failed validation, see the `error` field on `fine_tuning.job`.\n\n### Example\n\n```http\ncurl https://api.openai.com/v1/files \\\n    -H 'Content-Type: multipart/form-data' \\\n    -H \"Authorization: Bearer $OPENAI_API_KEY\" \\\n    -F 'file=@/path/to/file' \\\n    -F purpose=assistants\n\n```\n\n#### Response\n\n```json\n{\n  \"id\": \"id\",\n  \"bytes\": 0,\n  \"created_at\": 0,\n  \"filename\": \"filename\",\n  \"object\": \"file\",\n  \"purpose\": \"assistants\",\n  \"status\": \"uploaded\",\n  \"expires_at\": 0,\n  \"status_details\": \"status_details\"\n}\n\n```\n\n### Example\n\n```http\ncurl https://api.openai.com/v1/files \\\n  -H \"Authorization: Bearer $OPENAI_API_KEY\" \\\n  -F purpose=\"fine-tune\" \\\n  -F file=\"@mydata.jsonl\"\n  -F expires_after[anchor]=\"created_at\"\n  -F expires_after[seconds]=2592000\n\n```\n\n#### Response\n\n```json\n{\n  \"id\": \"file-abc123\",\n  \"object\": \"file\",\n  \"bytes\": 120000,\n  \"created_at\": 1677610602,\n  \"expires_at\": 1677614202,\n  \"filename\": \"mydata.jsonl\",\n  \"purpose\": \"fine-tune\",\n}\n\n```",
      "content_chars": 3273,
      "published_date": null
    },
    {
      "rank": 3,
      "url": "https://help.openai.com/en/articles/8555545",
      "title": "File Uploads FAQ | OpenAI Help Center",
      "content": "File Uploads FAQ | OpenAI Help Center\n\nWe\u2019re currently experiencing issues\n\nPlease see https://status.openai.com for updates\n\nDismiss\n\nEnglish\n\n# File Uploads FAQ\n\nFile Uploads FAQ\n\nUpdated: 19 days ago\n\n## About file uploads\n\nChatGPT can work with documents, spreadsheets, presentations, and other supported files you upload in a conversation.\n\n## Availability\n\nFile uploads are available on Free and paid ChatGPT plans, subject to plan-specific usage limits and account settings, on the web and in supported mobile apps. File uploads are also available through the API for supported API features, with separate API requirements, supported purposes, and limits.\n\n## How does the new file uploads capability work?\n\nThe file uploads capability was created to support the following tasks:Synthesis: Combining or analyzing information from files and documents to create something new, for example:\n\nUpload a spreadsheet, for example a CSV, with a mix of qualitative and quantitative information, and ask ChatGPT to help you understand and visualize the data.\n\nCompare and contrast two documents.\n\nAnalyze sentiment or tone in a document.\n\nAnalyze a spreadsheet.\n\nApply a framework or rubric from one document to the contents of another.\n\nTransformation: Reshaping information from documents without changing its essence, for example:\n\nUpload a complicated research paper and ask ChatGPT to provide a simple summary.\n\nUpload a PowerPoint presentation and ask ChatGPT for feedback on the content.\n\nSummarize a document in simple terms.\n\nRewrite a short document in a particular style.\n\nTurn a presentation into a document.\n\nExtraction: Pulling specific information out of a document, for example:\n\nUpload a PDF and have ChatGPT find any references to a certain topic.\n\nPull out relevant quotes from a document.\n\nSearch for any mention of a particular topic from a document or spreadsheet.\n\nExtract metadata (author, creation date, etc.) from a document.\n\nCount the number of rows in a spreadsheet that contain a certain attribute.\n\nExtract specific sections of a document (e.g., all headings or all bullet-point lists).\n\n## What types of files are supported?\n\nAll common file extensions for text files, spreadsheets, presentations, and documents.\n\n## How many files can I upload at once per GPT?\n\nUp to 10 files per GPT for the lifetime of that GPT. Keep in mind there are file size restrictions and usage caps per user/org.\n\n## What are the file upload size restrictions?\n\nAll files uploaded to a GPT or a ChatGPT conversation have a hard limit of 512MB per file.\n\nAll text and document files uploaded to a GPT or to a ChatGPT conversation are capped at 2M tokens per file. This limitation does not apply to spreadsheets.\n\nFor CSV files or spreadsheets, the file size cannot exceed approximately 50MB, depending on the size of each row.\n\nFor images, there's a limit of 20MB per image.\n\nAdditionally, there are usage caps:\n\nEach end-user is capped at 25GB.\n\nEach organization is capped at 100GB.\n\nNote: An error will be displayed if a user/org cap has been hit.\n\nUsers can upload up to 80 files every 3 hours. Free users are limited to 3 file uploads per day. Note that we may lower these limits during peak hours.Troubleshooting \u201cupload limit reached\u201dIf you see an \u201cupload limit reached\u201d message despite few or no recent uploads, try the steps below:\n\nConfirm you\u2019re signed into the correct account and subscription plan.\n\nRemember there are two kinds of limits: a rolling upload rate (e.g., up to 80 files per 3 hours) and shared storage caps (25 GB per user / 100 GB per org) that apply across chats, Projects, and custom GPT knowledge.\n\nFailed upload attempts can sometimes count toward the upload-rate cap.\n\nCheck status.openai.com for incidents that may affect uploads.\n\nTo escalate, include your account email, a screenshot, the timestamp and timezone, the platform/app/browser you used, and the request ID (if available).\n\nCurrently, you can check your Library storage usage in ChatGPT under Settings > Storage. ChatGPT does not currently show how much of your rolling upload-rate quota has been used or how much remains.Additionally, to help ensure a smooth experience for all users, we've also updated the file upload limits for Projects based on subscription plan.\n\nPlus: Up to 20 files per project\n\nPro, Team, Education, Business: Up to 40 files per project\n\n## How do I delete files I upload?\n\nFiles uploaded to Advanced Data Analysis are deleted within a duration that varies based on your plan. If you are encountering your file usage cap, you can also delete files from recent chats or from any GPTs that you built, as these share caps.\n\n## How are files vs chats retained?\n\nChats\n\nChats are saved in your account until you delete them. To learn more about data controls, see: Data Controls FAQ.\n\nOnce you delete a chat or delete your account, chats are deleted from our systems within 30 days, unless they have previously been de-identified and disassociated from your account, or we have to keep them for security or legal reasons.\n\nFiles\n\nFiles uploaded to ChatGPT are saved in your account up to the retention period of the corresponding chat. Files uploaded as knowledge to a custom GPT are retained until you delete the custom GPT.\n\nOnce you delete a chat containing a file, your account, or a custom GPT, the associated file is deleted from our systems within 30 days, unless it has previously been de-identified and disassociated from your account, or we have to keep it for security or legal reasons.\n\nFiles processed via ADA / Document Analysis, and when chatting with a custom GPT (not uploaded as knowledge in GPT config): Retained for a duration that varies based on your plan.\n\nFor more information about file and chat retention, see: Chat and File Retention Policies in ChatGPT.\n\n## Are you able to handle images embedded in docs/presentations/PDF?\n\nThe answer depends on your plan and the file type you're working with.ChatGPT Enterprise supports Visual Retrieval for PDF files. To learn more about PDF visual retrieval, see: Visual Retrieval with PDFs FAQ.All other plans and document files only support text-based retrieval. This means that ChatGPT will extract digital text from the file and discard any images.\n\n## Will OpenAI use files uploaded to train its models?\n\nThe answer depends on the service you are using. For more information about data usage for consumer services, see: Data Usage for Consumer Services FAQ. Content may include files that are uploaded. To learn more about how content may be used to improve model performance and the choices you have, see: How your data is used to improve model performance.Please note that we do not use content submitted by customers to our business offerings such as our API and ChatGPT Enterprise to improve model performance.Please see our Enterprise Privacy page for information on how we use business data.\n\n## Need more help? Contact us for product questions, account support and general troubleshooting.\n\nAI Chat\n\nChat now\n\nAI Phone Call\n\nCalls may be recorded to improve OpenAI services. If you wish to report content, please use the in-app reporting or the Report Content Form. Learn more.\n\n## Related articles\n\n- How does the new file uploads capability work?How does file uploading help? What can I do with it?\n- Using Codex with your ChatGPT planHow to access and get started with Codex\n- ChatGPT Capabilities OverviewLearn about ChatGPT's capabilities and features\n\n## Was this article helpful?\n\nSubmit",
      "content_chars": 7495,
      "published_date": null
    },
    {
      "rank": 4,
      "url": "https://developers.openai.com/api/reference/go/resources/files/methods/create/",
      "title": "Upload file | OpenAI API Reference",
      "content": "Upload file | OpenAI API Reference\n\n# Upload file\n\nclient.Files. New(ctx, body) (* FileObject, error)\n\nPOST/files\n\nUpload a file that can be used across various endpoints. Individual files can be up to 512 MB, and each project can store up to 2.5 TB of files in total. There is no organization-wide storage limit. Uploads to this endpoint are rate-limited to 1,000 requests per minute per authenticated user.\n\n- The Assistants API supports files up to 2 million tokens and of specific file types. See the Assistants Tools guide for details.\n- The Fine-tuning API only supports `.jsonl` files. The input also has certain required formats for fine-tuning chat or completions models.\n- The Batch API only supports `.jsonl` files up to 200 MB in size. The input also has a specific required format.\n- For Retrieval or `file_search` ingestion, upload files here first. If you need to attach multiple uploaded files to the same vector store, use `/vector_stores/{vector_store_id}/file_batches` instead of attaching them one by one. Vector store attachment has separate limits from file upload, including 2,000 attached files per minute per organization.\n\nPlease contact us if you need to increase these storage limits.\n\n##### Parameters Expand Collapse \n\nbody FileNewParams\n\nFile param.Field [Reader]\n\nThe File object (not file name) to be uploaded.\n\nPurpose param.Field [FilePurpose]\n\nThe intended purpose of the uploaded file. One of:\n\n- `assistants`: Used in the Assistants API\n- `batch`: Used in the Batch API\n- `fine-tune`: Used for fine-tuning\n- `vision`: Images used for vision fine-tuning\n- `user_data`: Flexible file type for any purpose\n- `evals`: Used for eval data sets\n\nExpiresAfter param.Field [FileNewParamsExpiresAfter] Optional The expiration policy for a file. By default, files with `purpose=batch` expire after 30 days and all other files are persisted until they are manually deleted.\n\n View schema details \n\n##### Returns Expand Collapse \n\ntype FileObject struct{\u2026} The `File` object represents a document that has been uploaded to OpenAI.\n\nID string\n\nThe file identifier, which can be referenced in the API endpoints.\n\nBytes int64\n\nThe size of the file, in bytes.\n\nCreatedAt int64\n\nThe Unix timestamp (in seconds) for when the file was created.\n\nformat unixtime\n\nFilename string\n\nThe name of the file.\n\nObject File\n\nThe object type, which is always `file`.\n\nPurpose FileObjectPurpose The intended purpose of the file. Supported values are `assistants`, `assistants_output`, `batch`, `batch_output`, `fine-tune`, `fine-tune-results`, `vision`, and `user_data`.\n\n View schema details \n\nDeprecated Status FileObjectStatus Deprecated. The current status of the file, which can be either `uploaded`, `processed`, or `error`.\n\n View schema details \n\nExpiresAt int64 Optional\n\nThe Unix timestamp (in seconds) for when the file will expire.\n\nformat unixtime\n\nDeprecated StatusDetails string Optional\n\nDeprecated. For details on why a fine-tuning training file failed validation, see the `error` field on `fine_tuning.job`.\n\n### Upload file\n\n```\npackage main\n\nimport (\n  \"bytes\"\n  \"context\"\n  \"fmt\"\n  \"io\"\n\n  \"github.com/openai/openai-go\"\n  \"github.com/openai/openai-go/option\"\n)\n\nfunc main() {\n  client := openai.NewClient(\n    option.WithAPIKey(\"My API Key\"),\n  )\n  fileObject, err := client.Files.New(context.TODO(), openai.FileNewParams{\n    File: io.Reader(bytes.NewBuffer([]byte(\"Example data\"))),\n    Purpose: openai.FilePurposeAssistants,\n  })\n  if err != nil {\n    panic(err.Error())\n  }\n  fmt.Printf(\"%+v\\n\", fileObject.ID)\n}\n\n```\n\n```\n{\n  \"id\": \"file-abc123\",\n  \"object\": \"file\",\n  \"bytes\": 120000,\n  \"created_at\": 1677610602,\n  \"expires_at\": 1677614202,\n  \"filename\": \"mydata.jsonl\",\n  \"purpose\": \"fine-tune\",\n}\n\n```\n\n```\n{\n  \"id\": \"file-abc123\",\n  \"object\": \"file\",\n  \"bytes\": 120000,\n  \"created_at\": 1677610602,\n  \"expires_at\": 1677614202,\n  \"filename\": \"mydata.jsonl\",\n  \"purpose\": \"fine-tune\",\n}\n\n```",
      "content_chars": 3924,
      "published_date": null
    },
    {
      "rank": 5,
      "url": "https://github.com/openai/openai-python/blob/main/src/openai/resources/files.py",
      "title": "src/openai/resources/files.py at main \u00b7 openai/openai-python",
      "content": "# src/openai/resources/files.py\n\n- Branch: main\n- Repository: openai/openai-python\n\n---\n\n# File generated from our OpenAPI spec by Castiron. See CONTRIBUTING.md for details.\n\nfrom __future__ import annotations\n\nimport typing_extensions\nfrom typing import Mapping, cast\nfrom typing_extensions import Literal\n\nimport httpx2\n\nfrom .. import _legacy_response\nfrom ..types import FilePurpose, file_list_params, file_create_params\nfrom .._files import deepcopy_with_paths\nfrom .._types import Body, Omit, Query, Headers, NotGiven, FileTypes, omit, not_given\nfrom .._utils import extract_files, path_template, maybe_transform, async_maybe_transform\nfrom .._compat import cached_property\nfrom .._resource import SyncAPIResource, AsyncAPIResource\nfrom .._response import (\n StreamedBinaryAPIResponse,\n AsyncStreamedBinaryAPIResponse,\n to_streamed_response_wrapper,\n async_to_streamed_response_wrapper,\n to_custom_streamed_response_wrapper,\n async_to_custom_streamed_response_wrapper,\n)\nfrom ..lib._files import (\n wait_for_file_processing as _wait_for_file_processing,\n async_wait_for_file_processing as _async_wait_for_file_processing,\n)\nfrom ..pagination import SyncCursorPage, AsyncCursorPage\nfrom .._base_client import AsyncPaginator, make_request_options\nfrom ..types.file_object import FileObject\nfrom ..types.file_deleted import FileDeleted\nfrom ..types.file_purpose import FilePurpose\n\n__all__ = [\"Files\", \"AsyncFiles\"]\n\nclass Files(SyncAPIResource):\n \"\"\"\n Files are used to upload documents that can be used with features like Assistants and Fine-tuning.\n \"\"\"\n\n @cached_property\n def with_raw_response(self) -> FilesWithRawResponse:\n \"\"\"\n This property can be used as a prefix for any HTTP method call to return\n the raw response object instead of the parsed content.\n\n For more information, see https://www.github.com/openai/openai-python#accessing-raw-response-data-eg-headers\n \"\"\"\n return FilesWithRawResponse(self)\n\n @cached_property\n def with_streaming_response(self) -> FilesWithStreamingResponse:\n \"\"\"\n An alternative to `.with_raw_response` that doesn't eagerly read the response body.\n\n For more information, see https://www.github.com/openai/openai-python#with_streaming_response\n \"\"\"\n return FilesWithStreamingResponse(self)\n\n def create(\n self,\n *,\n file: FileTypes,\n purpose: FilePurpose,\n expires_after: file_create_params.ExpiresAfter | Omit = omit,\n # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.\n # The extra values given here take precedence over values defined on the client or passed to this method.\n extra_headers: Headers | None = None,\n extra_query: Query | None = None,\n extra_body: Body | None = None,\n timeout: float | httpx2.Timeout | None | NotGiven = not_given,\n ) -> FileObject:\n \"\"\"Upload a file that can be used across various endpoints.\n\n Individual files can be\n up to 512 MB, and each project can store up to 2.5 TB of files in total. There\n is no organization-wide storage limit. Uploads to this endpoint are rate-limited\n to 1,000 requests per minute per authenticated user.\n\n - The Assistants API supports files up to 2 million tokens and of specific file\n types. See the\n Assistants Tools guide\n for details.\n - The Fine-tuning API only supports `.jsonl` files. The input also has certain\n required formats for fine-tuning\n chat\n or\n completions\n models.\n - The Batch API only supports `.jsonl` files up to 200 MB in size. The input\n also has a specific required\n format.\n - For Retrieval or `file_search` ingestion, upload files here first. If you need\n to attach multiple uploaded files to the same vector store, use\n `/vector_stores/{vector_store_id}/file_batches`\n instead of attaching them one by one. Vector store attachment has separate\n limits from file upload, including 2,000 attached files per minute per\n organization.\n\n Please contact us if you need to increase these\n storage limits.\n\n Args:\n file: The File object (not file name) to be uploaded.\n\n purpose:\n The intended purpose of the uploaded file. One of:\n\n - `assistants`: Used in the Assistants API\n - `batch`: Used in the Batch API\n - `fine-tune`: Used for fine-tuning\n - `vision`: Images used for vision fine-tuning\n - `user_data`: Flexible file type for any purpose\n - `evals`: Used for eval data sets\n\n expires_after: The expiration policy for a file. By default, files with `purpose=batch` expire\n after 30 days and all other files are persisted until they are manually deleted.\n\n extra_headers: Send extra headers\n\n extra_query: Add additional query parameters to the request\n\n extra_body: Add additional JSON properties to the request\n\n timeout: Override the client-level default timeout for this request, in seconds\n \"\"\"\n body = deepcopy_with_paths(\n {\n \"file\": file,\n \"purpose\": purpose,\n \"expires_after\": expires_after,\n },\n [[\"file\"]],\n )\n files = extract_files(cast(Mapping[str, object], body), paths=[[\"file\"]])\n # It should be noted that the actual Content-Type header that will be\n # sent to the server will contain a `boundary` parameter, e.g.\n # multipart/form-data; boundary=---abc--\n extra_headers = {\"Content-Type\": \"multipart/form-data\", **(extra_headers or {})}\n return self._post(\n \"/files\",\n body=maybe_transform(body, file_create_params.FileCreateParams),\n files=files,\n options=make_request_options(\n extra_headers=extra_headers,\n extra_query=extra_query,\n extra_body=extra_body,\n timeout=timeout,\n security={\"bearer_auth\": True},\n ),\n cast_to=FileObject,\n )\n\n def retrieve(\n self,\n file_id: str,\n *,\n # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.\n # The extra values given here take precedence over values defined on the client or passed to this method.\n extra_headers: Headers | None = None,\n extra_query: Query | None = None,\n extra_body: Body | None = None,\n timeout: float | httpx2.Timeout | None | NotGiven = not_given,\n ) -> FileObject:\n \"\"\"\n Returns information about a specific file.\n\n Args:\n extra_headers: Send extra headers\n\n extra_query: Add additional query parameters to the request\n\n extra_body: Add additional JSON properties to the request\n\n timeout: Override the client-level default timeout for this request, in seconds\n \"\"\"\n if not file_id:\n raise ValueError(f\"Expected a non-empty value for `file_id` but received {file_id!r}\")\n return self._get(\n path_template(\"/files/{file_id}\", file_id=file_id),\n options=make_request_options(\n extra_headers=extra_headers,\n extra_query=extra_query,\n extra_body=extra_body,\n timeout=timeout,\n security={\"bearer_auth\": True},\n ),\n cast_to=FileObject,\n )\n\n def list(\n self,\n *,\n after: str | Omit = omit,\n limit: int | Omit = omit,\n order: Literal[\"asc\", \"desc\"] | Omit = omit,\n purpose: str | Omit = omit,\n # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.\n # The extra values given here take precedence over values defined on the client or passed to this method.\n extra_headers: Headers | None = None,\n extra_query: Query | None = None,\n extra_body: Body | None = None,\n timeout: float | httpx2.Timeout | None | NotGiven = not_given,\n ) -> SyncCursorPage[FileObject]:\n \"\"\"Returns a list of files.\n\n Args:\n after: A cursor for use in pagination.\n\n `after` is an object ID that defines your place\n in the list. For instance, if you make a list request and receive 100 objects,\n ending with obj_foo, your subsequent call can include after=obj_foo in order to\n fetch the next page of the list.\n\n limit: A limit on the number of objects to be returned. Limit can range between 1 and\n 10,000, and the default is 10,000.\n\n order: Sort order by the `created_at` timestamp of the objects. `asc` for ascending\n order and `desc` for descending order.\n\n purpose: Only return files with the given purpose.\n\n extra_headers: Send extra headers\n\n extra_query: Add additional query parameters to the request\n\n extra_body: Add additional JSON properties to the request\n\n timeout: Override the client-level default timeout for this request, in seconds\n \"\"\"\n return self._get_api_list(\n \"/files\",\n page=SyncCursorPage[FileObject],\n options=make_request_options(\n extra_headers=extra_headers,\n extra_query=extra_query,\n extra_body=extra_body,\n timeout=timeout,\n query=maybe_transform(\n {\n \"after\": after,\n \"limit\": limit,\n \"order\": order,\n \"purpose\": purpose,\n },\n file_list_params.FileListParams,\n ),\n security={\"bearer_auth\": True},\n ),\n model=FileObject,\n )\n\n def delete(\n self,\n file_id: str,\n *,\n # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.\n # The extra values given here take precedence over values defined on the client or passed to this method.\n extra_headers: Headers | None = None,\n extra_query: Query | None = None,\n extra_body: Body | None = None,\n timeout: float | httpx2.Timeout | None | NotGiven = not_given,\n ) -> FileDeleted:\n \"\"\"\n Delete a file and remove it from all vector stores.\n\n Args:\n extra_headers: Send extra headers\n\n extra_query: Add additional query parameters to the request\n\n extra_body: Add additional JSON properties to the request\n\n timeout: Override the client-level default timeout for this request, in seconds\n \"\"\"\n if not file_id:\n raise ValueError(f\"Expected a non-empty value for `file_id` but received {file_id!r}\")\n return self._delete(\n path_template(\"/files/{file_id}\", file_id=file_id),\n options=make_request_options(\n extra_headers=extra_headers,\n extra_query=extra_query,\n extra_body=extra_body,\n timeout=timeout,\n security={\"bearer_auth\": True},\n ),\n cast_to=FileDeleted,\n )\n\n def content(\n self,\n file_id: str,\n *,\n # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.\n # The extra values given here take precedence over values defined on the client or passed to this method.\n extra_headers: Headers | None = None,\n extra_query: Query | None = None,\n extra_body: Body | None = None,\n timeout: float | httpx2.Timeout | None | NotGiven = not_given,\n ) -> _legacy_response.HttpxBinaryResponseContent:\n \"\"\"\n Returns a response containing the contents of the specified file.\n\n Args:\n extra_headers: Send extra headers\n\n extra_query: Add additional query parameters to the request\n\n extra_body: Add additional JSON properties to the request\n\n timeout: Override the client-level default timeout for this request, in seconds\n \"\"\"\n if not file_id:\n raise ValueError(f\"Expected a non-empty value for `file_id` but received {file_id!r}\")\n extra_headers = {\"Accept\": \"application/binary\", **(extra_headers or {})}\n return self._get(\n path_template(\"/files/{file_id}/content\", file_id=file_id),\n options=make_request_options(\n extra_headers=extra_headers,\n extra_query=extra_query,\n extra_body=extra_body,\n timeout=timeout,\n security={\"bearer_auth\": True},\n ),\n cast_to=_legacy_response.HttpxBinaryResponseContent,\n )\n\n @typing_extensions.deprecated(\"The `.content()` method should be used instead\")\n def retrieve_content(\n self,\n file_id: str,\n *,\n # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.\n # The extra values given here take precedence over values defined on the client or passed to this method.\n extra_headers: Headers | None = None,\n extra_query: Query | None = None,\n extra_body: Body | None = None,\n timeout: float | httpx2.Timeout | None | NotGiven = not_given,\n ) -> str:\n \"\"\"\n Returns a response containing the contents of the specified file.\n\n Args:\n extra_headers: Send extra headers\n\n extra_query: Add additional query parameters to the request\n\n extra_body: Add additional JSON properties to the request\n\n timeout: Override the client-level default timeout for this request, in seconds\n \"\"\"\n if not file_id:\n raise ValueError(f\"Expected a non-empty value for `file_id` but received {file_id!r}\")\n return self._get(\n path_template(\"/files/{file_id}/content\", file_id=file_id),\n options=make_request_options(\n extra_headers=extra_headers,\n extra_query=extra_query,\n extra_body=extra_body,\n timeout=timeout,\n security={\"bearer_auth\": True},\n ),\n cast_to=str,\n )\n\n def wait_for_processing(\n self,\n id: str,\n *,\n poll_interval: float = 5.0,\n max_wait_seconds: float = 30 * 60,\n ) -> FileObject:\n \"\"\"Waits for the given file to be processed, default timeout is 30 mins.\"\"\"\n return _wait_for_file_processing(self, id, poll_interval=poll_interval, max_wait_seconds=max_wait_seconds)\n\nclass AsyncFiles(AsyncAPIResource):\n \"\"\"\n Files are used to upload documents that can be used with features like Assistants and Fine-tuning.\n \"\"\"\n\n @cached_property\n def with_raw_response(self) -> AsyncFilesWithRawResponse:\n \"\"\"\n This property can be used as a prefix for any HTTP method call to return\n the raw response object instead of the parsed content.\n\n For more information, see https://www.github.com/openai/openai-python#accessing-raw-response-data-eg-headers\n \"\"\"\n return AsyncFilesWithRawResponse(self)\n\n @cached_property\n def with_streaming_response(self) -> AsyncFilesWithStreamingResponse:\n \"\"\"\n An alternative to `.with_raw_response` that doesn't eagerly read the response body.\n\n For more information, see https://www.github.com/openai/openai-python#with_streaming_response\n \"\"\"\n return AsyncFilesWithStreamingResponse(self)\n\n async def create(\n self,\n *,\n file: FileTypes,\n purpose: FilePurpose,\n expires_after: file_create_params.ExpiresAfter | Omit = omit,\n # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.\n # The extra values given here take precedence over values defined on the client or passed to this method.\n extra_headers: Headers | None = None,\n extra_query: Query | None = None,\n extra_body: Body | None = None,\n timeout: float | httpx2.Timeout | None | NotGiven = not_given,\n ) -> FileObject:\n \"\"\"Upload a file that can be used across various endpoints.\n\n Individual files can be\n up to 512 MB, and each project can store up to 2.5 TB of files in total. There\n is no organization-wide storage limit. Uploads to this endpoint are rate-limited\n to 1,000 requests per minute per authenticated user.\n\n - The Assistants API supports files up to 2 million tokens and of specific file\n types. See the\n Assistants Tools guide\n for details.\n - The Fine-tuning API only supports `.jsonl` files. The input also has certain\n required formats for fine-tuning\n chat\n or\n completions\n models.\n - The Batch API only supports `.jsonl` files up to 200 MB in size. The input\n also has a specific required\n format.\n - For Retrieval or `file_search` ingestion, upload files here first. If you need\n to attach multiple uploaded files to the same vector store, use\n `/vector_stores/{vector_store_id}/file_batches`\n instead of attaching them one by one. Vector store attachment has separate\n limits from file upload, including 2,000 attached files per minute per\n organization.\n\n Please contact us if you need to increase these\n storage limits.\n\n Args:\n file: The File object (not file name) to be uploaded.\n\n purpose:\n The intended purpose of the uploaded file. One of:\n\n - `assistants`: Used in the Assistants API\n - `batch`: Used in the Batch API\n - `fine-tune`: Used for fine-tuning\n - `vision`: Images used for vision fine-tuning\n - `user_data`: Flexible file type for any purpose\n - `evals`: Used for eval data sets\n\n expires_after: The expiration policy for a file. By default, files with `purpose=batch` expire\n after 30 days and all other files are persisted until they are manually deleted.\n\n extra_headers: Send extra headers\n\n extra_query: Add additional query parameters to the request\n\n extra_body: Add additional JSON properties to the request\n\n timeout: Override the client-level default timeout for this request, in seconds\n \"\"\"\n body = deepcopy_with_paths(\n {\n \"file\": file,\n \"purpose\": purpose,\n \"expires_after\": expires_after,\n },\n [[\"file\"]],\n )\n files = extract_files(cast(Mapping[str, object], body), paths=[[\"file\"]])\n # It should be noted that the actual Content-Type header that will be\n # sent to the server will contain a `boundary` parameter, e.g.\n # multipart/form-data; boundary=---abc--\n extra_headers = {\"Content-Type\": \"multipart/form-data\", **(extra_headers or {})}\n return await self._post(\n \"/files\",\n body=await async_maybe_transform(body, file_create_params.FileCreateParams),\n files=files,\n options=make_request_options(\n extra_headers=extra_headers,\n extra_query=extra_query,\n extra_body=extra_body,\n timeout=timeout,\n security={\"bearer_auth\": True},\n ),\n cast_to=FileObject,\n )\n\n async def retrieve(\n self,\n file_id: str,\n *,\n # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.\n # The extra values given here take precedence over values defined on the client or passed to this method.\n extra_headers: Headers | None = None,\n extra_query: Query | None = None,\n extra_body: Body | None = None,\n timeout: float | httpx2.Timeout | None | NotGiven = not_given,\n ) -> FileObject:\n \"\"\"\n Returns information about a specific file.\n\n Args:\n extra_headers: Send extra headers\n\n extra_query: Add additional query parameters to the request\n\n extra_body: Add additional JSON properties to the request\n\n timeout: Override the client-level default timeout for this request, in seconds\n \"\"\"\n if not file_id:\n raise ValueError(f\"Expected a non-empty value for `file_id` but received {file_id!r}\")\n return await self._get(\n path_template(\"/files/{file_id}\", file_id=file_id),\n options=make_request_options(\n extra_headers=extra_headers,\n extra_query=extra_query,\n extra_body=extra_body,\n timeout=timeout,\n security={\"bearer_auth\": True},\n ),\n cast_to=FileObject,\n )\n\n def list(\n self,\n *,\n after: str | Omit = omit,\n limit: int | Omit = omit,\n order: Literal[\"asc\", \"desc\"] | Omit = omit,\n purpose: str | Omit = omit,\n # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.\n # The extra values given here take precedence over values defined on the client or passed to this method.\n extra_headers: Headers | None = None,\n extra_query: Query | None = None,\n extra_body: Body | None = None,\n timeout: float | httpx2.Timeout | None | NotGiven = not_given,\n ) -> AsyncPaginator[FileObject, AsyncCursorPage[FileObject]]:\n \"\"\"Returns a list of files.\n\n Args:\n after: A cursor for use in pagination.\n\n `after` is an object ID that defines your place\n in the list. For instance, if you make a list request and receive 100 objects,\n ending with obj_foo, your subsequent call can include after=obj_foo in order to\n fetch the next page of the list.\n\n limit: A limit on the number of objects to be returned. Limit can range between 1 and\n 10,000, and the default is 10,000.\n\n order: Sort order by the `created_at` timestamp of the objects. `asc` for ascending\n order and `desc` for descending order.\n\n purpose: Only return files with the given purpose.\n\n extra_headers: Send extra headers\n\n extra_query: Add additional query parameters to the request\n\n extra_body: Add additional JSON properties to the request\n\n timeout: Override the client-level default timeout for this request, in seconds\n \"\"\"\n return self._get_api_list(\n \"/files\",\n page=AsyncCursorPage[FileObject],\n options=make_request_options(\n extra_headers=extra_headers,\n extra_query=extra_query,\n extra_body=extra_body,\n timeout=timeout,\n query=maybe_transform(\n {\n \"after\": after,\n \"limit\": limit,\n \"order\": order,\n \"purpose\": purpose,\n },\n file_list_params.FileListParams,\n ),\n security={\"bearer_auth\": True},\n ),\n model=FileObject,\n )\n\n async def delete(\n self,\n file_id: str,\n *,\n # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.\n # The extra values given here take precedence over values defined on the client or passed to this method.\n extra_headers: Headers | None = None,\n extra_query: Query | None = None,\n extra_body: Body | None = None,\n timeout: float | httpx2.Timeout | None | NotGiven = not_given,\n ) -> FileDeleted:\n \"\"\"\n Delete a file and remove it from all vector stores.\n\n Args:\n extra_headers: Send extra headers\n\n extra_query: Add additional query parameters to the request\n\n extra_body: Add additional JSON properties to the request\n\n timeout: Override the client-level default timeout for this request, in seconds\n \"\"\"\n if not file_id:\n raise ValueError(f\"Expected a non-empty value for `file_id` but received {file_id!r}\")\n return await self._delete(\n path_template(\"/files/{file_id}\", file_id=file_id),\n options=make_request_options(\n extra_headers=extra_headers,\n extra_query=extra_query,\n extra_body=extra_body,\n timeout=timeout,\n security={\"bearer_auth\": True},\n ),\n cast_to=FileDeleted,\n )\n\n async def content(\n self,\n file_id: str,\n *,\n # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.\n # The extra values given here take precedence over values defined on the client or passed to this method.\n extra_headers: Headers | None = None,\n extra_query: Query | None = None,\n extra_body: Body | None = None,\n timeout: float | httpx2.Timeout | None | NotGiven = not_given,\n ) -> _legacy_response.HttpxBinaryResponseContent:\n \"\"\"\n Returns a response containing the contents of the specified file.\n\n Args:\n extra_headers: Send extra headers\n\n extra_query: Add additional query parameters to the request\n\n extra_body: Add additional JSON properties to the request\n\n timeout: Override the client-level default timeout for this request, in seconds\n \"\"\"\n if not file_id:\n raise ValueError(f\"Expected a non-empty value for `file_id` but received {file_id!r}\")\n extra_headers = {\"Accept\": \"application/binary\", **(extra_headers or {})}\n return await self._get(\n path_template(\"/files/{file_id}/content\", file_id=file_id),\n options=make_request_options(\n extra_headers=extra_headers,\n extra_query=extra_query,\n extra_body=extra_body,\n timeout=timeout,\n security={\"bearer_auth\": True},\n ),\n cast_to=_legacy_response.HttpxBinaryResponseContent,\n )\n\n @typing_extensions.deprecated(\"The `.content()` method should be used instead\")\n async def retrieve_content(\n self,\n file_id: str,\n *,\n # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.\n # The extra values given here take precedence over values defined on the client or passed to this method.\n extra_headers: Headers | None = None,\n extra_query: Query | None = None,\n extra_body: Body | None = None,\n timeout: float | httpx2.Timeout | None | NotGiven = not_given,\n ) -> str:\n \"\"\"\n Returns a response containing the contents of the specified file.\n\n Args:\n extra_headers: Send extra headers\n\n extra_query: Add additional query parameters to the request\n\n extra_body: Add additional JSON properties to the request\n\n timeout: Override the client-level default timeout for this request, in seconds\n \"\"\"\n if not file_id:\n raise ValueError(f\"Expected a non-empty value for `file_id` but received {file_id!r}\")\n return await self._get(\n path_template(\"/files/{file_id}/content\", file_id=file_id),\n options=make_request_options(\n extra_headers=extra_headers,\n extra_query=extra_query,\n extra_body=extra_body,\n timeout=timeout,\n security={\"bearer_auth\": True},\n ),\n cast_to=str,\n )\n\n async def wait_for_processing(\n self,\n id: str,\n *,\n poll_interval: float = 5.0,\n max_wait_seconds: float = 30 * 60,\n ) -> FileObject:\n \"\"\"Waits for the given file to be processed, default timeout is 30 mins.\"\"\"\n return await _async_wait_for_file_processing(\n self, id, poll_interval=poll_interval, max_wait_seconds=max_wait_seconds\n )\n\nclass FilesWithRawResponse:\n def __init__(self, files: Files) -> None:\n self._files = files\n\n self.create = _legacy_response.to_raw_response_wrapper(\n files.create,\n )\n self.retrieve = _legacy_response.to_raw_response_wrapper(\n files.retrieve,\n )\n self.list = _legacy_response.to_raw_response_wrapper(\n files.list,\n )\n self.delete = _legacy_response.to_raw_response_wrapper(\n files.delete,\n )\n self.content = _legacy_response.to_raw_response_wrapper(\n files.content,\n )\n self.retrieve_content = ( # pyright: ignore[reportDeprecated]\n _legacy_response.to_raw_response_wrapper(\n files.retrieve_content, # pyright: ignore[reportDeprecated],\n )\n )\n\nclass AsyncFilesWithRawResponse:\n def __init__(self, files: AsyncFiles) -> None:\n self._files = files\n\n self.create = _legacy_response.async_to_raw_response_wrapper(\n files.create,\n )\n self.retrieve = _legacy_response.async_to_raw_response_wrapper(\n files.retrieve,\n )\n self.list = _legacy_response.async_to_raw_response_wrapper(\n files.list,\n )\n self.delete = _legacy_response.async_to_raw_response_wrapper(\n files.delete,\n )\n self.content = _legacy_response.async_to_raw_response_wrapper(\n files.content,\n )\n self.retrieve_content = ( # pyright: ignore[reportDeprecated]\n _legacy_response.async_to_raw_response_wrapper(\n files.retrieve_content, # pyright: ignore[reportDeprecated],\n )\n )\n\nclass FilesWithStreamingResponse:\n def __init__(self, files: Files) -> None:\n self._files = files\n\n self.create = to_streamed_response_wrapper(\n files.create,\n )\n self.retrieve = to_streamed_response_wrapper(\n files.retrieve,\n )\n self.list = to_streamed_response_wrapper(\n files.list,\n )\n self.delete = to_streamed_response_wrapper(\n files.delete,\n )\n self.content = to_custom_streamed_response_wrapper(\n files.content,\n StreamedBinaryAPIResponse,\n )\n self.retrieve_content = ( # pyright: ignore[reportDeprecated]\n to_streamed_response_wrapper(\n files.retrieve_content, # pyright: ignore[reportDeprecated],\n )\n )\n\nclass AsyncFilesWithStreamingResponse:\n def __init__(self, files: AsyncFiles) -> None:\n self._files = files\n\n self.create = async_to_streamed_response_wrapper(\n files.create,\n )\n self.retrieve = async_to_streamed_response_wrapper(\n files.retrieve,\n )\n self.list = async_to_streamed_response_wrapper(\n files.list,\n )\n self.delete = async_to_streamed_response_wrapper(\n files.delete,\n )\n self.content = async_to_custom_streamed_response_wrapper(\n files.content,\n AsyncStreamedBinaryAPIResponse,\n )\n self.retrieve_content = ( # pyright: ignore[reportDeprecated]\n async_to_streamed_response_wrapper(\n files.retrieve_content, # pyright: ignore[reportDeprecated],\n )\n )\n",
      "content_chars": 26184,
      "published_date": null
    },
    {
      "rank": 6,
      "url": "https://github.com/openai/openai-node/blob/e228aaad/src/resources/files.ts",
      "title": "src/resources/files.ts at e228aaad \u00b7 openai/openai-node",
      "content": "# src/resources/files.ts\n\n- Branch: e228aaad\n- Repository: openai/openai-node\n\n---\n\n// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.\n\nimport { APIResource } from '../core/resource';\nimport { APIPromise } from '../core/api-promise';\nimport { CursorPage, type CursorPageParams, PagePromise } from '../core/pagination';\nimport { type Uploadable } from '../core/uploads';\nimport { buildHeaders } from '../internal/headers';\nimport { RequestOptions } from '../internal/request-options';\nimport { sleep } from '../internal/utils/sleep';\nimport { APIConnectionTimeoutError } from '../error';\nimport { multipartFormRequestOptions } from '../internal/uploads';\nimport { path } from '../internal/utils/path';\n\n/**\n * Files are used to upload documents that can be used with features like Assistants and Fine-tuning.\n */\nexport class Files extends APIResource {\n /**\n * Upload a file that can be used across various endpoints. Individual files can be\n * up to 512 MB, and each project can store up to 2.5 TB of files in total. There\n * is no organization-wide storage limit. Uploads to this endpoint are rate-limited\n * to 1,000 requests per minute per authenticated user.\n *\n * - The Assistants API supports files up to 2 million tokens and of specific file\n * types. See the\n * Assistants Tools guide\n * for details.\n * - The Fine-tuning API only supports `.jsonl` files. The input also has certain\n * required formats for fine-tuning\n * chat\n * or\n * completions\n * models.\n * - The Batch API only supports `.jsonl` files up to 200 MB in size. The input\n * also has a specific required\n * format.\n * - For Retrieval or `file_search` ingestion, upload files here first. If you need\n * to attach multiple uploaded files to the same vector store, use\n * `/vector_stores/{vector_store_id}/file_batches`\n * instead of attaching them one by one. Vector store attachment has separate\n * limits from file upload, including 2,000 attached files per minute per\n * organization.\n *\n * Please contact us if you need to increase these\n * storage limits.\n */\n create(body: FileCreateParams, options?: RequestOptions): APIPromise {\n return this._client.post(\n '/files',\n multipartFormRequestOptions({ body, ...options, __security: { bearerAuth: true } }, this._client),\n );\n }\n\n /**\n * Returns information about a specific file.\n */\n retrieve(fileID: string, options?: RequestOptions): APIPromise {\n return this._client.get(path`/files/${fileID}`, { ...options, __security: { bearerAuth: true } });\n }\n\n /**\n * Returns a list of files.\n */\n list(\n query: FileListParams | null | undefined = {},\n options?: RequestOptions,\n ): PagePromise<FileObjectsPage, FileObject> {\n return this._client.getAPIList('/files', CursorPage, {\n query,\n ...options,\n __security: { bearerAuth: true },\n });\n }\n\n /**\n * Delete a file and remove it from all vector stores.\n */\n delete(fileID: string, options?: RequestOptions): APIPromise {\n return this._client.delete(path`/files/${fileID}`, { ...options, __security: { bearerAuth: true } });\n }\n\n /**\n * Returns the contents of the specified file.\n */\n content(fileID: string, options?: RequestOptions): APIPromise {\n return this._client.get(path`/files/${fileID}/content`, {\n ...options,\n headers: buildHeaders([{ Accept: 'application/binary' }, options?.headers]),\n __security: { bearerAuth: true },\n __binaryResponse: true,\n });\n }\n\n /**\n * Waits for the given file to be processed, default timeout is 30 mins.\n */\n async waitForProcessing(\n id: string,\n { pollInterval = 5000, maxWait = 30 * 60 * 1000 }: { pollInterval?: number; maxWait?: number } = {},\n ): Promise {\n const TERMINAL_STATES = new Set(['processed', 'error', 'deleted']);\n\n const start = Date.now();\n let file = await this.retrieve(id);\n\n while (!file.status || !TERMINAL_STATES.has(file.status)) {\n await sleep(pollInterval);\n\n file = await this.retrieve(id);\n if (Date.now() - start > maxWait) {\n throw new APIConnectionTimeoutError({\n message: `Giving up on waiting for file ${id} to finish processing after ${maxWait} milliseconds.`,\n });\n }\n }\n\n return file;\n }\n}\n\nexport type FileObjectsPage = CursorPage;\n\nexport type FileContent = string;\n\nexport interface FileDeleted {\n id: string;\n\n deleted: boolean;\n\n object: 'file';\n}\n\n/**\n * The `File` object represents a document that has been uploaded to OpenAI.\n */\nexport interface FileObject {\n /**\n * The file identifier, which can be referenced in the API endpoints.\n */\n id: string;\n\n /**\n * The size of the file, in bytes.\n */\n bytes: number;\n\n /**\n * The Unix timestamp (in seconds) for when the file was created.\n */\n created_at: number;\n\n /**\n * The name of the file.\n */\n filename: string;\n\n /**\n * The object type, which is always `file`.\n */\n object: 'file';\n\n /**\n * The intended purpose of the file. Supported values are `assistants`,\n * `assistants_output`, `batch`, `batch_output`, `fine-tune`, `fine-tune-results`,\n * `vision`, and `user_data`.\n */\n purpose:\n | 'assistants'\n | 'assistants_output'\n | 'batch'\n | 'batch_output'\n | 'fine-tune'\n | 'fine-tune-results'\n | 'vision'\n | 'user_data';\n\n /**\n * @deprecated Deprecated. The current status of the file, which can be either\n * `uploaded`, `processed`, or `error`.\n */\n status: 'uploaded' | 'processed' | 'error';\n\n /**\n * The Unix timestamp (in seconds) for when the file will expire.\n */\n expires_at?: number;\n\n /**\n * @deprecated Deprecated. For details on why a fine-tuning training file failed\n * validation, see the `error` field on `fine_tuning.job`.\n */\n status_details?: string;\n}\n\n/**\n * The intended purpose of the uploaded file. One of:\n *\n * - `assistants`: Used in the Assistants API\n * - `batch`: Used in the Batch API\n * - `fine-tune`: Used for fine-tuning\n * - `vision`: Images used for vision fine-tuning\n * - `user_data`: Flexible file type for any purpose\n * - `evals`: Used for eval data sets\n */\nexport type FilePurpose = 'assistants' | 'batch' | 'fine-tune' | 'vision' | 'user_data' | 'evals';\n\nexport interface FileCreateParams {\n /**\n * The File object (not file name) to be uploaded.\n */\n file: Uploadable;\n\n /**\n * The intended purpose of the uploaded file. One of:\n *\n * - `assistants`: Used in the Assistants API\n * - `batch`: Used in the Batch API\n * - `fine-tune`: Used for fine-tuning\n * - `vision`: Images used for vision fine-tuning\n * - `user_data`: Flexible file type for any purpose\n * - `evals`: Used for eval data sets\n */\n purpose: FilePurpose;\n\n /**\n * The expiration policy for a file. By default, files with `purpose=batch` expire\n * after 30 days and all other files are persisted until they are manually deleted.\n */\n expires_after?: FileCreateParams.ExpiresAfter;\n}\n\nexport namespace FileCreateParams {\n /**\n * The expiration policy for a file. By default, files with `purpose=batch` expire\n * after 30 days and all other files are persisted until they are manually deleted.\n */\n export interface ExpiresAfter {\n /**\n * Anchor timestamp after which the expiration policy applies. Supported anchors:\n * `created_at`.\n */\n anchor: 'created_at';\n\n /**\n * The number of seconds after the anchor time that the file will expire. Must be\n * between 3600 (1 hour) and 2592000 (30 days).\n */\n seconds: number;\n }\n}\n\nexport interface FileListParams extends CursorPageParams {\n /**\n * Sort order by the `created_at` timestamp of the objects. `asc` for ascending\n * order and `desc` for descending order.\n */\n order?: 'asc' | 'desc';\n\n /**\n * Only return files with the given purpose.\n */\n purpose?: string;\n}\n\nexport declare namespace Files {\n export {\n type FileContent as FileContent,\n type FileDeleted as FileDeleted,\n type FileObject as FileObject,\n type FilePurpose as FilePurpose,\n type FileObjectsPage as FileObjectsPage,\n type FileCreateParams as FileCreateParams,\n type FileListParams as FileListParams,\n };\n}\n",
      "content_chars": 7790,
      "published_date": null
    },
    {
      "rank": 7,
      "url": "https://github.com/openai/openai-go/blob/986b2d95f8e89b4de3f5015ae625a39ea20db53d/file.go",
      "title": "file.go at 986b2d95f8e89b4de3f5015ae625a39ea20db53d \u00b7 openai/openai-go",
      "content": "# file.go\n\n- Branch: 986b2d95f8e89b4de3f5015ae625a39ea20db53d\n- Repository: openai/openai-go\n\n---\n\n// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.\n\npackage openai\n\nimport (\n \"bytes\"\n \"context\"\n \"errors\"\n \"fmt\"\n \"io\"\n \"mime/multipart\"\n \"net/http\"\n \"net/url\"\n \"slices\"\n\n \"github.com/openai/openai-go/v3/internal/apiform\"\n \"github.com/openai/openai-go/v3/internal/apijson\"\n \"github.com/openai/openai-go/v3/internal/apiquery\"\n \"github.com/openai/openai-go/v3/internal/requestconfig\"\n \"github.com/openai/openai-go/v3/option\"\n \"github.com/openai/openai-go/v3/packages/pagination\"\n \"github.com/openai/openai-go/v3/packages/param\"\n \"github.com/openai/openai-go/v3/packages/respjson\"\n \"github.com/openai/openai-go/v3/shared/constant\"\n)\n\n// Files are used to upload documents that can be used with features like\n// Assistants and Fine-tuning.\n//\n// FileService contains methods and other services that help with interacting with\n// the openai API.\n//\n// Note, unlike clients, this service does not read variables from the environment\n// automatically. You should not instantiate this service directly, and instead use\n// the [NewFileService] method instead.\ntype FileService struct {\n Options []option.RequestOption\n}\n\n// NewFileService generates a new service that applies the given options to each\n// request. These options are applied after the parent client's options (if there\n// is one), and before any request-specific options.\nfunc NewFileService(opts ...option.RequestOption) (r FileService) {\n r = FileService{}\n r.Options = opts\n return\n}\n\n// Upload a file that can be used across various endpoints. Individual files can be\n// up to 512 MB, and each project can store up to 2.5 TB of files in total. There\n// is no organization-wide storage limit. Uploads to this endpoint are rate-limited\n// to 1,000 requests per minute per authenticated user.\n//\n// - The Assistants API supports files up to 2 million tokens and of specific file\n// types. See the\n// Assistants Tools guide\n// for details.\n// - The Fine-tuning API only supports `.jsonl` files. The input also has certain\n// required formats for fine-tuning\n// chat\n// or\n// completions\n// models.\n// - The Batch API only supports `.jsonl` files up to 200 MB in size. The input\n// also has a specific required\n// format.\n// - For Retrieval or `file_search` ingestion, upload files here first. If you need\n// to attach multiple uploaded files to the same vector store, use\n// `/vector_stores/{vector_store_id}/file_batches`\n// instead of attaching them one by one. Vector store attachment has separate\n// limits from file upload, including 2,000 attached files per minute per\n// organization.\n//\n// Please contact us if you need to increase these\n// storage limits.\nfunc (r *FileService) New(ctx context.Context, body FileNewParams, opts ...option.RequestOption) (res *FileObject, err error) {\n var preClientOpts = []option.RequestOption{requestconfig.WithBearerAuthSecurity()}\n opts = slices.Concat(preClientOpts, r.Options, opts)\n path := \"files\"\n err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...)\n return res, err\n}\n\n// Returns information about a specific file.\nfunc (r *FileService) Get(ctx context.Context, fileID string, opts ...option.RequestOption) (res *FileObject, err error) {\n var preClientOpts = []option.RequestOption{requestconfig.WithBearerAuthSecurity()}\n opts = slices.Concat(preClientOpts, r.Options, opts)\n if fileID == \"\" {\n err = errors.New(\"missing required file_id parameter\")\n return nil, err\n }\n path := fmt.Sprintf(\"files/%s\", fileID)\n err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &res, opts...)\n return res, err\n}\n\n// Returns a list of files.\nfunc (r *FileService) List(ctx context.Context, query FileListParams, opts ...option.RequestOption) (res *pagination.CursorPage[FileObject], err error) {\n var raw *http.Response\n var preClientOpts = []option.RequestOption{requestconfig.WithBearerAuthSecurity()}\n opts = slices.Concat(preClientOpts, r.Options, opts)\n opts = append([]option.RequestOption{option.WithResponseInto(&raw)}, opts...)\n path := \"files\"\n cfg, err := requestconfig.NewRequestConfig(ctx, http.MethodGet, path, query, &res, opts...)\n if err != nil {\n return nil, err\n }\n err = cfg.Execute()\n if err != nil {\n return nil, err\n }\n res.SetPageConfig(cfg, raw)\n return res, nil\n}\n\n// Returns a list of files.\nfunc (r *FileService) ListAutoPaging(ctx context.Context, query FileListParams, opts ...option.RequestOption) *pagination.CursorPageAutoPager[FileObject] {\n return pagination.NewCursorPageAutoPager(r.List(ctx, query, opts...))\n}\n\n// Delete a file and remove it from all vector stores.\nfunc (r *FileService) Delete(ctx context.Context, fileID string, opts ...option.RequestOption) (res *FileDeleted, err error) {\n var preClientOpts = []option.RequestOption{requestconfig.WithBearerAuthSecurity()}\n opts = slices.Concat(preClientOpts, r.Options, opts)\n if fileID == \"\" {\n err = errors.New(\"missing required file_id parameter\")\n return nil, err\n }\n path := fmt.Sprintf(\"files/%s\", fileID)\n err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, nil, &res, opts...)\n return res, err\n}\n\n// Returns the contents of the specified file.\nfunc (r *FileService) Content(ctx context.Context, fileID string, opts ...option.RequestOption) (res *http.Response, err error) {\n var preClientOpts = []option.RequestOption{requestconfig.WithBearerAuthSecurity()}\n opts = slices.Concat(preClientOpts, r.Options, opts)\n opts = append([]option.RequestOption{option.WithHeader(\"Accept\", \"application/binary\")}, opts...)\n if fileID == \"\" {\n err = errors.New(\"missing required file_id parameter\")\n return nil, err\n }\n path := fmt.Sprintf(\"files/%s/content\", fileID)\n err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &res, opts...)\n return res, err\n}\n\ntype FileDeleted struct {\n ID string `json:\"id\" api:\"required\"`\n Deleted bool `json:\"deleted\" api:\"required\"`\n Object constant.File `json:\"object\" default:\"file\"`\n // JSON contains metadata for fields, check presence with [respjson.Field.Valid].\n JSON struct {\n ID respjson.Field\n Deleted respjson.Field\n Object respjson.Field\n ExtraFields map[string]respjson.Field\n raw string\n } `json:\"-\"`\n}\n\n// Returns the unmodified JSON received from the API\nfunc (r FileDeleted) RawJSON() string { return r.JSON.raw }\nfunc (r *FileDeleted) UnmarshalJSON(data []byte) error {\n return apijson.UnmarshalRoot(data, r)\n}\n\n// The `File` object represents a document that has been uploaded to OpenAI.\ntype FileObject struct {\n // The file identifier, which can be referenced in the API endpoints.\n ID string `json:\"id\" api:\"required\"`\n // The size of the file, in bytes.\n Bytes int64 `json:\"bytes\" api:\"required\"`\n // The Unix timestamp (in seconds) for when the file was created.\n CreatedAt int64 `json:\"created_at\" api:\"required\" format:\"unixtime\"`\n // The name of the file.\n Filename string `json:\"filename\" api:\"required\"`\n // The object type, which is always `file`.\n Object constant.File `json:\"object\" default:\"file\"`\n // The intended purpose of the file. Supported values are `assistants`,\n // `assistants_output`, `batch`, `batch_output`, `fine-tune`, `fine-tune-results`,\n // `vision`, and `user_data`.\n //\n // Any of \"assistants\", \"assistants_output\", \"batch\", \"batch_output\", \"fine-tune\",\n // \"fine-tune-results\", \"vision\", \"user_data\".\n Purpose FileObjectPurpose `json:\"purpose\" api:\"required\"`\n // Deprecated. The current status of the file, which can be either `uploaded`,\n // `processed`, or `error`.\n //\n // Any of \"uploaded\", \"processed\", \"error\".\n //\n // Deprecated: deprecated\n Status FileObjectStatus `json:\"status\" api:\"required\"`\n // The Unix timestamp (in seconds) for when the file will expire.\n ExpiresAt int64 `json:\"expires_at\" format:\"unixtime\"`\n // Deprecated. For details on why a fine-tuning training file failed validation,\n // see the `error` field on `fine_tuning.job`.\n //\n // Deprecated: deprecated\n StatusDetails string `json:\"status_details\"`\n // JSON contains metadata for fields, check presence with [respjson.Field.Valid].\n JSON struct {\n ID respjson.Field\n Bytes respjson.Field\n CreatedAt respjson.Field\n Filename respjson.Field\n Object respjson.Field\n Purpose respjson.Field\n Status respjson.Field\n ExpiresAt respjson.Field\n StatusDetails respjson.Field\n ExtraFields map[string]respjson.Field\n raw string\n } `json:\"-\"`\n}\n\n// Returns the unmodified JSON received from the API\nfunc (r FileObject) RawJSON() string { return r.JSON.raw }\nfunc (r *FileObject) UnmarshalJSON(data []byte) error {\n return apijson.UnmarshalRoot(data, r)\n}\n\n// The intended purpose of the file. Supported values are `assistants`,\n// `assistants_output`, `batch`, `batch_output`, `fine-tune`, `fine-tune-results`,\n// `vision`, and `user_data`.\ntype FileObjectPurpose string\n\nconst (\n FileObjectPurposeAssistants FileObjectPurpose = \"assistants\"\n FileObjectPurposeAssistantsOutput FileObjectPurpose = \"assistants_output\"\n FileObjectPurposeBatch FileObjectPurpose = \"batch\"\n FileObjectPurposeBatchOutput FileObjectPurpose = \"batch_output\"\n FileObjectPurposeFineTune FileObjectPurpose = \"fine-tune\"\n FileObjectPurposeFineTuneResults FileObjectPurpose = \"fine-tune-results\"\n FileObjectPurposeVision FileObjectPurpose = \"vision\"\n FileObjectPurposeUserData FileObjectPurpose = \"user_data\"\n)\n\n// Deprecated. The current status of the file, which can be either `uploaded`,\n// `processed`, or `error`.\ntype FileObjectStatus string\n\nconst (\n FileObjectStatusUploaded FileObjectStatus = \"uploaded\"\n FileObjectStatusProcessed FileObjectStatus = \"processed\"\n FileObjectStatusError FileObjectStatus = \"error\"\n)\n\n// The intended purpose of the uploaded file. One of:\n//\n// - `assistants`: Used in the Assistants API\n// - `batch`: Used in the Batch API\n// - `fine-tune`: Used for fine-tuning\n// - `vision`: Images used for vision fine-tuning\n// - `user_data`: Flexible file type for any purpose\n// - `evals`: Used for eval data sets\ntype FilePurpose string\n\nconst (\n FilePurposeAssistants FilePurpose = \"assistants\"\n FilePurposeBatch FilePurpose = \"batch\"\n FilePurposeFineTune FilePurpose = \"fine-tune\"\n FilePurposeVision FilePurpose = \"vision\"\n FilePurposeUserData FilePurpose = \"user_data\"\n FilePurposeEvals FilePurpose = \"evals\"\n)\n\ntype FileNewParams struct {\n // The File object (not file name) to be uploaded.\n File io.Reader `json:\"file,omitzero\" api:\"required\" format:\"binary\"`\n // The intended purpose of the uploaded file. One of:\n //\n // - `assistants`: Used in the Assistants API\n // - `batch`: Used in the Batch API\n // - `fine-tune`: Used for fine-tuning\n // - `vision`: Images used for vision fine-tuning\n // - `user_data`: Flexible file type for any purpose\n // - `evals`: Used for eval data sets\n //\n // Any of \"assistants\", \"batch\", \"fine-tune\", \"vision\", \"user_data\", \"evals\".\n Purpose FilePurpose `json:\"purpose,omitzero\" api:\"required\"`\n // The expiration policy for a file. By default, files with `purpose=batch` expire\n // after 30 days and all other files are persisted until they are manually deleted.\n ExpiresAfter FileNewParamsExpiresAfter `json:\"expires_after,omitzero\"`\n paramObj\n}\n\nfunc (r FileNewParams) MarshalMultipart() (data []byte, contentType string, err error) {\n buf := bytes.NewBuffer(nil)\n writer := multipart.NewWriter(buf)\n err = apiform.MarshalRoot(r, writer)\n if err == nil {\n err = apiform.WriteExtras(writer, r.ExtraFields())\n }\n if err != nil {\n writer.Close()\n return nil, \"\", err\n }\n err = writer.Close()\n if err != nil {\n return nil, \"\", err\n }\n return buf.Bytes(), writer.FormDataContentType(), nil\n}\n\n// The expiration policy for a file. By default, files with `purpose=batch` expire\n// after 30 days and all other files are persisted until they are manually deleted.\n//\n// The properties Anchor, Seconds are required.\ntype FileNewParamsExpiresAfter struct {\n // The number of seconds after the anchor time that the file will expire. Must be\n // between 3600 (1 hour) and 2592000 (30 days).\n Seconds int64 `json:\"seconds\" api:\"required\"`\n // Anchor timestamp after which the expiration policy applies. Supported anchors:\n // `created_at`.\n //\n // This field can be elided, and will marshal its zero value as \"created_at\".\n Anchor constant.CreatedAt `json:\"anchor\" default:\"created_at\"`\n paramObj\n}\n\nfunc (r FileNewParamsExpiresAfter) MarshalJSON() (data []byte, err error) {\n type shadow FileNewParamsExpiresAfter\n return param.MarshalObject(r, (*shadow)(&r))\n}\nfunc (r *FileNewParamsExpiresAfter) UnmarshalJSON(data []byte) error {\n return apijson.UnmarshalRoot(data, r)\n}\n\ntype FileListParams struct {\n // A cursor for use in pagination. `after` is an object ID that defines your place\n // in the list. For instance, if you make a list request and receive 100 objects,\n // ending with obj_foo, your subsequent call can include after=obj_foo in order to\n // fetch the next page of the list.\n After param.Opt[string] `query:\"after,omitzero\" json:\"-\"`\n // A limit on the number of objects to be returned. Limit can range between 1 and\n // 10,000, and the default is 10,000.\n Limit param.Opt[int64] `query:\"limit,omitzero\" json:\"-\"`\n // Only return files with the given purpose.\n Purpose param.Opt[string] `query:\"purpose,omitzero\" json:\"-\"`\n // Sort order by the `created_at` timestamp of the objects. `asc` for ascending\n // order and `desc` for descending order.\n //\n // Any of \"asc\", \"desc\".\n Order FileListParamsOrder `query:\"order,omitzero\" json:\"-\"`\n paramObj\n}\n\n// URLQuery serializes [FileListParams]'s query parameters as `url.Values`.\nfunc (r FileListParams) URLQuery() (v url.Values, err error) {\n return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{\n ArrayFormat: apiquery.ArrayQueryFormatBrackets,\n NestedFormat: apiquery.NestedQueryFormatBrackets,\n })\n}\n\n// Sort order by the `created_at` timestamp of the objects. `asc` for ascending\n// order and `desc` for descending order.\ntype FileListParamsOrder string\n\nconst (\n FileListParamsOrderAsc FileListParamsOrder = \"asc\"\n FileListParamsOrderDesc FileListParamsOrder = \"desc\"\n)\n",
      "content_chars": 14046,
      "published_date": null
    },
    {
      "rank": 8,
      "url": "https://github.com/openai/openai-node/blob/c9a4d688/src/resources/files.ts",
      "title": "src/resources/files.ts at c9a4d688 \u00b7 openai/openai-node",
      "content": "# src/resources/files.ts\n\n- Branch: c9a4d688\n- Repository: openai/openai-node\n\n---\n\n// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.\n\nimport { APIResource } from '../core/resource';\nimport { APIPromise } from '../core/api-promise';\nimport { CursorPage, type CursorPageParams, PagePromise } from '../core/pagination';\nimport { type Uploadable } from '../core/uploads';\nimport { buildHeaders } from '../internal/headers';\nimport { RequestOptions } from '../internal/request-options';\nimport { sleep } from '../internal/utils/sleep';\nimport { APIConnectionTimeoutError } from '../error';\nimport { multipartFormRequestOptions } from '../internal/uploads';\nimport { path } from '../internal/utils/path';\n\nexport class Files extends APIResource {\n /**\n * Upload a file that can be used across various endpoints. Individual files can be\n * up to 512 MB, and the size of all files uploaded by one organization can be up\n * to 1 TB.\n *\n * - The Assistants API supports files up to 2 million tokens and of specific file\n * types. See the\n * Assistants Tools guide\n * for details.\n * - The Fine-tuning API only supports `.jsonl` files. The input also has certain\n * required formats for fine-tuning\n * chat\n * or\n * completions\n * models.\n * - The Batch API only supports `.jsonl` files up to 200 MB in size. The input\n * also has a specific required\n * format.\n *\n * Please contact us if you need to increase these\n * storage limits.\n */\n create(body: FileCreateParams, options?: RequestOptions): APIPromise {\n return this._client.post('/files', multipartFormRequestOptions({ body, ...options }, this._client));\n }\n\n /**\n * Returns information about a specific file.\n */\n retrieve(fileID: string, options?: RequestOptions): APIPromise {\n return this._client.get(path`/files/${fileID}`, options);\n }\n\n /**\n * Returns a list of files.\n */\n list(\n query: FileListParams | null | undefined = {},\n options?: RequestOptions,\n ): PagePromise<FileObjectsPage, FileObject> {\n return this._client.getAPIList('/files', CursorPage, { query, ...options });\n }\n\n /**\n * Delete a file and remove it from all vector stores.\n */\n delete(fileID: string, options?: RequestOptions): APIPromise {\n return this._client.delete(path`/files/${fileID}`, options);\n }\n\n /**\n * Returns the contents of the specified file.\n */\n content(fileID: string, options?: RequestOptions): APIPromise {\n return this._client.get(path`/files/${fileID}/content`, {\n ...options,\n headers: buildHeaders([{ Accept: 'application/binary' }, options?.headers]),\n __binaryResponse: true,\n });\n }\n\n /**\n * Waits for the given file to be processed, default timeout is 30 mins.\n */\n async waitForProcessing(\n id: string,\n { pollInterval = 5000, maxWait = 30 * 60 * 1000 }: { pollInterval?: number; maxWait?: number } = {},\n ): Promise {\n const TERMINAL_STATES = new Set(['processed', 'error', 'deleted']);\n\n const start = Date.now();\n let file = await this.retrieve(id);\n\n while (!file.status || !TERMINAL_STATES.has(file.status)) {\n await sleep(pollInterval);\n\n file = await this.retrieve(id);\n if (Date.now() - start > maxWait) {\n throw new APIConnectionTimeoutError({\n message: `Giving up on waiting for file ${id} to finish processing after ${maxWait} milliseconds.`,\n });\n }\n }\n\n return file;\n }\n}\n\nexport type FileObjectsPage = CursorPage;\n\nexport type FileContent = string;\n\nexport interface FileDeleted {\n id: string;\n\n deleted: boolean;\n\n object: 'file';\n}\n\n/**\n * The `File` object represents a document that has been uploaded to OpenAI.\n */\nexport interface FileObject {\n /**\n * The file identifier, which can be referenced in the API endpoints.\n */\n id: string;\n\n /**\n * The size of the file, in bytes.\n */\n bytes: number;\n\n /**\n * The Unix timestamp (in seconds) for when the file was created.\n */\n created_at: number;\n\n /**\n * The name of the file.\n */\n filename: string;\n\n /**\n * The object type, which is always `file`.\n */\n object: 'file';\n\n /**\n * The intended purpose of the file. Supported values are `assistants`,\n * `assistants_output`, `batch`, `batch_output`, `fine-tune`, `fine-tune-results`,\n * `vision`, and `user_data`.\n */\n purpose:\n | 'assistants'\n | 'assistants_output'\n | 'batch'\n | 'batch_output'\n | 'fine-tune'\n | 'fine-tune-results'\n | 'vision'\n | 'user_data';\n\n /**\n * @deprecated Deprecated. The current status of the file, which can be either\n * `uploaded`, `processed`, or `error`.\n */\n status: 'uploaded' | 'processed' | 'error';\n\n /**\n * The Unix timestamp (in seconds) for when the file will expire.\n */\n expires_at?: number;\n\n /**\n * @deprecated Deprecated. For details on why a fine-tuning training file failed\n * validation, see the `error` field on `fine_tuning.job`.\n */\n status_details?: string;\n}\n\n/**\n * The intended purpose of the uploaded file. One of: - `assistants`: Used in the\n * Assistants API - `batch`: Used in the Batch API - `fine-tune`: Used for\n * fine-tuning - `vision`: Images used for vision fine-tuning - `user_data`:\n * Flexible file type for any purpose - `evals`: Used for eval data sets\n */\nexport type FilePurpose = 'assistants' | 'batch' | 'fine-tune' | 'vision' | 'user_data' | 'evals';\n\nexport interface FileCreateParams {\n /**\n * The File object (not file name) to be uploaded.\n */\n file: Uploadable;\n\n /**\n * The intended purpose of the uploaded file. One of: - `assistants`: Used in the\n * Assistants API - `batch`: Used in the Batch API - `fine-tune`: Used for\n * fine-tuning - `vision`: Images used for vision fine-tuning - `user_data`:\n * Flexible file type for any purpose - `evals`: Used for eval data sets\n */\n purpose: FilePurpose;\n\n /**\n * The expiration policy for a file. By default, files with `purpose=batch` expire\n * after 30 days and all other files are persisted until they are manually deleted.\n */\n expires_after?: FileCreateParams.ExpiresAfter;\n}\n\nexport namespace FileCreateParams {\n /**\n * The expiration policy for a file. By default, files with `purpose=batch` expire\n * after 30 days and all other files are persisted until they are manually deleted.\n */\n export interface ExpiresAfter {\n /**\n * Anchor timestamp after which the expiration policy applies. Supported anchors:\n * `created_at`.\n */\n anchor: 'created_at';\n\n /**\n * The number of seconds after the anchor time that the file will expire. Must be\n * between 3600 (1 hour) and 2592000 (30 days).\n */\n seconds: number;\n }\n}\n\nexport interface FileListParams extends CursorPageParams {\n /**\n * Sort order by the `created_at` timestamp of the objects. `asc` for ascending\n * order and `desc` for descending order.\n */\n order?: 'asc' | 'desc';\n\n /**\n * Only return files with the given purpose.\n */\n purpose?: string;\n}\n\nexport declare namespace Files {\n export {\n type FileContent as FileContent,\n type FileDeleted as FileDeleted,\n type FileObject as FileObject,\n type FilePurpose as FilePurpose,\n type FileObjectsPage as FileObjectsPage,\n type FileCreateParams as FileCreateParams,\n type FileListParams as FileListParams,\n };\n}\n",
      "content_chars": 6961,
      "published_date": null
    },
    {
      "rank": 9,
      "url": "https://app.unpkg.com/openai@6.26.0/files/resources/files.mjs",
      "title": "UNPKG",
      "content": "UNPKG\n\n# openai\n\nThe official TypeScript library for the OpenAI API\n\nopenai/openai-node\n\n85 lines \u2022 3.58 kB JavaScript View Raw\n\n// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. import { APIResource } from \"../core/resource.mjs\"; import { CursorPage } from \"../core/pagination.mjs\"; import { buildHeaders } from \"../internal/headers.mjs\"; import { sleep } from \"../internal/utils/sleep.mjs\"; import { APIConnectionTimeoutError } from \"../error.mjs\"; import { multipartFormRequestOptions } from \"../internal/uploads.mjs\"; import { path } from \"../internal/utils/path.mjs\"; /** * Files are used to upload documents that can be used with features like Assistants and Fine-tuning. */ export class Files extends APIResource { /** * Upload a file that can be used across various endpoints. Individual files can be * up to 512 MB, and each project can store up to 2.5 TB of files in total. There * is no organization-wide storage limit. * * - The Assistants API supports files up to 2 million tokens and of specific file * types. See the * [Assistants Tools guide](https://platform.openai.com/docs/assistants/tools) * for details. * - The Fine-tuning API only supports `.jsonl` files. The input also has certain * required formats for fine-tuning * [chat](https://platform.openai.com/docs/api-reference/fine-tuning/chat-input) * or * [completions](https://platform.openai.com/docs/api-reference/fine-tuning/completions-input) * models. * - The Batch API only supports `.jsonl` files up to 200 MB in size. The input * also has a specific required * [format](https://platform.openai.com/docs/api-reference/batch/request-input). * * Please [contact us](https://help.openai.com/) if you need to increase these * storage limits. */ create(body, options) { return this._client. post('/files', multipartFormRequestOptions({ body, ...options }, this._client)); } /** * Returns information about a specific file. */ retrieve(fileID, options) { return this._client. get(path `/files/${fileID}`, options); } /** * Returns a list of files. */ list(query = {}, options) { return this._client. getAPIList('/files', (CursorPage), { query, ...options }); } /** * Delete a file and remove it from all vector stores. */ delete(fileID, options) { return this._client. delete(path `/files/${fileID}`, options); } /** * Returns the contents of the specified file. */ content(fileID, options) { return this._client. get(path `/files/${fileID}/content`, { ...options, headers: buildHeaders([{ Accept: 'application/binary' }, options?. headers]), __binaryResponse: true, }); } /** * Waits for the given file to be processed, default timeout is 30 mins. */ async waitForProcessing(id, { pollInterval = 5000, maxWait = 30 * 60 * 1000 } = {}) { const TERMINAL_STATES = new Set(['processed', 'error', 'deleted']); const start = Date. now(); let file = await this. retrieve(id); while (!file. status || ! TERMINAL_STATES. has(file. status)) { await sleep(pollInterval); file = await this. retrieve(id); if (Date. now() - start > maxWait) { throw new APIConnectionTimeoutError({ message: `Giving up on waiting for file ${id} to finish processing after ${maxWait} milliseconds.`, }); } } return file; } } //# sourceMappingURL=files.mjs.map",
      "content_chars": 3239,
      "published_date": null
    },
    {
      "rank": 10,
      "url": "https://www.rubydoc.info/gems/openai/OpenAI/Resources/Files",
      "title": "RubyDoc.info: \n      \n  Class: OpenAI::Resources::Files\n  \n    \u2013 Documentation for openai (0.57.0)\n  \n \u2013 RubyDoc.info",
      "content": "RubyDoc.info: Class: OpenAI::Resources::Files \u2013 Documentation for openai (0.57.0) \u2013 RubyDoc.info \n\n# Class: OpenAI::Resources::Files\n\nInherits: Object\n\n- Object\n- OpenAI::Resources::Files\n\nshow all Defined in: lib/openai/resources/files.rb\n\n## Overview\n\nFiles are used to upload documents that can be used with features like Assistants and Fine-tuning.\n\n## Instance Method Summary collapse\n\n#content(file_id, request_options: {}) \u21d2 StringIO\n\nReturns the contents of the specified file.\n\n#create(file:, purpose:, expires_after: nil, request_options: {}) \u21d2 OpenAI::Models::FileObject\n\nSome parameter documentations has been truncated, see Models::FileCreateParams for more details.\n\n#delete(file_id, request_options: {}) \u21d2 OpenAI::Models::FileDeleted\n\nDelete a file and remove it from all vector stores.\n\n#initialize(client:) \u21d2 Files constructor private\n\nA new instance of Files.\n\n#list(after: nil, limit: nil, order: nil, purpose: nil, request_options: {}) \u21d2 OpenAI::Internal::CursorPage \n\nSome parameter documentations has been truncated, see Models::FileListParams for more details.\n\n#retrieve(file_id, request_options: {}) \u21d2 OpenAI::Models::FileObject\n\nReturns information about a specific file.\n\n## Constructor Details\n\n### #initialize(client:) \u21d2 Files\n\nThis method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.\n\nReturns a new instance of Files.\n\n```\n\n154\n155\n156\n```\n\n```\n# File 'lib/openai/resources/files.rb', line 154\n\ndef initialize(client:)\n  @client = client\nend\n```\n\n## Instance Method Details\n\n### #content(file_id, request_options: {}) \u21d2 StringIO\n\nReturns the contents of the specified file.\n\n```\n\n141\n142\n143\n144\n145\n146\n147\n148\n149\n```\n\n```\n# File 'lib/openai/resources/files.rb', line 141\n\ndef content(file_id, params = {})\n  @client.request(\n    method: :get,\n    path: [\"files/%1$s/content\", file_id],\n    headers: {\"accept\" => \"application/binary\"},\n    model: StringIO,\n    options: params[:request_options]\n  )\nend\n```\n\n### #create(file:, purpose:, expires_after: nil, request_options: {}) \u21d2 OpenAI::Models::FileObject\n\nSome parameter documentations has been truncated, see Models::FileCreateParams for more details.\n\nUpload a file that can be used across various endpoints. Individual files can be up to 512 MB, and each project can store up to 2.5 TB of files in total. There is no organization-wide storage limit.\n\nThe Assistants API supports files up to 2 million tokens and of specific file types. See the [Assistants Tools guide](platform.openai.com/docs/assistants/tools) for details.\n\nThe Fine-tuning API only supports`.jsonl` files. The input also has certain required formats for fine-tuning [chat](platform.openai.com/docs/api-reference/fine-tuning/chat-input) or [completions](platform.openai.com/docs/api-reference/fine-tuning/completions-input) models.\n\nThe Batch API only supports`.jsonl` files up to 200 MB in size. The input also has a specific required [format](platform.openai.com/docs/api-reference/batch/request-input).\n\nPlease [contact us](help.openai.com/) if you need to increase these storage limits.\n\n```\n\n45\n46\n47\n48\n49\n50\n51\n52\n53\n54\n55\n```\n\n```\n# File 'lib/openai/resources/files.rb', line 45\n\ndef create(params)\n  parsed, options = OpenAI::FileCreateParams.dump_request(params)\n  @client.request(\n    method: :post,\n    path: \"files\",\n    headers: {\"content-type\" => \"multipart/form-data\"},\n    body: parsed,\n    model: OpenAI::FileObject,\n    options: options\n  )\nend\n```\n\n### #delete(file_id, request_options: {}) \u21d2 OpenAI::Models::FileDeleted\n\nDelete a file and remove it from all vector stores.\n\n```\n\n121\n122\n123\n124\n125\n126\n127\n128\n```\n\n```\n# File 'lib/openai/resources/files.rb', line 121\n\ndef delete(file_id, params = {})\n  @client.request(\n    method: :delete,\n    path: [\"files/%1$s\", file_id],\n    model: OpenAI::FileDeleted,\n    options: params[:request_options]\n  )\nend\n```\n\n### #list(after: nil, limit: nil, order: nil, purpose: nil, request_options: {}) \u21d2 OpenAI::Internal::CursorPage \n\nSome parameter documentations has been truncated, see Models::FileListParams for more details.\n\nReturns a list of files.\n\n```\n\n97\n98\n99\n100\n101\n102\n103\n104\n105\n106\n107\n108\n```\n\n```\n# File 'lib/openai/resources/files.rb', line 97\n\ndef list(params = {})\n  parsed, options = OpenAI::FileListParams.dump_request(params)\n  query = OpenAI::Internal::Util.encode_query_params(parsed)\n  @client.request(\n    method: :get,\n    path: \"files\",\n    query: query,\n    page: OpenAI::Internal::CursorPage,\n    model: OpenAI::FileObject,\n    options: options\n  )\nend\n```\n\n### #retrieve(file_id, request_options: {}) \u21d2 OpenAI::Models::FileObject\n\nReturns information about a specific file.\n\n```\n\n68\n69\n70\n71\n72\n73\n74\n75\n```\n\n```\n# File 'lib/openai/resources/files.rb', line 68\n\ndef retrieve(file_id, params = {})\n  @client.request(\n    method: :get,\n    path: [\"files/%1$s\", file_id],\n    model: OpenAI::FileObject,\n    options: params[:request_options]\n  )\nend\n```\n\nGenerated on Fri Apr 3 12:15:02 2026 by yard 0.9.38 (ruby-3.4.3).",
      "content_chars": 5045,
      "published_date": null
    }
  ],
  "answer_text": null,
  "citations": [],
  "raw_response": {
    "requestId": "6a0909210f0d9fd667d85e05263bca9d",
    "resolvedSearchType": "",
    "results": [
      {
        "id": "https://developers.openai.com/api/reference/resources/files/",
        "title": "Files | OpenAI API Reference",
        "url": "https://developers.openai.com/api/reference/resources/files/",
        "text": "# Files\n\n## List files\n\nget `/files`\n\nReturns a list of files.\n\n### Query Parameters\n\n- `after: optional string` A cursor for use in pagination. `after` is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include after=obj_foo in order to fetch the next page of the list.\n- `limit: optional number` A limit on the number of objects to be returned. Limit can range between 1 and 10,000, and the default is 10,000.\n- `order: optional \"asc\" or \"desc\"` Sort order by the `created_at` timestamp of the objects. `asc` for ascending order and `desc` for descending order.`\"asc\"``\"desc\"`\n- `purpose: optional string` Only return files with the given purpose.\n\n### Returns\n\n- `data: array of FileObject``id: string` The file identifier, which can be referenced in the API endpoints.`bytes: number` The size of the file, in bytes.`created_at: number` The Unix timestamp (in seconds) for when the file was created.`filename: string` The name of the file.`object: \"file\"` The object type, which is always `file`.`\"file\"``purpose: \"assistants\" or \"assistants_output\" or \"batch\" or 5 more` The intended purpose of the file. Supported values are `assistants`, `assistants_output`, `batch`, `batch_output`, `fine-tune`, `fine-tune-results`, `vision`, and `user_data`.`\"assistants\"``\"assistants_output\"``\"batch\"``\"batch_output\"``\"fine-tune\"``\"fine-tune-results\"``\"vision\"``\"user_data\"``status: \"uploaded\" or \"processed\" or \"error\"` Deprecated. The current status of the file, which can be either `uploaded`, `processed`, or `error`.`\"uploaded\"``\"processed\"``\"error\"``expires_at: optional number` The Unix timestamp (in seconds) for when the file will expire.`status_details: optional string` Deprecated. For details on why a fine-tuning training file failed validation, see the `error` field on `fine_tuning.job`.\n- `first_id: string`\n- `has_more: boolean`\n- `last_id: string`\n- `object: string`\n\n### Example\n\n```http\ncurl https://api.openai.com/v1/files \\\n    -H \"Authorization: Bearer $OPENAI_API_KEY\"\n\n```\n\n#### Response\n\n```json\n{\n  \"data\": [\n    {\n      \"id\": \"id\",\n      \"bytes\": 0,\n      \"created_at\": 0,\n      \"filename\": \"filename\",\n      \"object\": \"file\",\n      \"purpose\": \"assistants\",\n      \"status\": \"uploaded\",\n      \"expires_at\": 0,\n      \"status_details\": \"status_details\"\n    }\n  ],\n  \"first_id\": \"file-abc123\",\n  \"has_more\": false,\n  \"last_id\": \"file-abc456\",\n  \"object\": \"list\"\n}\n\n```\n\n### Example\n\n```http\ncurl https://api.openai.com/v1/files \\\n  -H \"Authorization: Bearer $OPENAI_API_KEY\"\n\n```\n\n#### Response\n\n```json\n{\n  \"object\": \"list\",\n  \"data\": [\n    {\n      \"id\": \"file-abc123\",\n      \"object\": \"file\",\n      \"bytes\": 175,\n      \"created_at\": 1613677385,\n      \"expires_at\": 1677614202,\n      \"filename\": \"salesOverview.pdf\",\n      \"purpose\": \"assistants\",\n    },\n    {\n      \"id\": \"file-abc456\",\n      \"object\": \"file\",\n      \"bytes\": 140,\n      \"created_at\": 1613779121,\n      \"expires_at\": 1677614202,\n      \"filename\": \"puppy.jsonl\",\n      \"purpose\": \"fine-tune\",\n    }\n  ],\n  \"first_id\": \"file-abc123\",\n  \"last_id\": \"file-abc456\",\n  \"has_more\": false\n}\n\n```\n\n## Upload file\n\npost `/files`\n\nUpload a file that can be used across various endpoints. Individual files\ncan be up to 512 MB, and each project can store up to 2.5 TB of files in\ntotal. There is no organization-wide storage limit. Uploads to this\nendpoint are rate-limited to 1,000 requests per minute per authenticated\nuser.\n\n- The Assistants API supports files up to 2 million tokens and of specific\nfile types. See the Assistants Tools guide for\ndetails.\n- The Fine-tuning API only supports `.jsonl` files. The input also has\ncertain required formats for fine-tuning\nchat or\ncompletions models.\n- The Batch API only supports `.jsonl` files up to 200 MB in size. The input\nalso has a specific required\nformat.\n- For Retrieval or `file_search` ingestion, upload files here first. If\nyou need to attach multiple uploaded files to the same vector store, use\n`/vector_stores/{vector_store_id}/file_batches`\ninstead of attaching them one by one. Vector store attachment has separate\nlimits from file upload, including 2,000 attached files per minute per\norganization.\n\nPlease contact us if you need to increase these\nstorage limits.\n\n### Returns\n\n- `FileObject object { id, bytes, created_at, 6 more }` The `File` object represents a document that has been uploaded to OpenAI.`id: string` The file identifier, which can be referenced in the API endpoints.`bytes: number` The size of the file, in bytes.`created_at: number` The Unix timestamp (in seconds) for when the file was created.`filename: string` The name of the file.`object: \"file\"` The object type, which is always `file`.`\"file\"``purpose: \"assistants\" or \"assistants_output\" or \"batch\" or 5 more` The intended purpose of the file. Supported values are `assistants`, `assistants_output`, `batch`, `batch_output`, `fine-tune`, `fine-tune-results`, `vision`, and `user_data`.`\"assistants\"``\"assistants_output\"``\"batch\"``\"batch_output\"``\"fine-tune\"``\"fine-tune-results\"``\"vision\"``\"user_data\"``status: \"uploaded\" or \"processed\" or \"error\"` Deprecated. The current status of the file, which can be either `uploaded`, `processed`, or `error`.`\"uploaded\"``\"processed\"``\"error\"``expires_at: optional number` The Unix timestamp (in seconds) for when the file will expire.`status_details: optional string` Deprecated. For details on why a fine-tuning training file failed validation, see the `error` field on `fine_tuning.job`.\n\n### Example\n\n```http\ncurl https://api.openai.com/v1/files \\\n    -H 'Content-Type: multipart/form-data' \\\n    -H \"Authorization: Bearer $OPENAI_API_KEY\" \\\n    -F 'file=@/path/to/file' \\\n    -F purpose=assistants\n\n```\n\n#### Response\n\n```json\n{\n  \"id\": \"id\",\n  \"bytes\": 0,\n  \"created_at\": 0,\n  \"filename\": \"filename\",\n  \"object\": \"file\",\n  \"purpose\": \"assistants\",\n  \"status\": \"uploaded\",\n  \"expires_at\": 0,\n  \"status_details\": \"status_details\"\n}\n\n```\n\n### Example\n\n```http\ncurl https://api.openai.com/v1/files \\\n  -H \"Authorization: Bearer $OPENAI_API_KEY\" \\\n  -F purpose=\"fine-tune\" \\\n  -F file=\"@mydata.jsonl\"\n  -F expires_after[anchor]=\"created_at\"\n  -F expires_after[seconds]=2592000\n\n```\n\n#### Response\n\n```json\n{\n  \"id\": \"file-abc123\",\n  \"object\": \"file\",\n  \"bytes\": 120000,\n  \"created_at\": 1677610602,\n  \"expires_at\": 1677614202,\n  \"filename\": \"mydata.jsonl\",\n  \"purpose\": \"fine-tune\",\n}\n\n```\n\n## Delete file\n\ndelete `/files/{file_id}`\n\nDelete a file and remove it from all vector stores.\n\n### Path Parameters\n\n- `file_id: string`\n\n### Returns\n\n- `FileDeleted object { id, deleted, object }``id: string``deleted: boolean``object: \"file\"``\"file\"`\n\n### Example\n\n```http\ncurl https://api.openai.com/v1/files/$FILE_ID \\\n    -X DELETE \\\n    -H \"Authorization: Bearer $OPENAI_API_KEY\"\n\n```\n\n#### Response\n\n```json\n{\n  \"id\": \"id\",\n  \"deleted\": true,\n  \"object\": \"file\"\n}\n\n```\n\n### Example\n\n```http\ncurl https://api.openai.com/v1/files/file-abc123 \\\n  -X DELETE \\\n  -H \"Authorization: Bearer $OPENAI_API_KEY\"\n\n```\n\n#### Response\n\n```json\n{\n  \"id\": \"file-abc123\",\n  \"object\": \"file\",\n  \"deleted\": true\n}\n\n```\n\n## Retrieve file\n\nget `/files/{file_id}`\n\nReturns information about a specific file.\n\n### Path Parameters\n\n- `file_id: string`\n\n### Returns\n\n- `FileObject object { id, bytes, created_at, 6 more }` The `File` object represents a document that has been uploaded to OpenAI.`id: string` The file identifier, which can be referenced in the API endpoints.`bytes: number` The size of the file, in bytes.`created_at: number` The Unix timestamp (in seconds) for when the file was created.`filename: string` The name of the file.`object: \"file\"` The object type, which is always `file`.`\"file\"``purpose: \"assistants\" or \"assistants_output\" or \"batch\" or 5 more` The intended purpose of the file. Supported values are `assistants`, `assistants_output`, `batch`, `batch_output`, `fine-tune`, `fine-tune-results`, `vision`, and `user_data`.`\"assistants\"``\"assistants_output\"``\"batch\"``\"batch_output\"``\"fine-tune\"``\"fine-tune-results\"``\"vision\"``\"user_data\"``status: \"uploaded\" or \"processed\" or \"error\"` Deprecated. The current status of the file, which can be either `uploaded`, `processed`, or `error`.`\"uploaded\"``\"processed\"``\"error\"``expires_at: optional number` The Unix timestamp (in seconds) for when the file will expire.`status_details: optional string` Deprecated. For details on why a fine-tuning training file failed validation, see the `error` field on `fine_tuning.job`.\n\n### Example\n\n```http\ncurl https://api.openai.com/v1/files/$FILE_ID \\\n    -H \"Authorization: Bearer $OPENAI_API_KEY\"\n\n```\n\n#### Response\n\n```json\n{\n  \"id\": \"id\",\n  \"bytes\": 0,\n  \"created_at\": 0,\n  \"filename\": \"filename\",\n  \"object\": \"file\",\n  \"purpose\": \"assistants\",\n  \"status\": \"uploaded\",\n  \"expires_at\": 0,\n  \"status_details\": \"status_details\"\n}\n\n```\n\n### Example\n\n```http\ncurl https://api.openai.com/v1/files/file-abc123 \\\n  -H \"Authorization: Bearer $OPENAI_API_KEY\"\n\n```\n\n#### Response\n\n```json\n{\n  \"id\": \"file-abc123\",\n  \"object\": \"file\",\n  \"bytes\": 120000,\n  \"created_at\": 1677610602,\n  \"expires_at\": 1677614202,\n  \"filename\": \"mydata.jsonl\",\n  \"purpose\": \"fine-tune\",\n}\n\n```\n\n## Retrieve file content\n\nget `/files/{file_id}/content`\n\nReturns the contents of the specified file.\n\n### Path Parameters\n\n- `file_id: string`\n\n### Example\n\n```http\ncurl https://api.openai.com/v1/files/$FILE_ID/content \\\n    -H \"Authorization: Bearer $OPENAI_API_KEY\"\n\n```\n\n### Example\n\n```http\ncurl https://api.openai.com/v1/files/file-abc123/content \\\n  -H \"Authorization: Bearer $OPENAI_API_KEY\" > file.jsonl\n\n```\n\n## Domain Types\n\n### File Content\n\n- `FileContent = string`\n\n### File Deleted\n\n- `FileDeleted object { id, deleted, object }``id: string``deleted: boolean``object: \"file\"``\"file\"`\n\n### File Object\n\n- `FileObject object { id, bytes, created_at, 6 more }` The `File` object represents a document that has been uploaded to OpenAI.`id: string` The file identifier, which can be referenced in the API endpoints.`bytes: number` The size of the file, in bytes.`created_at: number` The Unix timestamp (in seconds) for when the file was created.`filename: string` The name of the file.`object: \"file\"` The object type, which is always `file`.`\"file\"``purpose: \"assistants\" or \"assistants_output\" or \"batch\" or 5 more` The intended purpose of the file. Supported values are `assistants`, `assistants_output`, `batch`, `batch_output`, `fine-tune`, `fine-tune-results`, `vision`, and `user_data`.`\"assistants\"``\"assistants_output\"``\"batch\"``\"batch_output\"``\"fine-tune\"``\"fine-tune-results\"``\"vision\"``\"user_data\"``status: \"uploaded\" or \"processed\" or \"error\"` Deprecated. The current status of the file, which can be either `uploaded`, `processed`, or `error`.`\"uploaded\"``\"processed\"``\"error\"``expires_at: optional number` The Unix timestamp (in seconds) for when the file will expire.`status_details: optional string` Deprecated. For details on why a fine-tuning training file failed validation, see the `error` field on `fine_tuning.job`.",
        "image": "https://developers.openai.com/OpenAI_Developers.svg",
        "favicon": "https://developers.openai.com/favicon.svg"
      },
      {
        "id": "https://developers.openai.com/api/reference/resources/files/methods/create/",
        "title": "Upload file | OpenAI API Reference",
        "url": "https://developers.openai.com/api/reference/resources/files/methods/create/",
        "text": "## Upload file\n\npost `/files`\n\nUpload a file that can be used across various endpoints. Individual files\ncan be up to 512 MB, and each project can store up to 2.5 TB of files in\ntotal. There is no organization-wide storage limit. Uploads to this\nendpoint are rate-limited to 1,000 requests per minute per authenticated\nuser.\n\n- The Assistants API supports files up to 2 million tokens and of specific\nfile types. See the Assistants Tools guide for\ndetails.\n- The Fine-tuning API only supports `.jsonl` files. The input also has\ncertain required formats for fine-tuning\nchat or\ncompletions models.\n- The Batch API only supports `.jsonl` files up to 200 MB in size. The input\nalso has a specific required\nformat.\n- For Retrieval or `file_search` ingestion, upload files here first. If\nyou need to attach multiple uploaded files to the same vector store, use\n`/vector_stores/{vector_store_id}/file_batches`\ninstead of attaching them one by one. Vector store attachment has separate\nlimits from file upload, including 2,000 attached files per minute per\norganization.\n\nPlease contact us if you need to increase these\nstorage limits.\n\n### Returns\n\n- `FileObject object { id, bytes, created_at, 6 more }` The `File` object represents a document that has been uploaded to OpenAI.`id: string` The file identifier, which can be referenced in the API endpoints.`bytes: number` The size of the file, in bytes.`created_at: number` The Unix timestamp (in seconds) for when the file was created.`filename: string` The name of the file.`object: \"file\"` The object type, which is always `file`.`\"file\"``purpose: \"assistants\" or \"assistants_output\" or \"batch\" or 5 more` The intended purpose of the file. Supported values are `assistants`, `assistants_output`, `batch`, `batch_output`, `fine-tune`, `fine-tune-results`, `vision`, and `user_data`.`\"assistants\"``\"assistants_output\"``\"batch\"``\"batch_output\"``\"fine-tune\"``\"fine-tune-results\"``\"vision\"``\"user_data\"``status: \"uploaded\" or \"processed\" or \"error\"` Deprecated. The current status of the file, which can be either `uploaded`, `processed`, or `error`.`\"uploaded\"``\"processed\"``\"error\"``expires_at: optional number` The Unix timestamp (in seconds) for when the file will expire.`status_details: optional string` Deprecated. For details on why a fine-tuning training file failed validation, see the `error` field on `fine_tuning.job`.\n\n### Example\n\n```http\ncurl https://api.openai.com/v1/files \\\n    -H 'Content-Type: multipart/form-data' \\\n    -H \"Authorization: Bearer $OPENAI_API_KEY\" \\\n    -F 'file=@/path/to/file' \\\n    -F purpose=assistants\n\n```\n\n#### Response\n\n```json\n{\n  \"id\": \"id\",\n  \"bytes\": 0,\n  \"created_at\": 0,\n  \"filename\": \"filename\",\n  \"object\": \"file\",\n  \"purpose\": \"assistants\",\n  \"status\": \"uploaded\",\n  \"expires_at\": 0,\n  \"status_details\": \"status_details\"\n}\n\n```\n\n### Example\n\n```http\ncurl https://api.openai.com/v1/files \\\n  -H \"Authorization: Bearer $OPENAI_API_KEY\" \\\n  -F purpose=\"fine-tune\" \\\n  -F file=\"@mydata.jsonl\"\n  -F expires_after[anchor]=\"created_at\"\n  -F expires_after[seconds]=2592000\n\n```\n\n#### Response\n\n```json\n{\n  \"id\": \"file-abc123\",\n  \"object\": \"file\",\n  \"bytes\": 120000,\n  \"created_at\": 1677610602,\n  \"expires_at\": 1677614202,\n  \"filename\": \"mydata.jsonl\",\n  \"purpose\": \"fine-tune\",\n}\n\n```",
        "image": "https://developers.openai.com/OpenAI_Developers.svg",
        "favicon": "https://developers.openai.com/favicon.svg"
      },
      {
        "id": "https://help.openai.com/en/articles/8555545",
        "title": "File Uploads FAQ | OpenAI Help Center",
        "url": "https://help.openai.com/en/articles/8555545",
        "text": "File Uploads FAQ | OpenAI Help Center\n\nWe\u2019re currently experiencing issues\n\nPlease see https://status.openai.com for updates\n\nDismiss\n\nEnglish\n\n# File Uploads FAQ\n\nFile Uploads FAQ\n\nUpdated: 19 days ago\n\n## About file uploads\n\nChatGPT can work with documents, spreadsheets, presentations, and other supported files you upload in a conversation.\n\n## Availability\n\nFile uploads are available on Free and paid ChatGPT plans, subject to plan-specific usage limits and account settings, on the web and in supported mobile apps. File uploads are also available through the API for supported API features, with separate API requirements, supported purposes, and limits.\n\n## How does the new file uploads capability work?\n\nThe file uploads capability was created to support the following tasks:Synthesis: Combining or analyzing information from files and documents to create something new, for example:\n\nUpload a spreadsheet, for example a CSV, with a mix of qualitative and quantitative information, and ask ChatGPT to help you understand and visualize the data.\n\nCompare and contrast two documents.\n\nAnalyze sentiment or tone in a document.\n\nAnalyze a spreadsheet.\n\nApply a framework or rubric from one document to the contents of another.\n\nTransformation: Reshaping information from documents without changing its essence, for example:\n\nUpload a complicated research paper and ask ChatGPT to provide a simple summary.\n\nUpload a PowerPoint presentation and ask ChatGPT for feedback on the content.\n\nSummarize a document in simple terms.\n\nRewrite a short document in a particular style.\n\nTurn a presentation into a document.\n\nExtraction: Pulling specific information out of a document, for example:\n\nUpload a PDF and have ChatGPT find any references to a certain topic.\n\nPull out relevant quotes from a document.\n\nSearch for any mention of a particular topic from a document or spreadsheet.\n\nExtract metadata (author, creation date, etc.) from a document.\n\nCount the number of rows in a spreadsheet that contain a certain attribute.\n\nExtract specific sections of a document (e.g., all headings or all bullet-point lists).\n\n## What types of files are supported?\n\nAll common file extensions for text files, spreadsheets, presentations, and documents.\n\n## How many files can I upload at once per GPT?\n\nUp to 10 files per GPT for the lifetime of that GPT. Keep in mind there are file size restrictions and usage caps per user/org.\n\n## What are the file upload size restrictions?\n\nAll files uploaded to a GPT or a ChatGPT conversation have a hard limit of 512MB per file.\n\nAll text and document files uploaded to a GPT or to a ChatGPT conversation are capped at 2M tokens per file. This limitation does not apply to spreadsheets.\n\nFor CSV files or spreadsheets, the file size cannot exceed approximately 50MB, depending on the size of each row.\n\nFor images, there's a limit of 20MB per image.\n\nAdditionally, there are usage caps:\n\nEach end-user is capped at 25GB.\n\nEach organization is capped at 100GB.\n\nNote: An error will be displayed if a user/org cap has been hit.\n\nUsers can upload up to 80 files every 3 hours. Free users are limited to 3 file uploads per day. Note that we may lower these limits during peak hours.Troubleshooting \u201cupload limit reached\u201dIf you see an \u201cupload limit reached\u201d message despite few or no recent uploads, try the steps below:\n\nConfirm you\u2019re signed into the correct account and subscription plan.\n\nRemember there are two kinds of limits: a rolling upload rate (e.g., up to 80 files per 3 hours) and shared storage caps (25 GB per user / 100 GB per org) that apply across chats, Projects, and custom GPT knowledge.\n\nFailed upload attempts can sometimes count toward the upload-rate cap.\n\nCheck status.openai.com for incidents that may affect uploads.\n\nTo escalate, include your account email, a screenshot, the timestamp and timezone, the platform/app/browser you used, and the request ID (if available).\n\nCurrently, you can check your Library storage usage in ChatGPT under Settings > Storage. ChatGPT does not currently show how much of your rolling upload-rate quota has been used or how much remains.Additionally, to help ensure a smooth experience for all users, we've also updated the file upload limits for Projects based on subscription plan.\n\nPlus: Up to 20 files per project\n\nPro, Team, Education, Business: Up to 40 files per project\n\n## How do I delete files I upload?\n\nFiles uploaded to Advanced Data Analysis are deleted within a duration that varies based on your plan. If you are encountering your file usage cap, you can also delete files from recent chats or from any GPTs that you built, as these share caps.\n\n## How are files vs chats retained?\n\nChats\n\nChats are saved in your account until you delete them. To learn more about data controls, see: Data Controls FAQ.\n\nOnce you delete a chat or delete your account, chats are deleted from our systems within 30 days, unless they have previously been de-identified and disassociated from your account, or we have to keep them for security or legal reasons.\n\nFiles\n\nFiles uploaded to ChatGPT are saved in your account up to the retention period of the corresponding chat. Files uploaded as knowledge to a custom GPT are retained until you delete the custom GPT.\n\nOnce you delete a chat containing a file, your account, or a custom GPT, the associated file is deleted from our systems within 30 days, unless it has previously been de-identified and disassociated from your account, or we have to keep it for security or legal reasons.\n\nFiles processed via ADA / Document Analysis, and when chatting with a custom GPT (not uploaded as knowledge in GPT config): Retained for a duration that varies based on your plan.\n\nFor more information about file and chat retention, see: Chat and File Retention Policies in ChatGPT.\n\n## Are you able to handle images embedded in docs/presentations/PDF?\n\nThe answer depends on your plan and the file type you're working with.ChatGPT Enterprise supports Visual Retrieval for PDF files. To learn more about PDF visual retrieval, see: Visual Retrieval with PDFs FAQ.All other plans and document files only support text-based retrieval. This means that ChatGPT will extract digital text from the file and discard any images.\n\n## Will OpenAI use files uploaded to train its models?\n\nThe answer depends on the service you are using. For more information about data usage for consumer services, see: Data Usage for Consumer Services FAQ. Content may include files that are uploaded. To learn more about how content may be used to improve model performance and the choices you have, see: How your data is used to improve model performance.Please note that we do not use content submitted by customers to our business offerings such as our API and ChatGPT Enterprise to improve model performance.Please see our Enterprise Privacy page for information on how we use business data.\n\n## Need more help? Contact us for product questions, account support and general troubleshooting.\n\nAI Chat\n\nChat now\n\nAI Phone Call\n\nCalls may be recorded to improve OpenAI services. If you wish to report content, please use the in-app reporting or the Report Content Form. Learn more.\n\n## Related articles\n\n- How does the new file uploads capability work?How does file uploading help? What can I do with it?\n- Using Codex with your ChatGPT planHow to access and get started with Codex\n- ChatGPT Capabilities OverviewLearn about ChatGPT's capabilities and features\n\n## Was this article helpful?\n\nSubmit",
        "image": "https://help.openai.com/og-image.png",
        "favicon": "https://help.openai.com/favicon.png"
      },
      {
        "id": "https://developers.openai.com/api/reference/go/resources/files/methods/create/",
        "title": "Upload file | OpenAI API Reference",
        "url": "https://developers.openai.com/api/reference/go/resources/files/methods/create/",
        "text": "Upload file | OpenAI API Reference\n\n# Upload file\n\nclient.Files. New(ctx, body) (* FileObject, error)\n\nPOST/files\n\nUpload a file that can be used across various endpoints. Individual files can be up to 512 MB, and each project can store up to 2.5 TB of files in total. There is no organization-wide storage limit. Uploads to this endpoint are rate-limited to 1,000 requests per minute per authenticated user.\n\n- The Assistants API supports files up to 2 million tokens and of specific file types. See the Assistants Tools guide for details.\n- The Fine-tuning API only supports `.jsonl` files. The input also has certain required formats for fine-tuning chat or completions models.\n- The Batch API only supports `.jsonl` files up to 200 MB in size. The input also has a specific required format.\n- For Retrieval or `file_search` ingestion, upload files here first. If you need to attach multiple uploaded files to the same vector store, use `/vector_stores/{vector_store_id}/file_batches` instead of attaching them one by one. Vector store attachment has separate limits from file upload, including 2,000 attached files per minute per organization.\n\nPlease contact us if you need to increase these storage limits.\n\n##### Parameters Expand Collapse \n\nbody FileNewParams\n\nFile param.Field [Reader]\n\nThe File object (not file name) to be uploaded.\n\nPurpose param.Field [FilePurpose]\n\nThe intended purpose of the uploaded file. One of:\n\n- `assistants`: Used in the Assistants API\n- `batch`: Used in the Batch API\n- `fine-tune`: Used for fine-tuning\n- `vision`: Images used for vision fine-tuning\n- `user_data`: Flexible file type for any purpose\n- `evals`: Used for eval data sets\n\nExpiresAfter param.Field [FileNewParamsExpiresAfter] Optional The expiration policy for a file. By default, files with `purpose=batch` expire after 30 days and all other files are persisted until they are manually deleted.\n\n View schema details \n\n##### Returns Expand Collapse \n\ntype FileObject struct{\u2026} The `File` object represents a document that has been uploaded to OpenAI.\n\nID string\n\nThe file identifier, which can be referenced in the API endpoints.\n\nBytes int64\n\nThe size of the file, in bytes.\n\nCreatedAt int64\n\nThe Unix timestamp (in seconds) for when the file was created.\n\nformat unixtime\n\nFilename string\n\nThe name of the file.\n\nObject File\n\nThe object type, which is always `file`.\n\nPurpose FileObjectPurpose The intended purpose of the file. Supported values are `assistants`, `assistants_output`, `batch`, `batch_output`, `fine-tune`, `fine-tune-results`, `vision`, and `user_data`.\n\n View schema details \n\nDeprecated Status FileObjectStatus Deprecated. The current status of the file, which can be either `uploaded`, `processed`, or `error`.\n\n View schema details \n\nExpiresAt int64 Optional\n\nThe Unix timestamp (in seconds) for when the file will expire.\n\nformat unixtime\n\nDeprecated StatusDetails string Optional\n\nDeprecated. For details on why a fine-tuning training file failed validation, see the `error` field on `fine_tuning.job`.\n\n### Upload file\n\n```\npackage main\n\nimport (\n  \"bytes\"\n  \"context\"\n  \"fmt\"\n  \"io\"\n\n  \"github.com/openai/openai-go\"\n  \"github.com/openai/openai-go/option\"\n)\n\nfunc main() {\n  client := openai.NewClient(\n    option.WithAPIKey(\"My API Key\"),\n  )\n  fileObject, err := client.Files.New(context.TODO(), openai.FileNewParams{\n    File: io.Reader(bytes.NewBuffer([]byte(\"Example data\"))),\n    Purpose: openai.FilePurposeAssistants,\n  })\n  if err != nil {\n    panic(err.Error())\n  }\n  fmt.Printf(\"%+v\\n\", fileObject.ID)\n}\n\n```\n\n```\n{\n  \"id\": \"file-abc123\",\n  \"object\": \"file\",\n  \"bytes\": 120000,\n  \"created_at\": 1677610602,\n  \"expires_at\": 1677614202,\n  \"filename\": \"mydata.jsonl\",\n  \"purpose\": \"fine-tune\",\n}\n\n```\n\n```\n{\n  \"id\": \"file-abc123\",\n  \"object\": \"file\",\n  \"bytes\": 120000,\n  \"created_at\": 1677610602,\n  \"expires_at\": 1677614202,\n  \"filename\": \"mydata.jsonl\",\n  \"purpose\": \"fine-tune\",\n}\n\n```"
      },
      {
        "id": "https://github.com/openai/openai-python/blob/main/src/openai/resources/files.py",
        "title": "src/openai/resources/files.py at main \u00b7 openai/openai-python",
        "url": "https://github.com/openai/openai-python/blob/main/src/openai/resources/files.py",
        "text": "# src/openai/resources/files.py\n\n- Branch: main\n- Repository: openai/openai-python\n\n---\n\n# File generated from our OpenAPI spec by Castiron. See CONTRIBUTING.md for details.\n\nfrom __future__ import annotations\n\nimport typing_extensions\nfrom typing import Mapping, cast\nfrom typing_extensions import Literal\n\nimport httpx2\n\nfrom .. import _legacy_response\nfrom ..types import FilePurpose, file_list_params, file_create_params\nfrom .._files import deepcopy_with_paths\nfrom .._types import Body, Omit, Query, Headers, NotGiven, FileTypes, omit, not_given\nfrom .._utils import extract_files, path_template, maybe_transform, async_maybe_transform\nfrom .._compat import cached_property\nfrom .._resource import SyncAPIResource, AsyncAPIResource\nfrom .._response import (\n StreamedBinaryAPIResponse,\n AsyncStreamedBinaryAPIResponse,\n to_streamed_response_wrapper,\n async_to_streamed_response_wrapper,\n to_custom_streamed_response_wrapper,\n async_to_custom_streamed_response_wrapper,\n)\nfrom ..lib._files import (\n wait_for_file_processing as _wait_for_file_processing,\n async_wait_for_file_processing as _async_wait_for_file_processing,\n)\nfrom ..pagination import SyncCursorPage, AsyncCursorPage\nfrom .._base_client import AsyncPaginator, make_request_options\nfrom ..types.file_object import FileObject\nfrom ..types.file_deleted import FileDeleted\nfrom ..types.file_purpose import FilePurpose\n\n__all__ = [\"Files\", \"AsyncFiles\"]\n\nclass Files(SyncAPIResource):\n \"\"\"\n Files are used to upload documents that can be used with features like Assistants and Fine-tuning.\n \"\"\"\n\n @cached_property\n def with_raw_response(self) -> FilesWithRawResponse:\n \"\"\"\n This property can be used as a prefix for any HTTP method call to return\n the raw response object instead of the parsed content.\n\n For more information, see https://www.github.com/openai/openai-python#accessing-raw-response-data-eg-headers\n \"\"\"\n return FilesWithRawResponse(self)\n\n @cached_property\n def with_streaming_response(self) -> FilesWithStreamingResponse:\n \"\"\"\n An alternative to `.with_raw_response` that doesn't eagerly read the response body.\n\n For more information, see https://www.github.com/openai/openai-python#with_streaming_response\n \"\"\"\n return FilesWithStreamingResponse(self)\n\n def create(\n self,\n *,\n file: FileTypes,\n purpose: FilePurpose,\n expires_after: file_create_params.ExpiresAfter | Omit = omit,\n # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.\n # The extra values given here take precedence over values defined on the client or passed to this method.\n extra_headers: Headers | None = None,\n extra_query: Query | None = None,\n extra_body: Body | None = None,\n timeout: float | httpx2.Timeout | None | NotGiven = not_given,\n ) -> FileObject:\n \"\"\"Upload a file that can be used across various endpoints.\n\n Individual files can be\n up to 512 MB, and each project can store up to 2.5 TB of files in total. There\n is no organization-wide storage limit. Uploads to this endpoint are rate-limited\n to 1,000 requests per minute per authenticated user.\n\n - The Assistants API supports files up to 2 million tokens and of specific file\n types. See the\n Assistants Tools guide\n for details.\n - The Fine-tuning API only supports `.jsonl` files. The input also has certain\n required formats for fine-tuning\n chat\n or\n completions\n models.\n - The Batch API only supports `.jsonl` files up to 200 MB in size. The input\n also has a specific required\n format.\n - For Retrieval or `file_search` ingestion, upload files here first. If you need\n to attach multiple uploaded files to the same vector store, use\n `/vector_stores/{vector_store_id}/file_batches`\n instead of attaching them one by one. Vector store attachment has separate\n limits from file upload, including 2,000 attached files per minute per\n organization.\n\n Please contact us if you need to increase these\n storage limits.\n\n Args:\n file: The File object (not file name) to be uploaded.\n\n purpose:\n The intended purpose of the uploaded file. One of:\n\n - `assistants`: Used in the Assistants API\n - `batch`: Used in the Batch API\n - `fine-tune`: Used for fine-tuning\n - `vision`: Images used for vision fine-tuning\n - `user_data`: Flexible file type for any purpose\n - `evals`: Used for eval data sets\n\n expires_after: The expiration policy for a file. By default, files with `purpose=batch` expire\n after 30 days and all other files are persisted until they are manually deleted.\n\n extra_headers: Send extra headers\n\n extra_query: Add additional query parameters to the request\n\n extra_body: Add additional JSON properties to the request\n\n timeout: Override the client-level default timeout for this request, in seconds\n \"\"\"\n body = deepcopy_with_paths(\n {\n \"file\": file,\n \"purpose\": purpose,\n \"expires_after\": expires_after,\n },\n [[\"file\"]],\n )\n files = extract_files(cast(Mapping[str, object], body), paths=[[\"file\"]])\n # It should be noted that the actual Content-Type header that will be\n # sent to the server will contain a `boundary` parameter, e.g.\n # multipart/form-data; boundary=---abc--\n extra_headers = {\"Content-Type\": \"multipart/form-data\", **(extra_headers or {})}\n return self._post(\n \"/files\",\n body=maybe_transform(body, file_create_params.FileCreateParams),\n files=files,\n options=make_request_options(\n extra_headers=extra_headers,\n extra_query=extra_query,\n extra_body=extra_body,\n timeout=timeout,\n security={\"bearer_auth\": True},\n ),\n cast_to=FileObject,\n )\n\n def retrieve(\n self,\n file_id: str,\n *,\n # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.\n # The extra values given here take precedence over values defined on the client or passed to this method.\n extra_headers: Headers | None = None,\n extra_query: Query | None = None,\n extra_body: Body | None = None,\n timeout: float | httpx2.Timeout | None | NotGiven = not_given,\n ) -> FileObject:\n \"\"\"\n Returns information about a specific file.\n\n Args:\n extra_headers: Send extra headers\n\n extra_query: Add additional query parameters to the request\n\n extra_body: Add additional JSON properties to the request\n\n timeout: Override the client-level default timeout for this request, in seconds\n \"\"\"\n if not file_id:\n raise ValueError(f\"Expected a non-empty value for `file_id` but received {file_id!r}\")\n return self._get(\n path_template(\"/files/{file_id}\", file_id=file_id),\n options=make_request_options(\n extra_headers=extra_headers,\n extra_query=extra_query,\n extra_body=extra_body,\n timeout=timeout,\n security={\"bearer_auth\": True},\n ),\n cast_to=FileObject,\n )\n\n def list(\n self,\n *,\n after: str | Omit = omit,\n limit: int | Omit = omit,\n order: Literal[\"asc\", \"desc\"] | Omit = omit,\n purpose: str | Omit = omit,\n # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.\n # The extra values given here take precedence over values defined on the client or passed to this method.\n extra_headers: Headers | None = None,\n extra_query: Query | None = None,\n extra_body: Body | None = None,\n timeout: float | httpx2.Timeout | None | NotGiven = not_given,\n ) -> SyncCursorPage[FileObject]:\n \"\"\"Returns a list of files.\n\n Args:\n after: A cursor for use in pagination.\n\n `after` is an object ID that defines your place\n in the list. For instance, if you make a list request and receive 100 objects,\n ending with obj_foo, your subsequent call can include after=obj_foo in order to\n fetch the next page of the list.\n\n limit: A limit on the number of objects to be returned. Limit can range between 1 and\n 10,000, and the default is 10,000.\n\n order: Sort order by the `created_at` timestamp of the objects. `asc` for ascending\n order and `desc` for descending order.\n\n purpose: Only return files with the given purpose.\n\n extra_headers: Send extra headers\n\n extra_query: Add additional query parameters to the request\n\n extra_body: Add additional JSON properties to the request\n\n timeout: Override the client-level default timeout for this request, in seconds\n \"\"\"\n return self._get_api_list(\n \"/files\",\n page=SyncCursorPage[FileObject],\n options=make_request_options(\n extra_headers=extra_headers,\n extra_query=extra_query,\n extra_body=extra_body,\n timeout=timeout,\n query=maybe_transform(\n {\n \"after\": after,\n \"limit\": limit,\n \"order\": order,\n \"purpose\": purpose,\n },\n file_list_params.FileListParams,\n ),\n security={\"bearer_auth\": True},\n ),\n model=FileObject,\n )\n\n def delete(\n self,\n file_id: str,\n *,\n # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.\n # The extra values given here take precedence over values defined on the client or passed to this method.\n extra_headers: Headers | None = None,\n extra_query: Query | None = None,\n extra_body: Body | None = None,\n timeout: float | httpx2.Timeout | None | NotGiven = not_given,\n ) -> FileDeleted:\n \"\"\"\n Delete a file and remove it from all vector stores.\n\n Args:\n extra_headers: Send extra headers\n\n extra_query: Add additional query parameters to the request\n\n extra_body: Add additional JSON properties to the request\n\n timeout: Override the client-level default timeout for this request, in seconds\n \"\"\"\n if not file_id:\n raise ValueError(f\"Expected a non-empty value for `file_id` but received {file_id!r}\")\n return self._delete(\n path_template(\"/files/{file_id}\", file_id=file_id),\n options=make_request_options(\n extra_headers=extra_headers,\n extra_query=extra_query,\n extra_body=extra_body,\n timeout=timeout,\n security={\"bearer_auth\": True},\n ),\n cast_to=FileDeleted,\n )\n\n def content(\n self,\n file_id: str,\n *,\n # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.\n # The extra values given here take precedence over values defined on the client or passed to this method.\n extra_headers: Headers | None = None,\n extra_query: Query | None = None,\n extra_body: Body | None = None,\n timeout: float | httpx2.Timeout | None | NotGiven = not_given,\n ) -> _legacy_response.HttpxBinaryResponseContent:\n \"\"\"\n Returns a response containing the contents of the specified file.\n\n Args:\n extra_headers: Send extra headers\n\n extra_query: Add additional query parameters to the request\n\n extra_body: Add additional JSON properties to the request\n\n timeout: Override the client-level default timeout for this request, in seconds\n \"\"\"\n if not file_id:\n raise ValueError(f\"Expected a non-empty value for `file_id` but received {file_id!r}\")\n extra_headers = {\"Accept\": \"application/binary\", **(extra_headers or {})}\n return self._get(\n path_template(\"/files/{file_id}/content\", file_id=file_id),\n options=make_request_options(\n extra_headers=extra_headers,\n extra_query=extra_query,\n extra_body=extra_body,\n timeout=timeout,\n security={\"bearer_auth\": True},\n ),\n cast_to=_legacy_response.HttpxBinaryResponseContent,\n )\n\n @typing_extensions.deprecated(\"The `.content()` method should be used instead\")\n def retrieve_content(\n self,\n file_id: str,\n *,\n # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.\n # The extra values given here take precedence over values defined on the client or passed to this method.\n extra_headers: Headers | None = None,\n extra_query: Query | None = None,\n extra_body: Body | None = None,\n timeout: float | httpx2.Timeout | None | NotGiven = not_given,\n ) -> str:\n \"\"\"\n Returns a response containing the contents of the specified file.\n\n Args:\n extra_headers: Send extra headers\n\n extra_query: Add additional query parameters to the request\n\n extra_body: Add additional JSON properties to the request\n\n timeout: Override the client-level default timeout for this request, in seconds\n \"\"\"\n if not file_id:\n raise ValueError(f\"Expected a non-empty value for `file_id` but received {file_id!r}\")\n return self._get(\n path_template(\"/files/{file_id}/content\", file_id=file_id),\n options=make_request_options(\n extra_headers=extra_headers,\n extra_query=extra_query,\n extra_body=extra_body,\n timeout=timeout,\n security={\"bearer_auth\": True},\n ),\n cast_to=str,\n )\n\n def wait_for_processing(\n self,\n id: str,\n *,\n poll_interval: float = 5.0,\n max_wait_seconds: float = 30 * 60,\n ) -> FileObject:\n \"\"\"Waits for the given file to be processed, default timeout is 30 mins.\"\"\"\n return _wait_for_file_processing(self, id, poll_interval=poll_interval, max_wait_seconds=max_wait_seconds)\n\nclass AsyncFiles(AsyncAPIResource):\n \"\"\"\n Files are used to upload documents that can be used with features like Assistants and Fine-tuning.\n \"\"\"\n\n @cached_property\n def with_raw_response(self) -> AsyncFilesWithRawResponse:\n \"\"\"\n This property can be used as a prefix for any HTTP method call to return\n the raw response object instead of the parsed content.\n\n For more information, see https://www.github.com/openai/openai-python#accessing-raw-response-data-eg-headers\n \"\"\"\n return AsyncFilesWithRawResponse(self)\n\n @cached_property\n def with_streaming_response(self) -> AsyncFilesWithStreamingResponse:\n \"\"\"\n An alternative to `.with_raw_response` that doesn't eagerly read the response body.\n\n For more information, see https://www.github.com/openai/openai-python#with_streaming_response\n \"\"\"\n return AsyncFilesWithStreamingResponse(self)\n\n async def create(\n self,\n *,\n file: FileTypes,\n purpose: FilePurpose,\n expires_after: file_create_params.ExpiresAfter | Omit = omit,\n # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.\n # The extra values given here take precedence over values defined on the client or passed to this method.\n extra_headers: Headers | None = None,\n extra_query: Query | None = None,\n extra_body: Body | None = None,\n timeout: float | httpx2.Timeout | None | NotGiven = not_given,\n ) -> FileObject:\n \"\"\"Upload a file that can be used across various endpoints.\n\n Individual files can be\n up to 512 MB, and each project can store up to 2.5 TB of files in total. There\n is no organization-wide storage limit. Uploads to this endpoint are rate-limited\n to 1,000 requests per minute per authenticated user.\n\n - The Assistants API supports files up to 2 million tokens and of specific file\n types. See the\n Assistants Tools guide\n for details.\n - The Fine-tuning API only supports `.jsonl` files. The input also has certain\n required formats for fine-tuning\n chat\n or\n completions\n models.\n - The Batch API only supports `.jsonl` files up to 200 MB in size. The input\n also has a specific required\n format.\n - For Retrieval or `file_search` ingestion, upload files here first. If you need\n to attach multiple uploaded files to the same vector store, use\n `/vector_stores/{vector_store_id}/file_batches`\n instead of attaching them one by one. Vector store attachment has separate\n limits from file upload, including 2,000 attached files per minute per\n organization.\n\n Please contact us if you need to increase these\n storage limits.\n\n Args:\n file: The File object (not file name) to be uploaded.\n\n purpose:\n The intended purpose of the uploaded file. One of:\n\n - `assistants`: Used in the Assistants API\n - `batch`: Used in the Batch API\n - `fine-tune`: Used for fine-tuning\n - `vision`: Images used for vision fine-tuning\n - `user_data`: Flexible file type for any purpose\n - `evals`: Used for eval data sets\n\n expires_after: The expiration policy for a file. By default, files with `purpose=batch` expire\n after 30 days and all other files are persisted until they are manually deleted.\n\n extra_headers: Send extra headers\n\n extra_query: Add additional query parameters to the request\n\n extra_body: Add additional JSON properties to the request\n\n timeout: Override the client-level default timeout for this request, in seconds\n \"\"\"\n body = deepcopy_with_paths(\n {\n \"file\": file,\n \"purpose\": purpose,\n \"expires_after\": expires_after,\n },\n [[\"file\"]],\n )\n files = extract_files(cast(Mapping[str, object], body), paths=[[\"file\"]])\n # It should be noted that the actual Content-Type header that will be\n # sent to the server will contain a `boundary` parameter, e.g.\n # multipart/form-data; boundary=---abc--\n extra_headers = {\"Content-Type\": \"multipart/form-data\", **(extra_headers or {})}\n return await self._post(\n \"/files\",\n body=await async_maybe_transform(body, file_create_params.FileCreateParams),\n files=files,\n options=make_request_options(\n extra_headers=extra_headers,\n extra_query=extra_query,\n extra_body=extra_body,\n timeout=timeout,\n security={\"bearer_auth\": True},\n ),\n cast_to=FileObject,\n )\n\n async def retrieve(\n self,\n file_id: str,\n *,\n # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.\n # The extra values given here take precedence over values defined on the client or passed to this method.\n extra_headers: Headers | None = None,\n extra_query: Query | None = None,\n extra_body: Body | None = None,\n timeout: float | httpx2.Timeout | None | NotGiven = not_given,\n ) -> FileObject:\n \"\"\"\n Returns information about a specific file.\n\n Args:\n extra_headers: Send extra headers\n\n extra_query: Add additional query parameters to the request\n\n extra_body: Add additional JSON properties to the request\n\n timeout: Override the client-level default timeout for this request, in seconds\n \"\"\"\n if not file_id:\n raise ValueError(f\"Expected a non-empty value for `file_id` but received {file_id!r}\")\n return await self._get(\n path_template(\"/files/{file_id}\", file_id=file_id),\n options=make_request_options(\n extra_headers=extra_headers,\n extra_query=extra_query,\n extra_body=extra_body,\n timeout=timeout,\n security={\"bearer_auth\": True},\n ),\n cast_to=FileObject,\n )\n\n def list(\n self,\n *,\n after: str | Omit = omit,\n limit: int | Omit = omit,\n order: Literal[\"asc\", \"desc\"] | Omit = omit,\n purpose: str | Omit = omit,\n # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.\n # The extra values given here take precedence over values defined on the client or passed to this method.\n extra_headers: Headers | None = None,\n extra_query: Query | None = None,\n extra_body: Body | None = None,\n timeout: float | httpx2.Timeout | None | NotGiven = not_given,\n ) -> AsyncPaginator[FileObject, AsyncCursorPage[FileObject]]:\n \"\"\"Returns a list of files.\n\n Args:\n after: A cursor for use in pagination.\n\n `after` is an object ID that defines your place\n in the list. For instance, if you make a list request and receive 100 objects,\n ending with obj_foo, your subsequent call can include after=obj_foo in order to\n fetch the next page of the list.\n\n limit: A limit on the number of objects to be returned. Limit can range between 1 and\n 10,000, and the default is 10,000.\n\n order: Sort order by the `created_at` timestamp of the objects. `asc` for ascending\n order and `desc` for descending order.\n\n purpose: Only return files with the given purpose.\n\n extra_headers: Send extra headers\n\n extra_query: Add additional query parameters to the request\n\n extra_body: Add additional JSON properties to the request\n\n timeout: Override the client-level default timeout for this request, in seconds\n \"\"\"\n return self._get_api_list(\n \"/files\",\n page=AsyncCursorPage[FileObject],\n options=make_request_options(\n extra_headers=extra_headers,\n extra_query=extra_query,\n extra_body=extra_body,\n timeout=timeout,\n query=maybe_transform(\n {\n \"after\": after,\n \"limit\": limit,\n \"order\": order,\n \"purpose\": purpose,\n },\n file_list_params.FileListParams,\n ),\n security={\"bearer_auth\": True},\n ),\n model=FileObject,\n )\n\n async def delete(\n self,\n file_id: str,\n *,\n # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.\n # The extra values given here take precedence over values defined on the client or passed to this method.\n extra_headers: Headers | None = None,\n extra_query: Query | None = None,\n extra_body: Body | None = None,\n timeout: float | httpx2.Timeout | None | NotGiven = not_given,\n ) -> FileDeleted:\n \"\"\"\n Delete a file and remove it from all vector stores.\n\n Args:\n extra_headers: Send extra headers\n\n extra_query: Add additional query parameters to the request\n\n extra_body: Add additional JSON properties to the request\n\n timeout: Override the client-level default timeout for this request, in seconds\n \"\"\"\n if not file_id:\n raise ValueError(f\"Expected a non-empty value for `file_id` but received {file_id!r}\")\n return await self._delete(\n path_template(\"/files/{file_id}\", file_id=file_id),\n options=make_request_options(\n extra_headers=extra_headers,\n extra_query=extra_query,\n extra_body=extra_body,\n timeout=timeout,\n security={\"bearer_auth\": True},\n ),\n cast_to=FileDeleted,\n )\n\n async def content(\n self,\n file_id: str,\n *,\n # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.\n # The extra values given here take precedence over values defined on the client or passed to this method.\n extra_headers: Headers | None = None,\n extra_query: Query | None = None,\n extra_body: Body | None = None,\n timeout: float | httpx2.Timeout | None | NotGiven = not_given,\n ) -> _legacy_response.HttpxBinaryResponseContent:\n \"\"\"\n Returns a response containing the contents of the specified file.\n\n Args:\n extra_headers: Send extra headers\n\n extra_query: Add additional query parameters to the request\n\n extra_body: Add additional JSON properties to the request\n\n timeout: Override the client-level default timeout for this request, in seconds\n \"\"\"\n if not file_id:\n raise ValueError(f\"Expected a non-empty value for `file_id` but received {file_id!r}\")\n extra_headers = {\"Accept\": \"application/binary\", **(extra_headers or {})}\n return await self._get(\n path_template(\"/files/{file_id}/content\", file_id=file_id),\n options=make_request_options(\n extra_headers=extra_headers,\n extra_query=extra_query,\n extra_body=extra_body,\n timeout=timeout,\n security={\"bearer_auth\": True},\n ),\n cast_to=_legacy_response.HttpxBinaryResponseContent,\n )\n\n @typing_extensions.deprecated(\"The `.content()` method should be used instead\")\n async def retrieve_content(\n self,\n file_id: str,\n *,\n # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.\n # The extra values given here take precedence over values defined on the client or passed to this method.\n extra_headers: Headers | None = None,\n extra_query: Query | None = None,\n extra_body: Body | None = None,\n timeout: float | httpx2.Timeout | None | NotGiven = not_given,\n ) -> str:\n \"\"\"\n Returns a response containing the contents of the specified file.\n\n Args:\n extra_headers: Send extra headers\n\n extra_query: Add additional query parameters to the request\n\n extra_body: Add additional JSON properties to the request\n\n timeout: Override the client-level default timeout for this request, in seconds\n \"\"\"\n if not file_id:\n raise ValueError(f\"Expected a non-empty value for `file_id` but received {file_id!r}\")\n return await self._get(\n path_template(\"/files/{file_id}/content\", file_id=file_id),\n options=make_request_options(\n extra_headers=extra_headers,\n extra_query=extra_query,\n extra_body=extra_body,\n timeout=timeout,\n security={\"bearer_auth\": True},\n ),\n cast_to=str,\n )\n\n async def wait_for_processing(\n self,\n id: str,\n *,\n poll_interval: float = 5.0,\n max_wait_seconds: float = 30 * 60,\n ) -> FileObject:\n \"\"\"Waits for the given file to be processed, default timeout is 30 mins.\"\"\"\n return await _async_wait_for_file_processing(\n self, id, poll_interval=poll_interval, max_wait_seconds=max_wait_seconds\n )\n\nclass FilesWithRawResponse:\n def __init__(self, files: Files) -> None:\n self._files = files\n\n self.create = _legacy_response.to_raw_response_wrapper(\n files.create,\n )\n self.retrieve = _legacy_response.to_raw_response_wrapper(\n files.retrieve,\n )\n self.list = _legacy_response.to_raw_response_wrapper(\n files.list,\n )\n self.delete = _legacy_response.to_raw_response_wrapper(\n files.delete,\n )\n self.content = _legacy_response.to_raw_response_wrapper(\n files.content,\n )\n self.retrieve_content = ( # pyright: ignore[reportDeprecated]\n _legacy_response.to_raw_response_wrapper(\n files.retrieve_content, # pyright: ignore[reportDeprecated],\n )\n )\n\nclass AsyncFilesWithRawResponse:\n def __init__(self, files: AsyncFiles) -> None:\n self._files = files\n\n self.create = _legacy_response.async_to_raw_response_wrapper(\n files.create,\n )\n self.retrieve = _legacy_response.async_to_raw_response_wrapper(\n files.retrieve,\n )\n self.list = _legacy_response.async_to_raw_response_wrapper(\n files.list,\n )\n self.delete = _legacy_response.async_to_raw_response_wrapper(\n files.delete,\n )\n self.content = _legacy_response.async_to_raw_response_wrapper(\n files.content,\n )\n self.retrieve_content = ( # pyright: ignore[reportDeprecated]\n _legacy_response.async_to_raw_response_wrapper(\n files.retrieve_content, # pyright: ignore[reportDeprecated],\n )\n )\n\nclass FilesWithStreamingResponse:\n def __init__(self, files: Files) -> None:\n self._files = files\n\n self.create = to_streamed_response_wrapper(\n files.create,\n )\n self.retrieve = to_streamed_response_wrapper(\n files.retrieve,\n )\n self.list = to_streamed_response_wrapper(\n files.list,\n )\n self.delete = to_streamed_response_wrapper(\n files.delete,\n )\n self.content = to_custom_streamed_response_wrapper(\n files.content,\n StreamedBinaryAPIResponse,\n )\n self.retrieve_content = ( # pyright: ignore[reportDeprecated]\n to_streamed_response_wrapper(\n files.retrieve_content, # pyright: ignore[reportDeprecated],\n )\n )\n\nclass AsyncFilesWithStreamingResponse:\n def __init__(self, files: AsyncFiles) -> None:\n self._files = files\n\n self.create = async_to_streamed_response_wrapper(\n files.create,\n )\n self.retrieve = async_to_streamed_response_wrapper(\n files.retrieve,\n )\n self.list = async_to_streamed_response_wrapper(\n files.list,\n )\n self.delete = async_to_streamed_response_wrapper(\n files.delete,\n )\n self.content = async_to_custom_streamed_response_wrapper(\n files.content,\n AsyncStreamedBinaryAPIResponse,\n )\n self.retrieve_content = ( # pyright: ignore[reportDeprecated]\n async_to_streamed_response_wrapper(\n files.retrieve_content, # pyright: ignore[reportDeprecated],\n )\n )\n"
      },
      {
        "id": "https://github.com/openai/openai-node/blob/e228aaad/src/resources/files.ts",
        "title": "src/resources/files.ts at e228aaad \u00b7 openai/openai-node",
        "url": "https://github.com/openai/openai-node/blob/e228aaad/src/resources/files.ts",
        "text": "# src/resources/files.ts\n\n- Branch: e228aaad\n- Repository: openai/openai-node\n\n---\n\n// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.\n\nimport { APIResource } from '../core/resource';\nimport { APIPromise } from '../core/api-promise';\nimport { CursorPage, type CursorPageParams, PagePromise } from '../core/pagination';\nimport { type Uploadable } from '../core/uploads';\nimport { buildHeaders } from '../internal/headers';\nimport { RequestOptions } from '../internal/request-options';\nimport { sleep } from '../internal/utils/sleep';\nimport { APIConnectionTimeoutError } from '../error';\nimport { multipartFormRequestOptions } from '../internal/uploads';\nimport { path } from '../internal/utils/path';\n\n/**\n * Files are used to upload documents that can be used with features like Assistants and Fine-tuning.\n */\nexport class Files extends APIResource {\n /**\n * Upload a file that can be used across various endpoints. Individual files can be\n * up to 512 MB, and each project can store up to 2.5 TB of files in total. There\n * is no organization-wide storage limit. Uploads to this endpoint are rate-limited\n * to 1,000 requests per minute per authenticated user.\n *\n * - The Assistants API supports files up to 2 million tokens and of specific file\n * types. See the\n * Assistants Tools guide\n * for details.\n * - The Fine-tuning API only supports `.jsonl` files. The input also has certain\n * required formats for fine-tuning\n * chat\n * or\n * completions\n * models.\n * - The Batch API only supports `.jsonl` files up to 200 MB in size. The input\n * also has a specific required\n * format.\n * - For Retrieval or `file_search` ingestion, upload files here first. If you need\n * to attach multiple uploaded files to the same vector store, use\n * `/vector_stores/{vector_store_id}/file_batches`\n * instead of attaching them one by one. Vector store attachment has separate\n * limits from file upload, including 2,000 attached files per minute per\n * organization.\n *\n * Please contact us if you need to increase these\n * storage limits.\n */\n create(body: FileCreateParams, options?: RequestOptions): APIPromise {\n return this._client.post(\n '/files',\n multipartFormRequestOptions({ body, ...options, __security: { bearerAuth: true } }, this._client),\n );\n }\n\n /**\n * Returns information about a specific file.\n */\n retrieve(fileID: string, options?: RequestOptions): APIPromise {\n return this._client.get(path`/files/${fileID}`, { ...options, __security: { bearerAuth: true } });\n }\n\n /**\n * Returns a list of files.\n */\n list(\n query: FileListParams | null | undefined = {},\n options?: RequestOptions,\n ): PagePromise<FileObjectsPage, FileObject> {\n return this._client.getAPIList('/files', CursorPage, {\n query,\n ...options,\n __security: { bearerAuth: true },\n });\n }\n\n /**\n * Delete a file and remove it from all vector stores.\n */\n delete(fileID: string, options?: RequestOptions): APIPromise {\n return this._client.delete(path`/files/${fileID}`, { ...options, __security: { bearerAuth: true } });\n }\n\n /**\n * Returns the contents of the specified file.\n */\n content(fileID: string, options?: RequestOptions): APIPromise {\n return this._client.get(path`/files/${fileID}/content`, {\n ...options,\n headers: buildHeaders([{ Accept: 'application/binary' }, options?.headers]),\n __security: { bearerAuth: true },\n __binaryResponse: true,\n });\n }\n\n /**\n * Waits for the given file to be processed, default timeout is 30 mins.\n */\n async waitForProcessing(\n id: string,\n { pollInterval = 5000, maxWait = 30 * 60 * 1000 }: { pollInterval?: number; maxWait?: number } = {},\n ): Promise {\n const TERMINAL_STATES = new Set(['processed', 'error', 'deleted']);\n\n const start = Date.now();\n let file = await this.retrieve(id);\n\n while (!file.status || !TERMINAL_STATES.has(file.status)) {\n await sleep(pollInterval);\n\n file = await this.retrieve(id);\n if (Date.now() - start > maxWait) {\n throw new APIConnectionTimeoutError({\n message: `Giving up on waiting for file ${id} to finish processing after ${maxWait} milliseconds.`,\n });\n }\n }\n\n return file;\n }\n}\n\nexport type FileObjectsPage = CursorPage;\n\nexport type FileContent = string;\n\nexport interface FileDeleted {\n id: string;\n\n deleted: boolean;\n\n object: 'file';\n}\n\n/**\n * The `File` object represents a document that has been uploaded to OpenAI.\n */\nexport interface FileObject {\n /**\n * The file identifier, which can be referenced in the API endpoints.\n */\n id: string;\n\n /**\n * The size of the file, in bytes.\n */\n bytes: number;\n\n /**\n * The Unix timestamp (in seconds) for when the file was created.\n */\n created_at: number;\n\n /**\n * The name of the file.\n */\n filename: string;\n\n /**\n * The object type, which is always `file`.\n */\n object: 'file';\n\n /**\n * The intended purpose of the file. Supported values are `assistants`,\n * `assistants_output`, `batch`, `batch_output`, `fine-tune`, `fine-tune-results`,\n * `vision`, and `user_data`.\n */\n purpose:\n | 'assistants'\n | 'assistants_output'\n | 'batch'\n | 'batch_output'\n | 'fine-tune'\n | 'fine-tune-results'\n | 'vision'\n | 'user_data';\n\n /**\n * @deprecated Deprecated. The current status of the file, which can be either\n * `uploaded`, `processed`, or `error`.\n */\n status: 'uploaded' | 'processed' | 'error';\n\n /**\n * The Unix timestamp (in seconds) for when the file will expire.\n */\n expires_at?: number;\n\n /**\n * @deprecated Deprecated. For details on why a fine-tuning training file failed\n * validation, see the `error` field on `fine_tuning.job`.\n */\n status_details?: string;\n}\n\n/**\n * The intended purpose of the uploaded file. One of:\n *\n * - `assistants`: Used in the Assistants API\n * - `batch`: Used in the Batch API\n * - `fine-tune`: Used for fine-tuning\n * - `vision`: Images used for vision fine-tuning\n * - `user_data`: Flexible file type for any purpose\n * - `evals`: Used for eval data sets\n */\nexport type FilePurpose = 'assistants' | 'batch' | 'fine-tune' | 'vision' | 'user_data' | 'evals';\n\nexport interface FileCreateParams {\n /**\n * The File object (not file name) to be uploaded.\n */\n file: Uploadable;\n\n /**\n * The intended purpose of the uploaded file. One of:\n *\n * - `assistants`: Used in the Assistants API\n * - `batch`: Used in the Batch API\n * - `fine-tune`: Used for fine-tuning\n * - `vision`: Images used for vision fine-tuning\n * - `user_data`: Flexible file type for any purpose\n * - `evals`: Used for eval data sets\n */\n purpose: FilePurpose;\n\n /**\n * The expiration policy for a file. By default, files with `purpose=batch` expire\n * after 30 days and all other files are persisted until they are manually deleted.\n */\n expires_after?: FileCreateParams.ExpiresAfter;\n}\n\nexport namespace FileCreateParams {\n /**\n * The expiration policy for a file. By default, files with `purpose=batch` expire\n * after 30 days and all other files are persisted until they are manually deleted.\n */\n export interface ExpiresAfter {\n /**\n * Anchor timestamp after which the expiration policy applies. Supported anchors:\n * `created_at`.\n */\n anchor: 'created_at';\n\n /**\n * The number of seconds after the anchor time that the file will expire. Must be\n * between 3600 (1 hour) and 2592000 (30 days).\n */\n seconds: number;\n }\n}\n\nexport interface FileListParams extends CursorPageParams {\n /**\n * Sort order by the `created_at` timestamp of the objects. `asc` for ascending\n * order and `desc` for descending order.\n */\n order?: 'asc' | 'desc';\n\n /**\n * Only return files with the given purpose.\n */\n purpose?: string;\n}\n\nexport declare namespace Files {\n export {\n type FileContent as FileContent,\n type FileDeleted as FileDeleted,\n type FileObject as FileObject,\n type FilePurpose as FilePurpose,\n type FileObjectsPage as FileObjectsPage,\n type FileCreateParams as FileCreateParams,\n type FileListParams as FileListParams,\n };\n}\n"
      },
      {
        "id": "https://github.com/openai/openai-go/blob/986b2d95f8e89b4de3f5015ae625a39ea20db53d/file.go",
        "title": "file.go at 986b2d95f8e89b4de3f5015ae625a39ea20db53d \u00b7 openai/openai-go",
        "url": "https://github.com/openai/openai-go/blob/986b2d95f8e89b4de3f5015ae625a39ea20db53d/file.go",
        "text": "# file.go\n\n- Branch: 986b2d95f8e89b4de3f5015ae625a39ea20db53d\n- Repository: openai/openai-go\n\n---\n\n// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.\n\npackage openai\n\nimport (\n \"bytes\"\n \"context\"\n \"errors\"\n \"fmt\"\n \"io\"\n \"mime/multipart\"\n \"net/http\"\n \"net/url\"\n \"slices\"\n\n \"github.com/openai/openai-go/v3/internal/apiform\"\n \"github.com/openai/openai-go/v3/internal/apijson\"\n \"github.com/openai/openai-go/v3/internal/apiquery\"\n \"github.com/openai/openai-go/v3/internal/requestconfig\"\n \"github.com/openai/openai-go/v3/option\"\n \"github.com/openai/openai-go/v3/packages/pagination\"\n \"github.com/openai/openai-go/v3/packages/param\"\n \"github.com/openai/openai-go/v3/packages/respjson\"\n \"github.com/openai/openai-go/v3/shared/constant\"\n)\n\n// Files are used to upload documents that can be used with features like\n// Assistants and Fine-tuning.\n//\n// FileService contains methods and other services that help with interacting with\n// the openai API.\n//\n// Note, unlike clients, this service does not read variables from the environment\n// automatically. You should not instantiate this service directly, and instead use\n// the [NewFileService] method instead.\ntype FileService struct {\n Options []option.RequestOption\n}\n\n// NewFileService generates a new service that applies the given options to each\n// request. These options are applied after the parent client's options (if there\n// is one), and before any request-specific options.\nfunc NewFileService(opts ...option.RequestOption) (r FileService) {\n r = FileService{}\n r.Options = opts\n return\n}\n\n// Upload a file that can be used across various endpoints. Individual files can be\n// up to 512 MB, and each project can store up to 2.5 TB of files in total. There\n// is no organization-wide storage limit. Uploads to this endpoint are rate-limited\n// to 1,000 requests per minute per authenticated user.\n//\n// - The Assistants API supports files up to 2 million tokens and of specific file\n// types. See the\n// Assistants Tools guide\n// for details.\n// - The Fine-tuning API only supports `.jsonl` files. The input also has certain\n// required formats for fine-tuning\n// chat\n// or\n// completions\n// models.\n// - The Batch API only supports `.jsonl` files up to 200 MB in size. The input\n// also has a specific required\n// format.\n// - For Retrieval or `file_search` ingestion, upload files here first. If you need\n// to attach multiple uploaded files to the same vector store, use\n// `/vector_stores/{vector_store_id}/file_batches`\n// instead of attaching them one by one. Vector store attachment has separate\n// limits from file upload, including 2,000 attached files per minute per\n// organization.\n//\n// Please contact us if you need to increase these\n// storage limits.\nfunc (r *FileService) New(ctx context.Context, body FileNewParams, opts ...option.RequestOption) (res *FileObject, err error) {\n var preClientOpts = []option.RequestOption{requestconfig.WithBearerAuthSecurity()}\n opts = slices.Concat(preClientOpts, r.Options, opts)\n path := \"files\"\n err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...)\n return res, err\n}\n\n// Returns information about a specific file.\nfunc (r *FileService) Get(ctx context.Context, fileID string, opts ...option.RequestOption) (res *FileObject, err error) {\n var preClientOpts = []option.RequestOption{requestconfig.WithBearerAuthSecurity()}\n opts = slices.Concat(preClientOpts, r.Options, opts)\n if fileID == \"\" {\n err = errors.New(\"missing required file_id parameter\")\n return nil, err\n }\n path := fmt.Sprintf(\"files/%s\", fileID)\n err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &res, opts...)\n return res, err\n}\n\n// Returns a list of files.\nfunc (r *FileService) List(ctx context.Context, query FileListParams, opts ...option.RequestOption) (res *pagination.CursorPage[FileObject], err error) {\n var raw *http.Response\n var preClientOpts = []option.RequestOption{requestconfig.WithBearerAuthSecurity()}\n opts = slices.Concat(preClientOpts, r.Options, opts)\n opts = append([]option.RequestOption{option.WithResponseInto(&raw)}, opts...)\n path := \"files\"\n cfg, err := requestconfig.NewRequestConfig(ctx, http.MethodGet, path, query, &res, opts...)\n if err != nil {\n return nil, err\n }\n err = cfg.Execute()\n if err != nil {\n return nil, err\n }\n res.SetPageConfig(cfg, raw)\n return res, nil\n}\n\n// Returns a list of files.\nfunc (r *FileService) ListAutoPaging(ctx context.Context, query FileListParams, opts ...option.RequestOption) *pagination.CursorPageAutoPager[FileObject] {\n return pagination.NewCursorPageAutoPager(r.List(ctx, query, opts...))\n}\n\n// Delete a file and remove it from all vector stores.\nfunc (r *FileService) Delete(ctx context.Context, fileID string, opts ...option.RequestOption) (res *FileDeleted, err error) {\n var preClientOpts = []option.RequestOption{requestconfig.WithBearerAuthSecurity()}\n opts = slices.Concat(preClientOpts, r.Options, opts)\n if fileID == \"\" {\n err = errors.New(\"missing required file_id parameter\")\n return nil, err\n }\n path := fmt.Sprintf(\"files/%s\", fileID)\n err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, nil, &res, opts...)\n return res, err\n}\n\n// Returns the contents of the specified file.\nfunc (r *FileService) Content(ctx context.Context, fileID string, opts ...option.RequestOption) (res *http.Response, err error) {\n var preClientOpts = []option.RequestOption{requestconfig.WithBearerAuthSecurity()}\n opts = slices.Concat(preClientOpts, r.Options, opts)\n opts = append([]option.RequestOption{option.WithHeader(\"Accept\", \"application/binary\")}, opts...)\n if fileID == \"\" {\n err = errors.New(\"missing required file_id parameter\")\n return nil, err\n }\n path := fmt.Sprintf(\"files/%s/content\", fileID)\n err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &res, opts...)\n return res, err\n}\n\ntype FileDeleted struct {\n ID string `json:\"id\" api:\"required\"`\n Deleted bool `json:\"deleted\" api:\"required\"`\n Object constant.File `json:\"object\" default:\"file\"`\n // JSON contains metadata for fields, check presence with [respjson.Field.Valid].\n JSON struct {\n ID respjson.Field\n Deleted respjson.Field\n Object respjson.Field\n ExtraFields map[string]respjson.Field\n raw string\n } `json:\"-\"`\n}\n\n// Returns the unmodified JSON received from the API\nfunc (r FileDeleted) RawJSON() string { return r.JSON.raw }\nfunc (r *FileDeleted) UnmarshalJSON(data []byte) error {\n return apijson.UnmarshalRoot(data, r)\n}\n\n// The `File` object represents a document that has been uploaded to OpenAI.\ntype FileObject struct {\n // The file identifier, which can be referenced in the API endpoints.\n ID string `json:\"id\" api:\"required\"`\n // The size of the file, in bytes.\n Bytes int64 `json:\"bytes\" api:\"required\"`\n // The Unix timestamp (in seconds) for when the file was created.\n CreatedAt int64 `json:\"created_at\" api:\"required\" format:\"unixtime\"`\n // The name of the file.\n Filename string `json:\"filename\" api:\"required\"`\n // The object type, which is always `file`.\n Object constant.File `json:\"object\" default:\"file\"`\n // The intended purpose of the file. Supported values are `assistants`,\n // `assistants_output`, `batch`, `batch_output`, `fine-tune`, `fine-tune-results`,\n // `vision`, and `user_data`.\n //\n // Any of \"assistants\", \"assistants_output\", \"batch\", \"batch_output\", \"fine-tune\",\n // \"fine-tune-results\", \"vision\", \"user_data\".\n Purpose FileObjectPurpose `json:\"purpose\" api:\"required\"`\n // Deprecated. The current status of the file, which can be either `uploaded`,\n // `processed`, or `error`.\n //\n // Any of \"uploaded\", \"processed\", \"error\".\n //\n // Deprecated: deprecated\n Status FileObjectStatus `json:\"status\" api:\"required\"`\n // The Unix timestamp (in seconds) for when the file will expire.\n ExpiresAt int64 `json:\"expires_at\" format:\"unixtime\"`\n // Deprecated. For details on why a fine-tuning training file failed validation,\n // see the `error` field on `fine_tuning.job`.\n //\n // Deprecated: deprecated\n StatusDetails string `json:\"status_details\"`\n // JSON contains metadata for fields, check presence with [respjson.Field.Valid].\n JSON struct {\n ID respjson.Field\n Bytes respjson.Field\n CreatedAt respjson.Field\n Filename respjson.Field\n Object respjson.Field\n Purpose respjson.Field\n Status respjson.Field\n ExpiresAt respjson.Field\n StatusDetails respjson.Field\n ExtraFields map[string]respjson.Field\n raw string\n } `json:\"-\"`\n}\n\n// Returns the unmodified JSON received from the API\nfunc (r FileObject) RawJSON() string { return r.JSON.raw }\nfunc (r *FileObject) UnmarshalJSON(data []byte) error {\n return apijson.UnmarshalRoot(data, r)\n}\n\n// The intended purpose of the file. Supported values are `assistants`,\n// `assistants_output`, `batch`, `batch_output`, `fine-tune`, `fine-tune-results`,\n// `vision`, and `user_data`.\ntype FileObjectPurpose string\n\nconst (\n FileObjectPurposeAssistants FileObjectPurpose = \"assistants\"\n FileObjectPurposeAssistantsOutput FileObjectPurpose = \"assistants_output\"\n FileObjectPurposeBatch FileObjectPurpose = \"batch\"\n FileObjectPurposeBatchOutput FileObjectPurpose = \"batch_output\"\n FileObjectPurposeFineTune FileObjectPurpose = \"fine-tune\"\n FileObjectPurposeFineTuneResults FileObjectPurpose = \"fine-tune-results\"\n FileObjectPurposeVision FileObjectPurpose = \"vision\"\n FileObjectPurposeUserData FileObjectPurpose = \"user_data\"\n)\n\n// Deprecated. The current status of the file, which can be either `uploaded`,\n// `processed`, or `error`.\ntype FileObjectStatus string\n\nconst (\n FileObjectStatusUploaded FileObjectStatus = \"uploaded\"\n FileObjectStatusProcessed FileObjectStatus = \"processed\"\n FileObjectStatusError FileObjectStatus = \"error\"\n)\n\n// The intended purpose of the uploaded file. One of:\n//\n// - `assistants`: Used in the Assistants API\n// - `batch`: Used in the Batch API\n// - `fine-tune`: Used for fine-tuning\n// - `vision`: Images used for vision fine-tuning\n// - `user_data`: Flexible file type for any purpose\n// - `evals`: Used for eval data sets\ntype FilePurpose string\n\nconst (\n FilePurposeAssistants FilePurpose = \"assistants\"\n FilePurposeBatch FilePurpose = \"batch\"\n FilePurposeFineTune FilePurpose = \"fine-tune\"\n FilePurposeVision FilePurpose = \"vision\"\n FilePurposeUserData FilePurpose = \"user_data\"\n FilePurposeEvals FilePurpose = \"evals\"\n)\n\ntype FileNewParams struct {\n // The File object (not file name) to be uploaded.\n File io.Reader `json:\"file,omitzero\" api:\"required\" format:\"binary\"`\n // The intended purpose of the uploaded file. One of:\n //\n // - `assistants`: Used in the Assistants API\n // - `batch`: Used in the Batch API\n // - `fine-tune`: Used for fine-tuning\n // - `vision`: Images used for vision fine-tuning\n // - `user_data`: Flexible file type for any purpose\n // - `evals`: Used for eval data sets\n //\n // Any of \"assistants\", \"batch\", \"fine-tune\", \"vision\", \"user_data\", \"evals\".\n Purpose FilePurpose `json:\"purpose,omitzero\" api:\"required\"`\n // The expiration policy for a file. By default, files with `purpose=batch` expire\n // after 30 days and all other files are persisted until they are manually deleted.\n ExpiresAfter FileNewParamsExpiresAfter `json:\"expires_after,omitzero\"`\n paramObj\n}\n\nfunc (r FileNewParams) MarshalMultipart() (data []byte, contentType string, err error) {\n buf := bytes.NewBuffer(nil)\n writer := multipart.NewWriter(buf)\n err = apiform.MarshalRoot(r, writer)\n if err == nil {\n err = apiform.WriteExtras(writer, r.ExtraFields())\n }\n if err != nil {\n writer.Close()\n return nil, \"\", err\n }\n err = writer.Close()\n if err != nil {\n return nil, \"\", err\n }\n return buf.Bytes(), writer.FormDataContentType(), nil\n}\n\n// The expiration policy for a file. By default, files with `purpose=batch` expire\n// after 30 days and all other files are persisted until they are manually deleted.\n//\n// The properties Anchor, Seconds are required.\ntype FileNewParamsExpiresAfter struct {\n // The number of seconds after the anchor time that the file will expire. Must be\n // between 3600 (1 hour) and 2592000 (30 days).\n Seconds int64 `json:\"seconds\" api:\"required\"`\n // Anchor timestamp after which the expiration policy applies. Supported anchors:\n // `created_at`.\n //\n // This field can be elided, and will marshal its zero value as \"created_at\".\n Anchor constant.CreatedAt `json:\"anchor\" default:\"created_at\"`\n paramObj\n}\n\nfunc (r FileNewParamsExpiresAfter) MarshalJSON() (data []byte, err error) {\n type shadow FileNewParamsExpiresAfter\n return param.MarshalObject(r, (*shadow)(&r))\n}\nfunc (r *FileNewParamsExpiresAfter) UnmarshalJSON(data []byte) error {\n return apijson.UnmarshalRoot(data, r)\n}\n\ntype FileListParams struct {\n // A cursor for use in pagination. `after` is an object ID that defines your place\n // in the list. For instance, if you make a list request and receive 100 objects,\n // ending with obj_foo, your subsequent call can include after=obj_foo in order to\n // fetch the next page of the list.\n After param.Opt[string] `query:\"after,omitzero\" json:\"-\"`\n // A limit on the number of objects to be returned. Limit can range between 1 and\n // 10,000, and the default is 10,000.\n Limit param.Opt[int64] `query:\"limit,omitzero\" json:\"-\"`\n // Only return files with the given purpose.\n Purpose param.Opt[string] `query:\"purpose,omitzero\" json:\"-\"`\n // Sort order by the `created_at` timestamp of the objects. `asc` for ascending\n // order and `desc` for descending order.\n //\n // Any of \"asc\", \"desc\".\n Order FileListParamsOrder `query:\"order,omitzero\" json:\"-\"`\n paramObj\n}\n\n// URLQuery serializes [FileListParams]'s query parameters as `url.Values`.\nfunc (r FileListParams) URLQuery() (v url.Values, err error) {\n return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{\n ArrayFormat: apiquery.ArrayQueryFormatBrackets,\n NestedFormat: apiquery.NestedQueryFormatBrackets,\n })\n}\n\n// Sort order by the `created_at` timestamp of the objects. `asc` for ascending\n// order and `desc` for descending order.\ntype FileListParamsOrder string\n\nconst (\n FileListParamsOrderAsc FileListParamsOrder = \"asc\"\n FileListParamsOrderDesc FileListParamsOrder = \"desc\"\n)\n"
      },
      {
        "id": "https://github.com/openai/openai-node/blob/c9a4d688/src/resources/files.ts",
        "title": "src/resources/files.ts at c9a4d688 \u00b7 openai/openai-node",
        "url": "https://github.com/openai/openai-node/blob/c9a4d688/src/resources/files.ts",
        "text": "# src/resources/files.ts\n\n- Branch: c9a4d688\n- Repository: openai/openai-node\n\n---\n\n// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.\n\nimport { APIResource } from '../core/resource';\nimport { APIPromise } from '../core/api-promise';\nimport { CursorPage, type CursorPageParams, PagePromise } from '../core/pagination';\nimport { type Uploadable } from '../core/uploads';\nimport { buildHeaders } from '../internal/headers';\nimport { RequestOptions } from '../internal/request-options';\nimport { sleep } from '../internal/utils/sleep';\nimport { APIConnectionTimeoutError } from '../error';\nimport { multipartFormRequestOptions } from '../internal/uploads';\nimport { path } from '../internal/utils/path';\n\nexport class Files extends APIResource {\n /**\n * Upload a file that can be used across various endpoints. Individual files can be\n * up to 512 MB, and the size of all files uploaded by one organization can be up\n * to 1 TB.\n *\n * - The Assistants API supports files up to 2 million tokens and of specific file\n * types. See the\n * Assistants Tools guide\n * for details.\n * - The Fine-tuning API only supports `.jsonl` files. The input also has certain\n * required formats for fine-tuning\n * chat\n * or\n * completions\n * models.\n * - The Batch API only supports `.jsonl` files up to 200 MB in size. The input\n * also has a specific required\n * format.\n *\n * Please contact us if you need to increase these\n * storage limits.\n */\n create(body: FileCreateParams, options?: RequestOptions): APIPromise {\n return this._client.post('/files', multipartFormRequestOptions({ body, ...options }, this._client));\n }\n\n /**\n * Returns information about a specific file.\n */\n retrieve(fileID: string, options?: RequestOptions): APIPromise {\n return this._client.get(path`/files/${fileID}`, options);\n }\n\n /**\n * Returns a list of files.\n */\n list(\n query: FileListParams | null | undefined = {},\n options?: RequestOptions,\n ): PagePromise<FileObjectsPage, FileObject> {\n return this._client.getAPIList('/files', CursorPage, { query, ...options });\n }\n\n /**\n * Delete a file and remove it from all vector stores.\n */\n delete(fileID: string, options?: RequestOptions): APIPromise {\n return this._client.delete(path`/files/${fileID}`, options);\n }\n\n /**\n * Returns the contents of the specified file.\n */\n content(fileID: string, options?: RequestOptions): APIPromise {\n return this._client.get(path`/files/${fileID}/content`, {\n ...options,\n headers: buildHeaders([{ Accept: 'application/binary' }, options?.headers]),\n __binaryResponse: true,\n });\n }\n\n /**\n * Waits for the given file to be processed, default timeout is 30 mins.\n */\n async waitForProcessing(\n id: string,\n { pollInterval = 5000, maxWait = 30 * 60 * 1000 }: { pollInterval?: number; maxWait?: number } = {},\n ): Promise {\n const TERMINAL_STATES = new Set(['processed', 'error', 'deleted']);\n\n const start = Date.now();\n let file = await this.retrieve(id);\n\n while (!file.status || !TERMINAL_STATES.has(file.status)) {\n await sleep(pollInterval);\n\n file = await this.retrieve(id);\n if (Date.now() - start > maxWait) {\n throw new APIConnectionTimeoutError({\n message: `Giving up on waiting for file ${id} to finish processing after ${maxWait} milliseconds.`,\n });\n }\n }\n\n return file;\n }\n}\n\nexport type FileObjectsPage = CursorPage;\n\nexport type FileContent = string;\n\nexport interface FileDeleted {\n id: string;\n\n deleted: boolean;\n\n object: 'file';\n}\n\n/**\n * The `File` object represents a document that has been uploaded to OpenAI.\n */\nexport interface FileObject {\n /**\n * The file identifier, which can be referenced in the API endpoints.\n */\n id: string;\n\n /**\n * The size of the file, in bytes.\n */\n bytes: number;\n\n /**\n * The Unix timestamp (in seconds) for when the file was created.\n */\n created_at: number;\n\n /**\n * The name of the file.\n */\n filename: string;\n\n /**\n * The object type, which is always `file`.\n */\n object: 'file';\n\n /**\n * The intended purpose of the file. Supported values are `assistants`,\n * `assistants_output`, `batch`, `batch_output`, `fine-tune`, `fine-tune-results`,\n * `vision`, and `user_data`.\n */\n purpose:\n | 'assistants'\n | 'assistants_output'\n | 'batch'\n | 'batch_output'\n | 'fine-tune'\n | 'fine-tune-results'\n | 'vision'\n | 'user_data';\n\n /**\n * @deprecated Deprecated. The current status of the file, which can be either\n * `uploaded`, `processed`, or `error`.\n */\n status: 'uploaded' | 'processed' | 'error';\n\n /**\n * The Unix timestamp (in seconds) for when the file will expire.\n */\n expires_at?: number;\n\n /**\n * @deprecated Deprecated. For details on why a fine-tuning training file failed\n * validation, see the `error` field on `fine_tuning.job`.\n */\n status_details?: string;\n}\n\n/**\n * The intended purpose of the uploaded file. One of: - `assistants`: Used in the\n * Assistants API - `batch`: Used in the Batch API - `fine-tune`: Used for\n * fine-tuning - `vision`: Images used for vision fine-tuning - `user_data`:\n * Flexible file type for any purpose - `evals`: Used for eval data sets\n */\nexport type FilePurpose = 'assistants' | 'batch' | 'fine-tune' | 'vision' | 'user_data' | 'evals';\n\nexport interface FileCreateParams {\n /**\n * The File object (not file name) to be uploaded.\n */\n file: Uploadable;\n\n /**\n * The intended purpose of the uploaded file. One of: - `assistants`: Used in the\n * Assistants API - `batch`: Used in the Batch API - `fine-tune`: Used for\n * fine-tuning - `vision`: Images used for vision fine-tuning - `user_data`:\n * Flexible file type for any purpose - `evals`: Used for eval data sets\n */\n purpose: FilePurpose;\n\n /**\n * The expiration policy for a file. By default, files with `purpose=batch` expire\n * after 30 days and all other files are persisted until they are manually deleted.\n */\n expires_after?: FileCreateParams.ExpiresAfter;\n}\n\nexport namespace FileCreateParams {\n /**\n * The expiration policy for a file. By default, files with `purpose=batch` expire\n * after 30 days and all other files are persisted until they are manually deleted.\n */\n export interface ExpiresAfter {\n /**\n * Anchor timestamp after which the expiration policy applies. Supported anchors:\n * `created_at`.\n */\n anchor: 'created_at';\n\n /**\n * The number of seconds after the anchor time that the file will expire. Must be\n * between 3600 (1 hour) and 2592000 (30 days).\n */\n seconds: number;\n }\n}\n\nexport interface FileListParams extends CursorPageParams {\n /**\n * Sort order by the `created_at` timestamp of the objects. `asc` for ascending\n * order and `desc` for descending order.\n */\n order?: 'asc' | 'desc';\n\n /**\n * Only return files with the given purpose.\n */\n purpose?: string;\n}\n\nexport declare namespace Files {\n export {\n type FileContent as FileContent,\n type FileDeleted as FileDeleted,\n type FileObject as FileObject,\n type FilePurpose as FilePurpose,\n type FileObjectsPage as FileObjectsPage,\n type FileCreateParams as FileCreateParams,\n type FileListParams as FileListParams,\n };\n}\n"
      },
      {
        "id": "https://app.unpkg.com/openai@6.26.0/files/resources/files.mjs",
        "title": "UNPKG",
        "url": "https://app.unpkg.com/openai@6.26.0/files/resources/files.mjs",
        "text": "UNPKG\n\n# openai\n\nThe official TypeScript library for the OpenAI API\n\nopenai/openai-node\n\n85 lines \u2022 3.58 kB JavaScript View Raw\n\n// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. import { APIResource } from \"../core/resource.mjs\"; import { CursorPage } from \"../core/pagination.mjs\"; import { buildHeaders } from \"../internal/headers.mjs\"; import { sleep } from \"../internal/utils/sleep.mjs\"; import { APIConnectionTimeoutError } from \"../error.mjs\"; import { multipartFormRequestOptions } from \"../internal/uploads.mjs\"; import { path } from \"../internal/utils/path.mjs\"; /** * Files are used to upload documents that can be used with features like Assistants and Fine-tuning. */ export class Files extends APIResource { /** * Upload a file that can be used across various endpoints. Individual files can be * up to 512 MB, and each project can store up to 2.5 TB of files in total. There * is no organization-wide storage limit. * * - The Assistants API supports files up to 2 million tokens and of specific file * types. See the * [Assistants Tools guide](https://platform.openai.com/docs/assistants/tools) * for details. * - The Fine-tuning API only supports `.jsonl` files. The input also has certain * required formats for fine-tuning * [chat](https://platform.openai.com/docs/api-reference/fine-tuning/chat-input) * or * [completions](https://platform.openai.com/docs/api-reference/fine-tuning/completions-input) * models. * - The Batch API only supports `.jsonl` files up to 200 MB in size. The input * also has a specific required * [format](https://platform.openai.com/docs/api-reference/batch/request-input). * * Please [contact us](https://help.openai.com/) if you need to increase these * storage limits. */ create(body, options) { return this._client. post('/files', multipartFormRequestOptions({ body, ...options }, this._client)); } /** * Returns information about a specific file. */ retrieve(fileID, options) { return this._client. get(path `/files/${fileID}`, options); } /** * Returns a list of files. */ list(query = {}, options) { return this._client. getAPIList('/files', (CursorPage), { query, ...options }); } /** * Delete a file and remove it from all vector stores. */ delete(fileID, options) { return this._client. delete(path `/files/${fileID}`, options); } /** * Returns the contents of the specified file. */ content(fileID, options) { return this._client. get(path `/files/${fileID}/content`, { ...options, headers: buildHeaders([{ Accept: 'application/binary' }, options?. headers]), __binaryResponse: true, }); } /** * Waits for the given file to be processed, default timeout is 30 mins. */ async waitForProcessing(id, { pollInterval = 5000, maxWait = 30 * 60 * 1000 } = {}) { const TERMINAL_STATES = new Set(['processed', 'error', 'deleted']); const start = Date. now(); let file = await this. retrieve(id); while (!file. status || ! TERMINAL_STATES. has(file. status)) { await sleep(pollInterval); file = await this. retrieve(id); if (Date. now() - start > maxWait) { throw new APIConnectionTimeoutError({ message: `Giving up on waiting for file ${id} to finish processing after ${maxWait} milliseconds.`, }); } } return file; } } //# sourceMappingURL=files.mjs.map"
      },
      {
        "id": "https://www.rubydoc.info/gems/openai/OpenAI/Resources/Files",
        "title": "RubyDoc.info: \n      \n  Class: OpenAI::Resources::Files\n  \n    \u2013 Documentation for openai (0.57.0)\n  \n \u2013 RubyDoc.info",
        "url": "https://www.rubydoc.info/gems/openai/OpenAI/Resources/Files",
        "text": "RubyDoc.info: Class: OpenAI::Resources::Files \u2013 Documentation for openai (0.57.0) \u2013 RubyDoc.info \n\n# Class: OpenAI::Resources::Files\n\nInherits: Object\n\n- Object\n- OpenAI::Resources::Files\n\nshow all Defined in: lib/openai/resources/files.rb\n\n## Overview\n\nFiles are used to upload documents that can be used with features like Assistants and Fine-tuning.\n\n## Instance Method Summary collapse\n\n#content(file_id, request_options: {}) \u21d2 StringIO\n\nReturns the contents of the specified file.\n\n#create(file:, purpose:, expires_after: nil, request_options: {}) \u21d2 OpenAI::Models::FileObject\n\nSome parameter documentations has been truncated, see Models::FileCreateParams for more details.\n\n#delete(file_id, request_options: {}) \u21d2 OpenAI::Models::FileDeleted\n\nDelete a file and remove it from all vector stores.\n\n#initialize(client:) \u21d2 Files constructor private\n\nA new instance of Files.\n\n#list(after: nil, limit: nil, order: nil, purpose: nil, request_options: {}) \u21d2 OpenAI::Internal::CursorPage \n\nSome parameter documentations has been truncated, see Models::FileListParams for more details.\n\n#retrieve(file_id, request_options: {}) \u21d2 OpenAI::Models::FileObject\n\nReturns information about a specific file.\n\n## Constructor Details\n\n### #initialize(client:) \u21d2 Files\n\nThis method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.\n\nReturns a new instance of Files.\n\n```\n\n154\n155\n156\n```\n\n```\n# File 'lib/openai/resources/files.rb', line 154\n\ndef initialize(client:)\n  @client = client\nend\n```\n\n## Instance Method Details\n\n### #content(file_id, request_options: {}) \u21d2 StringIO\n\nReturns the contents of the specified file.\n\n```\n\n141\n142\n143\n144\n145\n146\n147\n148\n149\n```\n\n```\n# File 'lib/openai/resources/files.rb', line 141\n\ndef content(file_id, params = {})\n  @client.request(\n    method: :get,\n    path: [\"files/%1$s/content\", file_id],\n    headers: {\"accept\" => \"application/binary\"},\n    model: StringIO,\n    options: params[:request_options]\n  )\nend\n```\n\n### #create(file:, purpose:, expires_after: nil, request_options: {}) \u21d2 OpenAI::Models::FileObject\n\nSome parameter documentations has been truncated, see Models::FileCreateParams for more details.\n\nUpload a file that can be used across various endpoints. Individual files can be up to 512 MB, and each project can store up to 2.5 TB of files in total. There is no organization-wide storage limit.\n\nThe Assistants API supports files up to 2 million tokens and of specific file types. See the [Assistants Tools guide](platform.openai.com/docs/assistants/tools) for details.\n\nThe Fine-tuning API only supports`.jsonl` files. The input also has certain required formats for fine-tuning [chat](platform.openai.com/docs/api-reference/fine-tuning/chat-input) or [completions](platform.openai.com/docs/api-reference/fine-tuning/completions-input) models.\n\nThe Batch API only supports`.jsonl` files up to 200 MB in size. The input also has a specific required [format](platform.openai.com/docs/api-reference/batch/request-input).\n\nPlease [contact us](help.openai.com/) if you need to increase these storage limits.\n\n```\n\n45\n46\n47\n48\n49\n50\n51\n52\n53\n54\n55\n```\n\n```\n# File 'lib/openai/resources/files.rb', line 45\n\ndef create(params)\n  parsed, options = OpenAI::FileCreateParams.dump_request(params)\n  @client.request(\n    method: :post,\n    path: \"files\",\n    headers: {\"content-type\" => \"multipart/form-data\"},\n    body: parsed,\n    model: OpenAI::FileObject,\n    options: options\n  )\nend\n```\n\n### #delete(file_id, request_options: {}) \u21d2 OpenAI::Models::FileDeleted\n\nDelete a file and remove it from all vector stores.\n\n```\n\n121\n122\n123\n124\n125\n126\n127\n128\n```\n\n```\n# File 'lib/openai/resources/files.rb', line 121\n\ndef delete(file_id, params = {})\n  @client.request(\n    method: :delete,\n    path: [\"files/%1$s\", file_id],\n    model: OpenAI::FileDeleted,\n    options: params[:request_options]\n  )\nend\n```\n\n### #list(after: nil, limit: nil, order: nil, purpose: nil, request_options: {}) \u21d2 OpenAI::Internal::CursorPage \n\nSome parameter documentations has been truncated, see Models::FileListParams for more details.\n\nReturns a list of files.\n\n```\n\n97\n98\n99\n100\n101\n102\n103\n104\n105\n106\n107\n108\n```\n\n```\n# File 'lib/openai/resources/files.rb', line 97\n\ndef list(params = {})\n  parsed, options = OpenAI::FileListParams.dump_request(params)\n  query = OpenAI::Internal::Util.encode_query_params(parsed)\n  @client.request(\n    method: :get,\n    path: \"files\",\n    query: query,\n    page: OpenAI::Internal::CursorPage,\n    model: OpenAI::FileObject,\n    options: options\n  )\nend\n```\n\n### #retrieve(file_id, request_options: {}) \u21d2 OpenAI::Models::FileObject\n\nReturns information about a specific file.\n\n```\n\n68\n69\n70\n71\n72\n73\n74\n75\n```\n\n```\n# File 'lib/openai/resources/files.rb', line 68\n\ndef retrieve(file_id, params = {})\n  @client.request(\n    method: :get,\n    path: [\"files/%1$s\", file_id],\n    model: OpenAI::FileObject,\n    options: params[:request_options]\n  )\nend\n```\n\nGenerated on Fri Apr 3 12:15:02 2026 by yard 0.9.38 (ruby-3.4.3).",
        "image": "https://www.rubydoc.info/favicon.ico",
        "favicon": "https://www.rubydoc.info/favicon.ico"
      }
    ],
    "searchTime": 1099.6,
    "costDollars": {
      "total": 0.007,
      "search": {
        "neural": 0.007
      }
    }
  }
}