Skip to content

feat(provider): add Cheaper Inference preset and OpenCode provider mapping - #66

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

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

Conversation

@aiapienthusiast

Copy link
Copy Markdown

What does this PR do?

This PR adds a Cheaper Inference provider preset and maps the cheaperinference/ model prefix to CHEAPER_INFERENCE_API_KEY for OpenCode.
It mirrors the Requesty preset.

Cheaper Inference is an OpenAI-compatible LLM gateway.
One API key gives access to models from several labs.

Usage:

provider:
  baseUrl: "https://api.cheaperinference.com/v1"
  apiKey: "${CHEAPER_INFERENCE_API_KEY}"
  model: "cheaperinference/gpt-5.4-mini"

Model ids are bare (for example gpt-5.4-mini). OpenCode model discovery lists the account's text models from /v1/models. doctor and onboard detect CHEAPER_INFERENCE_API_KEY.

Type of change

  • Bug fix
  • New feature
  • Breaking change
  • Documentation update
  • Refactoring
  • Other (describe below)

Checklist

  • pnpm run build passes
  • pnpm run test passes (provider and engine suites; the full run has one pre-existing flake in engine-abort.test.ts that passes in isolation and is unrelated to this change)
  • New code has tests (if applicable)
  • Updated documentation (if applicable)

@0xranx

0xranx commented Oct 31, 2026

Copy link
Copy Markdown
Owner

Thanks for the contribution! Local tests pass (1,341 passed, 6 skipped), but I found two issues to fix before merging:

  1. The OpenCode provider config is incomplete. Cheaper Inference is not currently in models.dev, so it cannot rely on built-in defaults like Requesty. ensureOpenCodeConfig() generates only options.apiKey and models, even when given the documented base URL. Please also configure npm: "@ai-sdk/openai-compatible" and options.baseURL, honoring the configured URL. The new config test currently asserts the incomplete shape. See OpenCode's custom provider docs.

  2. Model discovery ignores the supplied API key. listModels() reads only process.env.CHEAPER_INFERENCE_API_KEY, ignoring opts.apiKey. I verified that with only opts.apiKey, the models endpoint is never called; with both set, it uses the environment key instead. Please prefer opts.apiKey and fall back to the environment variable.

Could you fix both and add regression tests for the generated config and explicit-key handling? Please also resolve the conflicts with main. A short authenticated smoke test covering a reply and a tool call would help confirm the integration; please omit credentials.

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.

2 participants