Coding-Agenten
Libremodel in OpenCode nutzen
OpenCode akzeptiert jeden OpenAI-kompatiblen Anbieter. Tragen Sie uns in die Konfigurationsdatei ein, und alle Modelle erscheinen in /models, mit ihren Limits und Preisen.
1. OpenCode installieren
curl -fsSL https://opencode.ai/install | bashnpm install -g opencode-ai2. API-Schlüssel speichern
Erstellen Sie einen Schlüssel unter API-Schlüssel und speichern Sie ihn als LIBREMODEL_API_KEY. Unter macOS und Linux fügen Sie die Zeile zu ~/.zshrc oder ~/.bashrc hinzu, damit jedes neue Terminal sie kennt.
export LIBREMODEL_API_KEY="sk-libremodel-..."[Environment]::SetEnvironmentVariable("LIBREMODEL_API_KEY", "sk-libremodel-...", "User")3. Libremodel hinzufügen
Speichern Sie dies als ~/.config/opencode/opencode.json, um es überall zu nutzen, oder als opencode.json in einem einzelnen Projekt. Gibt es die Datei schon, fügen Sie den Anbieter libremodel neben Ihren bestehenden hinzu.
{
"$schema": "https://opencode.ai/config.json",
"model": "libremodel/deepseek-v4.1-flash-1017",
"provider": {
"libremodel": {
"npm": "@ai-sdk/openai-compatible",
"name": "Libremodel",
"options": {
"baseURL": "https://api.libremodel.ai/v1",
"apiKey": "{env:LIBREMODEL_API_KEY}"
},
"models": {
"kimi-k3.1-pro-uncensored": {
"name": "Kimi K3.1 Pro Uncensored",
"tool_call": true,
"interleaved": {
"field": "reasoning_content"
},
"modalities": {
"input": [
"text",
"image"
],
"output": [
"text"
]
},
"limit": {
"context": 1048576,
"output": 131072
},
"cost": {
"input": 3,
"output": 9,
"cache_read": 0.3
},
"variants": {
"low": {
"reasoningEffort": "low"
},
"high": {
"reasoningEffort": "high"
},
"max": {
"reasoningEffort": "max"
}
}
},
"deepseek-v4.1-flash-1017-uncensored": {
"name": "DeepSeek V4.1 Flash Uncensored",
"tool_call": true,
"interleaved": {
"field": "reasoning_content"
},
"modalities": {
"input": [
"text",
"image"
],
"output": [
"text"
]
},
"limit": {
"context": 1048576,
"output": 131072
},
"cost": {
"input": 0.25,
"output": 0.9,
"cache_read": 0.04
},
"variants": {
"off": {
"reasoningEffort": "off"
},
"low": {
"reasoningEffort": "low"
},
"high": {
"reasoningEffort": "high"
},
"max": {
"reasoningEffort": "max"
}
}
},
"glm-5.3-flash-uncensored": {
"name": "GLM 5.3 Flash Uncensored",
"tool_call": true,
"interleaved": {
"field": "reasoning_content"
},
"modalities": {
"input": [
"text",
"image"
],
"output": [
"text"
]
},
"limit": {
"context": 1048576,
"output": 131072
},
"cost": {
"input": 0.3,
"output": 1.2,
"cache_read": 0.06
},
"variants": {
"low": {
"reasoningEffort": "low"
},
"high": {
"reasoningEffort": "high"
},
"max": {
"reasoningEffort": "max"
}
}
},
"kimi-k3.1-pro": {
"name": "Kimi K3.1 Pro",
"tool_call": true,
"interleaved": {
"field": "reasoning_content"
},
"modalities": {
"input": [
"text",
"image"
],
"output": [
"text"
]
},
"limit": {
"context": 1048576,
"output": 131072
},
"cost": {
"input": 1,
"output": 6,
"cache_read": 0.25
},
"variants": {
"low": {
"reasoningEffort": "low"
},
"high": {
"reasoningEffort": "high"
},
"max": {
"reasoningEffort": "max"
}
}
},
"deepseek-v4.1-flash-1017": {
"name": "DeepSeek V4.1 Flash",
"tool_call": true,
"interleaved": {
"field": "reasoning_content"
},
"modalities": {
"input": [
"text",
"image"
],
"output": [
"text"
]
},
"limit": {
"context": 1048576,
"output": 262144
},
"cost": {
"input": 0.04,
"output": 0.3,
"cache_read": 0.004
},
"variants": {
"off": {
"reasoningEffort": "off"
},
"low": {
"reasoningEffort": "low"
},
"high": {
"reasoningEffort": "high"
},
"max": {
"reasoningEffort": "max"
}
}
},
"minimax-m3.1-flash": {
"name": "MiniMax M3.1 Flash",
"tool_call": true,
"interleaved": {
"field": "reasoning_content"
},
"modalities": {
"input": [
"text",
"image"
],
"output": [
"text"
]
},
"limit": {
"context": 1048576,
"output": 131072
},
"cost": {
"input": 0.05,
"output": 0.2,
"cache_read": 0.005
},
"variants": {
"low": {
"reasoningEffort": "low"
},
"high": {
"reasoningEffort": "high"
},
"max": {
"reasoningEffort": "max"
}
}
}
}
}
}
}4. OpenCode starten
opencodeWechseln Sie das Modell mit /models und den Reasoning-Aufwand mit ctrl+t.
Fehlerbehebung
Führen Sie das im selben Terminal aus, in dem Sie das Tool starten. Es kostet nichts. Kommt die Modellliste zurück, ist der Schlüssel in Ordnung. Ein 401 bedeutet, dass LIBREMODEL_API_KEY in diesem Terminal leer oder falsch ist: Öffnen Sie nach dem Speichern ein neues.
curl -s https://api.libremodel.ai/v1/models -H "Authorization: Bearer $LIBREMODEL_API_KEY"curl.exe -s https://api.libremodel.ai/v1/models -H "Authorization: Bearer $env:LIBREMODEL_API_KEY"Ist der Schlüssel in Ordnung und das Tool bekommt ein 402, deckt Ihr Guthaben die Anfrage nicht. Siehe Guthaben und Abrechnung.