Repository navigation
Custom OpenAI-compatible provider options not being passed to API calls #5674
Description
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.
Environment
- OpenCode version: 1.0.164
- OS: Windows 10 (Git Bash)
- Provider: Custom NewAPI endpoint (OpenAI-compatible)
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
- Set up a local NewAPI endpoint (OpenAI-compatible) at
http://localhost:3000/v1 - Add custom provider configuration in
opencode.jsonas shown above - Run
opencode auth loginand select "Other" to add API key formy-newapi - Start OpenCode and select the custom provider model
- Send a message (e.g., "你好")
Expected Behavior
- The
baseURLandapiKeyfrom configuration should be passed to the@ai-sdk/openai-compatibleprovider - API requests should be sent to
http://localhost:3000/v1with the configured API key - The custom endpoint should receive and respond to requests
Actual Behavior
Logs show empty options
INFO service=llm providerID=my-newapi modelID=glm-4.6 ... params={"options":{}} params
The options object is empty - baseURL is not being passed.
Error
ERROR service=default e=NotFoundError rejection
Requests fail because they're not being sent to the correct endpoint.
Additional Information
Verification
- The NewAPI endpoint works correctly (verified with other tools using the same endpoint)
- The same configuration pattern works with built-in providers
- OpenCode correctly loads the config file and recognizes the provider
- The bundled
@ai-sdk/openai-compatibleprovider is being used
Attempted Solutions
- ✗ Added
options.namefield (based on Issue Model options are not forwarded for openai-compatible providers unless provider.name option is given #971) - no effect - ✗ Moved
apiKeytooptionsinstead ofauth.json- no effect - ✗ Used
{env:VARIABLE_NAME}syntax for apiKey - no effect - ✗ Changed provider ID to avoid conflicts - no effect
Related Issues
- Model options are not forwarded for openai-compatible providers unless provider.name option is given #971 - Options not forwarded for openai-compatible providers
- Custom OpenAI-compatible provider returns no text content #5210 - Custom OpenAI-compatible provider returns no text content
- Custom baseURL configuration returns "Route /api/messages not found" error #5163 - Custom baseURL configuration returns error
Root Cause
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.
Activity
github-actions commentedon Dec 17, 2025
This issue might be a duplicate of existing issues. Please check:
Feel free to ignore if none of these address your specific case.
rekram1-node commentedon Dec 17, 2025
i should fix this today
pyoif commentedon Dec 18, 2025
is this issue fixed? im on 1.0.167 and the options sill {}
rekram1-node commentedon Dec 18, 2025
Hm I can't replicate this
pyoif commentedon Dec 18, 2025
is there a way to verbose the logs? like where they hit, body, etc
rekram1-node commentedon Dec 18, 2025
@pyoif can u show me output of:
opencode debug configand
opencode auth listpyoif commentedon Dec 18, 2025
@rekram1-node
Output
{ "$schema": "https://opencode.ai/config.json", "autoupdate": true, "agent": { "plan": { "disable": true, "prompt": "", "name": "plan" }, "build": { "disable": true, "prompt": "", "name": "build" }, "specify": { "model": "mnnai/gemini-2.5-pro", "temperature": 0.8, "prompt": "## VARIABLE\n\nTEMPLATE_DIR = $XDG_CONFIG_HOME/opencode/templates\nSCRIPT_DIR = $XDG_CONFIG_HOME/opencode/scripts\nSCRIPT = {\nps: {SCRIPT_DIR}/bash/create-new-feature.sh --json \"{ARGS}\"\nbash: {SCRIPT_DIR}/powershell/create-new-feature.ps1 -Json \"{ARGS}\"\n}\n\n## OUTLINE\n\nImagine you are a project specification expert, you only has 1 job that is generating spec file. I will give you the feature description.\nGiven that feature description, do this:\n\n1. **Generate a concise short name** (2-4 words) for the branch:\n - Analyze the feature description and extract the most meaningful keywords\n - Create a 2-4 word short name that captures the essence of the feature\n - Use action-noun format when possible (e.g., \"add-user-auth\", \"fix-payment-bug\")\n - Preserve technical terms and acronyms (OAuth2, API, JWT, etc.)\n - Keep it concise but descriptive enough to understand the feature at a glance\n - Examples:\n - \"I want to add user authentication\" → \"user-auth\"\n - \"Implement OAuth2 integration for the API\" → \"oauth2-api-integration\"\n - \"Create a dashboard for analytics\" → \"analytics-dashboard\"\n - \"Fix payment processing timeout bug\" → \"fix-payment-timeout\"\n\n2. **Check for existing branches before creating new one**:\n\n a. First, fetch all remote branches to ensure we have the latest information:\n\n ```bash\n git fetch --all --prune\n ```\n\n b. Find the highest feature number across all sources for the short-name:\n - Remote branches: `git ls-remote --heads origin | grep -E 'refs/heads/[0-9]+-<short-name>$'`\n - Local branches: `git branch | grep -E '^[* ]*[0-9]+-<short-name>$'`\n - Specs directories: Check for directories matching `specs/[0-9]+-<short-name>`\n\n c. Determine the next available number:\n - Extract all numbers from all three sources\n - Find the highest number N\n - Use N+1 for the new branch number\n\n d. Run the script `{SCRIPT}` with the calculated number and short-name:\n - Pass `--number N+1` and `--short-name \"your-short-name\"` along with the feature description\n - Bash example: `{SCRIPT} --json --number 5 --short-name \"user-auth\" \"Add user authentication\"`\n - PowerShell example: `{SCRIPT} -Json -Number 5 -ShortName \"user-auth\" \"Add user authentication\"`\n\n **IMPORTANT**:\n - Check all three sources (remote branches, local branches, specs directories) to find the highest number\n - Only match branches/directories with the exact short-name pattern\n - If no existing branches/directories found with this short-name, start with number 1\n - You must only ever run this script once per feature\n - The JSON is provided in the terminal as output - always refer to it to get the actual content you're looking for\n - The JSON output will contain BRANCH_NAME and SPEC_FILE paths\n - For single quotes in args like \"I'm Groot\", use escape syntax: e.g 'I'\\''m Groot' (or double-quote if possible: \"I'm Groot\")\n\n3. Load `{TEMPLATE_DIR}/spec-template.md` to understand required sections.\n\n4. Follow this execution flow:\n 1. Parse user description from Input\n If empty: ERROR \"No feature description provided\"\n 2. Extract key concepts from description\n Identify: actors, actions, data, constraints\n 3. For unclear aspects:\n - Make informed guesses based on context and industry standards\n - Only mark with [NEEDS CLARIFICATION: specific question] if:\n - The choice significantly impacts feature scope or user experience\n - Multiple reasonable interpretations exist with different implications\n - No reasonable default exists\n - **LIMIT: Maximum 3 [NEEDS CLARIFICATION] markers total**\n - Prioritize clarifications by impact: scope > security/privacy > user experience > technical details\n 4. Fill User Scenarios & Testing section\n If no clear user flow: ERROR \"Cannot determine user scenarios\"\n 5. Generate Functional Requirements\n Each requirement must be testable\n Use reasonable defaults for unspecified details (document assumptions in Assumptions section)\n 6. Define Success Criteria\n Create measurable, technology-agnostic outcomes\n Include both quantitative metrics (time, performance, volume) and qualitative measures (user satisfaction, task completion)\n Each criterion must be verifiable without implementation details\n 7. Identify Key Entities (if data involved)\n 8. Return: SUCCESS (spec ready for planning)\n\n5. Write the specification to SPEC_FILE using the template structure, replacing placeholders with concrete details derived from the feature description (arguments) while preserving section order and headings.\n\n6. **Specification Quality Validation**: After writing the initial spec, validate it against quality criteria:\n\n a. **Create Spec Quality Checklist**: Generate a checklist file at `FEATURE_DIR/checklists/requirements.md` using the checklist template structure with these validation items:\n\n ```markdown\n # Specification Quality Checklist: [FEATURE NAME]\n\n **Purpose**: Validate specification completeness and quality before proceeding to planning\n **Created**: [DATE]\n **Feature**: [Link to spec.md]\n\n ## Content Quality\n\n - [ ] No implementation details (languages, frameworks, APIs)\n - [ ] Focused on user value and business needs\n - [ ] Written for non-technical stakeholders\n - [ ] All mandatory sections completed\n\n ## Requirement Completeness\n\n - [ ] No [NEEDS CLARIFICATION] markers remain\n - [ ] Requirements are testable and unambiguous\n - [ ] Success criteria are measurable\n - [ ] Success criteria are technology-agnostic (no implementation details)\n - [ ] All acceptance scenarios are defined\n - [ ] Edge cases are identified\n - [ ] Scope is clearly bounded\n - [ ] Dependencies and assumptions identified\n\n ## Feature Readiness\n\n - [ ] All functional requirements have clear acceptance criteria\n - [ ] User scenarios cover primary flows\n - [ ] Feature meets measurable outcomes defined in Success Criteria\n - [ ] No implementation details leak into specification\n\n ## Notes\n\n - Items marked incomplete require spec updates before calling plan agent\n ```\n\n b. **Run Validation Check**: Review the spec against each checklist item:\n - For each item, determine if it passes or fails\n - Document specific issues found (quote relevant spec sections)\n\n c. **Handle Validation Results**:\n - **If all items pass**: Mark checklist complete and proceed to step 6\n\n - **If items fail (excluding [NEEDS CLARIFICATION])**:\n 1. List the failing items and specific issues\n 2. Update the spec to address each issue\n 3. Re-run validation until all items pass (max 3 iterations)\n 4. If still failing after 3 iterations, document remaining issues in checklist notes and warn user\n\n - **If [NEEDS CLARIFICATION] markers remain**:\n 1. Extract all [NEEDS CLARIFICATION: ...] markers from the spec\n 2. **LIMIT CHECK**: If more than 3 markers exist, keep only the 3 most critical (by scope/security/UX impact) and make informed guesses for the rest\n 3. For each clarification needed (max 3), present options to user in this format:\n\n ```markdown\n ## Question [N]: [Topic]\n\n **Context**: [Quote relevant spec section]\n\n **What we need to know**: [Specific question from NEEDS CLARIFICATION marker]\n\n **Suggested Answers**:\n\n | Option | Answer | Implications |\n | ------ | ------------------------- | ------------------------------------- |\n | A | [First suggested answer] | [What this means for the feature] |\n | B | [Second suggested answer] | [What this means for the feature] |\n | C | [Third suggested answer] | [What this means for the feature] |\n | Custom | Provide your own answer | [Explain how to provide custom input] |\n\n **Your choice**: _[Wait for user response]_\n ```\n\n 4. **CRITICAL - Table Formatting**: Ensure markdown tables are properly formatted:\n - Use consistent spacing with pipes aligned\n - Each cell should have spaces around content: `| Content |` not `|Content|`\n - Header separator must have at least 3 dashes: `|--------|`\n - Test that the table renders correctly in markdown preview\n 5. Number questions sequentially (Q1, Q2, Q3 - max 3 total)\n 6. Present all questions together before waiting for responses\n 7. Wait for user to respond with their choices for all questions (e.g., \"Q1: A, Q2: Custom - [details], Q3: B\")\n 8. Update the spec by replacing each [NEEDS CLARIFICATION] marker with the user's selected or provided answer\n 9. Re-run validation after all clarifications are resolved\n\n d. **Update Checklist**: After each validation iteration, update the checklist file with current pass/fail status\n\n7. Report completion with branch name, spec file path, checklist results, and readiness for the next phase (@plan agent).\n\n**NOTE:** The script creates and checks out the new branch and initializes the spec file before writing.\n\n## General Guidelines\n\n## Quick Guidelines\n\n- Focus on **WHAT** users need and **WHY**.\n- Avoid HOW to implement (no tech stack, APIs, code structure).\n- Written for business stakeholders, not developers.\n- DO NOT create any checklists that are embedded in the spec. That will be a separate command.\n\n### Section Requirements\n\n- **Mandatory sections**: Must be completed for every feature\n- **Optional sections**: Include only when relevant to the feature\n- When a section doesn't apply, remove it entirely (don't leave as \"N/A\")\n\n### For AI Generation\n\nWhen creating this spec from a user prompt:\n\n1. **Make informed guesses**: Use context, industry standards, and common patterns to fill gaps\n2. **Document assumptions**: Record reasonable defaults in the Assumptions section\n3. **Limit clarifications**: Maximum 3 [NEEDS CLARIFICATION] markers - use only for critical decisions that:\n - Significantly impact feature scope or user experience\n - Have multiple reasonable interpretations with different implications\n - Lack any reasonable default\n4. **Prioritize clarifications**: scope > security/privacy > user experience > technical details\n5. **Think like a tester**: Every vague requirement should fail the \"testable and unambiguous\" checklist item\n6. **Common areas needing clarification** (only if no reasonable default exists):\n - Feature scope and boundaries (include/exclude specific use cases)\n - User types and permissions (if multiple conflicting interpretations possible)\n - Security/compliance requirements (when legally/financially significant)\n\n**Examples of reasonable defaults** (don't ask about these):\n\n- Data retention: Industry-standard practices for the domain\n- Performance targets: Standard web/mobile app expectations unless specified\n- Error handling: User-friendly messages with appropriate fallbacks\n- Authentication method: Standard session-based or OAuth2 for web apps\n- Integration patterns: RESTful APIs unless specified otherwise\n\n### Success Criteria Guidelines\n\nSuccess criteria must be:\n\n1. **Measurable**: Include specific metrics (time, percentage, count, rate)\n2. **Technology-agnostic**: No mention of frameworks, languages, databases, or tools\n3. **User-focused**: Describe outcomes from user/business perspective, not system internals\n4. **Verifiable**: Can be tested/validated without knowing implementation details\n\n**Good examples**:\n\n- \"Users can complete checkout in under 3 minutes\"\n- \"System supports 10,000 concurrent users\"\n- \"95% of searches return results in under 1 second\"\n- \"Task completion rate improves by 40%\"\n\n**Bad examples** (implementation-focused):\n\n- \"API response time is under 200ms\" (too technical, use \"Users see results instantly\")\n- \"Database can handle 1000 TPS\" (implementation detail, use user-facing metric)\n- \"React components render efficiently\" (framework-specific)\n- \"Redis cache hit rate above 80%\" (technology-specific)", "tools": { "write": true, "edit": true, "bash": true }, "description": "Create or update the feature specification from a natural language feature description.", "mode": "primary", "name": "specify" } }, "provider": { "openrouter": { "models": { "nex-agi/deepseek-v3.1-nex-n1:free": {}, "moonshotai/kimi-k2:free": {} } }, "mnnai": { "name": "MNN AI", "npm": "@ai-sdk/openai-compatible", "models": { "grok-4.1-fast": {}, "grok-4-fast": {}, "gemini-2.5-pro": { "name": "gemini-2.5-pro" } }, "options": { "baseURL": "https://api.mnnai.ru/v1/" } } }, "mode": {}, "plugin": [], "command": {}, "username": "hiyurigi", "keybinds": { "leader": "ctrl+x", "app_exit": "ctrl+c,ctrl+d,<leader>q", "editor_open": "<leader>e", "theme_list": "<leader>t", "sidebar_toggle": "<leader>b", "scrollbar_toggle": "none", "username_toggle": "none", "status_view": "<leader>s", "session_export": "<leader>x", "session_new": "<leader>n", "session_list": "<leader>l", "session_timeline": "<leader>g", "session_share": "none", "session_unshare": "none", "session_interrupt": "escape", "session_compact": "<leader>c", "messages_page_up": "pageup", "messages_page_down": "pagedown", "messages_half_page_up": "ctrl+alt+u", "messages_half_page_down": "ctrl+alt+d", "messages_first": "ctrl+g,home", "messages_last": "ctrl+alt+g,end", "messages_last_user": "none", "messages_copy": "<leader>y", "messages_undo": "<leader>u", "messages_redo": "<leader>r", "messages_toggle_conceal": "<leader>h", "tool_details": "none", "model_list": "<leader>m", "model_cycle_recent": "f2", "model_cycle_recent_reverse": "shift+f2", "model_cycle_favorite": "none", "model_cycle_favorite_reverse": "none", "command_list": "ctrl+p", "agent_list": "<leader>a", "agent_cycle": "tab", "agent_cycle_reverse": "shift+tab", "input_clear": "ctrl+c", "input_paste": "ctrl+v", "input_submit": "return", "input_newline": "shift+return,ctrl+return,alt+return,ctrl+j", "input_move_left": "left,ctrl+b", "input_move_right": "right,ctrl+f", "input_move_up": "up", "input_move_down": "down", "input_select_left": "shift+left", "input_select_right": "shift+right", "input_select_up": "shift+up", "input_select_down": "shift+down", "input_line_home": "ctrl+a", "input_line_end": "ctrl+e", "input_select_line_home": "ctrl+shift+a", "input_select_line_end": "ctrl+shift+e", "input_visual_line_home": "alt+a", "input_visual_line_end": "alt+e", "input_select_visual_line_home": "alt+shift+a", "input_select_visual_line_end": "alt+shift+e", "input_buffer_home": "home", "input_buffer_end": "end", "input_select_buffer_home": "shift+home", "input_select_buffer_end": "shift+end", "input_delete_line": "ctrl+shift+d", "input_delete_to_line_end": "ctrl+k", "input_delete_to_line_start": "ctrl+u", "input_backspace": "backspace,shift+backspace", "input_delete": "ctrl+d,delete,shift+delete", "input_undo": "ctrl+-,super+z", "input_redo": "ctrl+.,super+shift+z", "input_word_forward": "alt+f,alt+right,ctrl+right", "input_word_backward": "alt+b,alt+left,ctrl+left", "input_select_word_forward": "alt+shift+f,alt+shift+right", "input_select_word_backward": "alt+shift+b,alt+shift+left", "input_delete_word_forward": "alt+d,alt+delete,ctrl+delete", "input_delete_word_backward": "ctrl+w,ctrl+backspace,alt+backspace", "history_previous": "up", "history_next": "down", "session_child_cycle": "<leader>right", "session_child_cycle_reverse": "<leader>left", "terminal_suspend": "ctrl+z", "terminal_title_toggle": "none" } }Output
I already tried hitting the provider using curl, its working without a problem
J-Light commentedon Dec 18, 2025
Similar issue here, using openai-compatable with OpenWebUI API, the same api works for other tools.
pyoif commentedon Dec 18, 2025
@rekram1-node
I can confirm that opencode is hitting my provider endpoint correctly, and its consume my credits (in + out token), but no output in the opencode
rekram1-node commentedon Dec 19, 2025
Can u show me:
opencode run hello --print-logs --model mnnai/gemini-2.5-proI can't replicate your issue but I did find that in some cases the error returned was hard to read
pyoif commentedon Dec 19, 2025
I taking it into another levels, created a local proxy to log the http request and response, now i know where is the problem and fix it.
rekram1-node commentedon Dec 19, 2025
is it in our code?
pyoif commentedon Dec 19, 2025
in my case its provider issue, the provider doesnt response with a valid response when using tools, also i can confirm this issue is not opencode issue, opencode hit the api correctly (confirmed using my local proxy), its provider issue.
rekram1-node commentedon Dec 19, 2025
@ShiroEirin @J-Light can either of u share configs and the logs?
3 remaining items
fix: use custom provider to route OpenCode through hush proxy
fix: use custom OpenAI-compatible provider to resolve empty responses
gerudoking commentedon Mar 9, 2026
Hey! Is there any expectation on tackling this? After some search, I believe this is currently the single element blocking my team from using Opencode with our current local, self-hosted stack, which with OpenCode would be:
OpenCode <-- > LiteLLM <--> Ollama (model Qwen 3.5)
Thanks in advance!
J-Light commentedon Mar 10, 2026
Using a different solution, but in my investigation, it looks like the huge system prompt that goes to litellm/openwebui returns an empty response. I captured a request from opencode to my local service using a proxy and then ran a simple Python script I knew worked against it. However, the response was empty. Since this indicated an issue with Openwebui or litellm rather than opencode, I didn't investigate further.
J-Light commentedon Mar 10, 2026
It would be nice to trace the request from OpenCode from logs instead of having to employ other complex tools. That way we can/could address this issue better.
Dulani commentedon Mar 17, 2026
My agent and I think we've identified the root cause of this issue. Sharing in case it helps move things toward a fix.
Root cause:
sdkKey()intransform.tshas no case for@ai-sdk/openai-compatible.The
sdkKey()function maps npm package names to providerOptions namespaces:When
sdkKeyreturnsundefined, theproviderOptions()function in the same file falls back to keying options under the user's custom provider ID (e.g.,providerOptions["my-custom-provider"]). But the underlying@ai-sdk/openai-compatibleSDK reads from the"openai"namespace — so the options are silently ignored.Minimal fix: Add
@ai-sdk/openai-compatibleto the switch:This would route options like
store,include, andreasoningSummarytoproviderOptions["openai"]where the SDK actually reads them.Note: PR #14783 partially addresses the symptoms of this (filtering
reasoningSummaryat the model level), but doesn't fix the underlying namespace routing issue. ThesdkKey()fix would be complementary — it ensures ALL provider options reach the SDK, not just the ones that happen to cause errors.I've been running a local build with this
sdkKey()fix for several weeks against an Azure OpenAI gateway (gpt-5-nano, gpt-5-mini, gpt-5.2, gpt-5.2-codex) and it works correctly.Disclosure: This comment was drafted with AI assistance and reviewed/edited by a human before posting.
fix: opencode config, kimi thinking, key model access
snarkipus commentedon May 16, 2026
Work-around for
v1.15.0using@ai-sdk/openai-compatible(private Azure OpenAI)Configure the url as provider-level
api, notoptions.baseURL. Withoptions.baseURL, runtime fails before request auth withTypeError: "undefined/chat/completions" cannot be parsed as a URL.Why it worked (per GPT-5.5):
provider.options.baseURLshould work, but it is not reachingcreateOpenAICompatible.provider.apibecomesmodel.api.url.resolveSDK()falls back fromoptions.baseURLtomodel.api.url, then writes that back intooptions.baseURLbefore constructing the SDK.ColdSlither commentedon Jun 9, 2026
Confirmed still affecting v1.16.2 (Linux, June 2026)
Same issue reproduces on OpenCode 1.16.2 on Linux x86_64 with both:
1. Custom
@ai-sdk/openai-compatibleproviderConfig (opencode.jsonc):
{ "provider": { "openrouter-custom": { "npm": "@ai-sdk/openai-compatible", "name": "OpenRouter - Oya", "options": { "baseURL": "https://openrouter.ai/api/v1", "apiKey": "sk-or-...e876" }, "models": { "deepseek/deepseek-v4-flash": { "name": "deepseek/deepseek-v4-flash" } } } } }opencode debug configconfirms the options are loaded (baseURL and apiKey both present). But the runtime request hits OpenRouter withMissing Authentication header(401). Direct curl with the same key succeeds (HTTP 200).2. Built-in
openrouterprovider with auth.jsonAuth stored in
~/.local/share/opencode/auth.json:{ "openrouter": { "type": "api", "key": "sk-or-..." } }opencode providers listshows● OpenRouter apicorrectly, andOPENROUTER_API_KEYenv var is also detected. Still fails with same 401 at runtime.Confirmed workaround from @snarkipus (May 16, 2026)
Using provider-level
"api"instead of"options.baseURL"does route the URL correctly, butapiKey/headersstill get dropped — so auth still fails for endpoints that require one.Root cause validation
The analysis from @Dulani (Mar 17, 2026) —
sdkKey()intransform.tsreturningundefinedfor@ai-sdk/openai-compatible— aligns with what we see: the config is loaded and parsed correctly but options silently vanish at runtime.Workaround for this user
opencode/deepseek-v4-flash-free) work without auth — used for research/parallel crawlingKhnx-ai commentedon Jun 30, 2026
@rekram1-node
You can reproduce this issue using this API provider. Both the Anthropic and OpenAI SDKs do not return any response when configured to use the custom provider.
https://freemodel.dev/dashboard/docs#codex
https://freemodel.dev/dashboard/docs#claude-code
Robin1987China commentedon Jun 30, 2026
Confirmed — Dulani's root cause analysis is correct.
The
sdkKey()function atpackages/opencode/src/provider/transform.ts:30maps npm packages toproviderOptionsnamespaces, but has no case for@ai-sdk/openai-compatible.The fallback at line 1293-1297 uses
model.providerID.split(.)[0], but@ai-sdk/openai-compatiblereadsproviderOptionsfrom theopenaiCompatiblenamespace (same convention already documented forai-gateway-providerat lines 55-58). So the key never matches what the SDK expects.The fix is adding one case:
This also correctly triggers the existing
remaplogic at line 447-460 for provider options stored under the oldmodel.providerIDkey, so backward compatibility should be fine.Happy to open a PR with this fix + test if maintainers agree on the approach.
rekram1-node commentedon Jul 1, 2026
I tried to reproduce this and the duplicate report in #34681, and I don't think there is an option-forwarding bug here.
One important detail:
@ai-sdk/openai-compatibledoes not use only theopenaiCompatibleprovider-options key.For chat models, the SDK reads known options like
reasoningEffort,textVerbosity,user, andstrictJsonSchemafrom:But arbitrary passthrough body fields are only read from the provider-name key:
So the conclusion that opencode must put all direct OpenAI-compatible provider options under
openaiCompatibleis incorrect. That would make some known options work, but would drop passthrough fields.For direct
@ai-sdk/openai-compatibleproviders, opencode creates the SDK provider with the opencode provider id as the SDK name:Then request/model options are sent under that provider-name key. That is the key the SDK reads for both known options and passthrough body fields.
I tested this config:
{ "provider": { "bifrost-response": { "name": "Bifrost Response", "npm": "@ai-sdk/openai-compatible", "api": "https://example.com/v1", "models": { "weegam/gpt-5.4": { "limit": { "context": 1047576, "output": 65536 }, "name": "GPT-5.4", "options": { "include": ["reasoning.encrypted_content"], "reasoningEffort": "high", "reasoningSummary": "auto", "textVerbosity": "low" }, "reasoning": true, "tool_call": true } } } } }The captured request included:
So the model options were forwarded.
Also, the linked PR #34602 is not the right fix. Mapping direct
@ai-sdk/openai-compatibleproviders only toopenaiCompatiblewould keep some known options working, but it would break passthrough fields likeinclude,reasoningSummary,enable_thinking, and custom provider params.Closing this as not reproducible. If this still happens on a current version, please open a new issue with the full provider config, selected model, opencode version, and captured raw request/response showing the missing field.