Skip to main content
Version: 1.9.0

Govern OpenCode with DVARA

OpenCode can use any OpenAI-compatible provider. Add the DVARA AI governance platform as one, and every model call OpenCode makes gets policy, PII rules, guardrails, budgets, cost records and an audit entry, billed to one DVARA workspace.

Tested with OpenCode 1.18.35.

Add DVARA as a provider​

You need a running DVARA Gateway that OpenCode can reach, a provider on it for the models you pick, and a DVARA workspace API key. If the key has scopes, it needs completions:write.

Add a provider to opencode.json (in your project, or in OpenCode's config folder):

{
"$schema": "https://opencode.ai/config.json",
"provider": {
"dvara": {
"npm": "@ai-sdk/openai-compatible",
"name": "DVARA",
"options": {
"baseURL": "https://gateway.acme.example.com/v1",
"apiKey": "{env:DVARA_API_KEY}"
},
"models": {
"<model-id>": { "name": "<model-id>", "tool_call": true }
}
}
},
"model": "dvara/<model-id>"
}

Then set the key and start OpenCode:

export DVARA_API_KEY=<dvara-workspace-key>
opencode
  • baseURL ends in /v1. OpenCode calls /v1/chat/completions.
  • {env:DVARA_API_KEY} reads the key from the environment, so it is not written in the file.
  • Each model needs tool_call: true. OpenCode's agent works through tools.
  • <model-id> must be a model your Gateway routes, on any provider.

What DVARA governs​

Each call runs the same controls as any /v1/chat/completions call: policy, PII rules, guardrails, budgets, rate limits, cost records and the audit chain. The tool calls the model asks for, and the tool output OpenCode sends back, are checked like any other text.

What DVARA does not govern​

  • OpenCode's local actions. File edits, shell commands and OpenCode's own web fetch run on the developer's machine and never reach DVARA. To stop the agent fetching web pages, deny it in OpenCode's permissions: "permission": { "webfetch": "deny" }.
  • Other providers OpenCode is signed in to. Only models under the dvara provider go through DVARA.

Where to go next​