An asynchronous function that’s responsible for returning the LLM’s response. This function is
called every time a response is expected from the agent during a session. Inside this function, you
can truncate the chat history, call a RAG pipeline, use any LLM provider, or add any other logic
that controls the LLM’s response.
A stream of chat completion chunks. Each of these chunks must be in the format
below, which conforms to OpenAI’s streamed chat completion chunk specification. This means that if
you use an LLM client that conforms to OpenAI’s API, such as the official openai package, the
generated responses will be in the correct format automatically.Example returned chunks:
A unique identifier for the chat completion. Each chunk has the same ID.
array
required
A list of chat completion choices. Must be an array containing either one element or zero elements.
Hide properties
object
required
A chat completion delta generated by streamed model responses.
Hide properties
string or null
The contents of the chunk message.
array or null
A list of tool calls generated by the model.
Hide properties
integer
required
The sequential index for this tool call.
string
The ID of the tool call.
string or null
The type of the tool. Currently, only "function" is supported. Must be a string in the very first chunk and null in subsequent chunks.
object
Show properties
string or null
The name of the function to call. Must be a string in the very first chunk and null in subsequent chunks.
string
The arguments to call the function with, as generated by the model
in JSON format.
string or null
The role of the author of this message. Must be a string in the very first chunk and null in subsequent chunks.
string or null
required
The reason the model stopped generating tokens. This must be
stop if the model hit a natural stop point or a provided
stop sequence, length if the maximum number of tokens specified in the
request was reached, content_filter if content was omitted due to a flag from a
content filter, or tool_calls if the model called a tool.
integer
required
The index of the choice in the list of choices.
integer
required
The Unix timestamp (in seconds) of when the chat completion was created. Each chunk must have the same timestamp.
string
required
The model that generated the completion.
string
required
The object type, which is always "chat.completion.chunk".
object or null
Must be null for every chunk except for the last chunk, which can optionally contain the token usage statistics for the entire request.
Hide properties
integer
required
Number of tokens in the prompt.
integer
required
Number of tokens in the generated completion.
integer
required
Total number of tokens used in the request (prompt + completion).
{"docsConfig":{"$schema":"https://mintlify.com/docs.json","theme":"mint","name":"Jay","colors":{"primary":"#6c757d","light":"#1E90FF","dark":"#495057"},"favicon":"logo.svg","logo":null,"appearance":{"default":"dark","strict":true},"background":{"decoration":null,"color":{"light":"#ffffff","dark":"#111111"}},"navbar":{"links":[{"label":"Community","href":"https://discord.gg/mD4PpXuvss"}],"primary":{"type":"button","label":"Dashboard","href":"https://jay.so/dashboard"}},"footer":{"socials":{},"links":[{"header":"Company","items":[{"label":"Documentation","href":"https://docs.jay.so"},{"label":"Community","href":"https://discord.gg/mD4PpXuvss"}]},{"header":"Legal","items":[{"label":"Privacy Policy","href":"/privacy"},{"label":"Terms of Service","href":"/terms"}]}]},"navigation":{"pages":[]}},"deployment":{"deploymentMetadataValue":{"subdomain":"voice","hasAudioNarration":false,"actualSubdomain":"voice","customDomains":["docs.jay.so"],"gitSource":{"type":"github","owner":"token-js","repo":"jay","deployBranch":"main","contentDirectory":"services/website/docs","isPrivate":true,"mountPath":"","label":""},"entitlements":{},"buildId":"6ae92403277fb1e04545483d:success","clientVersion":"0.0.4352","searchFilterCounts":[{"language":"default","tag":"References","count":4},{"language":"default","tag":"Get Started","count":2},{"language":"default","tag":"Guides","count":2}]},"assistantConfig":{},"basePath":"","hasChatPermissions":false,"hasWebMcpPermissions":false,"toggles":[{"name":"kill-isr","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"custom-rbac-roles","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"agent-mintlify-slack","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"agent-integrations-settings","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"rbac-expansion","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"automations-pr-grouping","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"custom-prefix","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"analytics-v7","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"user-flows-analytics","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"no-publish-flow","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"snapshot-serving-live","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"stripTemperatureMiddleware","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"support-platform-pylon-zendesk","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"snapshot-serving","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"instant-rollback","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"granular-notifications-server","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"granular-notifications","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"automations-fable","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"fixed-ai-action-pricing","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"site-roles","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"automation-resolve-merge-conflict","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"scoped-publishing","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"mintql","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"page-level-analytics","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"editor-version-history-v2","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"billing-page-v2","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"full-page-search","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"workspace-projects","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"fork-pr-previews","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"revalidation-jwt","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"hobby-abuse-scan","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"dashboard-inbox","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"turbopuffer-dual-write","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"approve-review-flow","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"editor-metadata","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"turbopuffer-serve","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"live-agents","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"starter-pricing","enabled":true,"variant":{"name":"control","enabled":true,"payload":{"type":"string","value":"control"},"feature_enabled":true},"impressionData":false},{"name":"llms-txt-v2","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"wildcard-email-auth","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"custom-access","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false}],"starterQuestions":[],"googleFontsInlined":false},"customCss":[]}
{"page":{"pagePath":"references/llm-response-handler","slug":"/references/llm-response-handler","pageMetadata":{"title":"LLM Response Handler","description":null,"href":"/references/llm-response-handler"},"pageType":"default","mdx":{"mdxSource":{"compiledSource":"\"use strict\";const{Fragment:_Fragment,jsx:_jsx,jsxs:_jsxs}=arguments[0];const{useMDXComponents:_provideComponents}=arguments[0];function _createMdxContent(props){const _components={a:`a`,code:`code`,p:`p`,pre:`pre`,span:`span`,..._provideComponents(),...props.components},{CodeBlock,Expandable,Heading,ResponseField}=_components;if(!CodeBlock)_missingMdxReference(`CodeBlock`,true);if(!Expandable)_missingMdxReference(`Expandable`,true);if(!Heading)_missingMdxReference(`Heading`,true);if(!ResponseField)_missingMdxReference(`ResponseField`,true);return _jsxs(_Fragment,{children:[_jsx(Heading,{level:`1`,id:`llm_response_handler`,children:_jsx(_components.code,{children:`llm_response_handler`})}),`\n`,_jsx(_components.p,{children:`An asynchronous function that’s responsible for returning the LLM’s response. This function is\ncalled every time a response is expected from the agent during a session. Inside this function, you\ncan truncate the chat history, call a RAG pipeline, use any LLM provider, or add any other logic\nthat controls the LLM’s response.`}),`\n`,_jsx(Heading,{level:`2`,id:`example-usage`,children:`Example usage`}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`15`,language:`python`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`python`,children:_jsxs(_components.code,{language:`python`,numberOfLines:`15`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`from`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` jay_ai `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`import`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` LLMResponseHandlerInput`})]}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`async`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:` def`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:` llm_response_handler`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` input`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: LLMResponseHandlerInput`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`):`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` user_timezone `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#DCDCAA`},children:` input`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`[`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"session_data\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`][`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"my_user_timezone\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`]`})]}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` client `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` AsyncOpenAI(`}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:`api_key`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`os.environ[`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"OPENAI_API_KEY\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`])`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` messages `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#DCDCAA`},children:` input`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`[`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"messages\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`] `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`+`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` [{`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"role\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"system\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"content\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`f`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"User timezone: `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`{`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`user_timezone`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`}`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`}]`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` completion `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:` await`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` client.chat.completions.create(`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:` model`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"gpt-4o\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:` messages`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`messages,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:` stream`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:`True`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` )`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:` return`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` completion`})]}),`\n`]})})}),`\n`,_jsx(Heading,{level:`2`,id:`parameters`,children:`Parameters`}),`\n`,_jsx(ResponseField,{name:`input`,type:`object`,required:true,id:`param-input`,children:_jsxs(Expandable,{title:`properties`,defaultOpen:`true`,children:[_jsxs(ResponseField,{name:`messages`,type:`array of objects`,required:true,id:`param-messages`,children:[_jsx(_components.p,{children:`A list of the entire chat history that has occurred so far in the conversation.`}),_jsxs(Expandable,{title:`properties`,defaultOpen:`true`,children:[_jsx(ResponseField,{name:`content`,type:`string`,required:true,id:`param-content`,children:_jsx(_components.p,{children:`The text of the message`})}),_jsx(ResponseField,{name:`role`,type:`string`,required:true,id:`param-role`,children:_jsx(_components.p,{children:`The role of the speaker`})}),_jsx(ResponseField,{name:`name`,type:`string | None`,id:`param-name`,children:_jsx(_components.p,{children:`An optional name for the speaker. Some LLMs, such as OpenAI’s, can use this field to differentiate between participants of the same role.`})}),_jsx(ResponseField,{name:`tool_call_id`,type:`string | None`,id:`param-tool-call-id`,children:_jsxs(_components.p,{children:[`If the `,_jsx(_components.code,{children:`role`}),` is `,_jsx(_components.code,{children:`\"tool\"`}),`, this is the tool call ID that this message is responding to. Otherwise, it’s `,_jsx(_components.code,{children:`None`}),`.`]})})]})]}),_jsx(ResponseField,{name:`session_data`,type:`object`,required:true,id:`param-session-data`,children:_jsxs(_components.p,{children:[`Custom data that you specified in the `,_jsx(_components.a,{href:`https://docs.jay.so/references/configure-session#param-session-config`,children:_jsx(_components.code,{children:`SessionConfig`})}),` object`]})})]})}),`\n`,_jsxs(_components.p,{children:[`Example `,_jsx(_components.code,{children:`input`}),` parameter:`]}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`11`,language:`json`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`json`,children:_jsxs(_components.code,{language:`json`,numberOfLines:`11`,children:[_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`{`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#9CDCFE`},children:` \"messages\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: [`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` {`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#9CDCFE`},children:` \"content\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"Hello!\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#9CDCFE`},children:` \"role\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"user\"`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` }`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` ],`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#9CDCFE`},children:` \"session_data\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: {`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#9CDCFE`},children:` \"my_user_id\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"abc123\"`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` }`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`}`})}),`\n`]})})}),`\n`,_jsx(Heading,{level:`2`,id:`returns`,children:`Returns`}),`\n`,_jsxs(_components.p,{children:[`A stream of chat completion chunks. Each of these chunks must be in the format\nbelow, which conforms to OpenAI’s streamed chat completion chunk specification. This means that if\nyou use an LLM client that conforms to OpenAI’s API, such as the official `,_jsx(_components.code,{children:`openai`}),` package, the\ngenerated responses will be in the correct format automatically.`]}),`\n`,_jsx(_components.p,{children:`Example returned chunks:`}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`25`,language:`json`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`json`,children:_jsxs(_components.code,{language:`json`,numberOfLines:`25`,children:[_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#6E7781`,\"--shiki-dark\":`#6A9955`},children:`// Chunk 1`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`{`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#9CDCFE`},children:` \"id\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"chatcmpl-123\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#9CDCFE`},children:` \"object\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"chat.completion.chunk\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#9CDCFE`},children:` \"created\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#B5CEA8`},children:`1694268190`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#9CDCFE`},children:` \"model\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"gpt-4o\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#9CDCFE`},children:` \"choices\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: [`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` {`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#9CDCFE`},children:` \"index\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#B5CEA8`},children:`0`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#9CDCFE`},children:` \"delta\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: { `}),_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#9CDCFE`},children:`\"role\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"assistant\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#9CDCFE`},children:`\"content\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"The \"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` },`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#9CDCFE`},children:` \"finish_reason\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:`null`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` }`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` ]`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`}`})}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#6E7781`,\"--shiki-dark\":`#6A9955`},children:`// Chunk 2`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`{`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#9CDCFE`},children:` \"id\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"chatcmpl-123\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#9CDCFE`},children:` \"object\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"chat.completion.chunk\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#9CDCFE`},children:` \"created\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#B5CEA8`},children:`1694268190`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#9CDCFE`},children:` \"model\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"gpt-4o\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#9CDCFE`},children:` \"choices\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: [`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` { `}),_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#9CDCFE`},children:`\"index\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#B5CEA8`},children:`0`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#9CDCFE`},children:`\"delta\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: {}, `}),_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#9CDCFE`},children:`\"logprobs\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:`null`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#9CDCFE`},children:`\"finish_reason\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"stop\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` }`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` ]`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`}`})}),`\n`]})})}),`\n`,_jsx(ResponseField,{name:`ChatCompletionChunk`,type:`object`,required:true,id:`param-chat-completion-chunk`,children:_jsxs(Expandable,{title:`properties`,defaultOpen:`true`,children:[_jsx(ResponseField,{name:`id`,type:`string`,required:true,id:`param-id`,children:_jsx(_components.p,{children:`A unique identifier for the chat completion. Each chunk has the same ID.`})}),_jsxs(ResponseField,{name:`choices`,type:`array`,required:true,id:`param-choices`,children:[_jsx(_components.p,{children:`A list of chat completion choices. Must be an array containing either one element or zero elements.`}),_jsxs(Expandable,{title:`properties`,defaultOpen:`true`,children:[_jsxs(ResponseField,{name:`delta`,type:`object`,required:true,id:`param-delta`,children:[_jsx(_components.p,{children:`A chat completion delta generated by streamed model responses.`}),_jsxs(Expandable,{title:`properties`,defaultOpen:`true`,children:[_jsx(ResponseField,{name:`content`,type:`string or null`,id:`param-content-1`,children:_jsx(_components.p,{children:`The contents of the chunk message.`})}),_jsxs(ResponseField,{name:`tool_calls`,type:`array or null`,id:`param-tool-calls`,children:[_jsx(_components.p,{children:`A list of tool calls generated by the model.`}),_jsxs(Expandable,{title:`properties`,defaultOpen:`true`,children:[_jsx(ResponseField,{name:`index`,type:`integer`,required:true,id:`param-index`,children:_jsx(_components.p,{children:`The sequential index for this tool call.`})}),_jsx(ResponseField,{name:`id`,type:`string`,id:`param-id-1`,children:_jsx(_components.p,{children:`The ID of the tool call.`})}),_jsx(ResponseField,{name:`type`,type:`string or null`,id:`param-type`,children:_jsxs(_components.p,{children:[`The type of the tool. Currently, only `,_jsx(_components.code,{children:`\"function\"`}),` is supported. Must be a string in the very first chunk and null in subsequent chunks.`]})}),_jsx(ResponseField,{name:`function`,type:`object`,id:`param-function`,children:_jsxs(Expandable,{title:`properties`,children:[_jsx(ResponseField,{name:`name`,type:`string or null`,id:`param-name-1`,children:_jsx(_components.p,{children:`The name of the function to call. Must be a string in the very first chunk and null in subsequent chunks.`})}),_jsx(ResponseField,{name:`arguments`,type:`string`,id:`param-arguments`,children:_jsx(_components.p,{children:`The arguments to call the function with, as generated by the model\nin JSON format.`})})]})})]})]}),_jsx(ResponseField,{name:`role`,type:`string or null`,id:`param-role-1`,children:_jsx(_components.p,{children:`The role of the author of this message. Must be a string in the very first chunk and null in subsequent chunks.`})})]})]}),_jsx(ResponseField,{name:`finish_reason`,type:`string or null`,required:true,id:`param-finish-reason`,children:_jsxs(_components.p,{children:[`The reason the model stopped generating tokens. This must be\n`,_jsx(_components.code,{children:`stop`}),` if the model hit a natural stop point or a provided\nstop sequence, `,_jsx(_components.code,{children:`length`}),` if the maximum number of tokens specified in the\nrequest was reached, `,_jsx(_components.code,{children:`content_filter`}),` if content was omitted due to a flag from a\ncontent filter, or `,_jsx(_components.code,{children:`tool_calls`}),` if the model called a tool.`]})}),_jsx(ResponseField,{name:`index`,type:`integer`,required:true,id:`param-index-1`,children:_jsx(_components.p,{children:`The index of the choice in the list of choices.`})})]})]}),_jsx(ResponseField,{name:`created`,type:`integer`,required:true,id:`param-created`,children:_jsx(_components.p,{children:`The Unix timestamp (in seconds) of when the chat completion was created. Each chunk must have the same timestamp.`})}),_jsx(ResponseField,{name:`model`,type:`string`,required:true,id:`param-model`,children:_jsx(_components.p,{children:`The model that generated the completion.`})}),_jsx(ResponseField,{name:`object`,type:`string`,required:true,id:`param-object`,children:_jsxs(_components.p,{children:[`The object type, which is always `,_jsx(_components.code,{children:`\"chat.completion.chunk\"`}),`.`]})}),_jsxs(ResponseField,{name:`usage`,type:`object or null`,id:`param-usage`,children:[_jsxs(_components.p,{children:[`Must be `,_jsx(_components.code,{children:`null`}),` for every chunk except for the last chunk, which can optionally contain the token usage statistics for the entire request.`]}),_jsxs(Expandable,{title:`properties`,defaultOpen:`true`,children:[_jsx(ResponseField,{name:`prompt_tokens`,type:`integer`,required:true,id:`param-prompt-tokens`,children:_jsx(_components.p,{children:`Number of tokens in the prompt.`})}),_jsx(ResponseField,{name:`completion_tokens`,type:`integer`,required:true,id:`param-completion-tokens`,children:_jsx(_components.p,{children:`Number of tokens in the generated completion.`})}),_jsx(ResponseField,{name:`total_tokens`,type:`integer`,required:true,id:`param-total-tokens`,children:_jsx(_components.p,{children:`Total number of tokens used in the request (prompt + completion).`})})]})]})]})})]})}function MDXContent(props={}){const{wrapper:MDXLayout}={..._provideComponents(),...props.components};return MDXLayout?_jsx(MDXLayout,{...props,children:_jsx(_createMdxContent,{...props})}):_createMdxContent(props)}return{default:MDXContent};function _missingMdxReference(id,component){throw new Error(`Expected `+(component?`component`:`object`)+\" `\"+id+\"` to be defined: you likely forgot to import, pass, or provide it.\")}","frontmatter":{},"scope":{"config":{},"pageMetadata":{"title":"LLM Response Handler","description":null,"href":"/references/llm-response-handler"}}},"mdxSourceWithNoJs":null},"mdxExtracts":{"tableOfContents":[{"title":"llm_response_handler","slug":"llm_response_handler","depth":1,"children":[]},{"title":"Example usage","slug":"example-usage","depth":2,"children":[]},{"title":"Parameters","slug":"parameters","depth":2,"children":[]},{"title":"Returns","slug":"returns","depth":2,"children":[]}],"codeExamples":{}},"jsLinks":[],"subdomain":"voice","siteName":"Jay","title":"LLM Response Handler - Jay","contextualStarterQuestions":[],"navMaps":{"firstHrefInVersion":{},"firstHrefInLanguage":{}},"lastModified":"2026-01-07T05:45:31.557Z","originalFileLocation":"references/llm-response-handler.mdx"},"headHtml":"\u003cscript data-mint-head>(function(){var d=document.documentElement,p=\"dark\";if(!p){try{p=localStorage.getItem(\"isDarkMode\")}catch(e){}if(p==='true')p='dark';else if(p==='false')p='light';if(p!=='light'\u0026\u0026p!=='dark'\u0026\u0026p!=='system')p=\"dark\"}var r=p==='system'?(matchMedia(\"(prefers-color-scheme: dark)\").matches?'dark':'light'):p;d.classList.remove(r==='dark'?'light':'dark');d.classList.add(r);d.setAttribute(\"data-theme-preference\",p)})();\u003c/script>\u003cmeta data-mint-head name=\"application-name\" content=\"Jay\">\u003cmeta data-mint-head name=\"generator\" content=\"Mintlify\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"192x192\" href=\"/mintlify-assets/_mintlify/favicons/voice/Cw0PavXk-qut-KEZ/_generated/favicon/android-chrome-192x192.png\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"apple-touch-icon\" type=\"image/png\" sizes=\"180x180\" href=\"/mintlify-assets/_mintlify/favicons/voice/Cw0PavXk-qut-KEZ/_generated/favicon/apple-touch-icon.png\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"16x16\" href=\"/mintlify-assets/_mintlify/favicons/voice/Cw0PavXk-qut-KEZ/_generated/favicon/favicon-16x16.png\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"32x32\" href=\"/mintlify-assets/_mintlify/favicons/voice/Cw0PavXk-qut-KEZ/_generated/favicon/favicon-32x32.png\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"shortcut icon\" type=\"image/x-icon\" href=\"/mintlify-assets/_mintlify/favicons/voice/Cw0PavXk-qut-KEZ/_generated/favicon/favicon.ico\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"192x192\" href=\"/mintlify-assets/_mintlify/favicons/voice/Cw0PavXk-qut-KEZ/_generated/favicon-dark/android-chrome-192x192.png\" media=\"(prefers-color-scheme: dark)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"16x16\" href=\"/mintlify-assets/_mintlify/favicons/voice/Cw0PavXk-qut-KEZ/_generated/favicon-dark/favicon-16x16.png\" media=\"(prefers-color-scheme: dark)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"32x32\" href=\"/mintlify-assets/_mintlify/favicons/voice/Cw0PavXk-qut-KEZ/_generated/favicon-dark/favicon-32x32.png\" media=\"(prefers-color-scheme: dark)\">\u003clink data-mint-head rel=\"shortcut icon\" type=\"image/x-icon\" href=\"/mintlify-assets/_mintlify/favicons/voice/Cw0PavXk-qut-KEZ/_generated/favicon-dark/favicon.ico\" media=\"(prefers-color-scheme: dark)\">\u003cmeta data-mint-head property=\"og:title\" content=\"LLM Response Handler - Jay\">\u003cmeta data-mint-head property=\"og:site_name\" content=\"Jay\">\u003cmeta data-mint-head property=\"og:url\" content=\"https://docs.jay.so/references/llm-response-handler\">\u003cmeta data-mint-head property=\"og:type\" content=\"website\">\u003cmeta data-mint-head property=\"og:image\" content=\"https://voice.mintlify.site/_mintlify/api/og/v2?division=References\u0026amp;title=LLM+Response+Handler\u0026amp;theme=7d836672970412e681976e94\u0026amp;signature=25a533ac8082465781e0426d94f4d4dce546346cc7fe7307e5472cc670632f51\">\u003cmeta data-mint-head property=\"og:image:width\" content=\"1200\">\u003cmeta data-mint-head property=\"og:image:height\" content=\"630\">\u003cmeta data-mint-head name=\"twitter:card\" content=\"summary_large_image\">\u003cmeta data-mint-head name=\"twitter:title\" content=\"LLM Response Handler - Jay\">\u003cmeta data-mint-head name=\"twitter:image\" content=\"https://voice.mintlify.site/_mintlify/api/og/v2?division=References\u0026amp;title=LLM+Response+Handler\u0026amp;theme=7d836672970412e681976e94\u0026amp;signature=25a533ac8082465781e0426d94f4d4dce546346cc7fe7307e5472cc670632f51\">\u003cmeta data-mint-head name=\"twitter:image:width\" content=\"1200\">\u003cmeta data-mint-head name=\"twitter:image:height\" content=\"630\">\u003cmeta data-mint-head name=\"msapplication-config\" content=\"/mintlify-assets/_mintlify/favicons/voice/Cw0PavXk-qut-KEZ/_generated/favicon/browserconfig.xml\">\u003cmeta data-mint-head name=\"apple-mobile-web-app-title\" content=\"Jay\">\u003cmeta data-mint-head name=\"msapplication-TileColor\" content=\"#6c757d\">\u003clink data-mint-head rel=\"canonical\" href=\"https://docs.jay.so/references/llm-response-handler\">\u003clink data-mint-head rel=\"alternate\" type=\"application/xml\" href=\"/sitemap.xml\">\u003clink data-mint-head rel=\"alternate\" type=\"text/markdown\" href=\"/references/llm-response-handler.md\">\u003cscript data-mint-head type=\"application/ld+json\">{\"@context\":\"https://schema.org\",\"@graph\":[{\"@type\":\"Organization\",\"@id\":\"https://docs.jay.so/#organization\",\"name\":\"Jay\",\"url\":\"https://docs.jay.so\"},{\"@type\":\"WebSite\",\"@id\":\"https://docs.jay.so#website\",\"name\":\"Jay\",\"url\":\"https://docs.jay.so\",\"publisher\":{\"@id\":\"https://docs.jay.so/#organization\"}},{\"@type\":\"WebPage\",\"@id\":\"https://docs.jay.so/references/llm-response-handler#webpage\",\"url\":\"https://docs.jay.so/references/llm-response-handler\",\"name\":\"LLM Response Handler\",\"dateModified\":\"2026-01-07T05:45:31.557Z\",\"isPartOf\":{\"@id\":\"https://docs.jay.so#website\"},\"breadcrumb\":{\"@id\":\"https://docs.jay.so/references/llm-response-handler#breadcrumb\"}},{\"@type\":\"BreadcrumbList\",\"@id\":\"https://docs.jay.so/references/llm-response-handler#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"References\",\"item\":\"https://docs.jay.so/references/agent\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"LLM Response Handler\",\"item\":\"https://docs.jay.so/references/llm-response-handler\"}]},{\"@type\":[\"Article\",\"TechArticle\"],\"@id\":\"https://docs.jay.so/references/llm-response-handler#article\",\"headline\":\"LLM Response Handler\",\"name\":\"LLM Response Handler\",\"url\":\"https://docs.jay.so/references/llm-response-handler\",\"mainEntityOfPage\":{\"@id\":\"https://docs.jay.so/references/llm-response-handler#webpage\"},\"dateModified\":\"2026-01-07T05:45:31.557Z\",\"publisher\":{\"@id\":\"https://docs.jay.so/#organization\"},\"isPartOf\":{\"@id\":\"https://docs.jay.so#website\"}}]}\u003c/script>\u003cscript data-mint-head type=\"application/ld+json\">{\"@context\":\"https://schema.org\",\"@type\":\"WebSite\",\"name\":\"Jay\",\"publisher\":{\"@type\":\"Organization\",\"name\":\"Jay\"},\"provider\":{\"@type\":\"Organization\",\"name\":\"Mintlify\",\"url\":\"https://mintlify.com\"}}\u003c/script>","agentPointerHref":"/references/llm-response-handler.md","siteName":"Jay","nav":{"global":null,"groups":[{"group":"Get Started","pages":[{"title":"Quickstart","mode":"wide","href":"/get-started/quickstart"},{"title":"Agent Overview","href":"/get-started/agent-overview"}]},{"group":"Guides","pages":[{"title":"Starting Sessions","href":"/guides/starting-sessions"},{"title":"Function Calling","href":"/guides/function-calling"}]},{"group":"References","pages":[{"title":"Agent","href":"/references/agent"},{"title":"Configure Session","description":null,"href":"/references/configure-session"},{"title":"LLM Response Handler","href":"/references/llm-response-handler"},{"title":"Event Handlers","description":null,"href":"/references/event-handlers"}]}]},"basePath":"","title":"LLM Response Handler - Jay","deploymentId":"dpl_5nNsUVHqbVdUHouroPPzwztSbjmH","buildId":"dpl_5nNsUVHqbVdUHouroPPzwztSbjmH","dynamics":[],"chunks":[]}