<!DOCTYPE html>
<html>
<head>
<title>AI Model Data Pull</title>
<style>
</style>
</head>
<body>
<h1>Data Pull from OpenAI API</h1>
<div id="output"></div>
<script>
const apiKey = "YOUR_OPENAI_API_KEY";
const apiUrl = "https://api.openai.com/v1/";
async function fetchDataFromAPI() {
try {
const response = await fetch(apiUrl + "data", {
method: "GET",
headers: {
"Authorization": `Bearer ${apiKey}`,
"Content-Type": "application/json"
}
});
if (!response.ok) {
throw new Error("Error fetching data from API");
}
const data = await response.json();
displayData(data);
} catch (error) {
console.error(error);
}
}
function displayData(data) {
const outputDiv = document.getElementById("output");
outputDiv.innerHTML = "<pre>" + JSON.stringify(data, null, 4) + "</pre>";
}
window.addEventListener("load", fetchDataFromAPI);
</script>
</body>
</html>