Skip to main content
opencode manages models through provider configuration. When connecting to the powertokens platform, start with an OpenAI-compatible custom provider that points opencode at the platform /v1/chat/completions compatible endpoint. This page is for opencode text-agent workflows. Some image, speech, and video task models in /v1/models also declare openai, but that does not mean they are text Chat Completions models for opencode. If you need to choose the endpoint first, see Text model protocols and endpoints.

Choose a path

Goalopencode providerBase URLRecommended model
Recommended text pathcustom provider + @ai-sdk/openai-compatiblehttps://api.powertokens.ai/v1glm-5.2
MiniMax text pathcustom provider + @ai-sdk/openai-compatiblehttps://api.powertokens.ai/v1MiniMax-M3
Claude/Anthropic path@ai-sdk/anthropic custom providerhttps://api.powertokens.ai/v1Use only when you need to validate /v1/messages

Prepare the API key

Store the powertokens platform API key in an environment variable:
export POWERTOKENS_API_KEY="YOUR_POWERTOKENS_API_KEY"
You can also run /connect in the opencode TUI and save credentials there. The provider ID in opencode.json must match the provider ID used by /connect.

OpenAI-compatible provider example

Create or update .opencode/opencode.json in your project:
{
  "$schema": "https://opencode.ai/config.json",
  "model": "powertokens/glm-5.2",
  "small_model": "powertokens/glm-4.5-air",
  "provider": {
    "powertokens": {
      "npm": "@ai-sdk/openai-compatible",
      "name": "powertokens",
      "options": {
        "baseURL": "https://api.powertokens.ai/v1",
        "apiKey": "{env:POWERTOKENS_API_KEY}"
      },
      "models": {
        "glm-4.5-air": {
          "name": "glm-4.5-air"
        },
        "glm-5.2": {
          "name": "glm-5.2"
        },
        "MiniMax-M3": {
          "name": "MiniMax-M3"
        },
        "deepseek-v3-2-251201": {
          "name": "deepseek-v3-2-251201"
        }
      }
    }
  }
}
This path uses the platform POST /v1/chat/completions endpoint.

Model choice

Use glm-5.2 as the OpenAI-compatible default. Use MiniMax-M3 for MiniMax scenarios. When you need BytePlus or Seed text models, prefer the OpenAI-compatible provider. Do not add image-generation, openai-video, TTS, Kling, Vidu, or Wan task models to an opencode text provider. For the full text model matrix, see Text model protocols and endpoints.

Anthropic provider example

For Claude/Anthropic Messages, configure a separate @ai-sdk/anthropic custom provider. This path uses the platform /v1/messages endpoint; validate the current opencode version and target model end to end before relying on it.
{
  "$schema": "https://opencode.ai/config.json",
  "model": "powertokens-anthropic/glm-5.2",
  "small_model": "powertokens-anthropic/glm-5-turbo",
  "provider": {
    "powertokens-anthropic": {
      "npm": "@ai-sdk/anthropic",
      "name": "powertokens Anthropic",
      "options": {
        "baseURL": "https://api.powertokens.ai/v1",
        "apiKey": "{env:POWERTOKENS_API_KEY}"
      },
      "models": {
        "glm-5.2": {
          "name": "glm-5.2"
        },
        "glm-5-turbo": {
          "name": "glm-5-turbo"
        },
        "MiniMax-M3": {
          "name": "MiniMax-M3"
        },
        "deepseek-v3-2-251201": {
          "name": "deepseek-v3-2-251201"
        }
      }
    }
  }
}
Use glm-5.2 as the default Anthropic-path model. Use MiniMax-M3 for MiniMax-path validation. deepseek-v3-2-251201 passed opencode Anthropic-provider tool-workflow validation. Seed models except seed-1-6-flash-250715 also passed re-validation and can be selected for real-task validation. Do not use seed-1-6-flash-250715 as an opencode Anthropic-provider default.

Verify

First confirm opencode can read the provider and models:
opencode models powertokens
opencode models powertokens-anthropic
Then verify the OpenAI-compatible path in non-interactive mode:
opencode run --model powertokens/glm-5.2 "Reply exactly: ok"
You can also validate the same OpenAI-compatible path with a MiniMax text model:
opencode run --model powertokens/MiniMax-M3 "Reply exactly: ok"
Start opencode:
opencode
In the TUI, run:
/models
Select powertokens/glm-5.2 or powertokens-anthropic/glm-5.2, then send:
Reply with ok and print the active model name.

Capability boundaries

  • The opencode @ai-sdk/openai-compatible provider covers text Chat Completions semantics only.
  • A model declaring openai in supported_endpoint_types is not automatically suitable for opencode text-agent use; exclude image, speech, video, and task models.
  • Reasoning models such as MiniMax-M3 may return thinking content or consume extra output tokens. Validate the display behavior with real tasks.
  • A model declaring anthropic in supported_endpoint_types is not automatically suitable for the opencode Anthropic provider. opencode sends tool metadata and uses streaming output, so validate the full tool workflow.
  • deepseek-v3-2-251201 passed an opencode Anthropic-provider task with tool use.
  • seed-1-6-flash-250715 is not supported by its upstream provider on /v1/messages; prefer the OpenAI-compatible provider.
  • Do not write a real API key into .opencode/opencode.json or commit it to your repository.