Skip to content

feat: per-target API keys and add-target flow for /connect - #21

Open
thedonmon wants to merge 1 commit into
goniz:mainfrom
thedonmon:feat/target-api-keys
Open

thedonmon wants to merge 1 commit into
goniz:mainfrom
thedonmon:feat/target-api-keys

Conversation

@thedonmon

Copy link
Copy Markdown

Adds API key support so the plugin works with servers that need auth, like a hosted llama-swap with apiKeys set.

  • Targets take an optional apiKey ({env:VAR} works). It's sent as a Bearer token when probing and on chat requests.
  • "Add Custom Target" is now an oauth/auto method. That's the only type opencode runs from both /connect and opencode auth login, so it works in the TUI now and the dummy "enter none" key prompt is gone. The key prompt is optional, and there's a choice of which models to list.
  • llama-swap: opt-in includeUnloaded lists every model using /v1/models metadata, without loading them. The default is still loaded-only.
  • New openai kind as a fallback for any server with a /v1/models listing.
  • Adding a target only patches that target in config, so others keep their {env:VAR} references.
  • Updates @opencode-ai/plugin and @opencode-ai/sdk to 1.18.31.

Tested with unit tests and against a keyed llama-swap in opencode 1.18.31. I haven't run the Docker provider suite locally.

- Targets accept an optional apiKey, sent as a Bearer token when probing
  and on chat requests (via per-model headers). {env:VAR} works.
- Add Custom Target is now an oauth/auto method so it runs from both
  /connect and `opencode auth login`, asks for an optional key and which
  models to list, and no longer needs the dummy API key prompt. The
  target is saved in callback() because saving config restarts instances.
- Saving a target only patches that target, so other targets keep their
  {env:VAR} references.
- llama-swap: includeUnloaded lists every configured model using
  /v1/models metadata without loading them.
- New openai kind: fallback for any server with a /v1/models listing.
- Probe failures for configured targets are logged, with a clear
  message for 401/403.
- Update @opencode-ai/plugin and @opencode-ai/sdk to 1.18.31.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant