const workflow = await api.workflows.create({
name: "Triage",
trigger: { type: "manual" },
steps: [
{ id: "classify", type: "model.generate", config: { model: "gemini-3.5-flash",
prompt: "Is this urgent? {{input.text}}", schema: { type: "object", properties: { urgent: { type: "boolean" } } } } },
{ id: "check", type: "condition", config: { left: "{{steps.classify.output.urgent}}", operator: "eq", right: true } },
{ id: "approve", type: "human", config: { title: "Send the alert?" } },
{ id: "alert", type: "mail.send", config: { box: "ops@example.com", to: "team@example.com",
subject: "Urgent", text: "{{input.text}}" } },
{ id: "file", type: "storage.write", config: { storage: "…", action: "insert", collection: "tickets",
documents: [{ text: "{{input.text}}" }] } },
],
edges: [
{ from: "__trigger", to: "classify" },
{ from: "classify", to: "check" },
{ from: "check", to: "approve", branch: "true" },
{ from: "check", to: "file", branch: "false" },
{ from: "approve", to: "alert" },
],
});workflow = api.workflows.create({
"name": "Triage",
"trigger": {"type": "manual"},
"steps": [
{"id": "classify", "type": "model.generate", "config": {"model": "gemini-3.5-flash",
"prompt": "Is this urgent? {{input.text}}",
"schema": {"type": "object", "properties": {"urgent": {"type": "boolean"}}}}},
{"id": "check", "type": "condition", "config": {"left": "{{steps.classify.output.urgent}}", "operator": "eq", "right": True}},
{"id": "approve", "type": "human", "config": {"title": "Send the alert?"}},
{"id": "alert", "type": "mail.send", "config": {"box": "ops@example.com", "to": "team@example.com",
"subject": "Urgent", "text": "{{input.text}}"}},
{"id": "file", "type": "storage.write", "config": {"storage": "…", "action": "insert", "collection": "tickets",
"documents": [{"text": "{{input.text}}"}]}},
],
"edges": [
{"from": "__trigger", "to": "classify"},
{"from": "classify", "to": "check"},
{"from": "check", "to": "approve", "branch": "true"},
{"from": "check", "to": "file", "branch": "false"},
{"from": "approve", "to": "alert"},
],
})Ce qui est vérifié avant qu'il ne soit enregistré
- Chaque étape d'identification est unique et bien formée; il y en a au plus 30.
- Chaque type d'étape existe, et sa configuration requise est présente.
- Tous les
{{steps.…}}les noms de référence une étape qui existe et est en amont. - Le graphique a exactement un bord du déclencheur, aucun cycle, et aucune étape inaccessible.
- Une condition a une
trueet afalsechanfrein; un interrupteur a un par cas plusdefault; une fusion a au moins deux entrées. - Tout ce qui agit en dehors du compte a un
humanPas en amont. - Une
agent.runles noms seulement des outils qui existent.
{{steps.draft.output.text}} sur une étape qui court avant que le brouillon soit pris ici plutôt que de produire une chaîne vide au moment de l'exécution. La validation est stricte parce qu'un workflow échoue là où personne ne regarde.
Les outils d'agent sont sérialisés pour vous
{ id: "research", type: "agent.run", config: {
model: "gemini-3.5-flash",
tools: { search: api.tools.search, fetch: api.tools.fetch }, // the SDK serialises this
} }# In Python, an agent.run step names its built-in tools; the server runs them
{"id": "research", "type": "agent.run", "config": {
"model": "gemini-3.5-flash",
"tools": ["search", "fetch"],
}}Écrit en tant qu'objet, il devient le tableau que la plate-forme stocke. Écrit en tant que tableau déjà, il est envoyé tel quel — et un nom d'outil inconnu est refusé avec la liste de ceux qui existent.
Erreurs
Tout ce qui est en haut revient comme invalid_workflow (400), avec un message qui nomme l'étape et le problème. Il y a un code parce qu'il y a une réponse : corriger la définition.