1. It’s important to craft good prompts that will give best results.

    1. Provide a clear context.
    2. Provide clear instructions. One shot prompting is better in this case.
    3. Provide the output format you need.
    4. Iterate util you have the right prompt for the job.
    lib/
    ├─ llm/
    │  ├─ prompts/
    │  │  ├─ format-lyrics.ts // 👈 This is the prompt I used for formatting the lyrics
    │  │  └─ translate-lyrics.ts // 👈 This is the prompt I used for translating the lyrics
    │  └─ llm.ts
    
  2. I also created an abstract layer for talking to the model. This is a good practice in case you may want to switch between different modals by hiding implementation details and keeping the public interface intact.

    // Location: src\lib\llm\llm.ts
    // FILE. import statements
    
    const ai = new GoogleGenAI({
      apiKey: "",
    });
    
    const llmModal = {
      async formatLyrics(lyrics: string) {
    	  const response = await ai.models.generateContent({
    	      model: "gemini-2.5-flash",
    	      contents: lyrics,
    	      config: {
    	        systemInstruction: {
    	          text: formatLyrics,
    	        },
    	      },
    	    });
    	
    	    return response.text;
      },
    
      async translateLyrics(lyrics: Lyrics, targetLanguage: string) {
        const response = await ai.models.generateContent({
          model: "gemini-2.5-flash",
          contents: JSON.stringify(lyrics),
          config: {
            systemInstruction: {
              text: translateLyrics.replace("{{targetLanguage}}", targetLanguage),
            },
          },
        });
    
        return response.text;
      },
    };
    
    export default llmModal;