[FEATURE]: Add query parameter support for custom OpenAI-compatible providers #4357

Open
opened 2026-02-16 17:43:33 -05:00 by yindo · 4 comments
Owner

Originally created by @UranA1 on GitHub (Jan 7, 2026).

Originally assigned to: @Awowen on GitHub.

Feature hasn't been suggested before.

  • I have verified this feature I'm about to request hasn't been suggested before.

Describe the enhancement you want to request

Problem:
When configuring custom OpenAI-compatible providers, there's currently no way to add query parameters to API requests. Some OpenAI-compatible APIs require query parameters (e.g., ?api-version=2024-01-01) rather than or in addition to headers for configuration.
Currently, the @ai-sdk/openai-compatible package only supports:

  • baseURL
  • apiKey
  • headers
  • fetch (custom function)

Use Case:
Some providers like Azure OpenAI Service variants or custom enterprise APIs require query parameters for:

  • API versioning (api-version)
  • Tenant/workspace identifiers
  • Feature flags or capabilities
  • Authentication tokens in query string format

Current Workaround:
The only workaround is implementing a custom fetch function that intercepts requests and manually appends query parameters, which is not straightforward or well-documented.

Proposed Solution:
Add a queryParams option to provider configuration:

{
  provider: {
    custom-provider: {
      npm: @ai-sdk/openai-compatible,
      api: https://api.example.com/v1,
      options: {
        apiKey: your-key,
        queryParams: {
          api-version: 2024-01-01,
          tenant: my-org
        }
      }
    }
  }
}

These parameters would be automatically appended to all requests made to the provider.

Benefits:

  • Cleaner configuration for APIs requiring query parameters
  • No need for custom fetch implementations
  • Consistent with how headers are already handled
  • Enables support for more OpenAI-compatible API variants

Implementation Location:
The change would likely need to be made in:

  • packages/opencode/src/provider/provider.ts (lines 892-975, where SDK options are processed)
  • packages/opencode/src/provider/sdk/openai-compatible/src/openai-compatible-provider.ts (where URLs are constructed)
Originally created by @UranA1 on GitHub (Jan 7, 2026). Originally assigned to: @Awowen on GitHub. ### Feature hasn't been suggested before. - [x] I have verified this feature I'm about to request hasn't been suggested before. ### Describe the enhancement you want to request **Problem:** When configuring custom OpenAI-compatible providers, there's currently no way to add query parameters to API requests. Some OpenAI-compatible APIs require query parameters (e.g., ?api-version=2024-01-01) rather than or in addition to headers for configuration. Currently, the @ai-sdk/openai-compatible package only supports: - baseURL - apiKey - headers - fetch (custom function) **Use Case:** Some providers like Azure OpenAI Service variants or custom enterprise APIs require query parameters for: - API versioning (api-version) - Tenant/workspace identifiers - Feature flags or capabilities - Authentication tokens in query string format **Current Workaround:** The only workaround is implementing a custom fetch function that intercepts requests and manually appends query parameters, which is not straightforward or well-documented. **Proposed Solution:** Add a queryParams option to provider configuration: ``` { provider: { custom-provider: { npm: @ai-sdk/openai-compatible, api: https://api.example.com/v1, options: { apiKey: your-key, queryParams: { api-version: 2024-01-01, tenant: my-org } } } } } ``` These parameters would be automatically appended to all requests made to the provider. **Benefits:** - Cleaner configuration for APIs requiring query parameters - No need for custom fetch implementations - Consistent with how headers are already handled - Enables support for more OpenAI-compatible API variants **Implementation Location:** The change would likely need to be made in: - packages/opencode/src/provider/provider.ts (lines 892-975, where SDK options are processed) - packages/opencode/src/provider/sdk/openai-compatible/src/openai-compatible-provider.ts (where URLs are constructed)
yindo added the discussion label 2026-02-16 17:43:33 -05:00
Author
Owner

@github-actions[bot] commented on GitHub (Jan 7, 2026):

This issue might be a duplicate of existing issues. Please check:

  • #5674: Custom OpenAI-compatible provider options not being passed to API calls (similar configuration issues)
  • #1735: max_tokens defaults to 32000 when using a custom provider (related to custom provider configuration challenges)
  • #6088: Header-Based Credential Injection (related feature for credential management in custom providers)
  • #6231: Auto-discover models from OpenAI-compatible provider endpoints (related to OpenAI-compatible provider improvements)

Feel free to ignore if your feature request specifically requires query parameter support beyond what these issues address.

@github-actions[bot] commented on GitHub (Jan 7, 2026): This issue might be a duplicate of existing issues. Please check: - #5674: Custom OpenAI-compatible provider options not being passed to API calls (similar configuration issues) - #1735: max_tokens defaults to 32000 when using a custom provider (related to custom provider configuration challenges) - #6088: Header-Based Credential Injection (related feature for credential management in custom providers) - #6231: Auto-discover models from OpenAI-compatible provider endpoints (related to OpenAI-compatible provider improvements) Feel free to ignore if your feature request specifically requires query parameter support beyond what these issues address.
Author
Owner

@Awowen commented on GitHub (Jan 8, 2026):

I'd like to work on this issue. Can I be assigned?

@Awowen commented on GitHub (Jan 8, 2026): I'd like to work on this issue. Can I be assigned?
Author
Owner

@rekram1-node commented on GitHub (Jan 8, 2026):

sure

@rekram1-node commented on GitHub (Jan 8, 2026): sure
Author
Owner

@rsanchezc-pg commented on GitHub (Feb 9, 2026):

@rekram1-node can this be reviewed, please? 🙏🏼

https://github.com/anomalyco/opencode/pull/7375

@rsanchezc-pg commented on GitHub (Feb 9, 2026): @rekram1-node can this be reviewed, please? 🙏🏼 https://github.com/anomalyco/opencode/pull/7375
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#4357