AI Glot websiteOpen AI Glot
CLICLI automation and output

CLI automation and output

Run the AI Glot CLI safely in scripts and CI using JSON or NDJSON, environment credentials, profiles, exit codes and bounded retries.

The CLI prints readable tables to a terminal and JSON when output is piped, so the same command works interactively and in automation.

Terminal
aiglot batches list                    # table on a terminal
aiglot batches list | jq '.data[0].id' # JSON when piped
aiglot batches list --output ndjson    # one object per line
aiglot account --json                  # explicit JSON

Failures go to standard error, and so do warnings the caller still needs to see, such as a truncated page of results. Standard output therefore remains safe to pipe into another program.

Waiting for a translation to finish

A script that starts a translation usually has to wait for it. Poll batches get and stop on a terminal status:

Terminal
id=$(aiglot batches create catalogue.csv --instruction "Translate into French" --json | jq -r '.data.id')
aiglot batches approve "$id" --json > /dev/null

until status=$(aiglot batches get "$id" --json | jq -r '.data.status'); [ "$status" = "completed" ] || [ "$status" = "failed" ]; do
  sleep 5
done

[ "$status" = "completed" ] && aiglot batches download "$id" --output result.csv

These are every status a translation can report, and the three that end it. Each one answers the same question: who is waiting, and on what?

StatusMeaningWho waitsTerminal
analyzingthe file’s structure is being readus, for seconds
awaiting_instructionsthe file is read; nothing has been asked for yetyou
awaiting_approvala plan is ready and pricedyou
translatingrunning; the only state that has spent creditsus
completedfinished, and a result file is availablenobody
failedended without a result; read error.codeyou, to retry
cancelledstopped deliberately, charged only for work that rannobody

Pagination

batches list and glossaries list are cursor-based. Pass the next_cursor from the previous response back verbatim with --cursor, or let --all follow it for you until has_more is false (capped at 200 pages as a backstop):

Terminal
aiglot batches list --status completed --all
aiglot glossaries list --all --output ndjson

In --output ndjson, --all prints every row from every page as it arrives. In table and json mode it prints one combined result with has_more: false, next_cursor: null and a pages_fetched count in place of request_id, since no single request can be named once several ran.

CI authentication

Create a dedicated, minimum-scope API key and store it in the CI provider’s secret manager:

Terminal
export AIGLOT_API_KEY="aig_live_…"
aiglot account --json

The CLI checks credentials in this order: AIGLOT_API_KEY, OS keychain, then its protected config file.

Exit codes

CodeMeaning
0Success
1API or server error
2Invalid command or arguments
3Authentication or permission failure
4Resource not found
5Rate limited
6Resource state conflict

Scripts should branch on the exit code or structured error.code, not error-message text.

Retries

Retries are automatic, but only where a retry is safe. 429 is retried for every command, honouring Retry-After with bounded backoff. 408 and 5xx are retried only for requests that are idempotent (RFC 9110 §9.2.2): reads, glossaries replace, glossaries delete.

glossaries create, glossaries add, glossaries remove, batches rename and batches archive are not retried after a 5xx, because the write may already have landed and a second attempt would apply it twice. Those failures surface to your script with exit 1: re-read the resource and decide for yourself whether to try again rather than retrying blindly.

Use --no-retry when the caller owns retry policy, and --timeout <seconds> (default 60) to cap a single request. Destructive commands never wait forever for an interactive prompt: non-interactive use must pass --force.

Profiles

Use named profiles to keep credentials for different workspaces or environments separate:

Terminal
aiglot --profile client-a auth login --key "$CLIENT_A_KEY"
aiglot --profile client-a account
export AIGLOT_PROFILE=client-a

Environment variables

VariablePurpose
AIGLOT_API_KEYAPI key; overrides stored credentials
AIGLOT_PROFILENamed credential profile
AIGLOT_NO_TUIForce machine-readable output
AIGLOT_NO_KEYCHAINSkip the operating-system keychain
NO_COLORStandard (no-color.org). Disables colour only; it does not change the output format

Use these docs with your AI tools

An AI agent can read this documentation directly. You do not need an account or an API key. Everything here is public and read-only.

Query these docs via MCP

Recommended

Add this server to Claude, Claude Code, Cursor, Mistral, or any tool that supports MCP. Your agent can then search AI Glot Docs documentation and read it in full, instead of answering from memory.

https://ai-glot.com/docs/mcp
  • searchFind the passages that answer a question.
  • fetchRead one page in full, as Markdown.
  • list_pagesSee every page in this documentation.

Query these docs over HTTP

The same tools also work as plain web requests. Use this for scripts, or for any tool that does not support MCP. There is one endpoint per tool. Arguments go in the query string, and the answer comes back as JSON.

https://ai-glot.com/docs/api/docs/search?query=custom+domain

Read the OpenAPI description. It is built from the same definitions as the tools, so it always matches what the endpoints do.

Read these docs as Markdown

Add .md to any page URL to get its Markdown source. You can also send the headerAccept: text/markdown to the page URL itself.

To read the whole documentation in one file, open llms-full.txt. For a short index of every page, open llms.txt.