File size: 4,267 Bytes
a6f672d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>API Documentation</title>
    <style>
        body {
            font-family: Arial, sans-serif;
            line-height: 1.6;
            max-width: 800px;
            margin: 20px auto;
            padding: 0 20px;
            color: #333;
        }
        h1 {
            color: #0056b3;
        }
        code {
            background: #f4f4f4;
            padding: 2px 6px;
            border-radius: 4px;
        }
        pre {
            background: #f4f4f4;
            padding: 10px;
            border-radius: 4px;
            overflow-x: auto;
        }
    </style>
</head>
<body>
    <h1>API Documentation</h1>
    <p>This page documents the available APIs for the Node.js service, detailing endpoints, parameters, and expected responses.</p>

    <h2>1. GET /list-models</h2>
    <p>Retrieves a list of available models.</p>
    <strong>URL:</strong>
    <pre>GET /list-models</pre>
    <strong>Response:</strong>
    <pre>["Model 1", "Model 2", "Model 3"]</pre>

    <h2>2. GET /generate/speech</h2>
    <p>Generates speech audio based on the provided script.</p>
    <strong>URL:</strong>
    <pre>GET /generate/speech?api_key=<code>your_api_key</code>&payload=<code>script_payload</code></pre>
    <strong>Parameters:</strong>
    <ul>
        <li><strong>api_key</strong> (required): Your API key for authentication.</li>
        <li><strong>payload</strong> (required): The script payload containing speaker names and speech content.</li>
    </ul>
    <strong>Response:</strong>
    <pre>Audio file in MPEG format (served as a response file).</pre>

    <h2>3. POST /generate/speech/stream</h2>
    <p>Generates speech audio and streams the response via Server-Sent Events (SSE).</p>
    <strong>URL:</strong>
    <pre>POST /generate/speech/stream?api_key=<code>your_api_key</code></pre>
    <strong>Headers:</strong>
    <ul>
        <li><strong>Content-Type</strong>: application/json</li>
    </ul>
    <strong>Body:</strong>
    <pre>{
    "payload": "script_payload"
}</pre>
    <strong>Response:</strong>
    <ul>
        <li><code>audio_segment</code>: URL to generated audio segment.</li>
        <li><code>audio_complete</code>: URL to the final combined audio file.</li>
    </ul>

    <h2>4. GET /generate/image</h2>
    <p>Generates an image based on the provided prompt.</p>
    <strong>URL:</strong>
    <pre>GET /generate/image?prompt=<code>image_prompt</code>&width=<code>image_width</code>&height=<code>image_height</code>&response_format=<code>image</code> (default)</pre>
    <strong>Parameters:</strong>
    <ul>
        <li><strong>prompt</strong> (required): Description of the image to generate.</li>
        <li><strong>width</strong> (optional): Width of the generated image (default is 1024).</li>
        <li><strong>height</strong> (optional): Height of the generated image (default is 1024).</li>
        <li><strong>response_format</strong> (optional): Format of the response, can be "image" or "url".</li>
    </ul>
    <strong>Response:</strong>
    <pre>Generated image or URL to the image.</pre>

    <h2>5. POST /generate/image</h2>
    <p>Generates an image based on a prompt passed in the body of the request.</p>
    <strong>URL:</strong>
    <pre>POST /generate/image?response_format=<code>url</code> (default)</pre>
    <strong>Headers:</strong>
    <ul>
        <li><strong>Content-Type</strong>: application/json</li>
    </ul>
    <strong>Body:</strong>
    <pre>{
    "prompt": "A large hamster"
}</pre>
    <strong>Response:</strong>
    <pre>{ "imageUrl": "https://example.com/generated_image.jpg" }</pre>

    <h2>6. Serving Static Media Files</h2>
    <p>All generated media (audio and images) can be accessed via:</p>
    <strong>URL:</strong>
    <pre>GET /media/<code>filename</code></pre>

    <h2>Notes</h2>
    <ul>
        <li>Ensure that your API key is provided when required.</li>
        <li>Audio and image generation requires a valid script payload or image prompt respectively.</li>
        <li>The system uses OpenAI for TTS, and appropriate API keys need to be set in the environment variables.</li>
    </ul>
</body>
</html>