Flawless Text API Documentation

Explore Appy Pie's Flawless Text API documentation to easily incorporate advanced text generation features into your projects. This guide provides clear instructions, practical examples, and step-by-step guidance, helping you harness the full potential of the Flawless Text API. Whether you're a developer or a professional designer, learn how to optimize your applications with this powerful text generation tool.

Authentication:

To access the Flawless Text API, you need to subscribe and obtain a Subscription key. Include this key in your request header to authenticate and ensure seamless access to the API services.

Request Headers:

Content-Type Set to application/json
Cache-Control Recommended to set to no-cache
Ocp-Apim-Subscription-Key YOUR_SUBSCRIPTION_KEY

Endpoint

Base URL: https://gateway.appypie.com/flawless-api/v1/AppyText2Image

Request Body

API Parameters: The API POST- https://gateway.appypie.com/flawless-api/v1/AppyText2Image  takes the following parameters:

Parameter Type Required Description
prompt string Yes A prompt is a textual command or description provided to guide the AI in generating an image. For example, "a serene beach at sunset with gentle waves and a distant sailboat."
user_id string Yes A unique identifier for the user making request
gen_id string Yes A unique ID assigned to the specific image request.
req_id number Yes The request ID for this specific operation
type string Yes Indicates the purpose/environment, eg., testOnLocalServer.
from string Yes Identifies the source/module, eg., glyphImageGenerator.
numberOfImage integer Yes Specifies the number of images to generate (default:2).
advancedSettings object No A collection of optional parameters for advanced control.

advancedSettings Object

Parameter Type Description
texts_lines array of strings Line of text to appear on the image.
fontName array of strings List of fonts applied to the text. Example: AbhayaLibre-ExtraBold, MarykateRegular, Shrikhand-Regular.
lora_weight integer The seed is used to reproduce results. Providing the same seed will yield the same image each time. Use “null” for a random number seed.

Example Request Body

JSON

{
        "prompt": "Design a poster with heartfelt and warm wishes for a Merry Christmas",
        "user_id": "21245",
        "gen_id": "1234",
        "req_id": 1234,
        "type": "testOnLocalServer",
        "from": "glyphImageGenerator",
        "numberOfImages": 2
    }
    

Request Code

Input
    POST https://gateway.appypie.com/flawless-api/v1/AppyText2Image HTTP/1.1
    
    Content-Type: application/json
    Cache-Control: no-cache
    
    {
        "prompt": "Design a poster with heartfelt and warm wishes for a Merry Christmas",
        "user_id": "21245",
        "gen_id": "1234",
        "req_id": 1234,
        "type": "testOnLocalServer",
        "from": "glyphImageGenerator",
        "numberOfImages": 2
    }
    
    import urllib.request, json
    
    try:
        url = "https://gateway.appypie.com/flawless-api/v1/AppyText2Image"
    
        hdr ={
        # Request headers
        'Content-Type': 'application/json',
        'Cache-Control': 'no-cache',
        }
    
        # Request body
        data =  
        data = json.dumps(data)
        req = urllib.request.Request(url, headers=hdr, data = bytes(data.encode("utf-8")))
    
        req.get_method = lambda: 'POST'
        response = urllib.request.urlopen(req)
        print(response.getcode())
        print(response.read())
        except Exception as e:
        print(e)
    
    // Request body
    const body = {
        "prompt": "Design a poster with heartfelt and warm wishes for a Merry Christmas",
        "user_id": "21245",
        "gen_id": "1234",
        "req_id": 1234,
        "type": "testOnLocalServer",
        "from": "glyphImageGenerator",
        "numberOfImages": 2
    };
    
    fetch('https://gateway.appypie.com/flawless-api/v1/AppyText2Image', {
            method: 'POST',
            body: JSON.stringify(body),
            // Request headers
            headers: {
                'Content-Type': 'application/json',
                'Cache-Control': 'no-cache',}
        })
        .then(response => {
            console.log(response.status);
            console.log(response.text());
        })
        .catch(err => console.error(err));
    
    curl -v -X POST "https://gateway.appypie.com/flawless-api/v1/AppyText2Image" -H "Content-Type: application/json" -H "Cache-Control: no-cache" --data-raw "{
        \"prompt\": \"Design a poster with heartfelt and warm wishes for a Merry Christmas\",
        \"user_id\": \"21245\",
        \"gen_id\": \"1234\",
        \"req_id\": 1234,
        \"type\": \"testOnLocalServer\",
        \"from\": \"glyphImageGenerator\",
        \"numberOfImages\": 2
    }"
    
    import java.io.BufferedReader;
    import java.io.InputStreamReader;
    import java.net.HttpURLConnection;
    import java.net.URL;
    import java.net.URLEncoder;
    import java.util.HashMap;
    import java.util.Map;
    import java.io.UnsupportedEncodingException;
    import java.io.DataInputStream;
    import java.io.InputStream;
    import java.io.FileInputStream;
    
    public class HelloWorld {
    
      public static void main(String[] args) {
        try {
            String urlString = "https://gateway.appypie.com/flawless-api/v1/AppyText2Image";
            URL url = new URL(urlString);
            HttpURLConnection connection = (HttpURLConnection) url.openConnection();
    
            //Request headers
        connection.setRequestProperty("Content-Type", "application/json");
        
        connection.setRequestProperty("Cache-Control", "no-cache");
        
            connection.setRequestMethod("POST");
    
            // Request body
            connection.setDoOutput(true);
            connection
                .getOutputStream()
                .write(
                 "{ \"prompt\": \"Design a poster with heartfelt and warm wishes for a Merry Christmas\", \"user_id\": \"21245\", \"gen_id\": \"1234\", \"req_id\": 1234, \"type\": \"testOnLocalServer\", \"from\": \"glyphImageGenerator\", \"numberOfImages\": 2 }".getBytes()
                 );
        
            int status = connection.getResponseCode();
            System.out.println(status);
    
            BufferedReader in = new BufferedReader(
                new InputStreamReader(connection.getInputStream())
            );
            String inputLine;
            StringBuffer content = new StringBuffer();
            while ((inputLine = in.readLine()) != null) {
                content.append(inputLine);
            }
            in.close();
            System.out.println(content);
    
            connection.disconnect();
        } catch (Exception ex) {
          System.out.print("exception:" + ex.getMessage());
        }
      }
    }
    
    $url = "https://gateway.appypie.com/flawless-api/v1/AppyText2Image";
    $curl = curl_init($url);
    
    curl_setopt($curl, CURLOPT_CUSTOMREQUEST, "POST");
    curl_setopt($curl, CURLOPT_URL, $url);
    curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
    
    # Request headers
    $headers = array(
        'Content-Type: application/json',
        'Cache-Control: no-cache',);
    curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
    
    # Request body
    $request_body = '{
        "prompt": "Design a poster with heartfelt and warm wishes for a Merry Christmas",
        "user_id": "21245",
        "gen_id": "1234",
        "req_id": 1234,
        "type": "testOnLocalServer",
        "from": "glyphImageGenerator",
        "numberOfImages": 2
    }';
    curl_setopt($curl, CURLOPT_POSTFIELDS, $request_body);
    
    $resp = curl_exec($curl);
    curl_close($curl);
    var_dump($resp);
    


Response

JSON

        HTTP/1.1 200 OK
    
 
        
        {
            "statusCode": 200,
            "body": "{\"msg\": \"Image Getting Created\", \"glyph_image_light\": \"https://imagesai.appypie.com/GlyphImages/b4571137-dc36-4b04-883b-0c1321348550_light.png\", \"glyph_image_dark\": \"https://imagesai.appypie.com/GlyphImages/b4571137-dc36-4b04-883b-0c1321348550_dark.png\", \"fonts_used\": [\"en-Signika-Bold\", \"en-PTSans-Bold\", \"en-PTSans-Bold\", \"en-ClearSans-Bold\"], \"texts\": [[0.109375, 0.0546875, 0.48999999999999994, 0.06562499999999999], [0.06562499999999999, 0.1640625, 0.56875, 0.07656249999999999], [0.175, 0.284375, 0.48999999999999994, 0.055999999999999994], [0.175, 0.3828125, 0.48999999999999994, 0.06562499999999999]]}"
        }
        
    

Response Handling

The Flawless Text API provides clear HTTP status codes and detailed response messages to indicate whether a request was processed successfully or if an error occurred. It is essential for developers to implement robust error handling in their applications to interpret and manage these responses effectively.

Common Status Codes and Responses

Status Code Description Response Body
200 Success - The request was successfully processed, and the image generation is in progress or completed. { "msg": "Image Getting Created", ... }
400 Bad Request - The request contains invalid parameters or missing fields. { "error": "Invalid request parameters" }
401 Unauthorized - The provided subscription key is missing or invalid. { "error": "Invalid or missing authentication" }
403 Forbidden - The subscription does not have access to this API or action. { "error": "Access denied for this operation" }
404 Not Found - The requested resource or endpoint could not be found. { "error": "Endpoint not found" }
429 Too Many Requests - The request rate limit has been exceeded. { "error": "Rate limit exceeded, please retry later" }
500 Internal Server Error - An unexpected error occurred on the server. { "error": "An unexpected error occurred, please try again later" }

Example Error Response

        {
            "error": "Invalid prompt parameter"
        }    
    

Conclusion

This Flawless text API documentation provides all the necessary information for effectively using Appy Pie's Flawless Text API. Make sure to replace YOUR_SUBSCRIPTION_KEY with the actual key you obtained upon subscribing to the service.