| <!DOCTYPE html> |
| <html lang="en"> |
| <head> |
| <meta charset="UTF-8"> |
| <title>DeepSeek Test</title> |
| </head> |
| <body> |
|
|
| <h2>DeepSeek Chat Test</h2> |
|
|
| <button onclick="send()">Send Request</button> |
|
|
| <pre id="output"></pre> |
|
|
| <script> |
| const API_URL = "https://api.deepseek.com/chat/completions"; |
| const API_KEY = "sk-6080b89d5cb844c29ad10158144e45eb"; |
| |
| async function send() { |
| const output = document.getElementById("output"); |
| output.textContent = "Loading..."; |
| |
| try { |
| const response = await fetch(API_URL, { |
| method: "POST", |
| headers: { |
| "Content-Type": "application/json", |
| "Authorization": `Bearer ${API_KEY}` |
| }, |
| body: JSON.stringify({ |
| model: "deepseek-chat", |
| messages: [ |
| { role: "system", content: "You are a helpful assistant." }, |
| { role: "user", content: "Hello!" } |
| ], |
| stream: false |
| }) |
| }); |
| |
| const data = await response.json(); |
| output.textContent = data.choices[0].message.content; |
| |
| } catch (err) { |
| output.textContent = "Error: " + err.message; |
| } |
| } |
| </script> |
|
|
| </body> |
| </html> |
|
|