OpenCode can work with custom OpenAI-compatible model APIs. That means you can add LLMBase as a provider for coding, debugging, code review, and repository-oriented work without changing how you use OpenCode day to day.
This guide uses the direct LLMBase Inference API. It is appropriate when OpenCode should use an llmbase_... inference key and prepaid inference credits. If your work requires an EU-hosted model, choose a model marked EU-hosted in the LLMBase model catalog before using it in OpenCode. Processing location is a property of the selected model, so do not assume every model has identical processing information.
1. Create a dedicated LLMBase key for OpenCode
Create an inference API key in the LLMBase dashboard. The key begins with llmbase_... and is valid at:
https://api.llmbase.ai/v1
Keep it out of your repository. A practical pattern is to store it in your local environment or secret manager as LLMBASE_API_KEY, then let OpenCode read that variable. This gives OpenCode its own revocable key and avoids leaking it through a project configuration file.
Do not use an llmbase_chat_... chat-agent key with this setup. That key works only at the separate LLMBase agent endpoint for supported agent integrations.
2. Choose a model before writing the OpenCode config
OpenCode expects you to declare the models you want to expose through a custom provider. Get the exact model ID from the current LLMBase catalog or list models programmatically:
curl https://api.llmbase.ai/v1/models \
-H "Authorization: Bearer $LLMBASE_API_KEY"
For coding work, evaluate a model with a representative task from your real project: read a small module, explain a failing test, propose a minimal patch, and identify what a human should review. If OpenCode will use tools or a long context, inspect the current model metadata before enabling those capabilities.
When EU hosting is part of the requirement, select a model explicitly identified as EU-hosted in the catalog, then use that exact ID in the configuration below.
3. Add LLMBase as an OpenAI-compatible provider
OpenCode’s configuration schema evolves with the product, so first confirm the schema URL in the config file created by your installed version. Current OpenCode releases use the provider section and the OpenAI-compatible AI SDK package for custom endpoints.
Create or update opencode.json in your project or user configuration location:
{
"$schema": "https://opencode.ai/config.json",
"provider": {
"llmbase": {
"npm": "@ai-sdk/openai-compatible",
"name": "LLMBase",
"options": {
"baseURL": "https://api.llmbase.ai/v1",
"apiKey": "{env:LLMBASE_API_KEY}"
},
"models": {
"<model-id-from-llmbase-catalog>": {
"name": "LLMBase coding model"
}
}
}
},
"model": "llmbase/<model-id-from-llmbase-catalog>"
}
Replace both occurrences of <model-id-from-llmbase-catalog> with the same exact public LLMBase model ID. For example, if a model ID contains a slash, preserve it exactly. Do not replace it with a display name.
Some newer OpenCode installations may use a plural providers configuration shape and a package field instead. Use the schema and examples shown by that installation; the connection details remain the same: OpenAI-compatible package, https://api.llmbase.ai/v1, an llmbase_... inference key, and an exact LLMBase model ID. Do not combine fields from two config versions in the same file.
4. Verify the connection in a small repository
OpenCode works most safely when you start with a small, non-sensitive project and a bounded task. Open the project, select the LLMBase model in OpenCode’s model picker, and try a request such as:
Read the test failure in this repository. Explain the smallest likely cause, list the files you inspected, and propose a patch without applying it.
Review the answer and the proposed change before allowing anything to modify the working tree. A model connection does not change the local permissions OpenCode has. Keep project access narrow, keep secrets out of the repository, and treat generated changes as a reviewable draft—not an automatically correct implementation.
5. Match OpenCode features to model capabilities
OpenCode can use a model for more than plain text, but each feature requires a compatible model. Before enabling a workflow, verify the selected LLMBase model supports the relevant request shape:
- Tool use: confirm the model advertises tool support.
- Long codebases: check context length and output limits.
- Structured extraction: choose a model with JSON or structured-output support.
- Image or screenshot inputs: verify image input support and accepted media types.
- Reasoning controls: only send supported reasoning settings.
The LLMBase API rejects unsupported request options instead of silently applying an unknown setting. That is useful feedback: change the setting or choose a model whose documented capabilities match the job.
Common OpenCode and LLMBase setup mistakes
| Problem | What to do |
|---|---|
| OpenCode cannot authenticate | Confirm that LLMBASE_API_KEY contains an llmbase_... inference key and that baseURL ends in /v1. |
| The model is missing from the picker | Check the models key in opencode.json and use the exact public LLMBase model ID. |
| The config is rejected | Check which OpenCode schema your installed version uses. Use either its provider or providers form consistently. |
| A tool or image request fails | Select a model that currently advertises that capability, then keep the request fields within the documented API surface. |
| You need EU hosting | Use an exact LLMBase model labelled EU-hosted and document that choice in the project setup. |
FAQ: OpenCode with LLMBase
Is LLMBase compatible with OpenCode?
Yes. OpenCode supports custom OpenAI-compatible providers, and LLMBase exposes an OpenAI-compatible API at https://api.llmbase.ai/v1.
Which LLMBase key should OpenCode use?
Use an llmbase_... inference key. Keep it in a local environment variable or secret manager rather than committing it to opencode.json.
Can OpenCode use an EU-hosted LLMBase model?
Yes, select a model currently marked EU-hosted in the LLMBase catalog and configure that exact model ID. Review the current published information before relying on a model for a location-specific policy requirement.
For the API contract behind this setup, read the LLMBase Quickstart, OpenAI compatibility documentation, and model discovery reference.

