rpk ai run opencode
Launch OpenCode 2 with model traffic routed through the Redpanda AI gateway for the current environment.
rpk ai layers native v2 providers, model settings and policies over your OpenCode
configuration. A private standalone server owns this session; existing background
servers are not used or changed. Conflicting selected-provider configuration,
credentials and provider-use policies are refused before API-key acquisition.
Other agents, tools, MCP servers and themes remain available. User plugins are
trusted code, not an egress security boundary.
Each model uses the first supported wire API the server catalog declares:
openai_responses direct @opencode/ai/providers/openai/responses
{provider}/responses
anthropic_messages direct @opencode/ai/providers/anthropic
{provider}/v1/messages
gemini_generate_content direct @opencode/ai/providers/google
{provider}/v1beta/models/{model}:streamGenerateContent
openai_chat_completions direct @opencode/ai/providers/openai-compatible
{provider}/chat/completions
gemini_generate_content vertex @opencode/ai/providers/google
{provider}/v1beta/models/{model}:streamGenerateContent
anthropic_messages vertex @opencode/ai/providers/google-vertex/messages
{provider}/v1/projects/{p}/locations/{l}/publishers/anthropic/models/{model}:streamRawPredict
bedrock_converse bedrock_runtime @opencode/ai/providers/amazon-bedrock
{provider}/model/{model}/converse-stream
openai_responses bedrock_mantle @opencode/ai/providers/openai/responses
{provider}/openai/v1/responses
openai_responses bedrock_runtime @opencode/ai/providers/openai/responses
{provider}/openai/v1/responses
openai_chat_completions bedrock_mantle @opencode/ai/providers/openai-compatible
{provider}/openai/v1/chat/completions
openai_chat_completions bedrock_runtime @opencode/ai/providers/openai-compatible
{provider}/openai/v1/chat/completions
A model needs streaming, tools, multi-turn conversations and system prompts.
Unknown models and unsupported bindings are omitted; naming one with -m fails.
OpenAI-compatible providers require an explicit model allowlist and use Chat
Completions. Fireworks also requires an explicit allowlist.
Every bound model stays available through /models. -m optionally selects the
starting model; otherwise the first bound allowlisted or catalog model is used.
Title and compaction agents use that same initial model. A private fixed model
catalog and request-time guard prevent other provider/model selections.
The gateway signs Bedrock and Vertex requests upstream; no local AWS or Google
credentials are needed. The Agentic Data Plane API key is supplied only through the child
environment, never in argv or literal generated configuration. OpenCode expands
its environment placeholders, so its resolved local configuration may contain
credentials. Do not publish that output. --print-config prints only the generated
placeholder configuration without acquiring a key or starting OpenCode.
ChatGPT subscriptions: use an OpenAI passthrough provider whose upstream is
https://chatgpt.com/backend-api/codex. Sign in with OpenCode using
opencode auth login openai --method chatgpt-browser
or --method chatgpt-headless. Token-sharing logins are not supported for this
Codex backend. The native openai provider owns seat-token refresh and account
headers; the Agentic Data Plane key travels separately in X-Redpanda-Api-Key.
Claude subscriptions: an Anthropic passthrough provider uses OpenCode native
claude-agent and your native claude subscription login (claude 2.1.283 or newer).
No external adapter is installed and no login is copied. OpenCode bridges its
own tools to Claude; its permission controls and --auto apply. Subscription use
is subject to your provider terms and seat limits.
Requires OpenCode 2.2.7 or newer (v2 only). Server/attach overrides and commands that bypass the standalone model guard are refused. Start from the intended project directory; forwarded directory, worktree and resume selectors are refused. Pass OpenCode arguments after a literal --:
rpk ai run opencode -L openai -- run "explain this repository"
Flags
| Value | Type | Description |
|---|---|---|
|
string |
authenticate the session with an Agentic Data Plane API key: ask (ask before creating one), yes (create one without asking, also without a terminal), no (do not create a key; require an already provided Agentic Data Plane API key). Default: |
|
name |
AI gateway LLM provider name to route through. |
|
string |
Starting model ID. It must be in any configured allowlist and declare a supported wire API (default: the first bound model). Every bound model stays available through /models. |
|
bool |
Print the generated OpenCode configuration, then exit without launching OpenCode or creating an API key. Provider read access is required. |
Global flags
| Value | Type | Description |
|---|---|---|
|
string |
Redpanda or |
|
stringArray |
Override |
|
bool |
Ignore |
|
string |
|
|
bool |
Enable verbose logging. |