Inferway
Back to client guides
Client guides

OpenCode

Add Inferway as an OpenCode custom provider with @ai-sdk/openai-compatible.

Available

Use Inferway as a custom provider in OpenCode. Your account must have model access enabled before connecting.

Current Inferway catalog

Modelinferway/qwen3.8-27b
Context window262,144
Sample max tokens131,072

Verified on 1.18.25, macOS 26.6.2 arm64, 2026-09-19: basic conversation and file-read tool round trip against inferway/qwen3.8-27b.

Before you start

Install the named client using its official instructions. Pi here means the pi-mono coding agent; Hermes means Nous Research's Hermes Agent.

Once your Inferway account is activated, get an API key from Console → API keys. Use a dedicated key for this client and review its model access and spending limits. Both live and test prefixes use the same inference and billing path; test is an environment label, not a free or simulated inference mode.

Use an Inferway key for Inferway's endpoint. An OpenRouter key belongs to OpenRouter and cannot authenticate to this address.

Keep the key in the client's credential store or your local environment. Do not paste it into a prompt, screenshot, or committed configuration. These examples use bash/zsh on macOS or Linux.

Make the key available to this terminal

The prompt below hides your input and keeps the key out of shell history. Start the client from this same terminal; a separately opened app may not inherit this variable.

INFERWAY_API_KEYbash
printf 'Inferway API key: '
IFS= read -r -s INFERWAY_API_KEY
printf '\n'
export INFERWAY_API_KEY

Confirm the endpoint and model

Use the full model ID inferway/qwen3.8-27b. The Base URL ends in /v1 once; do not append /chat/completions to a Base URL setting. Check that the response below contains the model ID.

List modelsbash
curl --fail-with-body --silent --show-error --max-time 30 \
  'https://api.inferway.ai/v1/models' \
  -H "Authorization: Bearer $INFERWAY_API_KEY"

Create the scratch folder

OpenCode can load a project config from the project root (per-project config and custom paths are covered in the OpenCode configuration docs). Work in a scratch folder so the test never touches your daily settings or your global provider list.

The accepted live test used OpenCode CLI on macOS 26.6.2 arm64 against the catalog model below; check your own installed version before following along. git init just gives OpenCode a clean project root; no commit is needed for the check.

Scratch folderbash
# Scratch folder with a small read fixture
mkdir inferway-opencode-verify && cd inferway-opencode-verify && git init -q
printf 'nonce-7f3a9c\n' > read-tool-fixture.txt

Save the project config

Save this as opencode.json at the root of the scratch folder. The provider section keeps the public model ID as the model key; the composite model selector is provider/model. {env:INFERWAY_API_KEY} interpolates the variable set earlier; the key itself never enters the file. The 1024 output limit is the tested validation preset; a larger limit was not verified here.

opencode.jsonjson
{
  "$schema": "https://opencode.ai/config.json",
  "model": "inferway/inferway/qwen3.8-27b",
  "provider": {
    "inferway": {
      "npm": "@ai-sdk/openai-compatible",
      "name": "Inferway",
      "options": {
        "baseURL": "https://api.inferway.ai/v1",
        "apiKey": "{env:INFERWAY_API_KEY}"
      },
      "models": {
        "inferway/qwen3.8-27b": {
          "name": "Inferway",
          "limit": {
            "context": 262144,
            "output": 1024
          }
        }
      }
    }
  }
}

Run the basic check

Run from the terminal containing INFERWAY_API_KEY, inside the scratch folder. opencode run takes a positional message. Exit code 0 alone is not success — inspect the final text.

OpenCodebash
opencode run --pure --format json --title 'Inferway basic check' --model 'inferway/inferway/qwen3.8-27b' --agent build --dir . 'Reply with exactly: connected'

Confirm the connection

  1. Confirm the basic-check response text is exactly connected with no API error.
  2. Run the read check below. The prompt does not contain the nonce; confirm the final text is exactly the nonce from the fixture. This verifies the read loop only — edit, shell, and other tools are not claimed here.
  3. Open Console → Requests to confirm the inference requests and token usage. Actual billing is the Console's, not any client estimate.
Read checkbash
opencode run --pure --format json --title 'Inferway read fixture' --model 'inferway/inferway/qwen3.8-27b' --agent build --dir . 'Read the file read-tool-fixture.txt and reply with exactly the nonce it contains, nothing else.'

Optional: use Inferway in your daily config

After the checks pass, copy the provider block (and the model entry under it) into your existing OpenCode config, keeping your own settings. You do not need the scratch folder or the test fixture for daily use.

Cost and usage

Actual consumption is recorded by Inferway: open Console → Requests to see each request's status and token usage, and Console → Usage for totals. Numbers a client shows locally are its own estimates, not billing amounts; rely on the Console.

If a request fails

Authentication: check that an API key is present, active, and allowed to use the model. Reopen the client from the terminal containing the variable. Never print the full key when debugging.

Wrong endpoint or model: check for a duplicate /v1, use the exact published model ID, and confirm the client is using Chat Completions. A request to /responses or /completions cannot be repaired by changing the key.

Limits or timeout: check wallet balance and key limits, respect Retry-After, and reduce the prompt or output budget. Keep streaming enabled for long outputs. Avoid repeated agent retries while diagnosing.

When contacting support, share the client version, model ID, timestamp, and request ID if available. Redact credentials and source code.