forked from dhiaaeddine16/duckduckgo-ai-openai-api
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebsite.html
117 lines (106 loc) · 6.25 KB
/
website.html
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
116
117
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>DuckDuckGo AI OpenAI API</title>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/tailwindcss/2.2.19/tailwind.min.css">
<script>
let API_URL = "https://api.chatgpto.ooguy.com";
function showSpinner(outputId) {
document.getElementById(outputId).innerHTML = '<div class="animate-spin rounded-full h-6 w-6 border-b-2 border-gray-900 mx-auto"></div>';
}
async function create_API_KEY(ADMIN_API_KEY) {
const input = { ADMIN_API_KEY };
showSpinner("output_create");
const response = await fetch(`${API_URL}/api-keys`, {
method: "POST",
headers: {
"Content-Type": "application/json",
"Authorization": `Bearer ${ADMIN_API_KEY}`
},
body: JSON.stringify({ description: "Test key created via UI" })
});
const output = await response.json();
document.getElementById("output_create").innerText = JSON.stringify({ input, output }, null, 2);
}
async function chatRequest(API_KEY, prompt, model) {
const input = { API_KEY, prompt, model };
showSpinner("output_chat");
const response = await fetch(`${API_URL}/chat/completions`, {
method: "POST",
headers: {
"Content-Type": "application/json",
"Authorization": `Bearer ${API_KEY}`
},
body: JSON.stringify({ messages: [{ "role": "user", "content": prompt }], model:model })
});
const output = await response.json();
document.getElementById("output_chat").innerText = JSON.stringify({ input, output }, null, 2);
}
async function deleteRequest(API_KEY, ADMIN_API_KEY) {
const input = { API_KEY, ADMIN_API_KEY };
showSpinner("output_delete");
const response = await fetch(`${API_URL}/api-keys/${API_KEY}`, {
method: "DELETE",
headers: { "Authorization": `Bearer ${ADMIN_API_KEY}` }
});
const output = await response.json();
document.getElementById("output_delete").innerText = JSON.stringify({ input, output }, null, 2);
}
</script>
</head>
<body class="bg-gray-100">
<header class="bg-blue-600 text-white text-center p-6">
<h1 class="text-4xl font-bold">DuckDuckGo AI OpenAI API</h1>
<p class="text-lg mt-2">Fast, Free & Powerful AI Chat Completions</p>
</header>
<main class="max-w-4xl mx-auto p-6">
<section class="bg-white p-6 shadow-lg rounded-lg">
<h2 class="text-2xl font-semibold mb-4">🚀 About the API</h2>
<p>The API mimics OpenAI's functionality while leveraging DuckDuckGo's AI models to deliver chat completions with streaming and non-streaming responses.</p>
</section>
<section class="bg-white p-6 shadow-lg rounded-lg mt-6">
<h2 class="text-2xl font-semibold mb-4">✨ Features</h2>
<ul class="list-disc pl-6">
<li>🔑 API Key Management</li>
<li>📡 Streaming & Non-Streaming Responses</li>
<li>💾 Supports SQLite & PostgreSQL</li>
<li>🚫 Can Run Without a Database</li>
</ul>
</section>
<section class="bg-white p-6 shadow-lg rounded-lg mt-6">
<h2 class="text-2xl font-semibold mb-4">🔗 Try the API</h2>
<label for="api_url">API URL (try to use our api for free https://api.chatgpto.ooguy.com):</label>
<input id="api_url" type="text" placeholder="https://api.chatgpto.ooguy.com" value="https://api.chatgpto.ooguy.com" class="border p-2 mt-2 w-full" oninput="API_URL = this.value" />
<pre class="bg-gray-200 p-4 rounded-lg mt-4">Current API URL: <span id="current_api_url">https://api.chatgpto.ooguy.com</span></pre>
</section>
<section class="bg-white p-6 shadow-lg rounded-lg mt-6">
<h2 class="text-2xl font-semibold mb-4">🛠 API Testing</h2>
<label for="admin_api_key">Enter your Admin API Key (default: "your-super-secret-admin-token"):</label>
<input id="admin_api_key" type="text" placeholder="your-super-secret-admin-token" class="border p-2 mt-2 w-full" />
<button onclick="create_API_KEY(document.getElementById('admin_api_key').value)" class="bg-blue-500 text-white p-2 mt-2 w-full">Create API Key</button>
<pre id="output_create" class="bg-gray-200 p-4 rounded-lg mt-4"></pre>
<label for="api_key">API Key:</label>
<input id="api_key" type="text" placeholder="API Key" class="border p-2 mt-2 w-full" />
<label for="prompt">Chat Prompt:</label>
<input id="prompt" type="text" placeholder="Chat Prompt" class="border p-2 mt-2 w-full" />
<label for="model">Model:</label>
<select id="model" class="border p-2 mt-2 w-full">
<option value="o3-mini">o3-mini</option>
<option value="gpt-4o-mini">gpt-4o-mini</option>
<option value="llama-3.3-70b">llama-3.3-70b</option>
<option value="claude-3-haiku">claude-3-haiku</option>
<option value="mixtral-8x7b">mixtral-8x7b</option>
</select>
<button onclick="chatRequest(document.getElementById('api_key').value, document.getElementById('prompt').value, document.getElementById('model').value)" class="bg-green-500 text-white p-2 mt-2 w-full">Send Chat Request</button>
<pre id="output_chat" class="bg-gray-200 p-4 rounded-lg mt-4"></pre>
<button onclick="deleteRequest(document.getElementById('api_key').value, document.getElementById('admin_api_key').value)" class="bg-red-500 text-white p-2 mt-2 w-full">Delete API Key</button>
<pre id="output_delete" class="bg-gray-200 p-4 rounded-lg mt-4"></pre>
</section>
</main>
<footer class="text-center p-6 bg-gray-200 mt-6">
<p>© 2025 DuckDuckGo AI OpenAI API. All Rights Reserved.</p>
</footer>
</body>
</html>