Polish API

The Polish API improves the readability of text. It is powered by our custom AI language model and you can control the edits made, including: splitting up paragraphs into 1-2 sentences, reduced repetition, improved readability, and more.

Availability: The Polish API is only available with the Professional plan and higher.

Endpoint

POST https://koala.sh/api/polish/

How It Works

The input should be formatted as Markdown or HTML, and it will output in the same format. The API uses 2 credits per 3,000 input tokens.

You can try out the Polish feature in our demo here by clicking the Polish button, modifying the settings, and then clicking Start Polish. You can also replace the text with your own to see how it works.

Example Request

const response = await fetch("https://koala.sh/api/polish/", {
    method: "POST",
    headers: {
        Authorization: "Bearer YOUR_API_KEY",
        "Content-Type": "application/json"
    },
    body: JSON.stringify({
        input: `It's not just about the looks though, as the handle is also designed for practicality - with two subtle side lips that make it convenient to pour sauces or liquids without making a mess.`,
        settings: {
            "split-up-long-paragraphs": true,
            "remove-mid-article-conclusions": true,
            "remove-repetitive-sentences": true,
            "simplify-complex-sentences": true,
            "convert-passive-voice": true
        }
    })
});

const polishedText = await response.text();

Example Response

The handle is not just about the looks. It is also designed for practicality. It has two subtle side lips that make it convenient to pour sauces or liquids without making a mess.

As you can see in the example above, it split up a long, hard-to-read sentence into shorter ones to improve readability.

Parameters

NameTypeDescriptionRequired
inputstringThe text to be polished (Markdown or HTML format)Yes
settingsobjectConfiguration options for the polishing processNo

Settings Object

Setting NameTypeDescriptionDefault
split-up-long-paragraphsbooleanBreaks long paragraphs into shorter ones (1-2 sentences)true
remove-mid-article-conclusionsbooleanRemoves unnecessary concluding statements within the articletrue
remove-repetitive-sentencesbooleanEliminates sentences that repeat informationtrue
simplify-complex-sentencesbooleanMakes complex sentences easier to readtrue
convert-passive-voicebooleanConverts passive voice to active voice where appropriatetrue

Complete Example

async function polishText(text, settings = {}) {
  // Default settings
  const defaultSettings = {
    "split-up-long-paragraphs": true,
    "remove-mid-article-conclusions": true,
    "remove-repetitive-sentences": true,
    "simplify-complex-sentences": true,
    "convert-passive-voice": true
  };
  
  // Merge user settings with defaults
  const finalSettings = { ...defaultSettings, ...settings };
  
  try {
    const response = await fetch("https://koala.sh/api/polish/", {
      method: "POST",
      headers: {
        Authorization: "Bearer YOUR_API_KEY",
        "Content-Type": "application/json"
      },
      body: JSON.stringify({
        input: text,
        settings: finalSettings
      })
    });
    
    if (!response.ok) {
      throw new Error(`HTTP error! status: ${response.status}`);
    }
    
    const polishedText = await response.text();
    return polishedText;
  } catch (error) {
    console.error("Error polishing text:", error);
    return null;
  }
}

// Example usage
async function main() {
  const originalText = `The large dog, which was brown and had a long tail that wagged enthusiastically whenever anyone approached, barked loudly at the mailman who was delivering packages to the house next door, causing the neighbor to come outside to see what all the commotion was about.`;
  
  console.log("Original text:");
  console.log(originalText);
  
  const polishedText = await polishText(originalText);
  
  console.log("\nPolished text:");
  console.log(polishedText);
}

main();

Error Handling

The API will return appropriate HTTP status codes for different error conditions:

  • 400 Bad Request: Invalid parameters or request format
  • 401 Unauthorized: Invalid or missing API key
  • 402 Payment Required: Insufficient credits
  • 403 Forbidden: Professional plan required
  • 429 Too Many Requests: Rate limit exceeded
  • 500 Internal Server Error: Server-side error

Need Help?

If you need additional assistance with the Polish API, please contact us.