Create chat
curl --request POST \
--url https://macaly.com/api/chat \
--header 'Authorization: Bearer <token>'import requests
url = "https://macaly.com/api/chat"
headers = {"Authorization": "Bearer <token>"}
response = requests.post(url, headers=headers)
print(response.text)const options = {method: 'POST', headers: {Authorization: 'Bearer <token>'}};
fetch('https://macaly.com/api/chat', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://macaly.com/api/chat",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://macaly.com/api/chat"
req, _ := http.NewRequest("POST", url, nil)
req.Header.Add("Authorization", "Bearer <token>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://macaly.com/api/chat")
.header("Authorization", "Bearer <token>")
.asString();require 'uri'
require 'net/http'
url = URI("https://macaly.com/api/chat")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
response = http.request(request)
puts response.read_bodyEndpoint'ler
Create chat
Yeni bir sohbet oturumu oluşturun ve yapay zeka ile geliştirmeye başlayın
POST
/
api
/
chat
Create chat
curl --request POST \
--url https://macaly.com/api/chat \
--header 'Authorization: Bearer <token>'import requests
url = "https://macaly.com/api/chat"
headers = {"Authorization": "Bearer <token>"}
response = requests.post(url, headers=headers)
print(response.text)const options = {method: 'POST', headers: {Authorization: 'Bearer <token>'}};
fetch('https://macaly.com/api/chat', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://macaly.com/api/chat",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://macaly.com/api/chat"
req, _ := http.NewRequest("POST", url, nil)
req.Header.Add("Authorization", "Bearer <token>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://macaly.com/api/chat")
.header("Authorization", "Bearer <token>")
.asString();require 'uri'
require 'net/http'
url = URI("https://macaly.com/api/chat")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
response = http.request(request)
puts response.read_bodyYeni bir sohbet oturumu oluşturur ve yapay zeka işlemini başlatır.
JSON yanıtı (
Stream yanıtı (
Stream etkinleştirildiğinde yanıt bir metin stream’i olur:
İlk satır, sohbet kimliğini
İstek
POST /api/chat
Başlıklar
| Header | Zorunlu | Açıklama |
|---|---|---|
Authorization | Evet | Bearer macaly_... |
Content-Type | Evet | application/json |
İstek gövdesi parametreleri
| Alan | Tür | Zorunlu | Varsayılan | Açıklama |
|---|---|---|---|---|
content | string | Evet | - | Kullanıcının mesajı veya istemi |
stream | boolean | Hayır | true | false ise stream yerine JSON döndürür |
backend | string | Hayır | "DEFAULT" | Kullanılacak arka uç |
executionMode | "auto" | "planning" | "build" | Hayır | - | Yapay zekanın göreve nasıl yaklaşacağını belirler |
model | "gpt-5.6-terra" | "gpt-6.1-sol" | "gpt-6-luna" | "grok-4-6" | "kimi-k3" | "sonnet-5-5" | "opus-5-5" | "blueai-glm-5-3" | "blueai-glm-5-3-flash" | Hayır | - | Kullanılacak yapay zeka modeli. Varsayılan olarak ekip için yapılandırılmış model kullanılır |
reasoningEffort | "medium" | "high" | Hayır | - | Yapay zekanın görev üzerinde ne kadar derin düşüneceğini belirler |
experimental_attachments | array | Hayır | [] | Dosya ekleri (format için aşağıya bakın) |
Ek formatı
experimental_attachments dizisindeki her öğe aşağıdaki yapıya sahiptir:
| Alan | Tür | Zorunlu | Açıklama |
|---|---|---|---|
url | string | Evet | Eklenecek dosyanın URL’si |
name | string | Hayır | Ek için görüntülenecek ad |
contentType | string | Hayır | Dosyanın MIME türü |
Örnek istek
curl -X POST https://www.macaly.com/api/chat \
-H "Authorization: Bearer macaly_abc123..." \
-H "Content-Type: application/json" \
-d '{
"content": "Create a landing page for a coffee shop",
"stream": false
}'
const response = await fetch('https://www.macaly.com/api/chat', {
method: 'POST',
headers: {
'Authorization': 'Bearer macaly_abc123...',
'Content-Type': 'application/json',
},
body: JSON.stringify({
content: 'Create a landing page for a coffee shop',
stream: false,
}),
});
const data = await response.json();
console.log(data.chatId);
import requests
response = requests.post(
'https://www.macaly.com/api/chat',
headers={
'Authorization': 'Bearer macaly_abc123...',
'Content-Type': 'application/json',
},
json={
'content': 'Create a landing page for a coffee shop',
'stream': False,
},
)
data = response.json()
print(data['chatId'])
Yanıt
JSON yanıtı (stream: false olduğunda)
{
"chatId": "abc123def456",
"url": "https://www.macaly.com/chat/abc123def456",
"streamId": "stream_xyz789",
"assistantMessageId": "msg_123"
}
| Alan | Tür | Açıklama |
|---|---|---|
chatId | string | Sohbetin benzersiz kimliği |
url | string | Sohbeti görüntülemek için doğrudan URL |
streamId | string | undefined | Abone olmak için kullanılan stream kimliği. Yalnızca işlem tabanlı arka uçlarda bulunur |
assistantMessageId | string | undefined | Oluşturulmakta olan asistan mesajının kimliği. Yalnızca işlem tabanlı arka uçlarda bulunur |
Stream yanıtı (stream: true, varsayılan)
Stream etkinleştirildiğinde yanıt bir metin stream’i olur:
2:[{"chatId":"abc123def456"}]
0:"Starting to build..."
...
2:[{"chatId":"..."}] formatında içerir.
Sohbet kimliğini stream’den ayrıştırma
const text = await response.text();
const match = text.match(/2:\[{"chatId":"([^"]+)"/);
const chatId = match?.[1];
Durum kodları
| Durum | Açıklama |
|---|---|
| 200 | Başarılı - Sohbet oluşturuldu |
| 400 | Geçersiz istek gövdesi |
| 401 | Geçersiz veya eksik API anahtarı |
| 402 | Yetersiz kredi |
| 403 | Erişim reddedildi - Belirtilen ekip için yetkiniz yok |
| 422 | Doğrulama hatası |
| 429 | İstek limiti aşıldı |
| 500 | Sunucu hatası |
Sonraki adımlar
Bir sohbet oluşturduktan sonra:- İlerlemeyi takip edin -
GET /api/chat/{chatId}/status - Stream’e abone olun - Gerçek zamanlı güncellemeler için
GET /api/chat/{chatId}/subscribe - Takip mesajları gönderin -
POST /api/chat/{chatId}/publish
Bu sayfa yararlı mıydı?