Skip to content

Add Cheaper Inference as a model gateway backend - #144

Open
aiapienthusiast wants to merge 1 commit into
CodeGraphContext:mainfrom
aiapienthusiast:cheaperinference-provider
Open

aiapienthusiast wants to merge 1 commit into
CodeGraphContext:mainfrom
aiapienthusiast:cheaperinference-provider

Conversation

@aiapienthusiast

Copy link
Copy Markdown

This PR adds Cheaper Inference as a model gateway backend.
Cheaper Inference is an OpenAI-compatible LLM gateway.
One API key gives access to models from several labs.
It uses the same pattern as #102 (Novita).

Spec: cheaperinference/gpt-5.4-mini. Key: CHEAPER_INFERENCE_API_KEY (env or .env).

Changes:

  • grapharc/gateway/cheaperinference.py: CheaperInferenceChatModel, a thin subclass of OpenAICompatChatModel with a fixed endpoint, like novita.py.
  • config.py: CHEAPER_INFERENCE_KEYS and cheaper_inference_api_key().
  • registry.py: the backend in BACKENDS, a get_model() branch, a bare-backend example.
  • cli/main.py, cli/probe.py: the key line in grapharc models and a --check probe.
  • pyproject.toml, uv.lock: a cheaperinference extra, also in all.
  • Docs: 02-models.md (examples, table, transcripts) and the --check transcript in 06-serving-and-ops.md.
  • Tests: tests/test_gateway_cheaperinference.py (offline, plus one live-marked test), and the backend lists in the existing tests.
Two points to review
  • Model ids on this gateway are bare (gpt-5.4-mini), not author/slug.
    So vendor() reads every spec on it as cheaperinference.
    I did not map it to one lab in BACKEND_VENDOR, because the gateway serves several.
    The module docstring states the effect on different_providers.
  • The backend name has 16 characters, and BACKEND_COLUMN was 12.
    I changed it to 17, so the --check table stays aligned.
    This changes the width of every row.
    I updated the bedrock unprobed assertion in test_cli.py and both cookbook transcripts to the new width.
    The transcript in 06-serving-and-ops.md also gets the Novita row that it did not have.
    If you prefer a shorter backend name and no width change, I can change it.

Testing:

  • uv run pytest: green (2,424 selected, 14 deselected).
  • uv run ruff check .: clean.
  • grapharc models --check output matches the new transcripts.
  • I refreshed the count in docs/deep-dive.md with GRAPHARC_UPDATE_FIGURES=1. I did not re-run the other checks that paragraph lists.
  • I did not run the live test.

Cheaper Inference is an OpenAI-compatible LLM gateway at its own endpoint
(api.cheaperinference.com/v1), reached with one CHEAPER_INFERENCE_API_KEY.

Follows the Novita backend (CodeGraphContext#102): a thin subclass of
OpenAICompatChatModel, credentials resolved through the same env/.env
lookup in config.py, a new branch in the registry's get_model(), a
`models --check` probe, and a `cheaperinference` extra. Like OpenAI and
Novita, this backend reads no per-call cost, so calls are counted as
unpriced unless a rate card is supplied.

Model ids on this gateway are bare (gpt-5.4-mini), not author/slug, so
vendor() reads every spec on it as `cheaperinference`. It is not mapped
to one lab in BACKEND_VENDOR, because the gateway serves several.

Behaviour change: the `models --check` backend column grows from 12 to
17 characters so the 16-character name keeps the table aligned. The
test that pins `bedrock      unprobed` and both cookbook transcripts
are updated to the new width. The deep-dive test count was refreshed
with GRAPHARC_UPDATE_FIGURES=1.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant