> ## Documentation Index
> Fetch the complete documentation index at: https://inference-docs.cerebras.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Upload file

<Callout icon="lock" color="#b2b1b1ff" iconType="regular">
  This feature is in [Private Preview](/support/preview-releases). For access or more information, [contact us](https://www.cerebras.ai/contact) or reach out to your account representative.
</Callout>

Uploads a file for use with the [Batch API](/api-reference/batch/create-batch). Files can be up to **200 MB** and must be **JSONL** format.

Files are retained for 7 days by default.

## Request

<ParamField path="file" type="file" required="true">
  The file to upload. Must be a binary file.
</ParamField>

<ParamField path="purpose" type="string" required="true">
  The intended purpose of the file. Currently supported values:

  * `batch`: Input file for batch processing
</ParamField>

<ParamField path="expires_after" type="object">
  The expiration policy for the file. Files with `purpose=batch` expire after 7 days by default.

  <Expandable title="properties">
    <ParamField path="anchor" type="string" required>
      Anchor timestamp after which the expiration policy applies. Must be `created_at`.
    </ParamField>

    <ParamField path="seconds" type="integer" required>
      The number of seconds after the anchor point when the file expires. Must be between 3600 (1 hour) and 2592000 (30 days).
    </ParamField>
  </Expandable>
</ParamField>

## Response

<ResponseField name="id" type="string">
  A unique identifier for the file.
</ResponseField>

<ResponseField name="object" type="string">
  The object type, which is always `file`.
</ResponseField>

<ResponseField name="filename" type="string">
  The name of the uploaded file.
</ResponseField>

<ResponseField name="purpose" type="string">
  The intended purpose of the file.
</ResponseField>

<ResponseField name="bytes" type="integer">
  The size of the file in bytes.
</ResponseField>

<ResponseField name="created_at" type="integer">
  The Unix timestamp (in seconds) of when the file was created.
</ResponseField>

<ResponseField name="expires_at" type="integer">
  The Unix timestamp (in seconds) of when the file will be automatically deleted.
</ResponseField>

<RequestExample>
  ```python Python theme={null}
  from cerebras.cloud.sdk import Cerebras
  import os

  client = Cerebras(
      api_key=os.environ.get("CEREBRAS_API_KEY"),
  )

  file = client.files.create(
      file=open("batch-requests.jsonl", "rb"),
      purpose="batch"
  )

  print(file)
  ```

  ```javascript Node.js theme={null}
  import Cerebras from '@cerebras/cerebras_cloud_sdk';
  import * as fs from 'fs';

  const client = new Cerebras({
    apiKey: process.env['CEREBRAS_API_KEY'],
  });

  async function main() {
    const file = await client.files.create({
      file: fs.createReadStream("batch-requests.jsonl"),
      purpose: "batch"
    });

    console.log(file);
  }

  main();
  ```

  ```bash cURL theme={null}
  curl --location 'https://api.cerebras.ai/v1/files' \
  --header "Authorization: Bearer ${CEREBRAS_API_KEY}" \
  --form 'file=@"batch-requests.jsonl"' \
  --form 'purpose="batch"'
  ```
</RequestExample>

<ResponseExample>
  ```json Response theme={null}
  {
    "id": "fileI72lQshwSO6Z7LIQ850CvA",
    "object": "file",
    "filename": "test.jsonl",
    "bytes": 4213,
    "purpose": "batch",
    "created_at": 1765172961,
    "expires_at": 1767764961
  }
  ```
</ResponseExample>
