Skip to content
Docs

Coding agents

Use Libremodel in OpenCode

OpenCode takes any OpenAI-compatible provider. Add us to its config file and every model shows up in /models, with its limits and prices.

1. Install OpenCode

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

2. Set your API key

Create a key in API keys and save it as LIBREMODEL_API_KEY. On macOS and Linux, add the line to ~/.zshrc or ~/.bashrc so every new terminal has it.

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

3. Add Libremodel

Save this as ~/.config/opencode/opencode.json to use it everywhere, or as opencode.json in a single project. If the file exists, add the libremodel provider next to the ones you have.

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. Start it

Shell
opencode

Switch models with /models and reasoning effort with ctrl+t.

Troubleshooting

Run this in the same terminal you start the tool from. It costs nothing. A list of models means the key is fine. A 401 means LIBREMODEL_API_KEY is empty or wrong in that terminal; open a new one after saving it.

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

If the key is fine and the tool gets a 402, your balance does not cover the request. See Billing and credits.