Edits history of script submission #20984 for ' List all files (togetherai)'

  • bun
    One script reply has been approved by the moderators
    Ap­pro­ved
    //native
    type Togetherai = {
      api_key: string;
    };
    /**
     * List all files
     * List the metadata for all uploaded data files.
     */
    export async function main(auth: Togetherai) {
      const url = new URL(`https://api.together.xyz/v1/files`);
    
      const response = await fetch(url, {
        method: "GET",
        headers: {
          Authorization: "Bearer " + auth.api_key,
        },
        body: undefined,
      });
      if (!response.ok) {
        const text = await response.text();
        throw new Error(`${response.status} ${text}`);
      }
      return await response.json();
    }
    

    Submitted by hugo697 235 days ago