Skip to content

Docs(opencode): add API key provider config example#1209

Open
smallgun01 wants to merge 2 commits into
openabdev:mainfrom
smallgun01:branch-docs/api-key-provider-example
Open

Docs(opencode): add API key provider config example#1209
smallgun01 wants to merge 2 commits into
openabdev:mainfrom
smallgun01:branch-docs/api-key-provider-example

Conversation

@smallgun01

@smallgun01 smallgun01 commented Jun 26, 2026

Copy link
Copy Markdown

What problem does this solve?

The existing docs/opencode.md examples (Ollama Cloud, xAI Grok) only cover OAuth-based providers. API-key-based providers like opencode-go require a different config structure — the full provider.options.apiKey block — which is not documented anywhere. Users hit this gap immediately when trying to set up API-key providers.

Closes #1200

At a Glance

N/A — docs-only change.

Prior Art & Industry Research

Not applicable — docs-only change, adding a missing config example.

Proposed Solution

Add a new ## Example: API Key Providers section to docs/opencode.md, placed after the existing xAI Grok example and before ## Notes. The example uses opencode-go as a representative API-key provider, showing:

  • The full provider.options.apiKey + models block
  • ${OPENCODE_API_KEY} env var expansion
  • Restart step to pick up config

Why this approach?

Follows the exact same structure and conventions as the existing two provider examples (authenticate → set config → restart → verify). Uses kubectl exec + heredoc format consistent with the rest of the doc. Minimal, focused — one realistic example covers the pattern for all API-key providers.

Alternatives Considered

  • Adding a generic "Provider Config Reference" section: too much scope for a single example gap. A focused, copy-pasteable example is more useful to users who already understand the OAuth examples.
  • Including kubectl create secret step: unnecessary noise — Kubernetes Secret creation is covered elsewhere and varies by deployment.

Validation

  • Links are valid (all internal links point to existing anchors or docs)
  • Renders correctly in GitHub preview (standard markdown, code block)
  • kubectl exec heredoc syntax matches existing examples (unquoted << EOF allows env var expansion)
  • JSON schema matches the opencode.json spec as documented at opencode.ai
  • Discord Discussion URL: https://discord.com/channels/1491295327620169908/1520318436507648130

@smallgun01 smallgun01 requested a review from thepagent as a code owner June 26, 2026 07:02
@openab-app openab-app Bot added the closing-soon PR missing Discord Discussion URL — will auto-close in 24 hours. label Jun 26, 2026
Comment thread docs/opencode.md Outdated
"opencode-go": {
"options": {
"baseURL": "https://opencode.ai/zen/go/v1",
"apiKey": "${OPENCODE_API_KEY}"

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should it be {env:VAR} format?

https://opencode.ai/docs/config/#env-vars

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're right — {env:OPENCODE_API_KEY} is the official portable syntax per opencode docs.
Updating the example.

Side note for anyone reading: the ${OPENCODE_API_KEY} form in a kubectl exec heredoc also
works because the shell expands it before writing the file — but only in shell-generated configs.
For users hand-writing opencode.json or running via Docker CMD / systemd, {env:VAR} is the
only correct option.

Thanks @thepagent.

@openab-app openab-app Bot removed the closing-soon PR missing Discord Discussion URL — will auto-close in 24 hours. label Jun 27, 2026
The shell-style `${OPENCODE_API_KEY}` worked in the kubectl exec heredoc
because bash expands it before writing, but `{env:VAR}` is the portable
opencode-native form documented at
https://opencode.ai/docs/config/#env-vars.

Closes review feedback from @thepagent.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Docs: opencode config schema fixes — provider (singular), apiKey in options, agent.instructions format

2 participants