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

# Files

> Upload files to OpenAI

## Uploading Files

<Tabs>
  <Tab title="Python SDK">
    ```python theme={null}
    from obiguard import Obiguard

    client = Obiguard(
        obiguard_api_key="OBIGUARD_API_KEY",  # Your Obiguard API key
    )

    upload_file_response = client.files.create(
      purpose="batch",
      file=open("file.pdf", "rb")
    )

    print(upload_file_response)
    ```
  </Tab>

  <Tab title="OpenAI Python SDK">
    ```python theme={null}
    from openai import OpenAI
    from obiguard import OBIGUARD_GATEWAY_URL, createHeaders

    client = OpenAI(
        api_key='OPENAI_API_KEY',
        base_url=OBIGUARD_GATEWAY_URL,
        default_headers=createHeaders(
            provider="openai",
            obiguard_api_key="OBIGUARD_API_KEY"
        )
    )

    upload_file_response = client.files.create(
      purpose="batch",
      file=open("file.pdf", "rb")
    )

    print(upload_file_response)
    ```
  </Tab>
</Tabs>

## List Files

<Tabs>
  <Tab title="Python SDK">
    ```python theme={null}
    from obiguard import Obiguard

    client = Obiguard(
      obiguard_api_key="OBIGUARD_API_KEY",  # Your Obiguard API key
    )

    files = client.files.list()

    print(files)
    ```
  </Tab>

  <Tab title="OpenAI Python SDK">
    ```python theme={null}
    from openai import OpenAI
    from obiguard import OBIGUARD_GATEWAY_URL, createHeaders

    client = OpenAI(
      api_key='OPENAI_API_KEY',
      base_url=OBIGUARD_GATEWAY_URL,
      default_headers=createHeaders(
        provider="openai",
        obiguard_api_key="OBIGUARD_API_KEY"
      )
    )


    files = openai.files.list()

    print(files)
    ```
  </Tab>
</Tabs>

## Get File

<Tabs>
  <Tab title="Python" SDK>
    ```python theme={null}
     from obiguard import Obiguard

     client = Obiguard(
      obiguard_api_key="OBIGUARD_API_KEY",  # Your Obiguard API key
     )

    file = client.files.retrieve(file_id="file_id")

    print(file)
    ```
  </Tab>

  <Tab title="OpenAI Python SDK">
    ```python theme={null}
    from openai import OpenAI
          from obiguard import OBIGUARD_GATEWAY_URL, createHeaders

    client = OpenAI(
      api_key='OPENAI_API_KEY',
      base_url=OBIGUARD_GATEWAY_URL,
      default_headers=createHeaders(
      provider="openai",
        obiguard_api_key="OBIGUARD_API_KEY"
      )
    )

    file = client.files.retrieve(file_id="file_id")

    print(file)
    ```
  </Tab>
</Tabs>

## Get File Content

<Tabs>
  <Tab title="Python SDK">
    ```python theme={null}
     from obiguard import Obiguard

     client = Obiguard(
      obiguard_api_key="OBIGUARD_API_KEY",  # Your Obiguard API key
     )

    file_content = client.files.content(file_id="file_id")

    print(file_content)
    ```
  </Tab>

  <Tab title="OpenAI Python SDK">
    ```python theme={null}
    from openai import OpenAI
    from obiguard import OBIGUARD_GATEWAY_URL, createHeaders

    client = OpenAI(
      api_key='OPENAI_API_KEY',
      base_url=OBIGUARD_GATEWAY_URL,
      default_headers=createHeaders(
        provider="openai",
        obiguard_api_key="OBIGUARD_API_KEY"
      )
    )

    file_content = openai.files.content(file_id="file_id")

    print(file_content)
    ```
  </Tab>
</Tabs>

## Delete File

<Tabs>
  <Tab title="Python SDK">
    ```python theme={null}
     from obiguard import Obiguard

     client = Obiguard(
      obiguard_api_key="OBIGUARD_API_KEY",  # Your Obiguard API key
     )

    delete_file_response = client.files.delete(file_id="file_id")

    print(delete_file_response)
    ```
  </Tab>

  <Tab title="OpenAI Python SDK">
    ```python theme={null}
    from openai import OpenAI
    from openai import OpenAI
    from obiguard import OBIGUARD_GATEWAY_URL, createHeaders

    client = OpenAI(
      api_key='OPENAI_API_KEY',
      base_url=OBIGUARD_GATEWAY_URL,
      default_headers=createHeaders(
        provider="openai",
        obiguard_api_key="OBIGUARD_API_KEY"
      )
    )

    delete_file_response = client.files.delete(file_id="file_id")

    print(delete_file_response)
    ```
  </Tab>
</Tabs>
