Call any endpoint

Call Future AGI platform endpoints that have no dedicated command with fagi api: find the command, read, write, page through results and shape the output

fagi api calls the Future AGI platform API directly, one command per endpoint. Use it for anything without a dedicated fagi command, such as listing workspaces, submitting annotations, reading alert rules or changing one dataset cell. Each command takes its parameters as flags and prints a table, JSON (--json) or JSON Lines (-o jsonl). Sign-in, --workspace and the exit codes work as for every other command.

When a dedicated command fits, use it instead: it looks up names, waits for work to finish and checks the result. fagi datasets push and pull move whole files, fagi prompts pull and diff compare versions, fagi gateway try checks guardrails, and fagi epoch run (CLI 0.3.0 or later) fills an Epoch launch from its defaults. Simulation has no fagi api equivalent; use fagi sim, which ships in a later CLI release.

Prerequisites

Command groups

Commands are grouped by product area, then resource. Run fagi api --help for the current list.

GroupWhat it covers
fagi api annotationsAnnotation queues and their items: read an item, submit values, complete it
fagi api contextWho you are signed in as, and the workspaces you can use
fagi api dashboardsDashboards, their widgets, metric discovery, filter values and ad hoc metric queries
fagi api datasetsDatasets, columns, rows, cells, dataset evaluations, prompt columns, knowledge bases and prompt stats
fagi api epochEpochs on a finished run (launch options, launch, list, read, stop, retry), Debug failures, evidence imports and shipping a winner. Needs CLI 0.3.0 or later (see Epoch)
fagi api error-feedGrouped error issues, their overview and the traces in each
fagi api evaluationsEvaluation templates, evaluation groups, and testing a template on inputs
fagi api experimentsExperiments: create, list and read them
fagi api gatewayAI gateways, their config, analytics, request logs, sessions, guardrail rule counts and one test prompt
fagi api observabilityTracing projects, traces, spans, sessions, filter properties, online eval tasks, eval configs, alert rules and fired alerts
fagi api optimizationDataset optimization runs
fagi api promptsPrompt templates, their versions, running a version and reading its result
fagi api skillsSkills, agent contexts and their versions, publishing and labels, and whether a skill was loaded. Needs CLI 0.3.0 or later
fagi api usageUsage and cost overview for your organization. Future AGI Cloud only (see Self-hosted)

Find a command

Walk down the tree with --help. Each level lists the commands under it, and a command’s help gives its description, its flags with their limits and allowed values, its table columns, and whether it reads, writes or destroys data.

fagi api --help
fagi api observability --help
fagi api observability traces search --help

To search by words instead, use fagi schema --search; see Find commands.

Flags with a fixed set of values complete with Tab once shell completion is on. Completion is local and makes no request:

fagi api evaluations templates create --eval-type <TAB>

Read

Most reads act in one workspace; see Choose a workspace. WORKSPACE_ID is the ID column of fagi api context workspaces list. Every command sends only the flags you pass, so the server’s defaults apply to the rest.

fagi api context whoami
fagi api context workspaces list --json
fagi api observability projects list --workspace WORKSPACE_ID
fagi api observability traces search --project-id PROJECT_ID --page-size 50 --json

fagi api observability projects list prints a table like this:

ID                                    NAME            TRACE_TYPE  TRACE_COUNT
3fa85f64-5717-4562-b3fc-2c963f66afa6  support-agent   observe     1204

With --json it prints the full response object, with the rows under result.projects. PROJECT_ID is the ID column of that list.

Flags are checked before anything is sent; a bad or missing value exits 2 with no request made.

Page through a list

Each command sends one request and returns one page. The CLI never follows the next page on its own: pass the page or cursor flag the command takes, such as --page, --page-number or --cursor. Check the command’s --help for which paging flag it takes.

fagi api observability properties list --cursor-mode --page-size 50 --json
fagi api observability properties list --cursor-mode --page-size 50 --cursor NEXT_CURSOR --json

Here NEXT_CURSOR is the result.next_cursor field of the previous page’s JSON. The field differs between commands: read its path from cursor_field in the {"pagination":...} record on stderr (see What goes to stderr).

Some list commands have a CLI safety maximum for --page-size, below the server maximum. --help shows it, and --allow-large-pages bypasses it.

Write

Writes are sent once and never retried. After a timeout or a network error, read the resource to see whether the change landed before you run the command again.

Five commands are destructive and ask for confirmation: fagi api datasets delete, fagi api dashboards delete, fagi api observability eval-tasks update (it can rerun a task or reset its results), fagi api prompts delete and fagi api epoch evidence-imports discard (CLI 0.3.0 or later). On a terminal you type yes. With --no-input, or with no terminal, a missing confirmation exits 2 and sends nothing unless you pass --yes. A declined prompt also exits 2 and sends nothing.

Preview a write with --dry-run, then send it:

fagi api prompts delete --id PROMPT_ID --dry-run
fagi api prompts delete --id PROMPT_ID --yes --no-input

PROMPT_ID is the ID column of fagi api prompts list. Every fagi api command accepts --dry-run: it checks your flags and prints the request it would send (method, path, body, headers with secrets redacted, base URL and workspace) without reading credentials or contacting the server.

method        DELETE
path          /model-hub/prompt-templates/PROMPT_ID/
body          null
base_url      resolved at execution (dry-run reads no profile files)
workspace_id  resolved at execution; pass --workspace to pin it

Some writes start billed work, such as running a prompt, running dataset evaluations, sending a gateway test prompt or launching an Epoch. Run --dry-run first and check --help, which notes when a command may incur charges.

Request bodies

A command that sends a JSON body takes a flag for each simple field, plus one of:

FlagWhat it does
--data JSONThe body as an inline JSON object
--data-file PATHThe body from a JSON file, or - for stdin; at most 16 MiB

Flags you pass override the same keys in the data. Nested and secret fields have no flag of their own; help lists them under “Other body fields (set with —data/—data-file)”. Put secrets in a protected file or stdin rather than inline --data, which stays in shell history.

fagi api datasets delete --dataset-ids DATASET_ID --dry-run
echo '{"dataset_ids":["DATASET_ID"]}' | fagi api datasets delete --data-file - --yes --no-input --json

DATASET_ID is the ID column of fagi api datasets list. An array flag such as --dataset-ids takes comma-separated values or can be repeated.

Shape the output

A table and -o jsonl print only the rows, with the columns listed in --help; --json prints the whole response (see Output formats). If the response lacks the row collection, table and JSONL output exit 1; rerun with --json. An empty list succeeds and prints a No ... found. line.

Most list and search reads take --fields, which keeps only the row keys you name, in that order. It shapes the output locally and does not change the request. Keys are comma-separated top-level row keys, and a missing key becomes null. With --json the rest of the response is kept. An invalid list exits 2 with details.code invalid_fields. fagi schema does not list --fields, so check the command’s --help.

fagi api datasets list --fields id,name --json
fagi api observability traces search --project-id PROJECT_ID --fields trace_id,status,cost -o jsonl

Dive deeper

Was this page helpful?

Questions & Discussion