Assistants V2
Início Rápido
Crie e publique seu primeiro assistente versionado em 5 minutos
Este guia mostra como criar um assistente, adicionar nodes e tools ao draft, e publicar a primeira versão.
Pré-requisitos
- Uma organização Antonnia com um token de API (
sk_live_...)
Passos
Crie um assistente
curl -X POST https://services.antonnia.com/assistants/api/v2/assistants \
-H "Authorization: Bearer sk_live_YOUR_TOKEN" \
-H "Content-Type: application/json" \
-d '{ "name": "Suporte ao Cliente" }'import httpx
BASE_URL = "https://services.antonnia.com/assistants/api/v2"
HEADERS = {
"Authorization": "Bearer sk_live_YOUR_TOKEN",
"Content-Type": "application/json",
}
response = httpx.post(f"{BASE_URL}/assistants", headers=HEADERS, json={
"name": "Suporte ao Cliente",
})
data = response.json()
assistant_id = data["assistant"]["id"]
branch_name = "main"Resposta:
{
"assistant": {
"id": "a1b2c3d4e5f6",
"organization_id": "org_xyz",
"name": "Suporte ao Cliente",
"versioning_enabled": true,
"created_at": "2026-03-24T10:00:00Z",
"updated_at": "2026-03-24T10:00:00Z"
},
"main": {
"id": "b2c3d4e5f6a1",
"name": "main",
"head_commit_id": null
}
}A branch main é criada automaticamente.
Edite o draft com um changeset
Use o endpoint de changeset para aplicar todas as mudanças de uma vez — context, config, nodes, tools e variables.
curl -X PATCH "https://services.antonnia.com/assistants/api/v2/assistants/$ASSISTANT_ID/branches/main/draft" \
-H "Authorization: Bearer sk_live_YOUR_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"context": {
"assistant_name": "Suporte ao Cliente",
"assistant_description": "Assistente de suporte para e-commerce"
},
"config": {
"initial_node_id": "greeting"
},
"nodes": {
"upsert": [
{
"id": "greeting",
"name": "Saudação",
"description": "Node inicial de boas-vindas",
"type": "llm",
"config": {
"node_type": "llm",
"instructions": "Cumprimente o cliente e pergunte como pode ajudar.",
"next_node": null,
"tools": []
}
}
],
"delete": []
},
"tools": {
"upsert": [
{
"id": "check_order",
"name": "Consultar Pedido",
"description": "Consulta o status de um pedido pelo número",
"request": {
"url": "https://api.example.com/orders/{order_id}",
"method": "GET"
}
}
],
"delete": []
}
}'response = httpx.patch(
f"{BASE_URL}/assistants/{assistant_id}/branches/main/draft",
headers=HEADERS,
json={
"context": {
"assistant_name": "Suporte ao Cliente",
"assistant_description": "Assistente de suporte para e-commerce",
},
"config": {
"initial_node_id": "greeting",
},
"nodes": {
"upsert": [
{
"id": "greeting",
"name": "Saudação",
"description": "Node inicial de boas-vindas",
"type": "llm",
"config": {
"node_type": "llm",
"instructions": "Cumprimente o cliente e pergunte como pode ajudar.",
"next_node": None,
"tools": [],
},
}
],
"delete": [],
},
"tools": {
"upsert": [
{
"id": "check_order",
"name": "Consultar Pedido",
"description": "Consulta o status de um pedido pelo número",
"request": {
"url": "https://api.example.com/orders/{order_id}",
"method": "GET",
},
}
],
"delete": [],
},
},
)
changeset = response.json()Resposta:
{
"context_updated": true,
"config_updated": true,
"nodes_upserted": 1,
"nodes_deleted": 0,
"tools_upserted": 1,
"tools_deleted": 0,
"variables_upserted": 0,
"variables_deleted": 0
}Publique a versão
curl -X POST "https://services.antonnia.com/assistants/api/v2/assistants/$ASSISTANT_ID/branches/main/publish" \
-H "Authorization: Bearer sk_live_YOUR_TOKEN" \
-H "Content-Type: application/json" \
-d '{ "message": "Versão inicial do assistente de suporte" }'response = httpx.post(
f"{BASE_URL}/assistants/{assistant_id}/branches/main/publish",
headers=HEADERS,
json={"message": "Versão inicial do assistente de suporte"},
)
commit = response.json()Resposta:
{
"commit": {
"id": "c3d4e5f6a1b2",
"assistant_id": "a1b2c3d4e5f6",
"parent_commit_id": null,
"message": "Versão inicial do assistente de suporte",
"author_type": "human",
"created_at": "2026-03-24T10:05:00Z"
}
}O draft agora virou um commit imutável. O head_commit_id da branch main aponta para este commit.
Verifique o runtime
O endpoint de runtime retorna o snapshot completo do assistente que o orquestrador usa em produção.
curl -X GET "https://services.antonnia.com/assistants/api/v2/assistants/$ASSISTANT_ID/runtime" \
-H "Authorization: Bearer sk_live_YOUR_TOKEN"response = httpx.get(
f"{BASE_URL}/assistants/{assistant_id}/runtime",
headers=HEADERS,
)
snapshot = response.json()Resposta:
{
"context": {
"assistant_name": "Suporte ao Cliente",
"assistant_description": "Assistente de suporte para e-commerce"
},
"graph": {
"initial_node_id": "greeting",
"nodes": {
"greeting": {
"id": "greeting",
"name": "Saudação",
"type": "llm",
"config": {
"node_type": "llm",
"instructions": "Cumprimente o cliente e pergunte como pode ajudar."
}
}
}
},
"tools": [
{
"id": "check_order",
"name": "Consultar Pedido",
"description": "Consulta o status de um pedido pelo número"
}
],
"variables": []
}Próximos passos
- Versionamento — entenda branches, commits e drafts
- API de Branches — crie branches, publique e faça merge
- API de Drafts — edite nodes, tools e variables individualmente