(input: Provider.Model | RequestInput, headers?: Record<string, string>)
| 151 | } |
| 152 | |
| 153 | export const model = (input: Provider.Model | RequestInput, headers?: Record<string, string>) => { |
| 154 | const model = "model" in input ? input.model : input |
| 155 | const url = baseURL(input) |
| 156 | const options = { |
| 157 | ...("model" in input && input.apiKey ? { apiKey: input.apiKey } : {}), |
| 158 | ...(url ? { baseURL: url } : {}), |
| 159 | headers: Object.keys({ ...model.headers, ...headers }).length === 0 ? undefined : { ...model.headers, ...headers }, |
| 160 | limits: { |
| 161 | context: model.limit.context, |
| 162 | output: model.limit.output, |
| 163 | }, |
| 164 | } |
| 165 | if (model.api.npm === "@ai-sdk/openai") return OpenAI.configure(options).responses(model.api.id) |
| 166 | if (model.api.npm === "@ai-sdk/azure") |
| 167 | return Azure.configure({ ...options, baseURL: requireBaseURL(model, url) }).responses(model.api.id) |
| 168 | if (model.api.npm === "@ai-sdk/anthropic") return Anthropic.configure(options).model(model.api.id) |
| 169 | if (model.api.npm === "@ai-sdk/google") return Google.configure(options).model(model.api.id) |
| 170 | if (model.api.npm === "@ai-sdk/amazon-bedrock") return AmazonBedrock.configure(options).model(model.api.id) |
| 171 | if (model.api.npm === "@ai-sdk/openai-compatible") |
| 172 | return OpenAICompatible.configure({ |
| 173 | ...options, |
| 174 | provider: String(model.providerID), |
| 175 | baseURL: requireBaseURL(model, url), |
| 176 | }).model(model.api.id) |
| 177 | if (model.api.npm === "@openrouter/ai-sdk-provider") return OpenRouter.configure(options).model(model.api.id) |
| 178 | throw new Error(`Native LLM request adapter does not support provider package ${model.api.npm}`) |
| 179 | } |
| 180 | |
| 181 | export const request = (input: RequestInput) => { |
| 182 | const converted = messages(input.messages) |
no test coverage detected