Browse all docs & guides
On this page
CLI / API

Create with CLI & API.

Use the portable CLI with browser login, or create one scoped workspace API key.

AGENT PROMPT · PASTE INTO YOUR AGENT OR AUTO-READ
Read https://opengen.dev/docs/clients/cli.md.
Use the OpenGen CLI (@opengen-dev/cli) to run `opengen doctor`, inspect `openai/gpt-image-2` for `text-to-image` and its published pricing for a 1K low-quality studio product photo of a matte ceramic teapot on dark slate, confirm the paying workspace and maxCostMicros spend cap, and wait for my approval before running `opengen generate` with a saved Idempotency-Key.
View raw .md ↗
OpenGen browser PKCE login / scoped API key

A few steps to get connected.

  1. Install @opengen-dev/cli into an isolated prefix on Node 22.12 or later (npm install --prefix "$HOME/.opengen/cli" @opengen-dev/cli --ignore-scripts --no-audit --no-fund), or install from the checksum-verified offline release bundle, then add "$HOME/.opengen/cli/node_modules/.bin" to your PATH.
  2. Set OPENGEN_API_URL if targeting a self-hosted gateway (defaults to https://opengen.dev; MEDIA_ROUTER_URL remains a supported alias), then run login and doctor below. Review the paying workspace and read/generate permissions in your browser.
  3. For a backend API integration, create a separate expiring read/generate key in Workspace → API keys (/app/keys). Save it once as OPENGEN_API_KEY in your secret manager and send it only in the Authorization header.
Sign in, diagnose your workspace, and search the catalog
export OPENGEN_API_URL="https://opengen.dev"
opengen login
opengen doctor
opengen catalog search "gpt-image-2"
Submit once with a persisted idempotency key
cat <<'EOF' > request.json
{
  "modelId": "openai/gpt-image-2",
  "operation": "text-to-image",
  "input": {
    "prompt": "A matte ceramic teapot on dark slate, studio lighting",
    "resolution": "1K",
    "quality": "low"
  },
  "billing": "managed",
  "maxCostMicros": 50000
}
EOF

# After confirming route, published rate and balance (save OPENGEN_IDEMPOTENCY_KEY once and reuse it on retry):
opengen generate --input request.json --idempotency-key "${OPENGEN_IDEMPOTENCY_KEY:?Set and save a unique ID before submitting}"
Try your first prompt · discovery is free
Use the OpenGen CLI to run `opengen doctor`, inspect `openai/gpt-image-2` for `text-to-image` and its published pricing for a 1K low-quality studio product photo of a matte ceramic teapot on dark slate, and wait for my approval before running `opengen generate`.

Instructions based on OpenGen MCP & CLI guide ↗, reviewed 2026-11-30. Client interfaces and permissions can change.

Need a scoped key for scripts or servers? Manage workspace API keys →

If setup stops halfway

The browser sign-in is unavailable

Your deployment must have sign-in configured. Start at your workspace to check availability. Hosted assistants need a publicly reachable HTTPS endpoint; installing code inside their sandbox does not create a hosted connector.

I denied consent or chose the wrong workspace

Start connection again and review the paying workspace before approving. A key stays in its issued workspace. To change an agent’s workspace, revoke its old authorization and sign in again with the intended selection.

Local login expired or was interrupted

Run opengen doctor using the installed CLI. Sign in again when expired or revoked. A stale profile lock requires checking that no OpenGen process is active before removing it; never bypass token-reuse checks or share the profile.

I want to disconnect

Revoke the connected app in OpenGen’s workspace, then remove its client configuration. For OpenGen’s CLI, opengen logout revokes before deleting the private profile. If revocation fails, keep the profile and retry.