API v2
API Documentation
Integrate AIGENCY's AI capabilities into your applications. Available in Pro and Business plans.
| Base URL | https://aigency.dev/api/v2 |
| Format | JSON + Multipart |
| Rate Limit | 60 req/min |
| Auth | URL Token |
Authentication
All requests require an API access token in the URL. Get your token from the API Applications section in your dashboard. API access is available in Pro and Business plans.
http
GET /api/v2/credit/{YOUR_API_TOKEN}⚠️ Never expose your API key client-side. Keep it server-side.
Endpoints
Credit & Account
Assistants
Chat
Error Codes
200Success400Bad request or missing parameters401Invalid or missing API key402Insufficient credit balance403Feature not available in your plan429Rate limit exceeded (60 req/min)500Server errorPlan Requirements
API access is available in Pro and Business plans.
Feature
Pro
Business
API Access
✓
✓
Monthly Token Limit
100K
500K
Rate Limit
60/dk
60/dk
File Upload
✓
✓
Image Generation
Unlimited
Unlimited
Document Generation
✓
✓
Credit Management
API applications have a separate credit balance. You can transfer credits from your account to your app.
How It Works?
1.Purchase Pro or Business plan → Tokens loaded to your account
2.Create an app from API Applications page (aigency.dev/application)
3.Transfer tokens from your account to the app (min: 1,000 tokens)
4.Each API call deducts tokens from the app's credit
5.When depleted, transfer more or purchase a new package
💡 Tip: Each message response includes remaining_credit. Monitor this value to warn users before credit runs out.
Operation
Est. Cost
Note
Short message
~6 credits
100 token query + 500 token response
Medium message
~12 credits
200 token query + 1000 token response
Long message
~25 credits
500 token query + 2000 token response
Image generation
1 credits
Fixed cost
Credit check
0 credits
Free
List assistants
0 credits
Free
Examples
Python
python
import requests
TOKEN = "YOUR_API_TOKEN"
BASE = "https://aigency.dev/api/v2"
# Kredi sorgula
credit = requests.get(f"{BASE}/credit/{TOKEN}").json()
print(f"Kalan kredi: {credit['credit']}")
if credit.get("low_credit"):
print("⚠️ Kredi azalıyor!")
# Asistanları listele
assistants = requests.get(f"{BASE}/ai-team-list/{TOKEN}").json()
ai_id = assistants[0]["id"]
print(f"Asistan: {assistants[0]['name']['name_tr']}")
# Yeni sohbet başlat
chat = requests.post(f"{BASE}/newChat/{ai_id}/{TOKEN}",
json={"message": "Merhaba!"}).json()
print(f"AI: {chat['message']}")
print(f"Kalan kredi: {chat.get('remaining_credit')}")
# Mesaj gönder (multipart)
resp = requests.post(f"{BASE}/sendMessage/{TOKEN}",
data={"chat_id": chat["chat_id"],
"message": "Python ile REST API yaz"}).json()
print(f"AI: {resp['message'][:100]}")
print(f"Kalan kredi: {resp.get('remaining_credit')}")
# Sohbet geçmişi
history = requests.post(
f"{BASE}/resumeChat/{chat['chat_id']}/{TOKEN}").json()
for msg in history["messages"]:
print(f"{msg['role']}: {msg['content'][:50]}...")JavaScript (Node.js)
javascript
const TOKEN = "YOUR_API_TOKEN";
const BASE = "https://aigency.dev/api/v2";
// Kredi kontrol
const credit = await fetch(`${BASE}/credit/${TOKEN}`).then(r => r.json());
console.log("Kredi:", credit.credit);
if (credit.no_credit) console.error("Kredi tükendi!");
// Yeni sohbet başlat
const chat = await fetch(`${BASE}/newChat/16/${TOKEN}`, {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({ message: "Merhaba!" })
}).then(r => r.json());
console.log("AI:", chat.message);
console.log("Kalan:", chat.remaining_credit);
// Mesaj gönder (multipart - dosya ekleme destekli)
const form = new FormData();
form.append("chat_id", chat.chat_id);
form.append("message", "React ile todo uygulaması yaz");
// form.append("attachements", file); // Dosya eklemek için
const resp = await fetch(`${BASE}/sendMessage/${TOKEN}`,
{ method: "POST", body: form }).then(r => r.json());
console.log("AI:", resp.message);
console.log("Kalan:", resp.remaining_credit);cURL
bash
# Kredi sorgula
curl https://aigency.dev/api/v2/credit/YOUR_API_TOKEN
# Asistanları listele
curl https://aigency.dev/api/v2/ai-team-list/YOUR_API_TOKEN
# Yeni sohbet başlat
curl -X POST https://aigency.dev/api/v2/newChat/16/YOUR_API_TOKEN \
-H "Content-Type: application/json" \
-d '{"message": "Merhaba"}'
# Mesaj gönder (multipart)
curl -X POST https://aigency.dev/api/v2/sendMessage/YOUR_API_TOKEN \
-F "chat_id=CHAT_ID" \
-F "message=Python ile API yaz"
# Sohbet geçmişi
curl -X POST https://aigency.dev/api/v2/resumeChat/CHAT_ID/YOUR_API_TOKEN
# Sohbet listesi
curl https://aigency.dev/api/v2/view-chats/16/YOUR_API_TOKEN
# Sohbet sil
curl -X DELETE https://aigency.dev/api/v2/deleteChat/CHAT_ID/YOUR_API_TOKENImportant Notes
- • Your API key is app-specific. Each app has its own credit balance.
- • Credits are transferred from your account to the app. Purchase packages to top up.
- • Each response includes remaining_credit. Monitor this to act before depletion.
- • System prompt tokens are not billed. Only message + response tokens count.
- • Use multipart/form-data for file uploads. Maximum file size is 30MB.
- • Responses with is_image: true contain image filenames. Access via /api/image?fileName=FILENAME.
- • Rate limit: 60 requests per minute. Returns 429 when exceeded.
Ready to start?
My API Apps →