Aller au contenu
Docs

Agents de code

Utilisez Libremodel dans OpenCode

OpenCode accepte tout fournisseur compatible avec OpenAI. Ajoutez-nous à son fichier de configuration et tous les modèles apparaissent dans /models, avec leurs limites et leurs prix.

1. Installez OpenCode

curl -fsSL https://opencode.ai/install | bash

2. Enregistrez votre clé API

Créez une clé dans Clés API et enregistrez-la sous LIBREMODEL_API_KEY. Sous macOS et Linux, ajoutez la ligne à ~/.zshrc ou à ~/.bashrc pour que chaque nouveau terminal la reprenne.

export LIBREMODEL_API_KEY="sk-libremodel-..."

3. Ajoutez Libremodel

Enregistrez ceci sous ~/.config/opencode/opencode.json pour l’utiliser partout, ou sous opencode.json dans un seul projet. Si le fichier existe déjà, ajoutez le fournisseur libremodel à côté de ceux que vous avez.

opencode.json
{
  "$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. Lancez OpenCode

Shell
opencode

Changez de modèle avec /models et de niveau d’effort avec ctrl+t.

En cas de problème

Lancez cette commande dans le terminal depuis lequel vous ouvrez l’outil. Elle ne coûte rien. Si la liste des modèles s’affiche, la clé fonctionne. Un 401 signifie que LIBREMODEL_API_KEY est vide ou incorrecte dans ce terminal : ouvrez-en un nouveau après l’avoir enregistrée.

curl -s https://api.libremodel.ai/v1/models -H "Authorization: Bearer $LIBREMODEL_API_KEY"

Si la clé fonctionne et que l’outil reçoit un 402, votre solde ne couvre pas la requête. Voir Solde et crédits.