SDK clients store defaultHeaders and fetch in a private _options field.
Extract the access pattern into getSdkClientOptions() with runtime
validation and a narrow return type, eliminating as-any from all three
adapter getLanguageModel() implementations.
Pass defaultHeaders from SDK client instances through to the AI SDK
providers. This is critical for Azure OpenAI (api-key header) and any
custom proxy setups. Also forward organization and project for OpenAI.
Service adapters (OpenAIAdapter, AnthropicAdapter, GroqAdapter) accept
custom SDK instances with provider-specific configuration (e.g. Azure
OpenAI with custom baseURL/apiKey/headers), but CopilotRuntime discards
those instances and reconstructs a plain "provider/model" string for
BuiltInAgent. The agent's resolveModel() then creates a fresh provider
using only environment variables, losing all custom configuration.
Add getLanguageModel() to CopilotServiceAdapter so adapters can produce
a pre-configured Vercel AI SDK LanguageModel. CopilotRuntime now prefers
this over the string format when creating BuiltInAgent.
FixesCopilotKit/CopilotKit#2903