Uploading Files

from portkey_ai import Portkey

# Initialize the Portkey client
portkey = Portkey(
    api_key="PORTKEY_API_KEY",  # Replace with your Portkey API key
    virtual_key="VIRTUAL_KEY",   # Add your provider's virtual key
    provider="fireworks-ai",
    fireworks_account_id="FIREWORKS_ACCOUNT_ID"
)

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

print(upload_file_response)

Get File

from portkey_ai import Portkey

# Initialize the Portkey client
portkey = Portkey(
    api_key="PORTKEY_API_KEY",  # Replace with your Portkey API key
    virtual_key="VIRTUAL_KEY",   # Add your provider's virtual key
    fireworks_account_id="FIREWORKS_ACCOUNT_ID"
)

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

print(file)

Get File Content

from portkey_ai import Portkey

# Initialize the Portkey client
portkey = Portkey(
    api_key="PORTKEY_API_KEY",  # Replace with your Portkey API key
    virtual_key="VIRTUAL_KEY",   # Add your provider's virtual key
    fireworks_account_id="FIREWORKS_ACCOUNT_ID",
)

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

print(file_content)