You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Question: What format does OPENCODE_API_KEY use for CI authentication? #57338
I'm trying to understand how the opencode GitHub Action handles authentication internally. Specifically:
When the workflow runs opencode run, does the CLI pick up OPENCODE_API_KEY from the environment automatically?
Is the GITHUB_TOKEN used for anything beyond gh CLI commands?
What's the format of the OPENCODE_API_KEY - is it a JWT, an opaque token, or something else?
I'm asking because I'm building a similar CI integration and want to understand the token lifecycle.
Context
I've read through the source code but couldn't find documentation on the key format. Looking at packages/opencode/src/provider/opencode.ts, it seems like the key is passed as a Bearer token to api.opencode.ai, but I'm not sure if it's validated differently for GitHub Actions vs CLI usage.
Could a maintainer or the bot help clarify the token format? Even just knowing the prefix pattern (like sk- for OpenAI keys) would be helpful for my validation logic.
Model access:OPENCODE_API_KEY is read from the environment for the OpenCode provider, including in non-interactive runs. Select an OpenCode model; other providers use their own credentials. This is not a GitHub-specific credential or token exchange.
GitHub access: The action supports use_github_token: true with a caller-provided GITHUB_TOKEN. It is used for GitHub API operations and repository access, not just gh commands. By default, the action exchanges a GitHub Actions OIDC token for an OpenCode GitHub App installation token. Neither flow replaces model-provider authentication. See github/action.yml and github/index.ts.
Key format/lifecycle: Treat the provider key as an opaque secret, not a JWT to decode or validate locally. Current V2 Console API keys are documented with an oc_sk_... prefix, but that is not a universal format guarantee for older credentials. For an integration, avoid hard-coded prefix/length validation; let the service validate the credential. Current Console service-account keys support optional expiry and explicit revocation—see the API authentication docs.
For CI, store credentials in Actions secrets and grant only the permissions needed. Never print keys or environment dumps into logs or issues.
Activity
neriousy commentedon Oct 20, 2026
These are two separate authentication flows:
OPENCODE_API_KEYis read from the environment for the OpenCode provider, including in non-interactive runs. Select an OpenCode model; other providers use their own credentials. This is not a GitHub-specific credential or token exchange.use_github_token: truewith a caller-providedGITHUB_TOKEN. It is used for GitHub API operations and repository access, not justghcommands. By default, the action exchanges a GitHub Actions OIDC token for an OpenCode GitHub App installation token. Neither flow replaces model-provider authentication. See github/action.yml and github/index.ts.oc_sk_...prefix, but that is not a universal format guarantee for older credentials. For an integration, avoid hard-coded prefix/length validation; let the service validate the credential. Current Console service-account keys support optional expiry and explicit revocation—see the API authentication docs.For CI, store credentials in Actions secrets and grant only the permissions needed. Never print keys or environment dumps into logs or issues.