convoy goal --provider <anthropic|openai> --model <id> [flags] "<text>"goal is the only command that calls a model directly. It needs no running convoyd. The model you name here only writes the swarm. The swarm declares its own providers and models.
What it does
-
Checks flags. A missing
--provideror--model, or an unknown provider, is a usage error (exit 2) before any network call. There are no defaults. -
Builds the system prompt (meta prompt 1) from the goal and three inserts: the providers, models, and tools a swarm may declare (all priced, so a generated
max_cost_usdpasses validation); the embedded DSL reference; and two embedded example swarms. -
Calls the model with the goal as the user message. The model returns files as blocks:
<file path="main.cvy"> ... </file> <file path="prompts/writer.md"> ... </file>Paths must be relative, contain no
.., and sit under.orprompts/. -
Loads the files in memory and runs the same checks as
convoy validate. -
Writes the files if they pass, and prints a summary.
The retry loop
If validation reports errors and attempts remain, the CLI appends the model’s reply and a new user message to the conversation: convoy validate reported these errors. Return the full corrected set of files., followed by every error in plain text. The model returns a complete corrected set and the loop repeats.
- Warnings are printed but never trigger a retry.
--attemptsbounds the loop (default 3).- If errors remain after the last attempt, nothing is written. The diagnostics are printed, the last model output is saved to
.convoy/goal-failed.txt, and the command exits 3.
Flags
| Flag | Default | Meaning |
|---|---|---|
--provider | required | anthropic or openai. openai also covers OpenAI-compatible servers with --base-url |
--model | required | Model id, passed through unchanged. Not checked against any price catalog |
--base-url | provider default | Override the inference URL for a proxy, gateway, or self-hosted server |
--attempts | 3 | Total model calls before giving up |
--max-retries | 3 | Retries of a failed model request (network or API errors) |
--overwrite | off | Replace main.cvy and any other returned file that already exists |
--dry-run | off | Print the files to stdout instead of writing |
Global flags such as --dir apply. The key comes from ANTHROPIC_API_KEY or OPENAI_API_KEY in your shell.
Example
$ convoy goal --provider anthropic --model claude-opus-5 \
"Write a sourced 10-page market report on edge inference chips"
wrote ./main.cvy
wrote ./prompts/research.md
wrote ./prompts/writer.md
wrote ./prompts/critic.md
validate: ok
agents researcher[nvidia, groq, cerebras, tenstorrent] -> writer <-> critic
edges researcher -> writer
topics findings, drafts, review, human
review the files, then: convoy runThe summary collapses each count or for_each agent into one line, with its index range (worker[0..3]) or its keys, lists dependency edges as a -> b, and ends by pointing at convoy run.
When a first attempt fails and the second passes, the extra diagnostics go to stderr:
$ convoy goal --provider openai --model gpt-6.1-sol "Fix the failing tests in ./repo"
attempt 1: 2 errors, retrying
main.cvy:14: error: agent "fixer" references undeclared topic "results"
main.cvy:22: error: swarm "fix_tests" has no done_when
wrote ./main.cvy
wrote ./prompts/fixer.md
validate: okExisting files
After validation, if main.cvy or any returned path exists and --overwrite is not set, the command exits 1 with main.cvy exists; pass --overwrite. Nothing is written.
Exit codes
| Code | Cause |
|---|---|
0 | Files written (or printed with --dry-run) |
1 | A file exists and --overwrite is not set, or the model request failed |
2 | Missing --provider or --model, or an unknown provider |
3 | Errors remain after the last attempt |
API endpoint
None. goal talks to the model provider, not to convoyd.
Related
- convoy validate runs the same checks on the result.
- convoy run is the next step.
- Your first swarm shows editing a generated file.
- Validation rules