You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
App is calling the wrong endpoint for the Ollama provider when using local models #4341
I discovered that the application is using the wrong endpoint when sending requests to the Ollama provider for local models.
Currently, OpenCode is calling:
/chat/completions
However, the correct endpoint for the Ollama chat API is:
/chat
This causes messages to not be processed correctly by the local Ollama models.
The implementation needs to be updated so that the provider uses the /chat endpoint as defined in the official Ollama documentation.
@filaupe can you show me your opencode config? If you are using the openai compatible provider then it will use the openai compatible endpoint because /chat isn't compatible
@filaupe can you show me your opencode config? If you are using the openai compatible provider then it will use the openai compatible endpoint because /chat isn't compatible
Apparently that was it, but what would be the correct config? After I removed that line, it started returning an error.
Hm is there any reason you can't use the openai compatible one? I think a patch needs to be made to this ollama provider to work for your usecase if this is breaking^
Hm is there any reason you can't use the openai compatible one? I think a patch needs to be made to this ollama provider to work for your usecase if this is breaking^
Here is the text in English:
I was able to fix the issue. The solution was to keep using "npm": "@ai-sdk/openai-compatible", but update the Ollama baseURL to "http://ollama-server:11434/v1". After that, everything worked correctly.
Activity
rekram1-node commentedon Nov 14, 2025
@filaupe can you show me your opencode config? If you are using the openai compatible provider then it will use the openai compatible endpoint because /chat isn't compatible
filaupe commentedon Nov 14, 2025
Apparently that was it, but what would be the correct config? After I removed that line, it started returning an error.
|opencode server listening on http://0.0.0.0:4096
507 | ...options,
508 | })
509 | s.sdk.set(key, loaded)
510 | return loaded as SDK
511 | })().catch((e) => {
512 | throw new InitError({ providerID: provider.id }, { cause: e })
ProviderInitError: ProviderInitError
data: {
providerID: "ollama",
},
500 | timeout: false,
501 | })
502 | }
503 | }
504 | const fn = mod[Object.keys(mod).find((key) => key.startsWith("create"))!]
505 | const loaded = fn({
TypeError: fn2 is not a function. (In 'fn2({
rekram1-node commentedon Nov 14, 2025
Maybe try replacing the
npmpackage withollama-ai-provider-v2If u show ur config I can help you through it
filaupe commentedon Nov 14, 2025
Ok:
{
"$schema": "https://opencode.ai/config.json",
"agent": {
"build": {
"mode": "primary",
"disable": false,
"model": "ollama/gemma3:4b",
"prompt": "{file:./prompts/build.txt}",
"description": "Builds code for best practices and potential issues"
},
"code-review": {
"mode": "subagent",
"disable": false,
"model": "ollama/gemma3:4b",
"prompt": "{file:./prompts/code-review.txt}",
"description": "Reviews code for best practices and potential issues"
}
},
"disabled_providers": ["opencode"],
"provider": {
"ollama": {
"name": "Ollama (local)",
"options": {
"baseURL": "http://local-llm:11434"
},
"models": {
"gemma3:4b": {
"name": "gemma3:4b"
}
}
}
},
"tools": {
"write": true,
"edit": true,
"read": true,
"bash": true,
"list": true,
"grep": true,
"patch": true,
"glob": true,
"todowrite": true,
"todoread": true,
"webfetch": true
}
}
rekram1-node commentedon Nov 15, 2025
And this one causes that issue right:
Hm is there any reason you can't use the openai compatible one? I think a patch needs to be made to this ollama provider to work for your usecase if this is breaking^
filaupe commentedon Nov 16, 2025
Here is the text in English:
I was able to fix the issue. The solution was to keep using
"npm": "@ai-sdk/openai-compatible", but update the OllamabaseURLto"http://ollama-server:11434/v1". After that, everything worked correctly.rekram1-node commentedon Nov 16, 2025
Awesome