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
Configuring an open-source coding agent means choosing a provider/model, making credentials available to the project, and defining what tools the agent may use. In OpenCode, you can select a model with /models, set a persistent default in opencode.json or opencode.jsonc, authenticate with an API key or OAuth, and write permission rules that allow, deny, or ask before an action. Other agents use different files and precedence rules, so treat OpenCode as a documented example and use your agent’s schema as the authority.
What does it mean to configure an open-source coding agent?
There are three separate decisions:
- Model routing: which provider and model should answer requests.
- Credentials: how the agent proves that it may call that provider.
- Permissions: which tools, files, commands, or network operations can run automatically, require approval, or remain forbidden.
Keeping those decisions separate prevents common mistakes. A model can be listed in a configuration file but remain unavailable because its provider has no credential. Conversely, a valid credential does not grant permission to execute shell commands or edit files. Project settings may also be narrowed by a global or organization-managed policy.
OpenCode’s configuration documentation describes its schema as the source of truth for accepted fields and nested shapes. That statement matters because configuration keys, provider IDs, defaults, and permission syntax change over time. Copy the pattern below, then verify the current schema for the version you installed.
Do these 3 things before closing this tab:
1Fix the driver behind crashes, sound loss and screen glitches2Clear out junk files and repair common Windows errors3Scan for outdated or missing drivers - takes under a minuteWhat should you prepare before changing settings?
Have these items ready before opening the agent:
- The project directory in which the agent will run. Many agents load project configuration relative to this directory.
- The provider account you intend to use and a model ID that provider currently exposes.
- An API key, OAuth-capable account, or provider-specific login method. Decide whether credentials will be supplied interactively or through the process environment.
- A written permission policy. List the tools that need unattended access, the operations that should always prompt, and the operations that should never run.
- A way to validate changes without giving the agent more access than necessary. Start with a harmless read-only request, then test a narrowly scoped command such as checking repository status.
Do not put a live secret in a repository file. Use an environment variable or the agent’s credential store, add local secret files to .gitignore, and review the final diff before committing configuration.
Popular on Amazon
- 【90 Degree Full Function USB C Adapter】Supports the latest USB4 standard for up to 40Gbps of bandwidth, 8K video support, and up to 240W Fast charging; Support USB PD 3.1 Extended Power Range (EPR) including 140W, 180W and 240W. Your productivity is easily doubled. *Warm Tip: For the best fit, please make sure the USB-C port is fully exposed; thick or bulky cases may affect compatibility.
- 【Reliable Quality】Made from high-quality, scratch-resistant aluminum alloy, delicate metal frame. get excellent wear resistance and heat dissipation. Non-Slip Design for easier insertion and removal.
- 【Small and portable】Ultra thin size, ultra compact design, a petite physique that matches the minimalist design of your modern laptops. Coming with a slim figure that won't block the port next to the one it's plugged into.
- 【Compatibility】Widely work with most usb c, thunderbolt 4/3 devices. Compatibilit for ROG Ally, Steam Deck, Switch, MacBook Pro, Quest 3 VR headset, Surface Book 2, iPhone 18/17/16/15, Samsung Galaxy S23/S22/S21, Note 20/10, Google Pixel, ChromeBook, etc.
- 【Excellence Customer Support】If you experience any issues or cable failure, simply reach out to our dedicated customer service team. We provide a prompt response within 18 hours, providing you with the necessary technical support to resolve any concerns.
How do you select a model in OpenCode?
Use /models for a temporary session choice, or set a default in opencode.json or opencode.jsonc for future sessions. OpenCode identifies a model with a provider/model reference. The selector shows only models whose provider is enabled and authenticated in the current project, as explained in the OpenCode models guide.
Choose a model for one session
- Start OpenCode from the project directory.
- Enter
/models. - Select an available provider/model entry.
- Send a small request and confirm that the response comes from the intended provider.
This selection takes precedence for that session, but it does not rewrite your configuration file. Opening a new session can therefore return to the configured default.
Set a persistent default
Add the model reference to the project configuration, using the exact ID displayed by your provider:
Recommended Free Tools
{
"$schema": "https://opencode.ai/config.json",
"model": "provider/model-id"
}
The snippet shows the shape, not a universal model name. Replace provider/model-id with an ID present in your authenticated catalog. If the agent reports that the model is unknown, check spelling, provider availability, and whether the command is running in the same project that contains the credentials.
Understand project scope
OpenCode does not automatically make every credential and setting from one project available in another. A model that appears in one directory may be absent in a different directory because provider configuration, environment variables, or policy files differ. When troubleshooting, print or inspect the environment of the actual server process and launch location rather than assuming your shell or another project has the same settings.
How do you connect an API key or other credentials?
Authentication methods depend on the provider. OpenCode documents API keys, OAuth, provider-specific commands, and environment variables; these are examples of available paths, not a standard shared by every open-source agent.
Also popular on Amazon
- 5-in-1 Connectivity: Equipped with a 4K HDMI port, a 5 Gbps USB-C data port, two 5 Gbps USB-A ports, and a USB C 100W PD-IN port. Note: The USB C 100W PD-IN port supports only charging and does not support data transfer devices such as headphones or speakers.
- Powerful Pass-Through Charging: Supports up to 85W pass-through charging so you can power up your laptop while you use the hub. Note: Pass-through charging requires a charger (not included). Note: To achieve full power for iPad, we recommend using a 45W wall charger.
- Transfer Files in Seconds: Move files to and from your laptop at speeds of up to 5 Gbps via the USB-C and USB-A data ports. Note: The USB C 5Gbps Data port does not support video output.
- HD Display: Connect to the HDMI port to stream or mirror content to an external monitor in resolutions of up to 4K@30Hz. Note: The USB-C ports do not support video output.
- What You Get: Anker 332 USB-C Hub (5-in-1), welcome guide, our worry-free 18-month warranty, and friendly customer service.
Use the OpenCode login flow
For an interactive provider picker, run:
opencode auth login
To request a particular key-based method for a provider, OpenCode documents this form:
opencode auth login anthropic --method key
The provider name and supported methods can change. If a command is rejected, consult the current provider CLI documentation instead of substituting a command from another tool.
Supply a key through the environment
Environment variables are useful for CI, containers, and local development because the secret stays outside the committed configuration. Configure the provider to read the variable expected by that provider, then export it before starting the agent or its server process:
export PROVIDER_API_KEY='replace-this-locally'
opencode
Use the provider’s documented variable name. An environment variable set in an interactive shell is not necessarily visible to a GUI launcher, background service, container, or remote server. Confirm the variable is present in the process that actually runs the agent, without printing its value to logs.
Keep credentials separate from model defaults
A model reference tells the agent what to request; it does not itself contain authorization. If the provider credential is missing, expired, restricted to a different endpoint, or blocked by policy, the model can disappear from the selector or fail at request time. Rotate keys at the provider, update the secret store or environment, and restart the process if it only reads variables at startup.
Free tools Windows power users keep installed
One-click scans. No signup required.
How do you configure a custom provider or endpoint?
OpenCode supports custom provider definitions that describe the endpoint, credential source, runtime package, and available model IDs. The exact keys belong to the OpenCode version and runtime you use; consult the provider configuration guide and schema before copying a definition.
Also popular on Amazon
- Sleek 7-in-1 USB-C Hub: Features an HDMI port, two USB-A 3.0 ports, and a USB-C data port, each providing 5Gbps transfer speeds. It also includes a USB-C PD input port for charging up to 100W and dual SD and TF card slots, all in a compact design.
- Flawless 4K@60Hz Video with HDMI: Delivers exceptional clarity and smoothness with its 4K@60Hz HDMI port, making it ideal for high-definition presentations and entertainment. (Note: Only the HDMI port supports video projection; the USB-C port is for data transfer only.)
- Double Up on Efficiency: The two USB-A 3.0 ports and a USB-C port support a fast 5Gbps data rate, significantly boosting your transfer speeds and improving productivity.
- Fast and Reliable 85W Charging: Offers high-capacity, speedy charging for laptops up to 85W, so you spend less time tethered to an outlet and more time being productive.
- What You Get: Anker USB-C Hub (7-in-1), welcome guide, 18-month warranty, and our friendly customer service.
A custom-provider plan normally contains these parts:
- Provider identifier: a stable name used in
provider/model-idreferences. - Base URL: the inference endpoint, including any required API path.
- Credential mapping: the environment variable or secret reference that supplies the key.
- Runtime: the provider adapter or package capable of speaking to that endpoint.
- Model catalog: the model IDs and display names the endpoint accepts.
Use environment substitution for endpoint keys and never commit a literal secret. After saving the provider definition, restart the agent if required, authenticate the endpoint, and check whether its models now appear under /models. A successful configuration still does not prove that the endpoint’s model supports every tool or context feature; verify those capabilities in the provider’s documentation.
Custom endpoint failure modes
- Model not listed: the provider definition may not have loaded, the model ID may be misspelled, or credentials may be unavailable in the current project.
- 401 or 403 response: the key is invalid, scoped to another account, or not accepted by that endpoint.
- 404 response: the base URL or model path is wrong for the provider’s API format.
- Timeout: check network access, proxy settings, TLS certificates, and whether the endpoint is reachable from the agent’s server process.
- Tool-call errors: the model may answer text but not implement the tool or structured-output interface expected by the agent.
How should permission rules be designed?
Permission systems answer three questions: what resource is covered, what effect applies, and which layer wins when rules conflict. OpenCode rules can allow an action, deny it, or ask for approval. The permissions documentation illustrates a broad shell prompt combined with a narrower allowance for a safe status command.
Quick wins for a faster PC:
Repair Windows errors before they cause bigger problemsFix Now →Scan for outdated or missing drivers - takes under a minuteDriver Scan →Start restrictive, then add narrow exceptions
A practical baseline is to ask before shell use, allow only a read-only command that you understand, and deny destructive operations. The following is an illustrative policy shape; use the current schema to confirm the exact resource and action names for your version:
{
"permission": {
"*": "ask",
"bash": {
"git status": "allow"
}
}
}
Do not treat this example as a universal default. Some agents call the same capability shell, terminal, or exec, and their matching syntax may differ. The important design is the narrow exception: a specific command is allowed while unrelated shell commands still require confirmation.
Use deny for hard boundaries
An approval prompt is a workflow gate, not an absolute security boundary. If an operation must never occur, use a documented deny rule or remove the capability at a stronger policy layer. Keep deny rules for destructive file operations, secret directories, credential stores, production hosts, and network destinations that the project does not need.
Also popular on Amazon
- Portable and powerful USB-C HUB: BENFEI USB Type-C HUB, with super-soft and knot-free silicone woven design cable, meets most mobile office needs. Compact, lightweight, stylish, and powerful portable USB C Hub equipped with 1 x HDMI port, 1 x 100W charging, and 3 x USB ports. 18-month warranty, 24-hour response, to ensure you feel at ease when using our product.
- Design centered on comfort and reliability: Thanks to BENFEI's end-to-end in-house cable production capability, in-house PCBA and assembly capability, using the industry's most advanced silicone woven design and process, 20cm cable in length, no knots, super-soft, the HUB is easy to use in all scenarios: laptop, tablet, stand etc. Super-soft, 25000+ life cycles, to meet your daily carrying and office needs.
- 100W Charging: Support up to 90W USB C pass-through charging via Type-C port to keep your laptop powered. 10W is reserved for other interface operations. No data and video function on the Type-C port.
- 4K HDMI Display: The HDMI port supports media display at resolutions up to 4K 30Hz, keeping every incredible moment detailed and ultra vivid. Please note that the C port of the Host device needs to support video output.
- Transfer Files in Seconds: Transfer files and from your laptop at speeds up to 10 Gbps with USB A 3.2 port. Extra 2 USB A 2.0 ports are perfectly for your keyboards and mouse.
Review saved approvals
OpenCode can turn an approval into a durable, project-scoped allow rule. That is convenient for repetitive work but can silently broaden access after the original task ends. Review saved approvals periodically, remove rules that no longer serve the project, and avoid approving a wildcard when a command- or path-specific rule is sufficient.
Windows Errors? Fix Them Before They Spread
Repair common Windows errors and clear accumulated junk for a smoother, more stable PC - no reinstall needed.Free scan · no reinstallOutdated Drivers Are Slowing You Down
One free scan finds every outdated or missing driver and matches the right update for your exact hardware.Free scan · exact hardware matchWhich configuration layer wins when rules conflict?
OpenCode evaluates ordered rules and preserves configured denies. A project-level allow or ask result can still be converted to deny by a stronger global or organization-managed policy; a higher policy layer cannot grant access that the project did not request. This distinction is critical when a command works on a personal project but is blocked in a managed workspace.
Think of precedence as a narrowing process:
- Agent defaults establish the baseline.
- User or global settings can impose restrictions across projects.
- Project configuration describes what this repository needs.
- Organization or Console policy can enforce a final boundary for managed workspaces.
The exact order and names vary by agent, so verify them in the relevant documentation. When diagnosing a denial, identify the resource, matched rule, and layer that produced the decision. Do not “fix” a managed denial by adding a broader project allow; that changes local intent but cannot override the organization boundary.
How do managed providers work for a team?
OpenCode Console can connect provider accounts for a workspace and optionally restrict members to workspace-managed providers. Its documented gateway model stores the provider credential and serves access through the gateway, so individual members do not receive the provider key. Read the current Console provider documentation before enabling this arrangement.
Managed access changes the operational questions:
- Who can add or remove a provider connection?
- Which models are permitted for the workspace?
- How are usage limits, logs, and revocation handled?
- What happens when a member works offline or outside the managed project?
Console also documents optional pay-as-you-go model access billed per request. Treat availability and pricing as time-sensitive and check the current Console models page before budgeting or promising a particular model.
What is a safe setup workflow for a new project?
- Inspect the schema and version. Open the agent’s current configuration reference and note the supported permission and provider fields.
- Create a minimal project file. Set only the default model and essential provider configuration. Avoid copying a large policy from an unrelated repository.
- Authenticate privately. Use the documented login flow or export the required environment variable in the process that will run the agent.
- Verify model visibility. Run
/modelsand confirm the intended provider/model appears. If it does not, check project location, credentials, and provider ID before editing permissions. - Apply least-privilege permissions. Start with ask or deny, then add narrowly matched allows for routine, reversible commands.
- Exercise a read-only request. Ask for an explanation or file listing that does not modify the repository.
- Approve one controlled action. Use a harmless command, inspect the approval scope, and reject any wildcard you did not intend to save.
- Test a deliberate denial. Confirm that a forbidden operation is blocked and record which policy layer produced the decision.
- Document the setup. Record required variable names, provider IDs, and safe startup steps without recording secret values.
How do you troubleshoot a model, key, or permission problem?
| Symptom | Likely cause | Next check |
|---|---|---|
The model is absent from /models |
Provider is not enabled, credentials are unavailable, or the project differs | Launch from the intended directory; verify provider ID, environment visibility, and login status |
| Authentication fails immediately | Wrong method, expired key, or unsupported provider login | Use the provider’s current OpenCode instructions and rotate the key if necessary |
| Requests reach the wrong service | Incorrect base URL or stale custom-provider definition | Check endpoint spelling, API path, and loaded configuration |
| A command always prompts | No matching allow rule or a stronger policy forces ask | Inspect the matched resource and precedence; add a narrow rule only if policy permits |
| An allowed action is denied | Global or organization policy overrides the project | Find the higher-level policy owner; a project allow cannot grant access above it |
| A previously approved action is now blocked | Saved approval was removed, scope changed, or policy tightened | Review durable project rules and managed-policy changes rather than widening permissions blindly |
What security checks should you perform before sharing the configuration?
- Search the repository and shell history for accidental API keys.
- Use environment substitution or a secret manager instead of literal credentials.
- Limit keys at the provider to the projects, models, origins, or spending bounds that are available.
- Prefer read-only and path-specific permissions; reserve broad shell access for isolated environments.
- Review network and file permissions separately. A model that cannot edit files may still expose data through a permitted command.
- Revoke credentials when a contractor, machine, workspace, or repository no longer needs them.
- Recheck provider IDs, model catalogs, authentication methods, permission defaults, and managed-service pricing whenever you upgrade the agent or change providers.
Can these practices be used with another open-source agent?
The concepts transfer, but the syntax does not. Most agents have equivalents for a model default, provider credentials, and tool permissions, yet they may use different filenames, environment-variable conventions, policy precedence, or credential stores. Use the same sequence—identify the active project, authenticate the provider, select a model, define least-privilege rules, and test both an allowed and denied action—while substituting that agent’s documented commands and schema.
Also popular on Amazon
- 【Read before You Buy】 Note: This adapter is USB 2.0 version and cannot transmit HDM, VGA, or other video signals. Nevertheless, they are fully capable of charging devices,duplicating files, and can be seamlessly integrated with USB-C earphones, wireless network adapters, and SD card adapters.
- 【Easy to Use and Safe】Thanks to modern manufacturing techniques, we've made these adapters sufficiently compact so that they can remain inserted in your device without noticeable protrusion or inconvenience. This means you don't have to constantly plug and unplug them, reducing the likelihood of wear and misalignment, and making them more convenient to carry around.
- 【Reliable Quality】Engineered for enhanced durability, durable aluminum alloy shell material,get excellent wear resistance and heat dissipation,the male USB C and female USB connectors & the male USB and female USB C connectors are designed to be plugged and unplugged up to 20000 times. Provides data transfer, device charging, memory space expansion, and additional computer peripherals.
- 【Think more for you】Do you need to connect a USB-C-enabled device to an odd device that only has USB-A ports? Then these USB-A male to USB-C female adapters are made for you.Simply insert the adapter into the USB-A port on the device, and you can instantly connect your USB-C device to the device that originally didn't have the correct connection port.
- 【Trusted xiwxi Quality and Service】As a responsible brand seller, you will receive xiwxi's 12-month Quality assurance and lifetime friendly customer service, you're not just buying a product,you're investing in peace of mind with all-round quality and exceptional customer service.
OpenCode is a useful concrete reference because its documentation exposes each layer separately. It should not be treated as proof that another agent supports /models, opencode auth login, the same JSON keys, or the same policy hierarchy.
Configuration checklist
- Model reference uses the exact provider/model ID.
- Provider credentials are available to the actual server process.
- No secret is committed to
opencode.json,opencode.jsonc, or source control. - Session model choices are understood to be temporary unless written to configuration.
- Permission rules specify a resource, an effect, and an intentional scope.
- Destructive operations have a hard deny or an equivalent stronger control.
- Saved approvals have been reviewed for wildcard scope.
- Global and organization policies have been checked before diagnosing a project denial.
- Custom endpoint, runtime, and model IDs match the current provider documentation.
- A rotation and revocation procedure exists for every credential.
Frequently Asked Questions
Why does my coding agent show no models after I added a key?
The agent may be running in a different project or process that cannot see the environment variable, or the provider definition may use a different ID than the key supports. Check the provider’s authentication status and model catalog from the same launch context as the agent, then restart a server that reads credentials only at startup.
Should I put an API key directly in the agent configuration file?
Usually no. A committed file can expose the key through version history, pull requests, backups, or logs; use the agent’s credential store, an environment substitution, or a secret manager and restrict access at the provider.
Can a permission prompt protect a production repository by itself?
A prompt reduces accidental execution but is not equivalent to a hard boundary, especially if a user can approve the action or a broader tool can reach the same resource. Combine approval prompts with deny rules, filesystem or network isolation, and organization policy for production work.
Why does a project-level allow rule fail in a managed workspace?
A global or organization-managed policy can convert an allow or ask result into deny. The project cannot grant access above that boundary, so the workspace administrator must change the managed policy or provide an approved provider and tool path.
What should I record so teammates can reproduce the setup safely?
Document the agent version, configuration filename, provider and model IDs, required environment-variable names, login method, and permission rationale. Leave out secret values and include a rotation or revocation contact so the setup can be retired cleanly.

