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
Custom OpenAI-compatible provider options not being passed to API calls
Description
Summary
When using a custom provider with @ai-sdk/openai-compatible, the options (including baseURL and apiKey) configured in opencode.json are not being passed to the actual API calls. This results in NotFoundError because requests are being sent without the custom endpoint configuration.
The bundled @ai-sdk/openai-compatible provider in OpenCode appears to not be forwarding the options from the config to the actual provider instance, resulting in API calls being made without the custom baseURL and other options.
Workaround
None found. Custom OpenAI-compatible endpoints are currently unusable with OpenCode.
Logs
From ~/.local/share/opencode/log/:
INFO service=provider providerID=my-newapi pkg=@ai-sdk/openai-compatible using bundled provider
INFO service=provider status=completed duration=0 providerID=my-newapi getSDK
INFO service=llm providerID=my-newapi modelID=glm-4.6 sessionID=ses_*** small=false agent=build params={"options":{}} params
ERROR service=default e=NotFoundError rejection
The critical line shows params={"options":{}} - the options that should contain baseURL are completely empty.
Custom OpenAI-compatible provider options not being passed to API calls
Description
Summary
When using a custom provider with
@ai-sdk/openai-compatible, theoptions(includingbaseURLandapiKey) configured inopencode.jsonare not being passed to the actual API calls. This results inNotFoundErrorbecause requests are being sent without the custom endpoint configuration.Environment
Configuration
~/.config/opencode/opencode.json{ "$schema": "https://opencode.ai/config.json", "model": "my-newapi/glm-4.6", "provider": { "my-newapi": { "npm": "@ai-sdk/openai-compatible", "name": "NewAPI Local", "options": { "baseURL": "http://localhost:3000/v1" }, "models": { "glm-4.6": { "name": "GLM-4.6" } } } } }~/.local/share/opencode/auth.json{ "my-newapi": { "type": "api", "key": "sk-*********************" } }Steps to Reproduce
http://localhost:3000/v1opencode.jsonas shown aboveopencode auth loginand select "Other" to add API key formy-newapiExpected Behavior
baseURLandapiKeyfrom configuration should be passed to the@ai-sdk/openai-compatibleproviderhttp://localhost:3000/v1with the configured API keyActual Behavior
Logs show empty options
The
optionsobject is empty -baseURLis not being passed.Error
Requests fail because they're not being sent to the correct endpoint.
Additional Information
Verification
@ai-sdk/openai-compatibleprovider is being usedAttempted Solutions
options.namefield (based on Issue Model options are not forwarded for openai-compatible providers unless provider.name option is given #971) - no effectapiKeytooptionsinstead ofauth.json- no effect{env:VARIABLE_NAME}syntax for apiKey - no effectRelated Issues
Root Cause
The bundled
@ai-sdk/openai-compatibleprovider in OpenCode appears to not be forwarding theoptionsfrom the config to the actual provider instance, resulting in API calls being made without the custombaseURLand other options.Workaround
None found. Custom OpenAI-compatible endpoints are currently unusable with OpenCode.
Logs
From
~/.local/share/opencode/log/:The critical line shows
params={"options":{}}- the options that should containbaseURLare completely empty.