When using Ollama as a provider in opencode, the model appears to reload into memory for each request.
This significantly increases latency (especially for large models such as qwen3-coder:30b) and consumes unnecessary system resources.
Example configuration:
{
"$schema": "https://opencode.ai/config.json",
"provider": {
"ollama": {
"npm": "@ai-sdk/openai-compatible",
"name": "Ollama (local)",
"options": {
"baseURL": "http://localhost:11434/v1"
},
"models": {
"qwen3-coder:30b": {
"name": "qwen3-coder:30b",
"options": {
"keep_alive": -1
}
}
}
}
}
}
Behavior:
Each time opencode sends a new request to the Ollama endpoint, the model is unloaded and reloaded by the Ollama server.
This can add up to 60 seconds of overhead on every call for large models.
Direct requests to Ollama using its API or CLI (with keep_alive or OLLAMA_KEEP_ALIVE) can keep the model resident in memory — but this flag seems not to be propagated or respected through the opencode integration.
Expected behavior
When configured, models should remain loaded in memory for a configurable duration (e.g., keep_alive: 300) between requests.
The keep_alive value should be passed through to Ollama’s /v1/chat/completions or /v1/completions API payload, if supported.
Optionally, a global default could be set in the provider’s options.
The following didn't worked :
"options": {
"baseURL": "http://localhost:11434/v1",
"keep_alive": 300
}
When using Ollama as a provider in opencode, the model appears to reload into memory for each request.
This significantly increases latency (especially for large models such as qwen3-coder:30b) and consumes unnecessary system resources.
Example configuration:
{ "$schema": "https://opencode.ai/config.json", "provider": { "ollama": { "npm": "@ai-sdk/openai-compatible", "name": "Ollama (local)", "options": { "baseURL": "http://localhost:11434/v1" }, "models": { "qwen3-coder:30b": { "name": "qwen3-coder:30b", "options": { "keep_alive": -1 } } } } } }Behavior:
Each time opencode sends a new request to the Ollama endpoint, the model is unloaded and reloaded by the Ollama server.
This can add up to 60 seconds of overhead on every call for large models.
Direct requests to Ollama using its API or CLI (with keep_alive or OLLAMA_KEEP_ALIVE) can keep the model resident in memory — but this flag seems not to be propagated or respected through the opencode integration.
Expected behavior
When configured, models should remain loaded in memory for a configurable duration (e.g., keep_alive: 300) between requests.
The keep_alive value should be passed through to Ollama’s /v1/chat/completions or /v1/completions API payload, if supported.
Optionally, a global default could be set in the provider’s options.
The following didn't worked :