Edits history of script submission #17189 for ' Add audio to a generation (lumaai)'

  • bun
    One script reply has been approved by the moderators
    Ap­pro­ved
    //native
    type Lumaai = {
      apiKey: string;
    };
    /**
     * Add audio to a generation
     * Add audio to a generation by its ID
     */
    export async function main(
      auth: Lumaai,
      id: string,
      body: {
        generation_type?: "add_audio";
        prompt?: string;
        negative_prompt?: string;
        callback_url?: string;
      },
    ) {
      const url = new URL(
        `https://api.lumalabs.ai/dream-machine/v1/generations/${id}/audio`,
      );
    
      const response = await fetch(url, {
        method: "POST",
        headers: {
          "Content-Type": "application/json",
          Authorization: "Bearer " + auth.apiKey,
        },
        body: JSON.stringify(body),
      });
      if (!response.ok) {
        const text = await response.text();
        throw new Error(`${response.status} ${text}`);
      }
      return await response.json();
    }
    

    Submitted by hugo697 235 days ago