Provider file reference

Every key a provider file can have. For a walkthrough, see Writing a provider. Unknown keys are an error, so a typo fails at provider add instead of being ignored.

Top level

Key Required Meaning
schema yes File format version. Always 1.
name yes Lowercase letters, digits, and dashes. Used in -m name:model, provider login name, and $IMG_CLI_<NAME>_KEY.
title Display name.
description One sentence on what the provider offers. Shown when installing from GitHub or a URL.
homepage The vendor's or the file's web page.
author Who maintains the file: a name or a GitHub user.
base_url yes, unless inherited API origin. Paths in the file are relative to it.
currency Unit of reported costs, such as USD, CNY, or credits.
extends Name of another installed provider to inherit from.

[auth]

Key Meaning
type bearer (default) sends Authorization: Bearer <key>; header sends the key in the header named by header; query adds it as the query parameter named by query.
header Header name, for type = "header", such as x-goog-api-key.
query Parameter name, for type = "query".
env An extra environment variable to read the key from, such as LAOZHANG_API_KEY. $IMG_CLI_<NAME>_KEY is always read first.
key_url Where users create a key; shown by provider login.

[hosts]

Alternative origins by name, picked with img-cli provider host <name> <host>:

[hosts]
cn = "https://grsai.dakka.com.cn"

[apis.<name>]

One request shape. Models refer to it by name with api = "<name>".

Key Meaning
submit "METHOD /path", a template. Starts the generation.
body JSON body template. Omit for a request without a body.
poll "METHOD /path", a template. Checks a task. Omit for a synchronous API.
poll_every Time between polls, such as "10s". Default 3s for images and speech, 5s for video.
media "url" when the API accepts only public URLs for input files; local files are then refused.
idempotency Header name, when the API deduplicates submits by a key in it. img-cli then sends a new UUID with each submit and retries the submit after network and server errors. Without it, submits are never retried.

[apis.<name>.result]

Where values are in the responses. Paths are dot-separated keys; [] steps into each array element, as in data[].url or candidates[].content.parts[].

Key Read from Meaning
id submit response Task id. Required when there is a poll.
status submit and poll responses Status value.
done Status values that mean success.
failed Status values that mean failure. Any other value means still running.
outputs Path to result URLs.
outputs_base64 Path to result data, as base64 or data: URIs.
error Path to the error message.
cost Path to the cost, a number in currency.

A synchronous API without status succeeds when it has outputs. A success with no outputs is reported as a failure, with error or the response body as the message.

Templates

Templates are Go text/template.

Body rules

  1. Write every value with json. It escapes strings and keeps numbers and booleans typed. Nil, empty strings, and empty lists render as null.
  2. The rendered text is parsed as HuJSON: trailing commas and // and /* */ comments are allowed.
  3. Every field whose value is null, and every null array element, is removed before sending.

Functions

Function Does
json Encode a value as JSON, empty as null.
upper, lower Change case.
default {{default "x" .V}} is .V, or "x" when .V is empty.
urlquery Escape for a query string.

Go's built-ins also work: if, with, range, or, and, eq, print, len, index.

Fields

Field Type From
.Kind string image, video, or speech
.Model string model id, without the provider
.Prompt string prompt; the text to speak, for speech
.Negative string --negative
.Aspect string --aspect, such as 16:9
.Size string --size
.Resolution string --resolution, lowercase, such as 720p
.Duration, .N, .Seed integer or nil --duration, --n, --seed
.Audio boolean or nil --audio
.Voice, .Format string --voice, --format
.Speed number or nil --speed
.Refs list of files --ref
.FirstFrame, .LastFrame file or nil --first-frame, --last-frame
.Fields map the model's fields
.ID string task id, path-escaped; in poll only
.RawID string task id as returned; in poll only

When a model lists allowed values in supports, the field holds the listed spelling: a user's 720p becomes 720P if that is what the model lists.

Each file has:

Field Meaning
.URL the remote URL; empty for a local file
.Base64 the file data in base64
.DataURI data:<mime>;base64,<data>
.MIME media type

Local files are read only when a template uses .Base64 or .DataURI. Using them on a URL is an error, so write (or .URL .Base64) to accept both.

[[models]]

Key Meaning
id Model id, as the vendor spells it.
kind image, video, or speech.
api An [apis] name or a built-in protocol.
supports The flags the model accepts; see below.
fields Per-model values for templates, read as .Fields.<key>. Typically vendor field names that differ between models.

supports

Keys are flag names with underscores: aspect, size, resolution, duration, n, seed, negative, audio, voice, speed, format, ref, first_frame, last_frame.

Value Means
true any value
false or absent not supported
list allowed values, compared case-insensitively
"min..max" an integer range
number for file flags: the most files

A flag the model does not support is refused before any request. A model without supports sends whatever flags its API can carry, with a warning.

Built-in protocols

Use these as api values. The flags each one can send are fixed; any other flag is refused.

Protocol Requests Flags
openai-images POST /v1/images/generations (JSON); with --ref, POST /v1/images/edits (multipart, field image[]). Results from data[].url or data[].b64_json. --size, --n, --ref
openai-videos POST /v1/videos (multipart with input_reference when there is a first frame); polls GET /v1/videos/{id}; downloads video_url or GET /v1/videos/{id}/content. --duration (as seconds), --resolution as WIDTHxHEIGHT (as size), --first-frame
openai-speech POST /v1/audio/speech; the response body is the audio. --voice, --speed, --format (as response_format)
gemini POST /v1beta/models/{model}:generateContent with responseModalities: ["IMAGE"]; local files as inlineData, URLs as fileData; thought images are skipped. --aspect, --size, --ref

Authentication still comes from the provider's [auth], so gemini works with Google's x-goog-api-key and with gateways that use bearer tokens.

Catalog

[catalog] reads the model list from the vendor. Models in [[models]] take precedence over models with the same id.

Key Meaning
get Path of the list request.
items Path to the array of models; empty when the response is the array.
id Path to the id within an item. Default id.
kind Path to the vendor's modality within an item.
kinds Map from the vendor's modality to img-cli's kind, such as { audio = "speech" }.
apis Map from kind to the API to use. Models of kinds not in this map are skipped.
cache How long to keep the list, such as "6h". Default 24h.

[catalog.detail]

Reads one model's parameters when the model is used or shown, and turns them into supports and fields.

Key Meaning
get Path template; .ID is the escaped model id.
template Template over the detail response that renders {"supports": {...}, "fields": {...}}. Unlike body templates, missing keys are fine and render as empty.
cache Default 24h.

Example, from the VibeToken plugin:

[catalog.detail]
get = "/api/v1/models/{{.ID}}"
template = '''
{{$f := .parameter_schema.fields}}
{
  "supports": {
    {{with or $f.aspect_ratio $f.ratio}}"aspect": {{json .rules.values}},{{end}}
    {{with $f.duration}}{{with .rules}}"duration": "{{.min}}..{{.max}}",{{end}}{{end}}
  },
  "fields": { {{if $f.ratio}}"aspect": "ratio",{{end}} },
}
'''

If the detail request fails, img-cli warns and sends flags unchecked.

[balance]

Key Meaning
get Path of the balance request.
amount Path to the amount.
currency Path to the currency; falls back to the top-level currency.

extends

A provider with extends = "<parent>" starts from the parent and overrides:

  • title, base_url, currency, and each [auth] key that it sets;
  • [hosts], [catalog], and [balance] as whole tables;
  • [apis.<name>] and [[models]] entries with the same name or id; others are added.

The parent must be installed.