
Company News
Andrew Becherer Joins Socket as Chief Information Security Officer
Socket’s first CISO brings deep experience securing high-growth SaaS companies as open source supply chain threats accelerate.
@tarquinen/opencode-auth-provider
Advanced tools
Reuse OpenCode authentication & provider logic for clean AI calls in plugins
A reusable runtime that mirrors OpenCode's provider discovery logic so plugins can reuse the credentials stored in ~/.local/share/opencode/auth.json (API keys and OAuth) to run clean AI calls via the Vercel AI SDK.
opencode.jsonc configuration layers (global + workspace) and merges provider overrides~/.local/share/opencode/auth.json and environment variables just like the CLILanguageModel instancesopencode.jsonc, e.g. opencode-gemini-auth) so refresh logic matches the CLIimport { OpencodeAI } from "opencode-auth-provider"
import { generateText } from "ai"
const runtime = new OpencodeAI({ workspaceDir: process.cwd() })
const { providerID, modelID } = await runtime.getDefaultModel()
const model = await runtime.getLanguageModel(providerID, modelID)
const result = await generateText({
model,
prompt: "Summarize the most recent changes",
})
console.log(result.text)
const githubModel = await runtime.getLanguageModel("github-copilot", "gpt-4o-mini")
const response = await generateText({
model: githubModel,
messages: [{ role: "user", content: "Explain the PR diff" }],
})
Call runtime.reset() if you update opencode.jsonc or auth.json during runtime.
A ready-to-run script lives at scripts/run-model.ts. It uses the package to pick a model and print the response.
~/.local/share/opencode/auth.json plus any opencode.jsonc files you rely on)./home/dan/.config/opencode/opencode-auth-provider).cd /home/dan/.config/opencode/opencode-auth-provider
bun install # install deps (already done if you ran it once)
Quick single-shot call
bun scripts/run-model.ts --prompt "Say hello"
--provider <id> and --model <id> to override the defaults (otherwise it uses whatever opencode.jsonc marks as default).--cwd /path/to/project if you want the runtime to load configs from another workspace.Interactive picker
bun scripts/chat-with-provider.ts
Bun.spawn, Bun.hash, and Bun's package installer for on-demand provider SDKs.opencode.jsonc and installing their npm packages alongside this library.OPENCODE_DISABLE_DEFAULT_PLUGINS=1).models.dev is included so cold starts work offline; when the network is available, it continues to refresh the cache hourly just like the CLI.FAQs
Reuse OpenCode authentication & provider logic for clean AI calls in plugins
The npm package @tarquinen/opencode-auth-provider receives a total of 497 weekly downloads. As such, @tarquinen/opencode-auth-provider popularity was classified as not popular.
We found that @tarquinen/opencode-auth-provider demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Company News
Socket’s first CISO brings deep experience securing high-growth SaaS companies as open source supply chain threats accelerate.

Company News
Replit is integrating Socket Firewall into its AI-powered development experience to help protect builders from malicious open source packages.

Security News
npm confirmed a tooling bug incorrectly marked several one-character packages as security holders and said it was working on a rollback.