| 197 | reasoningEnabled: options.reasoningEnabled ?? true |
| 198 | }; |
| 199 | if (!zeroDataRetention.isReady()) await zeroDataRetention.ensureReady(); |
| 200 | // The title model receives the first message. With zero data retention |
| 201 | // on and no eligible provider for it, keep the local title instead. |
| 202 | if (zeroDataRetention.isEnabled() && !zeroDataRetention.supportsModel(requestOptions.modelId)) { |
| 203 | return Promise.resolve(''); |
| 204 | } |
| 205 | return this.withRequestAccess(token, requestOptions, request => |
| 206 | request._generateSessionTitle(prompt, token, requestOptions)); |
| 207 | } |
| 208 | |
| 209 | streamCompletion(messages, modelId, token, onChunk, onTokenUpdate, files = [], searchEnabled = false, abortController = null, onStreamOpen = null, onReasoningChunk = null, reasoningEnabled = true, reasoningEffort = DEFAULT_REASONING_EFFORT, onAccessProgress = null, onStreamHealth = null) { |
| 210 | try { validateConversationInput(messages, this.getModelBudgetMetadata(modelId), files, modelId); } |
| 211 | catch (error) { return Promise.reject(error); } |
| 212 | return this.withRequestAccess(token, { |
| 213 | signal: abortController?.signal, |
| 214 | onProgress: onAccessProgress, |
| 215 | modelId, |
| 216 | reasoningEnabled |
| 217 | }, request => request._streamCompletion(messages, modelId, token, onChunk, |
| 218 | onTokenUpdate, files, searchEnabled, abortController, onStreamOpen, |
| 219 | onReasoningChunk, reasoningEnabled, reasoningEffort, onAccessProgress, onStreamHealth)); |
| 220 | } |
| 221 | |
| 222 | // Get API key - only use ticket-based key |
| 223 | getApiKey() { |
| 224 | const key = apiKeyStore.getApiKey(); |
| 225 | if (!key) return null; |
| 226 | if (apiKeyStore.isExpired()) return null; |