Today we are looking at a quick setup of OpenCode in Business Application Studio, using SAP AI Core as the backbone for LLMs. This is useful if you want a coding agent fully enabled by BTP components — without any local installation on your machine. In general this also works in VS Code.
Prerequisites
- Business Application Studio
- SAP AI Core instance + AI Core service key
- Resource Group exists in AI Core
- Orchestration Deployment exists in the Resource Group on AI Core
If you are unsure about the AI Core part, check out this tutorial: Provisioning Generative AI Hub in SAP AI Core.
Install OpenCode
Basically, follow the official installation guide — at the time of writing this is done with the following command:
curl -fsSL https://opencode.ai/install | bashCheck if it's working
Just type:
opencodeand see how it loads up. If you are doing this on your local machine, make sure to add it to your shell config (.bashrc / .zshrc).
Hook up SAP AI Core as integration
In OpenCode, use /connect to search for SAP AI Core. Here you need to hand in a service key and submit with Enter.
Search for SAP AI Core
Paste your AI Core Service Key
And select a model. It could be that you are also asked for the thinking effort. Here you will see all the models available in orchestration — see SAP Note 3437766.
Then you can try it out and ask “Hi” — this might work.
Hitting “Schema validation failed”?
The moment you ask for something real — build a plan, create an agent, use a tool — you will likely see the turn fall apart like this, with Error: Schema validation failed after every message:
A plain “hi” may still answer (with that error trailing behind it), but anything that makes the agent plan or call a tool dies and nothing renders. Third-party models (DeepSeek and friends) work fine, which makes it look like an AI Core problem — it isn't.
TL;DR — you need an OpenCode config. Create opencode.json (global at ~/.config/opencode/opencode.json, or in your project root) with this one override, then opencode service restart:
“$schema”: “https://opencode.ai/config.json”,
“provider”: {
“sap-ai-core”: {
“npm”: “@jerome-benoit/sap-ai-provider@5.1.2”
}
}
}
Nothing else changes — same service key, same models, same model IDs. That's the whole fix.
Why this happens
OpenCode (≥ 2.4) talks to providers through the AI SDK V3 interface, where a finish reason is an object { normalized, raw } validated against a fixed set (stop | length | tool-calls | content-filter | error | unknown). But the model registry wires sap-ai-core to the provider's V2 package, where the finish reason is a plain string. The V2→V3 bridge turns “unknown” (and anything it can't classify) into “other” — a value OpenCode's own schema rejects, so the turn is dropped.
The override above simply points sap-ai-core at the provider's V3 package (@Jerome-benoit/sap-ai-provider) instead of the -v2 one, which emits the object shape OpenCode expects. I pinned it to 5.1.2 (the version this post was tested on); drop the @5.1.2 if you'd rather always pull the latest.
This is tracked upstream — models.dev#14467 (registry should point at the V3 package) and opencode#66153 (the finish-reason bridge). Once either lands, you can drop the override entirely. Full write-up and a reproducible before/after script: opencode-sap-ai-core-fix.
The result
With the config in place, restart and the same prompt that blew up before now runs end to end — the agent explores the workspace, reads files, calls tools, and builds its plan, all on GPT-6.1 Sol · SAP AI Core:
From here you have a fully working coding agent on SAP AI Core — start it with opencode, pick your model with /models (e.g. sap-ai-core/anthropic–claude-4.6-sonnet, sap-ai-core/gpt-6.1-sol), and go.
Alternative
Also check out the setup with Cline as an alternative: Using Cline with SAP AI Core in VS Code — A Complete Setup Guide.
