Opencode

Point Opencode at a Tokenmaxer access token.

Before you start

  • Opencode installed, with opencode on your PATH. The setup script configures a harness; it does not install one. Install Opencode →
  • Node.js 18 or newer, which the setup script runs on.
  • A Tokenmaxer API key. Create one →

Run the setup script

Run this, pick Opencode, and paste your key when it asks. It writes the configuration below for you, backing up anything it touches.

Terminal
curl -fsSL https://tokenmaxer.dev/setup.sh | bash

To skip the menu, pass the harness: curl -fsSL https://tokenmaxer.dev/setup.sh | bash -s -- opencode. Run it again after connecting another provider plan to refresh the available models, or curl -fsSL https://tokenmaxer.dev/setup.sh | bash -s -- --undo to put your files back.

Test it

Terminal
opencode run --model tokenmaxer/anthropic/claude-sonnet-5-5 'say hello'

A reply, and `/models` lists the Tokenmaxer provider with every model you configured.

Configure it manually

This is what the setup script writes, for anyone who would rather edit the files themselves. Replace<YOUR_KEY> with your Tokenmaxer access token.

opencode takes the `/v1` suffix despite speaking the Anthropic API, because the AI SDK provider appends its own path segment.

  • Declare `limit` on every model

    opencode has no catalogue entry for Tokenmaxer model ids and falls back to a default context window, which makes it compact far too early.

  • Declare `modalities` on every model

    Same missing catalogue entry, and here the fallback is `false` for every modality. Drag an image or a PDF onto a model with no `modalities` and opencode replaces it with `ERROR: Cannot read … (this model does not support image input)` before the request leaves your machine, so it reads like the model refused rather than like a config gap. Every model except GPT-5.3 Codex Spark accepts images and PDFs.

Claude models

~/.config/opencode/opencode.jsonc

Adds Tokenmaxer as a provider. opencode deep-merges config, so your existing providers are untouched.

~/.config/opencode/opencode.jsonc
{
  "provider": {
    "tokenmaxer": {
      "npm": "@ai-sdk/anthropic",
      "name": "Tokenmaxer",
      "options": {
        "baseURL": "https://api.tokenmaxer.dev/v1",
        "apiKey": "<YOUR_KEY>"
      },
      "models": {
        "anthropic/claude-opus-5-5": {
          "name": "Claude Opus 5.5",
          "reasoning": true,
          "tool_call": true,
          "attachment": true,
          "modalities": {
            "input": [
              "text",
              "image",
              "pdf"
            ],
            "output": [
              "text"
            ]
          },
          "limit": {
            "context": 1000000,
            "output": 128000
          }
        },
        "anthropic/claude-sonnet-5-5": {
          "name": "Claude Sonnet 5.5",
          "reasoning": true,
          "tool_call": true,
          "attachment": true,
          "modalities": {
            "input": [
              "text",
              "image",
              "pdf"
            ],
            "output": [
              "text"
            ]
          },
          "limit": {
            "context": 1000000,
            "output": 128000
          }
        },
        "anthropic/claude-fable-5-1": {
          "name": "Claude Fable 5.1",
          "reasoning": true,
          "tool_call": true,
          "attachment": true,
          "modalities": {
            "input": [
              "text",
              "image",
              "pdf"
            ],
            "output": [
              "text"
            ]
          },
          "limit": {
            "context": 1000000,
            "output": 64000
          }
        },
        "anthropic/claude-haiku-5-5": {
          "name": "Claude Haiku 5.5",
          "reasoning": true,
          "tool_call": true,
          "attachment": true,
          "modalities": {
            "input": [
              "text",
              "image",
              "pdf"
            ],
            "output": [
              "text"
            ]
          },
          "limit": {
            "context": 1000000,
            "output": 128000
          }
        }
      }
    }
  }
}

~/.config/opencode/opencode.jsonc

Optional

Makes Tokenmaxer the default. Skip it to keep your current default and pick Tokenmaxer from `/models` instead.

~/.config/opencode/opencode.jsonc
{
  "model": "tokenmaxer/anthropic/claude-sonnet-5-5"
}

ChatGPT models

~/.config/opencode/opencode.jsonc

Adds Tokenmaxer as a provider. opencode deep-merges config, so your existing providers are untouched.

~/.config/opencode/opencode.jsonc
{
  "provider": {
    "tokenmaxer-codex": {
      "npm": "@ai-sdk/openai",
      "name": "Tokenmaxer (Codex)",
      "options": {
        "baseURL": "https://api.tokenmaxer.dev/v1",
        "apiKey": "<YOUR_KEY>"
      },
      "models": {
        "openai/gpt-6.1-sol": {
          "name": "GPT-6.1 Sol",
          "reasoning": true,
          "tool_call": true,
          "attachment": true,
          "modalities": {
            "input": [
              "text",
              "image",
              "pdf"
            ],
            "output": [
              "text"
            ]
          },
          "limit": {
            "context": 872000,
            "output": 128000
          }
        },
        "openai/gpt-6-astra": {
          "name": "GPT-6 Astra",
          "reasoning": true,
          "tool_call": true,
          "attachment": true,
          "modalities": {
            "input": [
              "text",
              "image",
              "pdf"
            ],
            "output": [
              "text"
            ]
          },
          "limit": {
            "context": 872000,
            "output": 128000
          }
        },
        "openai/gpt-6-sol": {
          "name": "GPT-6 Sol",
          "reasoning": true,
          "tool_call": true,
          "attachment": true,
          "modalities": {
            "input": [
              "text",
              "image",
              "pdf"
            ],
            "output": [
              "text"
            ]
          },
          "limit": {
            "context": 872000,
            "output": 128000
          }
        },
        "openai/gpt-6-luna": {
          "name": "GPT-6 Luna",
          "reasoning": true,
          "tool_call": true,
          "attachment": true,
          "modalities": {
            "input": [
              "text",
              "image",
              "pdf"
            ],
            "output": [
              "text"
            ]
          },
          "limit": {
            "context": 872000,
            "output": 128000
          }
        },
        "openai/gpt-5.6-terra": {
          "name": "GPT-5.6 Terra",
          "reasoning": true,
          "tool_call": true,
          "attachment": true,
          "modalities": {
            "input": [
              "text",
              "image",
              "pdf"
            ],
            "output": [
              "text"
            ]
          },
          "limit": {
            "context": 872000,
            "output": 128000
          }
        },
        "openai/gpt-5.6-luna": {
          "name": "GPT-5.6 Luna",
          "reasoning": true,
          "tool_call": true,
          "attachment": true,
          "modalities": {
            "input": [
              "text",
              "image",
              "pdf"
            ],
            "output": [
              "text"
            ]
          },
          "limit": {
            "context": 872000,
            "output": 128000
          }
        }
      }
    }
  }
}

~/.config/opencode/opencode.jsonc

Optional

Makes Tokenmaxer the default. Skip it to keep your current default and pick Tokenmaxer from `/models` instead.

~/.config/opencode/opencode.jsonc
{
  "model": "tokenmaxer-codex/openai/gpt-5.6-terra"
}