Forward CometAPI request fields through AI SDK before forking the adapter
If your TypeScript chat integration only needs to add a request-body field that CometAPI’s endpoint documentation explicitly supports, try configuration before maintenance-heavy adapter code. CometAPI documents an OpenAI-compatible chat endpoint at https://api.cometapi.com/v1, authenticated with an API key, with the usual model and messages inputs.
The AI SDK’s OpenAI Compatible Provider exposes the relevant seam: create the provider with that base URL and key, then put the provider-specific field in providerOptions under the provider instance’s name. The namespace is camelCase: a provider named comet-api is addressed as providerOptions.cometApi. The field is then forwarded into the request body, so a transport-only extension does not require forking the provider or SDK.
That conclusion is deliberately narrow. The SDK documentation’s customOption is an example of forwarding, not proof that CometAPI accepts customOption (or any particular value). CometAPI’s compatibility page likewise does not establish a specific custom field, its semantics, or support across models. Use only a field and value documented for the endpoint you selected.
Keep three checks separate:
- Construction: did the SDK put the intended key and value in the outgoing body?
- Acceptance: does the selected CometAPI endpoint accept that body for the selected model?
- Effect: does the model actually apply the option as intended?
Only the first follows from the provider-options mechanism. Validate the latter two with the endpoint and model documentation, then with a credentialed integration test in your own environment. If the requirement instead changes response parsing, needs arbitrary body transformation, or lacks an endpoint contract, this no-fork recommendation no longer follows; choose an adapter or application-layer change based on that concrete requirement.