AI API
My API Keys
Recent Requests
AI API - Documentation
Complete documentation for using GreatHost's Artificial Intelligence API.
Table of Contents
Introduction
GreatHost's AI API allows you to integrate powerful artificial intelligence models into your applications. Our API is compatible with the OpenAI format and supports multiple advanced models.
Base URL
https://greathost.es/api/ai-api
Authentication
All API requests require a valid API Key. You can create and manage your API Keys from the control panel.
Authorization Header
Authorization: Bearer gha_your_api_key_here
Available Models
We currently offer the following models:
Advanced model with default reasoning. Ideal for complex tasks.
Cost: 0.50 credits per request
Fast model without additional reasoning. Perfect for direct responses.
Cost: 0.50 credits per request
Balanced model with low reasoning. Good quality-price ratio.
Cost: 0.50 credits per request
Model with integrated tools (web search and code interpreter).
Cost: 0.50 credits per request
Advanced conversational AI model with high-quality instruction following.
Cost: 0.50 credits per request
Large-scale model with low reasoning effort for efficient processing.
Cost: 0.50 credits per request
Large-scale model with medium reasoning effort for balanced performance.
Cost: 0.50 credits per request
Large-scale model with high reasoning effort for complex tasks.
Cost: 0.50 credits per request
Meta's latest Llama model optimized for instruction following and reasoning.
Cost: 0.50 credits per request
Endpoints
POST /chat/completions
Makes a chat completion request to an AI model.
Body Parameters
Array of messages in OpenAI format.
Request Example
{
"messages": [
{
"role": "user",
"content": "Hello, how are you?"
}
]
}
Response
{
"response": "Hello! I'm doing great, thanks for asking. How can I help you today?"
}
GET /models
Gets the list of available models.
Response
[
{
"id": "qwen-32b-default",
"name": "Qwen 32B (Default)",
"cost_per_request": 0.50
},
{
"id": "qwen-32b-none",
"name": "Qwen 32B (None)",
"cost_per_request": 0.50
},
{
"id": "gpt-oss-20b-low",
"name": "GPT OSS 20B (Low)",
"cost_per_request": 0.50
},
{
"id": "gpt-oss-20b-tools",
"name": "GPT OSS 20B (Tools)",
"cost_per_request": 0.50
},
{
"id": "kimi-k2-instruct",
"name": "Moonshot AI Kimi K2 Instruct",
"cost_per_request": 0.50
},
{
"id": "gpt-oss-120b-low",
"name": "GPT OSS 120B (Low)",
"cost_per_request": 0.50
},
{
"id": "gpt-oss-120b-medium",
"name": "GPT OSS 120B (Medium)",
"cost_per_request": 0.50
},
{
"id": "gpt-oss-120b-high",
"name": "GPT OSS 120B (High)",
"cost_per_request": 0.50
},
{
"id": "llama-4-scout-17b",
"name": "Meta Llama 4 Scout 17B Instruct",
"cost_per_request": 0.50
}
]
Usage Examples
JavaScript/Node.js
const response = await fetch('https://greathost.es/api/ai-api/chat/completions', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Authorization': 'Bearer gha_your_api_key_here'
},
body: JSON.stringify({
messages: [
{
role: 'user',
content: 'What is the capital of Spain?'
}
]
})
});
const data = await response.json();
console.log(data.response);
Python
import requests
url = "https://greathost.es/api/ai-api/chat/completions"
headers = {
"Content-Type": "application/json",
"Authorization": "Bearer gha_your_api_key_here"
}
data = {
"messages": [
{
"role": "user",
"content": "What is the capital of Spain?"
}
]
}
response = requests.post(url, headers=headers, json=data)
result = response.json()
print(result["response"])
cURL
curl -X POST https://greathost.es/api/ai-api/chat/completions \
-H "Content-Type: application/json" \
-H "Authorization: Bearer gha_your_api_key_here" \
-d '{
"messages": [
{
"role": "user",
"content": "What is the capital of Spain?"
}
]
}'
PHP
<?php
$url = "https://greathost.es/api/ai-api/chat/completions";
$headers = [
"Content-Type: application/json",
"Authorization: Bearer gha_your_api_key_here"
];
$data = [
"messages" => [
[
"role" => "user",
"content" => "What is the capital of Spain?"
]
]
];
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
curl_close($ch);
$result = json_decode($response, true);
echo $result["response"];
?>
Error Codes
Missing or invalid API key.
Insufficient balance to make the request.
Request limit reached.
Invalid request parameters.
Internal server error.
Limits and Costs
Costs
All models currently cost 0.005 credits per request.
Limits
- You can set custom limits per API Key
- Requests are processed in real time
- Streaming is enabled by default
- Maximum tokens per request: varies by model
API Key Management
From your control panel you can:
- Create multiple API Keys
- Set usage limits
- Monitor usage in real time
- View request history
- Activate/deactivate API Keys
Need help?
If you have questions or need technical support, don't hesitate to contact us: