Chat aanmaken
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_bodyEndpoints
Chat aanmaken
Maak een nieuwe chatsessie aan en begin te bouwen met AI
POST
/
api
/
chat
Chat aanmaken
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_bodyMaakt een nieuwe chatsessie aan en start de AI-workflow.
JSON-respons (bij
Streamingrespons (bij
Wanneer streaming is ingeschakeld, is de respons een tekststroom:
De eerste regel bevat de chat-ID in het formaat
Verzoek
POST /api/chat
Headers
| Header | Vereist | Beschrijving |
|---|---|---|
Authorization | Ja | Bearer macaly_... |
Content-Type | Ja | application/json |
Bodyparameters
| Veld | Type | Vereist | Standaard | Beschrijving |
|---|---|---|---|---|
content | string | Ja | - | Het bericht of de prompt van de gebruiker |
stream | boolean | Nee | true | Als false, retourneert JSON in plaats van een stream |
backend | string | Nee | "DEFAULT" | Te gebruiken backend |
executionMode | "auto" | "planning" | "build" | Nee | - | Bepaalt hoe de AI de taak benadert |
model | "sonnet-4-5" | "sonnet-4-6" | "opus-4-5" | "opus-4-6" | Nee | - | AI-model om te gebruiken. Standaard het geconfigureerde model van het team |
reasoningEffort | "medium" | "high" | Nee | - | Bepaalt hoe diep de AI nadenkt over de taak |
experimental_attachments | array | Nee | [] | Bestandsbijlagen (zie formaat hieronder) |
Bijlageformaat
Elk item in deexperimental_attachments-array heeft de volgende structuur:
| Veld | Type | Vereist | Beschrijving |
|---|---|---|---|
url | string | Ja | URL van het bestand om bij te voegen |
name | string | Nee | Weergavenaam voor de bijlage |
contentType | string | Nee | MIME-type van het bestand |
Voorbeeldverzoek
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'])
Respons
JSON-respons (bij stream: false)
{
"chatId": "abc123def456",
"url": "https://www.macaly.com/chat/abc123def456",
"streamId": "stream_xyz789",
"assistantMessageId": "msg_123"
}
| Veld | Type | Beschrijving |
|---|---|---|
chatId | string | De unieke chat-ID |
url | string | Directe URL om de chat te bekijken |
streamId | string | undefined | Stream-ID om u te abonneren. Alleen aanwezig voor workflow-backends |
assistantMessageId | string | undefined | ID van het assistentbericht dat wordt gegenereerd. Alleen aanwezig voor workflow-backends |
Streamingrespons (bij stream: true, standaard)
Wanneer streaming is ingeschakeld, is de respons een tekststroom:
2:[{"chatId":"abc123def456"}]
0:"Starting to build..."
...
2:[{"chatId":"..."}].
De chat-ID uit de stream halen
const text = await response.text();
const match = text.match(/2:\[{"chatId":"([^"]+)"/);
const chatId = match?.[1];
Statuscodes
| Status | Beschrijving |
|---|---|
| 200 | Succes - Chat aangemaakt |
| 400 | Ongeldig verzoek |
| 401 | Ongeldige of ontbrekende API-sleutel |
| 402 | Onvoldoende credits |
| 403 | Forbidden - Geen toestemming voor het opgegeven team |
| 422 | Validatiefout |
| 429 | Limiet bereikt |
| 500 | Serverfout |
Volgende stappen
Na het aanmaken van een chat:- Controleer de status met
GET /api/chat/{chatId}/status - Abonneer u op de stream met
GET /api/chat/{chatId}/subscribevoor realtime updates - Stuur vervolgberichten met
POST /api/chat/{chatId}/publish
Was deze pagina nuttig?