Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

iTechGuides is reader-supported. When you buy through links on our site, we may earn an affiliate commission. As an Amazon Associate I earn from qualifying purchases. Learn more

The most reliable OpenCode setup is a two-tier policy: keep a stronger model for multi-step debugging, architecture, security-sensitive edits, and work where rework is costly; send lightweight transformations, titles, short explanations, and other low-risk requests to small_model. OpenCode supports separate model and small_model settings, so you can make that trade-off explicit instead of using one model for every request.

There is no universal winner for speed or quality. Provider performance depends on workload, context size, limits, availability, and pricing. Use OpenCode’s benchmark-informed recommendations as a starting point, then measure representative tasks from your own repository and review real spend regularly.

What model routing means in OpenCode

Model routing is the rule that decides which language model handles a request. In OpenCode, the practical pattern is to define a primary model with model and a cheaper, lighter option with small_model. OpenCode documentation describes the small model as suitable for lightweight tasks and says OpenCode attempts to use a cheaper available model by default when appropriate.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

This is not simply a “best model” decision. You are balancing four outcomes:

  • Quality: Does the response solve the task correctly on the first attempt and preserve the repository’s conventions?
  • Speed: How quickly does streaming begin, how long does completion take, and how often do requests time out?
  • Cost: What do input, output, and cached-read tokens cost for the provider and contract you actually use?
  • Reliability: Is the provider available, compatible with OpenCode’s API expectations, and controllable with limits, headers, retries, and timeouts?

A routing policy should optimize the whole task, not the price of one request. A cheap model that requires several corrective prompts can cost more than a stronger model that finishes cleanly.

Set a primary model and a small model

Use model for consequential work

Set model to the model you trust for difficult coding decisions. Typical examples include debugging involving several interacting modules, architectural changes, authentication or authorization edits, migrations, concurrency issues, and changes that must satisfy strict tests or security requirements. The primary model should have enough context capacity and maximum-output capacity for your largest normal tasks.

Use small_model for bounded work

Set small_model to a lower-cost model that is fast enough for short, well-scoped requests. Good candidates include generating a few titles, converting a format, explaining a small function, drafting a short comment, extracting fields, or making a mechanical transformation whose result you can inspect immediately. Do not route a task merely because it is short: a ten-line security change can be higher risk than a long documentation edit.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Configuration location and precedence

OpenCode reads configuration from opencode.json or opencode.jsonc. Keep a general default in your user configuration when you want the same policy across repositories. Put repository-specific defaults in the project configuration when a codebase needs a different provider, context limit, or model. OpenCode’s configuration documentation states that project configuration has the highest precedence among the standard configuration files, so a project setting can override a broader user default.

A minimal configuration expresses the routing intent directly:

{
  "model": "provider-primary-model",
  "small_model": "provider-lightweight-model"
}

The names above are illustrative identifiers. Replace them with model IDs exposed by the provider you configure. Keep the two roles distinct in documentation and code review so that a later model change does not silently move high-risk work to the inexpensive route.

Route tasks by risk, context, and rework cost

Use the following policy as a starting point, then adjust it after observing your own success and rework rates.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Task type Default route Why Override conditions
Titles, short rewrites, simple explanations small_model Short context and easy human verification keep failure cost low. Use the primary model when tone, legal wording, or brand terminology is unusually sensitive.
Mechanical refactors with strong tests small_model or primary Tests provide a feedback loop, but a refactor can still alter behavior outside the edited files. Use the primary model when test coverage is weak or the change crosses package boundaries.
Ordinary feature work Primary model Requirements, existing patterns, and edge cases usually require multi-step reasoning. Try the small model only for a narrowly defined subtask with a clear acceptance check.
Multi-step debugging Primary model Hypothesis formation, log interpretation, and iterative fixes make rework expensive. Use the small model for a final, mechanical cleanup after the defect is understood.
Architecture and dependency changes Primary model Long-term coupling and migration risk outweigh token savings. None by default; use a small model only for documentation or inventory work.
Security-sensitive edits Primary model Missing an authorization, validation, or secret-handling detail can create disproportionate harm. Never downgrade solely to reduce latency; require human review and tests.
Long-context repository analysis Primary model with sufficient context limit Dropping files or truncating history can produce a confident but incomplete answer. Split the analysis into verified, smaller stages if the primary route cannot accept the context.

Context length is a routing signal. A request can be conceptually simple yet expensive when it includes a large repository snapshot. Conversely, a complex question with a carefully selected set of files may fit a smaller model. Record the input-token volume and not just the visible prompt when evaluating a route.

Choose a provider with a measured trade-off

OpenCode’s Zen documentation says its recommended list is based on benchmarking combinations of model and provider. Treat that list as a useful starting filter, not as a permanent global ranking. The available documentation does not publish a workload-independent leaderboard proving which route is always fastest or most accurate.

Compare candidates on the dimensions below. A provider that wins one column may lose the overall decision once rework and outages are included.

Dimension What to measure Decision question
Output quality Acceptance rate, test pass rate, reviewer corrections, and rework prompts on representative tasks. Does the route produce usable code, not merely plausible text?
Latency Time to first streamed token, total completion time, and timeout frequency. Is it fast enough for interactive work at your normal context size?
Token economics Input, output, and cached-read prices, plus the tokens consumed by retries and corrective turns. What is the effective cost per completed task?
Limits Context-window and maximum-output values exposed in the model configuration. Can the route handle your largest routine request without truncation?
Reliability Availability, error rate, retry behavior, and provider-specific incidents. Will a time-sensitive task complete when you need it?
Compatibility Support for OpenCode’s provider integration, authentication, streaming, headers, and custom base URL. Can you operate the route without undocumented workarounds?
Operational control Timeouts, model limits, custom headers, and the ability to change pricing metadata. Can you enforce predictable behavior and account for your real contract?

Build a small evaluation set before changing defaults

Do not infer a model’s quality from one impressive answer. Create a compact evaluation set that resembles the work your team actually sends to OpenCode. The recommended categories are quick edits, ordinary feature work, difficult debugging, and long-context tasks.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
  1. Select representative prompts. Include a few tasks from each category, with the same repository snapshot and acceptance criteria for every candidate route.
  2. Define success before running the test. For coding tasks, specify tests that must pass, files that may change, required behavior, and review conditions. For text tasks, define factual and formatting requirements.
  3. Run each route under comparable conditions. Keep the prompt, available files, model limits, and time window consistent. Record whether the model streamed normally or encountered a timeout or retry.
  4. Score the result, not just the first response. Record first-pass acceptance, corrections, tests passed, reviewer changes, and the number of additional turns needed to finish.
  5. Capture token and time data. Separate input and output tokens when the provider exposes them. Record time to first token, total latency, and total elapsed time including retries.
  6. Route by evidence. Keep high-risk categories on the stronger route when failures are costly. Move only well-understood, low-risk categories to the small route.

This is a local evaluation plan, not a published benchmark. Your repository, prompts, context sizes, and provider contract determine the result.

Configure an OpenAI-compatible endpoint

OpenCode supports provider definitions for hosted services and local models. For an OpenAI-compatible endpoint, the configuration needs the provider package, a baseURL, model IDs, authentication headers, and token-limit information. Exact property names and supported options depend on the provider integration, so use the integration’s current configuration reference when filling in those values.

A provider definition should make these decisions explicit:

  • Endpoint: the base URL used for API requests.
  • Authentication: a header or credential method accepted by the endpoint; keep secrets out of committed project files.
  • Model mapping: the exact IDs for the primary and lightweight models.
  • Limits: context and maximum-output values that match the provider’s published limits.
  • Timeout behavior: a ceiling appropriate for interactive work and a longer allowance for large, deliberate requests.
  • Pricing metadata: input, output, and cached-read rates when the provider or OpenCode cost accounting supports them.

Test the provider with a harmless prompt before routing production changes. Verify authentication, streaming, model selection, context handling, and failure behavior independently; a successful login does not prove that every model ID or limit is valid.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Control API cost with accurate accounting

Use OpenCode Console pricing controls

OpenCode Console records request cost from model-pricing data and allows custom cost tiers when your negotiated rate differs from the provider’s public list price. Set those tiers to the rates on your actual contract so dashboards, budgets, and alerts reflect what you pay. If a provider changes prices or your agreement changes, update the metadata rather than treating an old estimate as a bill.

Review input, output, and cached-read usage separately. A route that looks inexpensive per output token can become costly when it receives large repository context on every turn. Likewise, a model that generates concise answers may still incur substantial input charges when repeated corrective prompts resend the same files.

Understand the OpenCode Go figures

The OpenCode Go page lists two subscription options labeled “OpenCode, 2026”: $10 per month and $40 per month. The $40 option provides higher usage limits. The same page lists model-level token prices; one example is GLM-5.3-Flash at $0.15 per 1 million input tokens and $0.50 per 1 million output tokens, labeled “OpenCode, 2026.” The retrieved page does not establish a cached-read figure for that example, so do not infer one.

These prices and model availabilities can change. Recheck the current OpenCode Go page and your account terms before budgeting or publishing a cost comparison. A subscription allowance and a per-token rate are different accounting models: calculate whether your workload is constrained by monthly usage limits, token prices, or both.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Calculate effective task cost

For a simple estimate, multiply input tokens by the input rate and output tokens by the output rate, then divide each rate by 1,000,000. Add cached-read charges when applicable. Include retries and follow-up corrections. The useful number for routing is cost per accepted task, not cost per initial completion.

For example, if the inexpensive route uses fewer tokens but succeeds only after two correction turns, compare the total tokens and elapsed time across all three turns with one primary-model attempt. Keep the calculation tied to the provider, model, region or account terms, and date of measurement.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Set limits and timeouts for predictable behavior

OpenCode exposes provider timeout controls and model limit fields. Use them to prevent a stalled request from consuming an unbounded amount of time and to prevent a model from generating output beyond what the task needs.

Choose a timeout by workload

  • Use a shorter timeout for interactive title generation or small transformations where a delayed response is less useful than a retry.
  • Allow more time for long-context analysis, repository-wide refactors, and debugging that requires substantial output.
  • Measure timeout frequency after changing the value. A timeout that is too short appears as provider unreliability; one that is too long ties up the session and delays recovery.

Set output limits deliberately

Maximum-output settings should match the requested artifact. A short explanation does not need the same ceiling as a migration plan or a multi-file patch. Excessive limits can increase cost and make it harder to detect runaway generation. Limits that are too low can truncate code or reasoning, producing an incomplete result that looks like a model failure.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Plan for transient failures

When a request times out, first determine whether the provider completed the request but the client lost the stream, whether the endpoint rejected the context, or whether the model was unavailable. Retry only after checking for duplicate side effects in tools or external systems. For code changes, inspect the working tree before submitting the same instruction again.

Operate routing as a weekly policy

Model routing is not a one-time configuration task. Prices, model availability, limits, and provider behavior change. Once a week, review:

  • Spend by model, provider, project, and task category.
  • Input, output, and cached-read token totals.
  • First-pass acceptance and rework rate for each route.
  • Median and tail latency, streaming interruptions, timeouts, and retries.
  • Tasks that exceeded context or output limits.
  • Changes to provider pricing, subscription allowances, model IDs, or availability.

Use the review to make one controlled change at a time: alter a route, limit, timeout, or provider, then observe the same evaluation set. Keep a rollback path by retaining the previous model ID and configuration in version control or a documented change log.

Troubleshoot common routing failures

The small model produces plausible but incorrect code

Move the task to the primary route when it involves hidden dependencies, weak tests, security controls, or ambiguous requirements. If the task is genuinely low risk, narrow the prompt, provide the exact acceptance check, and ask for a minimal diff rather than a broad solution.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

The request is too slow

Check context size, provider queueing, timeout settings, and streaming behavior before changing models. Remove irrelevant files from the prompt, split the task into verified stages, or use the small route for an independent preliminary step. Do not trade away correctness on a high-risk change solely to improve time to first token.

Costs are higher than expected

Inspect repeated context, output length, retries, and correction turns. Confirm that Console pricing metadata matches your negotiated rate and that cached-read accounting is configured correctly when available. Route bounded, low-risk work to small_model, but retain the primary route for tasks where rework would erase the saving.

A model cannot handle the repository context

Verify the model’s context and maximum-output limits. Reduce the file set to the smallest complete context, summarize stable background information, or choose a model with higher limits. Never assume that truncation is harmless; omitted files can contain the interface or test that determines whether a proposed change is valid.

The configured provider or model ID fails

Check the provider package, base URL, authentication headers, exact model ID, and declared limits. Test a minimal request, then test streaming and a context near your normal size. Keep credentials private and avoid committing them to a project configuration file.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

A practical default policy

For most teams, start with one high-quality primary model and one inexpensive small model. Route titles, short transformations, and easily verified explanations to the small model. Keep architecture, security-sensitive edits, difficult debugging, and long-context changes on the primary model. Measure success, rework, latency, timeouts, and total token cost on a representative evaluation set. Use OpenCode Console’s custom pricing controls for accurate accounting, and revisit the policy whenever prices, limits, or availability change.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.