Skip to content

xigua366/shanke-chatgpt

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 

Repository files navigation

shanke-chatgpt

【开源模型】

【AI 绘图】

【优质文章或视频】

【聚合网站】

一个最简单的访问 API 的 HTML 页面

<!DOCTYPE html>
<html lang="zh">
<head>
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>API 请求测试</title>
    <script>
        async function callAPI() {
            const apiKey = '你的API密钥'; // 请将这里替换为您的实际API密钥
            const url = 'https://api.openai.com/v1/chat/completions';
	    const inputText = document.getElementById('inputText').value;
            const requestData = {
                model: 'gpt-3.5-turbo',
                messages: [{"role": "user", "content": inputText}],
                temperature: 0.7
            };

            const response = await fetch(url, {
                method: 'POST',
                headers: {
                    'Content-Type': 'application/json',
                    'Authorization': `Bearer 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`
                },
                body: JSON.stringify(requestData)
            });

            if (response.ok) {
                const jsonResponse = await response.json();
                const result = jsonResponse.choices[0].message.content;
		console.log(jsonResponse.choices[0].message.content);
                document.getElementById('result').innerText = result;
            } else {
                document.getElementById('result').innerText = '请求失败';
            }
        }
    </script>
</head>
<body>
    <h1>ChatGPT API 请求测试</h1>
    <p>输入文本:</p>
    <textarea width:100px height:100px id="inputText"></textarea>
    <p/>
    <button onclick="callAPI()">发送请求</button>
    <p>返回结果:</p>
    <div id="result" style="border: 1px solid black; padding: 10px;"></div>
</body>
</html>

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published