Use cloud backends
Use a cloud backend when you want hosted inference instead of the local
llama-server backend. Each provider needs an API key in the environment; ajq does not
read API keys from config.toml.
Use Anthropic Claude
Export an Anthropic API key:
export ANTHROPIC_API_KEY="sk-ant-..."Run a semantic query with
--cloud:printf '{"msg":"urgent billing issue"}' \ | ajq --cloud --model haiku '.msg =~ "urgent"'--cloudis the same as--backend anthropic. If you omit--model, ajq usesclaude-haiku-4-5. The shipped aliases arehaiku,sonnet, andopus.If the key is missing, ajq stops before contacting the provider:
ajq: error: anthropic backend API key is empty; set ANTHROPIC_API_KEY
Use OpenAI
Export an OpenAI API key:
export OPENAI_API_KEY="sk-..."Choose an OpenAI model explicitly:
printf '{"msg":"urgent billing issue"}' \ | ajq --backend openai --model gpt-4o-mini '.msg =~ "urgent"'If you use an OpenAI-compatible proxy, pass its API root with
--base-url:ajq --backend openai --base-url http://127.0.0.1:8000/v1 --model my-model \ '.msg =~ "urgent"'
Use OpenRouter
Export an OpenRouter API key:
export OPENROUTER_API_KEY="sk-or-..."Choose an OpenRouter model id:
printf '{"msg":"urgent billing issue"}' \ | ajq --backend openrouter --model openai/gpt-4o-mini '.msg =~ "urgent"'OpenRouter uses
https://openrouter.ai/api/v1by default.
Keep a spending guardrail
Paid backends (anthropic, openai, and openrouter) default to a 100-judgement cap.
Lower it while testing:
ajq --cloud --max-calls 10 '.[] | select(.msg =~ "urgent")'
See Control semantic costs for the full estimate/cap/stats workflow.
Related
- Backends reference — defaults, required settings, and caps.
- Configuration reference — precedence and env-only API keys.
Feedback
Was this page helpful?
Glad to hear it! Please tell us how we can improve.
Sorry to hear that. Please tell us how we can improve.