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

# Files

> Upload files to Fireworks

## Uploading Files

> [tab] REST
>
> ```sh theme={"system"}
> # you can also use a provider from Model Catalog here
> curl --location 'https://aigw.portkey.ai/v1/files' \
> --header 'Authorization: Bearer <portkey_api_key>' \
> --header 'x-portkey-provider: fireworks-ai' \
> --header 'Content-Type: application/json' \
> --header 'x-portkey-fireworks-account-id: {YOUR_FIREWORKS_ACCOUNT_ID}' \
> --form 'file=@"{YOUR_FILE_PATH}"',
> --form 'purpose="batch"'
> ```

> [tab] OpenAI NodeJS
>
> ```js theme={"system"}
> import OpenAI from 'openai'; // We're using the v4 SDK
>
> const openai = new OpenAI({
>   apiKey: "PORTKEY_API_KEY", // defaults to process.env["OPENAI_API_KEY"],
>   baseURL: "https://aigw.portkey.ai/v1",
>   defaultHeaders: {
>       "x-portkey-provider": "fireworks-ai",
>       // defaults to process.env["PORTKEY_API_KEY"]
>       "x-portkey-fireworks-account-id": "FIREWORKS_ACCOUNT_ID",
>   }
> });
>
> const uploadFile = async () => {
>   const file = await openai.files.create({
>     purpose: "batch",
>     file: fs.createReadStream("file.pdf")
>   });
>
>   console.log(file);
> }
>
> await uploadFile();
> ```

> [tab] OpenAI Python
>
> ```python theme={"system"}
> from openai import OpenAI
>
> openai = OpenAI(
>     api_key="PORTKEY_API_KEY",
>     base_url="https://aigw.portkey.ai/v1",
>     default_headers={"x-portkey-provider": "fireworks-ai", "x-portkey-fireworks-account-id": "FIREWORKS_ACCOUNT_ID"}
> )
>
> upload_file_response = openai.files.create(
>   purpose="batch",
>   file=open("file.pdf", "rb")
> )
>
> print(upload_file_response)
> ```

## Get File

> [tab] REST
>
> ```sh theme={"system"}
> curl --location 'https://aigw.portkey.ai/v1/files/<file_id>' \
> --header 'Authorization: Bearer <portkey_api_key>' \
> --header 'x-portkey-provider: @provider' \
> --header 'x-portkey-fireworks-account-id: {YOUR_FIREWORKS_ACCOUNT_ID}'
> ```

> [tab] OpenAI NodeJS
>
> ```js theme={"system"}
> import OpenAI from 'openai'; // We're using the v4 SDK
>
> const openai = new OpenAI({
>   apiKey: "PORTKEY_API_KEY", // defaults to process.env["OPENAI_API_KEY"],
>   baseURL: "https://aigw.portkey.ai/v1",
>   defaultHeaders: {
>       "x-portkey-provider": "fireworks-ai",
>       // defaults to process.env["PORTKEY_API_KEY"]
>       "x-portkey-fireworks-account-id": "FIREWORKS_ACCOUNT_ID",
>   }
> });
>
> const getFile = async () => {
>   const file = await openai.files.retrieve(file_id="file_id");
>
>   console.log(file);
> }
>
> await getFile();
> ```

> [tab] OpenAI Python
>
> ```python theme={"system"}
> from openai import OpenAI
>
> openai = OpenAI(
>     api_key="PORTKEY_API_KEY",
>     base_url="https://aigw.portkey.ai/v1",
>     default_headers={"x-portkey-provider": "fireworks-ai", "x-portkey-fireworks-account-id": "FIREWORKS_ACCOUNT_ID"}
> )
>
> file = openai.files.retrieve(file_id="file_id")
>
> print(file)
> ```

## Get File Content

> [tab] REST
>
> ```sh theme={"system"}
> curl --location 'https://aigw.portkey.ai/v1/files/<file_id>/content' \
> --header 'Authorization: Bearer <portkey_api_key>' \
> --header 'x-portkey-provider: @provider' \
> --header 'x-portkey-fireworks-account-id: {YOUR_FIREWORKS_ACCOUNT_ID}'
> ```

> [tab] OpenAI NodeJS
>
> ```js theme={"system"}
> import OpenAI from 'openai'; // We're using the v4 SDK
>
> const openai = new OpenAI({
>   apiKey: "PORTKEY_API_KEY", // defaults to process.env["OPENAI_API_KEY"],
>   baseURL: "https://aigw.portkey.ai/v1",
>   defaultHeaders: {
>       "x-portkey-provider": "fireworks-ai",
>       // defaults to process.env["PORTKEY_API_KEY"]
>       "x-portkey-fireworks-account-id": "FIREWORKS_ACCOUNT_ID",
>   }
> });
>
> const getFileContent = async () => {
>   const file_content = await openai.files.content(file_id="file_id");
>
>   console.log(file_content);
> }
>
> await getFileContent();
> ```

> [tab] OpenAI Python
>
> ```python theme={"system"}
> from openai import OpenAI
>
> openai = OpenAI(
>     api_key="PORTKEY_API_KEY",
>     base_url="https://aigw.portkey.ai/v1",
>     default_headers={"x-portkey-provider": "fireworks-ai", "x-portkey-fireworks-account-id": "FIREWORKS_ACCOUNT_ID"}
> )
>
> file_content = openai.files.content(file_id="file_id")
>
> print(file_content)
> ```

* [Fireworks Datasets API](https://docs.fireworks.ai/api-reference/list-datasets)


## Related topics

- [Files](https://docs.portkey.ai/docs/aigw/integrations/llms/anthropic/files.md)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.