To check the available models, make a GET request to the /v1/models endpoint:
Get your API key using the Zanity - API bot:
Use the /getkey
slash command after you have the @Zanity Premium #
role.
Include the API key in all request headers:
Authorization: Bearer YOUR_API_KEY
Premium API: 15 requests per minute
const API_KEY = 'your_api_key_here';
const API_URL = 'https://api.zanity.net/v1/chat/completions';
const requestBody = {
model: 'gpt-4o',
messages: [
{ role: 'system', content: 'You are a helpful assistant.' },
{ role: 'user', content: 'Hello, how are you?' }
]
};
async function callZanityAPI() {
try {
const response = await fetch(API_URL, {
method: 'POST',
headers: {
'Authorization': `Bearer ${API_KEY}`,
'Content-Type': 'application/json'
},
body: JSON.stringify(requestBody)
});
if (!response.ok) {
throw new Error(`HTTP error! status: ${response.status}`);
}
const data = await response.json();
console.log(data.choices[0].message.content);
} catch (error) {
console.error('Error:', error);
}
}
callZanityAPI();
JSON mode is available on all chat models but the performance may vary depending on the model. Just include the following in your request body:
response_format: { type: 'json_object' }