Documentação da API
Autentique, crie sessões e transmita respostas dos seus agentes em tempo real (SSE).
Autenticação & Chaves
As rotas /we/** documentadas abaixo exigem o header Authorization: Bearer <TOKEN>, onde TOKEN é o token de sessão (JWT) obtido ao logar na Engine com Google.
- Token de sessão (JWT) — válido para todas as rotas
/we/**listadas nesta página. - API Key — gerada em Opções → API Keys, serve apenas para a API pública
POST /api/v1/swarm/chat. Não funciona nestas rotas/we/**.
Base URL (produção): https://news-verifier-163762341148.southamerica-east1.run.app · (staging): https://news-verifier-staging-163762341148.southamerica-east1.run.app
Streaming SSE de mensagens
POST /we/chat/stream
Envia uma mensagem ao agente e recebe a resposta em streaming (Server-Sent Events). O corpo é JSON.
import httpx
url = "https://news-verifier-163762341148.southamerica-east1.run.app/we/chat/stream"
headers = {"Authorization": "Bearer SEU_TOKEN", "Content-Type": "application/json"}
body = {
"agent_id": "SEU_AGENT_ID",
"session_id": "web_123",
"text": "Explique em 3 tópicos o que é streaming SSE.",
"files": [],
"model_override": None
}
async with httpx.AsyncClient(timeout=180) as client:
async with client.stream("POST", url, headers=headers, json=body) as r:
async for chunk in r.aiter_text():
print(chunk, end="", flush=True)
Listagem de agentes
GET /we/agents
Retorna os agentes aos quais o usuário autenticado tem acesso.
import httpx
resp = httpx.get(
"https://news-verifier-163762341148.southamerica-east1.run.app/we/agents",
headers={"Authorization": "Bearer SEU_TOKEN"}
)
print(resp.json())
Gerenciamento de sessões
POST /we/agents/{agent_id}/sessions
Cria uma nova sessão de conversa para o agente. Retorna { "session_id": "...", "title": "Nova conversa" }.
import httpx
resp = httpx.post(
"https://news-verifier-163762341148.southamerica-east1.run.app/we/agents/SEU_AGENT_ID/sessions",
headers={"Authorization": "Bearer SEU_TOKEN"}
)
print(resp.json())
Modelos ativos
GET /we/models
Retorna o catálogo oficial de modelos disponíveis para os agentes.
import httpx
resp = httpx.get(
"https://news-verifier-163762341148.southamerica-east1.run.app/we/models",
headers={"Authorization": "Bearer SEU_TOKEN"}
)
print(resp.json())