# OpenCode

> Aggiungi NotHoly come provider in opencode.json.


`notholy run opencode` richiede la CLI di NotHoly, installata e con l'accesso fatto ([Installa la CLI](/it/cli/install)), e OpenCode stesso: `npm i -g @opencode/cli`. La configurazione manuale qui sotto richiede solo una chiave API.

```bash
notholy run opencode
```

Le impostazioni esistono solo per quell'esecuzione, su un server OpenCode privato. I tuoi file di OpenCode e il servizio in background restano come sono.

`notholy connect opencode` scrive le stesse impostazioni in `~/.config/opencode/opencode.json` e mantiene gli altri provider. Prima fa un backup, e `notholy connect opencode --undo` lo ripristina.

`connect` aggiunge anche il server MCP `notholy` sotto `mcp` in quel file, e `notholy run opencode` passa lo stesso server solo per quell'esecuzione. Entrambi usano il percorso assoluto di questa CLI e l'accesso salvato.

## Configurazione manuale

Aggiungi il provider a `~/.config/opencode/opencode.json`. Su Windows il file è `%USERPROFILE%\.config\opencode\opencode.json`, e se `XDG_CONFIG_HOME` è impostata, OpenCode cerca lì.

```json
{
  "$schema": "https://opencode.ai/config.json",
  "model": "notholy/notholy-specter",
  "providers": {
    "notholy": {
      "name": "NotHoly",
      "env": ["NOTHOLY_API_KEY"],
      "package": "@opencode/ai/providers/openai-compatible",
      "settings": { "baseURL": "https://api.notholy.com/v1" },
      "models": {
        "notholy-specter": { "name": "NotHoly Specter", "capabilities": { "tools": true, "input": ["text"], "output": ["text"], "reasoning": { "supported": true, "effort": ["low", "high", "max"] } }, "limit": { "context": 1048576, "output": 131072 } },
        "notholy-pulse": { "name": "NotHoly Pulse Flash", "capabilities": { "tools": true, "input": ["text", "image"], "output": ["text"], "reasoning": { "supported": true, "effort": ["low", "high", "max"] } }, "limit": { "context": 1048576, "output": 131072 } },
        "notholy-vector": { "name": "NotHoly Vector Flash 1017", "capabilities": { "tools": true, "input": ["text", "image"], "output": ["text"], "reasoning": { "supported": true, "effort": ["off", "low", "high", "max"] } }, "limit": { "context": 1048576, "output": 131072 } },
        "notholy-wisp": { "name": "NotHoly Wisp Flash", "capabilities": { "tools": true, "input": ["text", "image"], "output": ["text"], "reasoning": { "supported": true, "effort": ["off", "low", "high", "max"] } }, "limit": { "context": 1048576, "output": 131072 } }
      }
    }
  }
}
```

Metti la tua chiave in `NOTHOLY_API_KEY`. In PowerShell usa `$env:NOTHOLY_API_KEY = "nh_live_..."`. Se il servizio in background di OpenCode è già in esecuzione, riavvialo, perché legge la variabile all'avvio.

```bash
export NOTHOLY_API_KEY="nh_live_..."
opencode service restart
opencode models
```

I modelli NotHoly compaiono in quell'elenco come `notholy/...`. Ogni livello in `effort` è una variante che puoi scegliere aggiungendola al modello: `opencode run -m notholy/notholy-specter#<level> "..."`.

Se i limiti o i livelli cambiano, confrontali con `GET /v1/models`.

## OpenCode 1

Il pacchetto `opencode-ai` su npm è OpenCode 1. Ignora `providers`, quindi richiede questa versione del file. Non ha un servizio in background e legge la stessa variabile.

```json
{
  "$schema": "https://opencode.ai/config.json",
  "model": "notholy/notholy-specter",
  "provider": {
    "notholy": {
      "npm": "@ai-sdk/openai-compatible",
      "name": "NotHoly",
      "options": { "baseURL": "https://api.notholy.com/v1", "apiKey": "{env:NOTHOLY_API_KEY}" },
      "models": {
        "notholy-specter": { "name": "NotHoly Specter", "tool_call": true, "reasoning": true, "attachment": false, "modalities": { "input": ["text"], "output": ["text"] }, "limit": { "context": 1048576, "output": 131072 }, "variants": { "low": { "reasoningEffort": "low" }, "high": { "reasoningEffort": "high" }, "max": { "reasoningEffort": "max" } } },
        "notholy-pulse": { "name": "NotHoly Pulse Flash", "tool_call": true, "reasoning": true, "attachment": true, "modalities": { "input": ["text", "image"], "output": ["text"] }, "limit": { "context": 1048576, "output": 131072 }, "variants": { "low": { "reasoningEffort": "low" }, "high": { "reasoningEffort": "high" }, "max": { "reasoningEffort": "max" } } },
        "notholy-vector": { "name": "NotHoly Vector Flash 1017", "tool_call": true, "reasoning": true, "attachment": true, "modalities": { "input": ["text", "image"], "output": ["text"] }, "limit": { "context": 1048576, "output": 131072 }, "variants": { "off": { "reasoningEffort": "off" }, "low": { "reasoningEffort": "low" }, "high": { "reasoningEffort": "high" }, "max": { "reasoningEffort": "max" } } },
        "notholy-wisp": { "name": "NotHoly Wisp Flash", "tool_call": true, "reasoning": true, "attachment": true, "modalities": { "input": ["text", "image"], "output": ["text"] }, "limit": { "context": 1048576, "output": 131072 }, "variants": { "off": { "reasoningEffort": "off" }, "low": { "reasoningEffort": "low" }, "high": { "reasoningEffort": "high" }, "max": { "reasoningEffort": "max" } } }
      }
    }
  }
}
```

Verifica con `opencode models notholy`. `notholy run` e `notholy connect` funzionano con entrambe le versioni.

## Prossimi passi

- [API dei modelli](/it/api/models)
