---
title: "OpenCode custom provider for security-tuned models"
canonical: https://pentestllm.ai/guides/opencode
generated: 2026-11-18T03:35:50.382Z
source: https://pentestllm.ai/guides/opencode
base_url: https://api.pentestllm.ai/v1
---

# OpenCode on a security model that answers

Wire OpenCode to this API with a single provider entry in opencode.json naming the openai-compatible package, the base URL, an environment variable for the key and the ids /models should list. Then what an agent turn costs and how to read each error.

Steps checked November 2, 2026 · prices as of November 18, 2026

A terminal agent that stops to lecture you about the exploit you are reviewing on an authorized target is useless mid-engagement. OpenCode gets around that with one custom provider in `opencode.json`: the OpenAI-compatible package, this API’s base URL, a key and the model ids. From then on a security-tuned or abliterated build runs in your terminal with tool calls for file edits and shell commands. The same ids also work in [Cursor](https://pentestllm.ai/guides/cursor) and, via a router, in [Claude Code](https://pentestllm.ai/guides/claude-code).

## What you need

OpenCode installed, a key from the [console](https://app.pentestllm.ai/console), and a shell you can export a variable in. Nothing else. If you want to see a security build answer before touching a config file, the home page gives a few free turns in its prompt box and [the playground](https://pentestllm.ai/playground) runs the same catalog without an install.

OpenCode loads two config files: `opencode.json` (or `opencode.jsonc`, which allows comments) at the project root, and `~/.config/opencode/opencode.json` for everything. When both define a key, the project copy takes precedence. `OPENCODE_CONFIG` redirects it to any other path. Inside the TUI, `/connect` saves a provider key (a custom provider goes under **Other**) and `/models` lists what your config declares so you can switch.

## Shortest path to a first reply

1. Export the key in the shell you will launch OpenCode from:

```bash
export PENTESTLLM_API_KEY="sk-ptl-live-…"
```

1. Put the provider block in the project’s `opencode.json`, or in the global file if every project should have it. The four ids under `models` are the ones OpenCode users on this API request most. Add any other id from the [models page](https://pentestllm.ai/models) the same way; the `name` values come from the catalog:

```
{
  "$schema": "https://opencode.ai/config.json",
  "provider": {
    "pentestllm": {
      "npm": "@ai-sdk/openai-compatible",
      "name": "PentestLLM",
      "options": {
        "baseURL": "https://api.pentestllm.ai/v1",
        "apiKey": "{env:PENTESTLLM_API_KEY}"
      },
      "models": {
        "glm-5.3-uncensored": { "name": "GLM-5.3 Uncensored" },
        "glm-5.3-flash-uncensored": { "name": "GLM-5.3 Flash Uncensored" },
        "deepseek-v4.1-flash-abliterated": { "name": "DeepSeek V4.1 Flash Abliterated" },
        "deepseek-v4-pro-uncensored": { "name": "DeepSeek V4 Pro Uncensored" }
      }
    }
  },
  "model": "pentestllm/glm-5.3-uncensored"
}
```

1. Launch `opencode` inside the project. The `model` line has already chosen `glm-5.3-uncensored`; type `/models` to pick a different id under **PentestLLM** for this session.

Would rather not leave the key in your environment? Run `/connect`, pick **Other**, type `pentestllm` when asked for the provider id, then paste the key. OpenCode writes it to `~/.local/share/opencode/auth.json`. Keep the block above but delete the `apiKey` line; the id you give `/connect` must equal the key under `provider` in the config. The [OpenCode agent page](https://pentestllm.ai/agents/opencode) shows the newer `providers` block format and an alias for the `auto/security` router if you are on a recent OpenCode.

## Each line of the block

- npm: @ai-sdk/openai-compatible the SDK package OpenCode loads; it speaks /v1/chat/completions, the route this API serves
- name: PentestLLM the label /models shows for the provider
- options.baseURL: https://api.pentestllm.ai/v1 the destination for requests; keep the trailing /v1
- options.apiKey: {env:PENTESTLLM_API_KEY} the full sk-ptl- key, pulled from the variable at launch; if it is unset you get an empty string, not an error
- models: id → { name } what the picker lists: each id spelled as on the models page, with its display name
- model: pentestllm/glm-5.3-uncensored the build sessions open with, written provider id / model id; small_model, used for titles, takes the same form

## Which build to start with

Through that package OpenCode sends OpenAI-format requests, which every build in the catalog accepts. Cost is set by the shape of an agent turn: the conversation, each file OpenCode has opened and each tool result go back out on every turn, and a short edit comes in. So the input price is nearly the whole bill, and the build with the lowest input price costs least per turn. Tool-call support, which the agent loop needs for edits and shell commands, is in the right-hand column.

| Build | Cost of one agent turn | Tool calls |
| --- | --- | --- |
| [GLM-5.3 Uncensored](https://pentestllm.ai/models/glm-5.3-uncensored) | $0.01 | [model page](https://pentestllm.ai/models/glm-5.3-uncensored) |
| [GLM-5.3 Flash Uncensored](https://pentestllm.ai/models/glm-5.3-flash-uncensored) | $0.0047 | [model page](https://pentestllm.ai/models/glm-5.3-flash-uncensored) |
| [DeepSeek V4.1 Flash Abliterated](https://pentestllm.ai/models/deepseek-v4.1-flash-abliterated) | $0.04 | [model page](https://pentestllm.ai/models/deepseek-v4.1-flash-abliterated) |
| [DeepSeek V4 Pro Uncensored](https://pentestllm.ai/models/deepseek-v4-pro-uncensored) | $0.04 | [model page](https://pentestllm.ai/models/deepseek-v4-pro-uncensored) |
| [GLM-5.3 Abliterated](https://pentestllm.ai/models/glm-5.3-abliterated) | $0.09 | [model page](https://pentestllm.ai/models/glm-5.3-abliterated) |
| [GLM-5.3 Flash Code Uncensored](https://pentestllm.ai/models/glm-5.3-flash-code-uncensored) | $0.25 | [model page](https://pentestllm.ai/models/glm-5.3-flash-code-uncensored) |

A turn here is 40,000 tokens in and 1,200 out, priced from the catalog as of 2026-11-18. Tool-call support is whatever the catalog states; when it states nothing, the model page has the answer.

| Model | Build | Input $/M | Output $/M |
| --- | --- | --- | --- |
| [GLM-5.3 Uncensored](https://pentestllm.ai/models/glm-5.3-uncensored) glm-5.3-uncensored | Uncensored | $0.282 | $0.846 |
| [GLM-5.3 Flash Uncensored](https://pentestllm.ai/models/glm-5.3-flash-uncensored) glm-5.3-flash-uncensored | Uncensored | $0.1053 | $0.3685 |
| [DeepSeek V4.1 Flash Abliterated](https://pentestllm.ai/models/deepseek-v4.1-flash-abliterated) deepseek-v4.1-flash-abliterated | Abliterated | $0.8488 | $1.6975 |
| [DeepSeek V4 Pro Uncensored](https://pentestllm.ai/models/deepseek-v4-pro-uncensored) deepseek-v4-pro-uncensored | Uncensored | $0.97 | $1.94 |
| [GLM-5.3 Abliterated](https://pentestllm.ai/models/glm-5.3-abliterated) glm-5.3-abliterated | Abliterated | $2.1825 | $4.365 |
| [GLM-5.3 Flash Code Uncensored](https://pentestllm.ai/models/glm-5.3-flash-code-uncensored) glm-5.3-flash-code-uncensored | Uncensored | $6.00 | $6.00 |

Prices per million tokens, read from the live catalog on 2026-11-18.

Spending the day reviewing a client codebase for injection and auth flaws? [The coding guide](https://pentestllm.ai/guides/uncensored-coding-ai) compares the code builds and prices a full day on each. [The coding AI page](https://pentestllm.ai/uncensored-coding-ai) covers why stock assistants refuse that kind of review.

## Confirm it works

Ask the API which models the key may call. Each id you declared under `models` should come back:

```bash
curl https://api.pentestllm.ai/v1/models -H "Authorization: Bearer sk-ptl-live-…"
```

Then fire one request shaped like OpenCode’s. The `-i` flag shows the response headers, which carry a request id and, on a non-streamed reply, the charge in USD.

```bash
curl -i https://api.pentestllm.ai/v1/chat/completions \
  -H "Authorization: Bearer sk-ptl-live-…" \
  -H "Content-Type: application/json" \
  -d '{"model": "glm-5.3-uncensored", "messages": [{"role": "user", "content": "Reply with the single word ok."}]}'
```

Inside OpenCode, select one of your ids and give it an in-scope job, for example “read `scope.md` and list every host the engagement letter excludes”. The request appears on the console’s usage page with its token counts and charge, and its user agent identifies the OpenCode version.

## When something fails

- `401 invalid_api_key`: bad or revoked key, or `PENTESTLLM_API_KEY` was never exported in the shell that launched OpenCode, so `apiKey` resolved to nothing. Export it and relaunch, or copy a fresh key from the console.
- `404 model_not_found`: an id in your `models` map does not exist in the catalog. Compare the spelling; the id is the map key, not the `name` value.
- `402 insufficient_balance`: the balance cannot cover this call; add credit in the console. A `402 monthly_limit_reached` instead means the key reached the monthly spend ceiling you gave it.
- `403 scope_denied`: this key is restricted to a model list and the requested id is outside it.
- `429 rate_limited`: the key is over its rate limit. Read `retry-after` on the response.
- Requests that never arrive, or land on a path other than `/chat/completions`: wrong package. OpenCode’s docs put `@ai-sdk/openai-compatible` on endpoints that serve `/v1/chat/completions`, which this one does, and `@ai-sdk/openai` on endpoints that serve `/v1/responses`. Leave `npm` on the first.
- After `/connect` the provider is not in `/models`: the id you typed in `/connect` does not match the key under `provider`. Make them identical.

## Questions

### Does OpenCode work with OpenAI-compatible endpoints?

Yes, with OpenAI itself and with every endpoint speaking the OpenAI chat completions format. OpenCode reaches it through the @ai-sdk/openai-compatible package plus a baseURL and a key. This API is such an endpoint, so the block on this page is the entire setup.

### What providers can OpenCode use?

A built-in list that /connect shows by name, plus a custom entry for any other OpenAI-compatible API, declared under provider in opencode.json: package, base URL, model ids. This page walks the custom route.

### Which of these models are OpenAI compatible?

All of them. Each id on the models page serves /v1/chat/completions in OpenAI format under one shared key, so any id can go into the provider block’s models map, spelled as the page spells it. See the models page.

### How much does an OpenCode session cost on this API?

You pay per token at the model’s listed price out of prepaid credit, with no subscription required. The table above prices a typical agent turn per build at the current rate. When a long session repeats the same prefix, the cached input tokens are charged at that model’s discounted cache price.

Every model above is on the [uncensored model list](https://pentestllm.ai/models) with its live price per million tokens. [Per-token pricing](https://pentestllm.ai/pricing) sets the whole catalog side by side, and the [family directory](https://pentestllm.ai/uncensored) groups the builds by base model.

[Get a key](https://app.pentestllm.ai/console) Prepaid from $10, no subscription.

## New models and price changes, once a month.

New uncensored builds with their prices, price moves, and what the daily model check found.
