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_bodyEndpoints
Create chat
Skapa en ny chatt och börja bygga med AI
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_bodySkapar en ny chatt och startar AI-arbetsflödet.
JSON-svar (när
Streamat svar (när
När streaming är aktiverat är svaret en textström:
Första raden innehåller chatt-ID:t i formatet
Anrop
POST /api/chat
Headers
| Header | Obligatorisk | Beskrivning |
|---|---|---|
Authorization | Ja | Bearer macaly_... |
Content-Type | Ja | application/json |
Parametrar i request body
| Fält | Typ | Obligatoriskt | Standardvärde | Beskrivning |
|---|---|---|---|---|
content | string | Ja | - | Användarens meddelande eller prompt |
stream | boolean | Nej | true | Om false returneras JSON i stället för en stream |
backend | string | Nej | "DEFAULT" | Vilken backend som används |
executionMode | "auto" | "planning" | "build" | Nej | - | Styr hur AI:n angriper uppgiften |
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" | Nej | - | AI-modell som ska användas. Om du inte anger någon används teamets konfigurerade modell |
reasoningEffort | "medium" | "high" | Nej | - | Styr hur djupt AI:n resonerar kring uppgiften |
experimental_attachments | array | Nej | [] | Filbilagor (format nedan) |
Format för bilagor
Varje objekt i arrayenexperimental_attachments har följande struktur:
| Fält | Typ | Obligatoriskt | Beskrivning |
|---|---|---|---|
url | string | Ja | URL till filen som ska bifogas |
name | string | Nej | Visningsnamn för bilagan |
contentType | string | Nej | Filens MIME-typ |
Exempelanrop
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'])
Svar
JSON-svar (när stream: false)
{
"chatId": "abc123def456",
"url": "https://www.macaly.com/chat/abc123def456",
"streamId": "stream_xyz789",
"assistantMessageId": "msg_123"
}
| Fält | Typ | Beskrivning |
|---|---|---|
chatId | string | Chattens unika ID |
url | string | Direkt-URL för att öppna chatten |
streamId | string | undefined | Stream-ID som används för att prenumerera. Finns bara för workflow-backends |
assistantMessageId | string | undefined | ID för assistentmeddelandet som genereras. Finns bara för workflow-backends |
Streamat svar (när stream: true, standard)
När streaming är aktiverat är svaret en textström:
2:[{"chatId":"abc123def456"}]
0:"Starting to build..."
...
2:[{"chatId":"..."}].
Läsa ut chatt-ID:t ur strömmen
const text = await response.text();
const match = text.match(/2:\[{"chatId":"([^"]+)"/);
const chatId = match?.[1];
Statuskoder
| Status | Beskrivning |
|---|---|
| 200 | Lyckades, chatten skapades |
| 400 | Ogiltig request body |
| 401 | Ogiltig eller saknad API-nyckel |
| 402 | Otillräckligt med krediter |
| 403 | Åtkomst nekad, behörighet saknas för angivet team |
| 422 | Valideringsfel |
| 429 | För många anrop |
| 500 | Serverfel |
Nästa steg
Efter att du har skapat en chatt:- Kontrollera tills den är klar med
GET /api/chat/{chatId}/status - Prenumerera på strömmen med
GET /api/chat/{chatId}/subscribeför uppdateringar i realtid - Skicka uppföljningsmeddelanden med
POST /api/chat/{chatId}/publish
Var denna sida till hjälp?