Skip to content

Question: What format does OPENCODE_API_KEY use for CI authentication? #57338

Closed as not planned

Description

@abdelaziz11

Question

Question

I'm trying to understand how the opencode GitHub Action handles authentication internally. Specifically:

  1. When the workflow runs opencode run, does the CLI pick up OPENCODE_API_KEY from the environment automatically?
  2. Is the GITHUB_TOKEN used for anything beyond gh CLI commands?
  3. 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.

Activity

  1. neriousy commented on Oct 20, 2026

    @neriousy
    Member

    These are two separate authentication flows:

    1. 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.
    2. 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.
    3. 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions