MCPcopy Create free account
hub / github.com/AnukarOP/claude-code-leaked / queryWithModel

Function queryWithModel

source code/services/api/claude.ts:3302–3350  ·  view source on GitHub ↗
({
  systemPrompt = asSystemPrompt([]),
  userPrompt,
  outputFormat,
  signal,
  options,
}: {
  systemPrompt: SystemPrompt
  userPrompt: string
  outputFormat?: BetaJSONOutputFormat
  signal: AbortSignal
  options: QueryWithModelOptions
})

Source from the content-addressed store, hash-verified

3300 * betas, and headers - unlike direct API calls.
3301 */
3302export async function queryWithModel({
3303 systemPrompt = asSystemPrompt([]),
3304 userPrompt,
3305 outputFormat,
3306 signal,
3307 options,
3308}: {
3309 systemPrompt: SystemPrompt
3310 userPrompt: string
3311 outputFormat?: BetaJSONOutputFormat
3312 signal: AbortSignal
3313 options: QueryWithModelOptions
3314}): Promise<AssistantMessage> {
3315 const result = await withVCR(
3316 [
3317 createUserMessage({
3318 content: systemPrompt.map(text => ({ type: 'text', text })),
3319 }),
3320 createUserMessage({
3321 content: userPrompt,
3322 }),
3323 ],
3324 async () => {
3325 const messages = [
3326 createUserMessage({
3327 content: userPrompt,
3328 }),
3329 ]
3330
3331 const result = await queryModelWithoutStreaming({
3332 messages,
3333 systemPrompt,
3334 thinkingConfig: { type: 'disabled' },
3335 tools: [],
3336 signal,
3337 options: {
3338 ...options,
3339 enablePromptCaching: options.enablePromptCaching ?? false,
3340 outputFormat,
3341 async getToolPermissionContext() {
3342 return getEmptyToolPermissionContext()
3343 },
3344 },
3345 })
3346 return [result]
3347 },
3348 )
3349 return result[0]! as AssistantMessage
3350}
3351
3352// Non-streaming requests have a 10min max per the docs:
3353// https://platform.claude.com/docs/en/api/errors#long-requests

Callers 3

summarizeTranscriptChunkFunction · 0.85
extractFacetsFromAPIFunction · 0.85
generateSectionInsightFunction · 0.85

Calls 4

asSystemPromptFunction · 0.85
withVCRFunction · 0.85
createUserMessageFunction · 0.85

Tested by

no test coverage detected