<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>xAI API</title>
<style>
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body, html {
height: 100%;
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
background: url('https://ipgeo-bingpic.hf.space') no-repeat center center fixed;
background-size: cover;
color: white;
text-shadow: 1px 1px 2px rgba(0,0,0,0.8);
}
.container {
max-width: 800px;
width: 90%;
margin: 0 auto;
height: 100%;
padding: 20px;
display: flex;
flex-direction: column;
justify-content: center;
}
h1 {
text-align: center;
margin-bottom: 20px;
}
h2 {
text-align: left;
margin-bottom: 10px;
}
pre {
background: rgba(255,255,255,0.1);
padding: 15px;
border-radius: 8px;
max-width: 100%;
overflow-x: auto;
font-size: 14px;
line-height: 1.6;
text-align: left;
}
footer {
position: fixed;
bottom: 10px;
width: 100%;
text-align: center;
font-size: 12px;
color: white;
text-shadow: 1px 1px 2px rgba(0,0,0,0.8);
}
footer a {
color: white;
text-decoration: none;
}
footer a:hover {
text-decoration: underline;
}
@media (max-width: 600px) {
pre {
font-size: 12px;
padding: 10px;
}
}
</style>
</head>
<body>
<div class="container">
<h1>xAI API</h1>
<h2>Streaming Request</h2>
<pre><code id="stream-code"></code></pre>
<h2>Non-Streaming Request</h2>
<pre><code id="normal-code"></code></pre>
</div>
<footer>Copyright © <span id="current-year"></span> All Rights Reserved by <a href="https://linux.do" target="_blank">LINUX DO</a></footer>
<script>
document.getElementById('current-year').textContent = new Date().getFullYear();
const apiURL = window.location.href.replace(/\/$/, '');
document.getElementById('stream-code').textContent = `fetch('${apiURL}/v1/chat/completions', {
method: 'POST',
headers: {
'Authorization': 'Bearer YOUR_API_KEY',
'Content-Type': 'application/json'
},
body: JSON.stringify({
'model': 'grok-beta',
'stream': true,
'messages': [{'role': 'user', 'content': 'message'}]
})
})`.replace('${apiURL}', apiURL);
document.getElementById('normal-code').textContent = `fetch('${apiURL}/v1/chat/completions', {
method: 'POST',
headers: {
'Authorization': 'Bearer YOUR_API_KEY',
'Content-Type': 'application/json'
},
body: JSON.stringify({
'model': 'grok-beta',
'messages': [{'role': 'user', 'content': 'message'}]
})
})`.replace('${apiURL}', apiURL);
</script>
</body>
</html>