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
Create chat
Creazione di una nuova chat e avvio del lavoro con l’IA
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_bodyCrea una nuova chat e avvia l’elaborazione da parte dell’IA.
Risposta JSON (con
Risposta in streaming (con
Quando lo streaming è attivo, la risposta è uno stream di testo:
La prima riga contiene l’ID della chat nel formato
Richiesta
POST /api/chat
Header
| Header | Obbligatorio | Descrizione |
|---|---|---|
Authorization | Sì | Bearer macaly_... |
Content-Type | Sì | application/json |
Parametri del corpo della richiesta
| Campo | Tipo | Obbligatorio | Predefinito | Descrizione |
|---|---|---|---|---|
content | string | Sì | - | Il messaggio o prompt dell’utente |
stream | boolean | No | true | Se false, restituisce JSON invece di uno stream |
backend | string | No | "DEFAULT" | Backend da utilizzare |
executionMode | "auto" | "planning" | "build" | No | - | Determina come l’IA affronta il compito |
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" | No | - | Modello AI da utilizzare. Se non specificato, viene usato il modello configurato per il team |
reasoningEffort | "medium" | "high" | No | - | Determina quanto a fondo il modello ragiona sul compito |
experimental_attachments | array | No | [] | Allegati di file (formato descritto di seguito) |
Formato degli allegati
Ogni elemento dell’arrayexperimental_attachments ha la struttura seguente:
| Campo | Tipo | Obbligatorio | Descrizione |
|---|---|---|---|
url | string | Sì | URL del file da allegare |
name | string | No | Nome visualizzato dell’allegato |
contentType | string | No | Tipo MIME del file |
Esempio di richiesta
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'])
Risposta
Risposta JSON (con stream: false)
{
"chatId": "abc123def456",
"url": "https://www.macaly.com/chat/abc123def456",
"streamId": "stream_xyz789",
"assistantMessageId": "msg_123"
}
| Campo | Tipo | Descrizione |
|---|---|---|
chatId | string | L’identificatore univoco della chat |
url | string | URL diretta per visualizzare la chat |
streamId | string | undefined | Identificatore dello stream a cui sottoscriversi. Presente solo per i backend basati su elaborazione |
assistantMessageId | string | undefined | ID del messaggio dell’assistente in fase di generazione. Presente solo per i backend basati su elaborazione |
Risposta in streaming (con stream: true, predefinito)
Quando lo streaming è attivo, la risposta è uno stream di testo:
2:[{"chatId":"abc123def456"}]
0:"Starting to build..."
...
2:[{"chatId":"..."}].
Estrarre l’ID della chat dallo stream
const text = await response.text();
const match = text.match(/2:\[{"chatId":"([^"]+)"/);
const chatId = match?.[1];
Codici di stato
| Codice | Descrizione |
|---|---|
| 200 | Operazione riuscita: chat creata |
| 400 | Corpo della richiesta non valido |
| 401 | Chiave API non valida o mancante |
| 402 | Crediti insufficienti |
| 403 | Accesso negato: permessi insufficienti per il team specificato |
| 422 | Errore di validazione |
| 429 | Limite di richieste raggiunto |
| 500 | Errore del server |
Passaggi successivi
Dopo aver creato una chat:- Segui l’avanzamento con
GET /api/chat/{chatId}/status - Sottoscrivi lo stream con
GET /api/chat/{chatId}/subscribeper gli aggiornamenti in tempo reale - Invia messaggi successivi con
POST /api/chat/{chatId}/publish
Questa pagina è stata utile?