Skip to main content

llm-apimaster

PyPI Tests License

Plugin for LLM adding APIMaster and any other OpenAI-compatible gateway — plus the image and video generation that llm has no model type for.

Install

llm install llm-apimaster

Configure

llm keys set apimaster
# <paste your key>

llm apimaster refresh

refresh reads the live catalog and caches it. Chat models then show up as apimaster/<id>:

llm models | grep apimaster
# APIMaster: apimaster/gpt-5.5
# APIMaster: apimaster/claude-sonnet-4-6

Run refresh again whenever a model id stops working — aggregator catalogs change, and a removed id comes back as a 400 that looks like a plugin bug.

Use

llm -m apimaster/gpt-5.5 "Explain time-to-first-token in one paragraph"

llm -m apimaster/claude-sonnet-4-6 "Summarise this" < notes.md

# conversations, schemas, tools and everything else llm does, unchanged
llm -m apimaster/gpt-5.5 --schema 'name, age int' "Invent a character"

Images

llm has no image models, so this ships as a command:

llm apimaster image "a corgi astronaut on the moon" --size 16:9 -o corgi.png
llm apimaster image "replace the background with a desert sunset" --ref https://example.com/a.png
llm apimaster image "a detailed matte painting" --resolution 4k --async -o matte.png

Use --async for 2k and 4k. Synchronous generation at those sizes can exceed the gateway's own timeout and return a 408; the command tells you to switch when that happens.

Video

llm apimaster video "a waterfall forming a rainbow, cinematic" --duration 4 -o clip.mp4
llm apimaster video "slow push-in, hair in the breeze" --ref https://example.com/face.jpg --aspect 9:16

Always pass --aspect for image-to-video: a portrait reference with no aspect is treated as 16:9 by the gateway and comes back letterboxed.

Seeing everything the endpoint serves

llm apimaster models                 # all cached models with capability flags
llm apimaster models --kind image
llm apimaster models --kind video --json

Another gateway

Nothing here is specific to one vendor:

llm apimaster refresh --base-url https://your-gateway/v1
llm apimaster image "..." --base-url https://your-gateway/v1

The base URL from the last refresh is remembered in the cache and used for model registration.

How it decides capabilities

An OpenAI-compatible /models response says nothing about vision, schema or tool support, so the plugin guesses from the model id and writes the result into the cache:

{ "id": "claude-sonnet-4-6", "kind": "chat", "vision": true, "schema": true, "tools": true }

If a guess is wrong, edit the cache file directly — llm apimaster models prints its location, and the format is stable.

Design notes

Two things worth knowing if you read the source:

  • register_models never makes a network call. It runs on every single llm invocation; a request there would slow the whole CLI down and break it offline. The catalog comes from the cache, with a two-model seed list so the plugin works before the first refresh.
  • No new dependencies. It reuses whichever httpx llm already ships (0.35 pins httpx2, older releases pin httpx) behind a two-line import shim.

Development

pip install -e '.[test]'
python -m pytest tests/ -q

Tests run against a mock HTTP server built into the test file — no key, no network, nothing spent.

License

MIT

Metadata

Release files for llm-apimaster 0.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for llm-apimaster 0.1.1
File Size Uploaded Provenance Actions
llm_apimaster-0.1.1.tar.gz 12.1 kB With provenance Details for llm_apimaster-0.1.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for llm-apimaster 0.1.1
File Interpreter ABI Platform Actions
llm_apimaster-0.1.1-py3-none-any.whl Python 3 none any Details for llm_apimaster-0.1.1-py3-none-any.whl

Total release size: 22.5 kB

Release files / llm_apimaster-0.1.1.tar.gz

Download URL llm_apimaster-0.1.1.tar.gz
Size 12.1 kB
Tags Source
SHA-256 checksum
How to use checksums
d8c542547f20f41271455c4b9a2b8ece3090430ad141576e601f356032a8b7e5
BLAKE2b-256 checksum
How to use checksums
b1c7e02bc8f2a1ef21c3fa13bec135e3864b863481c2cae527e4572a5ec6a7b3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 28, 2026.

Transparency log

Release files / llm_apimaster-0.1.1-py3-none-any.whl

Download URL llm_apimaster-0.1.1-py3-none-any.whl
Size 10.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
3409eaa780a9a66b53e31d71f0166ef0690e0ad844b2c29414b79359e914e160
BLAKE2b-256 checksum
How to use checksums
a2abcc8fc6a2096f1bf2fd3e5534946db840c8b62624504922e29e4d6e8217d2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 28, 2026.

Transparency log

Security for llm-apimaster 0.1.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for llm_apimaster-0.1.1.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 28, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 release files Full provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page