We can leverage the OpenAI instrumentation to log calls from inference servers that use messages-based API, such as vLLM, LMStudio or HuggingFace’s TGI.
You shouldn’t configure this integration if you’re already using another integration like LangChain or LlamaIndex. Both integrations would record the same generation and create duplicate steps in the UI.
Create a new Python file named app.py in your project directory. This file will contain the main logic for your LLM application.In app.py, import the necessary packages and define one function to handle messages incoming from the UI.
from openai import AsyncOpenAIimport chainlit as clclient = AsyncOpenAI(base_url="http://localhost:1234/v1", api_key="lm-studio")# Instrument the OpenAI clientcl.instrument_openai()settings = { "model": "gpt-3.5-turbo", "temperature": 0, # ... more settings}@cl.on_messageasync def on_message(message: cl.Message): response = await client.chat.completions.create( messages=[ { "content": "You are a helpful bot, you always reply in Spanish", "role": "system" }, { "content": message.content, "role": "user" } ], **settings ) await cl.Message(content=response.choices[0].message.content).send()
Create a file named .env in the same folder as your app.py file. Add your OpenAI API key in the OPENAI_API_KEY variable.To start your app, open a terminal and navigate to the directory containing app.py. Then run the following command:
chainlit run app.py -w
The -w flag tells Chainlit to enable auto-reloading, so you don’t need to restart the server every time you make changes to your application. Your chatbot UI should now be accessible at http://localhost:8000.
{"docsConfig":{"theme":"mint","$schema":"https://mintlify.com/docs.json","name":"Chainlit","colors":{"primary":"#F80061","light":"#FFE7EB","dark":"#980039"},"logo":{"light":"https://mintcdn.com/chainlit-43/bY2N4qUEa_bGPLfY/logo/light.svg?fit=max\u0026auto=format\u0026n=bY2N4qUEa_bGPLfY\u0026q=85\u0026s=1b972cff6fb5980cf9bfb5c54d6b6821","dark":"https://mintcdn.com/chainlit-43/bY2N4qUEa_bGPLfY/logo/dark.svg?fit=max\u0026auto=format\u0026n=bY2N4qUEa_bGPLfY\u0026q=85\u0026s=2a67b9dc2c050be4fc5095c69d4adbb0","href":"https://github.com/Chainlit/chainlit"},"favicon":"https://mintcdn.com/chainlit-43/b2WeFP1vh0enOZXn/favicon.svg?fit=max\u0026auto=format\u0026n=b2WeFP1vh0enOZXn\u0026q=85\u0026s=513b4ccbfc1227b2ee36e6d5bb798e8e","appearance":{"default":"dark","strict":false},"background":{"color":{"dark":"#111010"}},"navbar":{"links":[{"href":"https://github.com/Chainlit/chainlit","label":"Github"}],"primary":{"type":"button","label":"Join Discord","href":"https://discord.gg/k73SQ3FyUh"}},"footer":{"socials":{"github":"https://github.com/Chainlit/chainlit","discord":"https://discord.gg/k73SQ3FyUh","x":"https://x.com/chainlit_io","linkedin":"https://www.linkedin.com/company/chainlit"}},"banner":{"content":"Chainlit is archived and no longer maintained. No bug fixes, security updates, or support are provided. [Read the project status](/get-started/project-status).","dismissible":false},"styling":{"latex":false},"navigation":{"global":{"anchors":[{"anchor":"Chainlit Help","icon":"comment","href":"https://help.chainlit.io"}]},"pages":[]}},"deployment":{"deploymentMetadataValue":{"subdomain":"chainlit-43","hasAudioNarration":false,"actualSubdomain":"chainlit-43","customDomains":["docs.chainlit.io"],"gitSource":{"type":"github","owner":"chainlit","repo":"docs","deployBranch":"main","contentDirectory":"","isPrivate":false,"mountPath":"","label":""},"chroma":{"liveDeploymentHistoryId":"6adb25e2a0e78eb4aee8763a","collectionId":"50ed0ff5-a69b-41c0-b43c-04c8a1ce621f","schemaVersion":"v3","latestBuiltDeploymentHistoryId":"6adb25e2a0e78eb4aee8763a"},"feedback":{"thumbs":true,"edits":true,"issues":true},"entitlements":{"AI_CHAT":{"status":"DISABLED"}},"buildId":"6adb25e2a0e78eb4aee8763a","clientVersion":"0.0.4044","searchFilterCounts":[{"language":"default","tag":"Documentation","count":74},{"language":"default","tag":"API Reference","count":44},{"language":"default","tag":"Get Started","count":13},{"language":"default","tag":"Elements","count":11},{"language":"default","tag":"Integrations","count":11},{"language":"default","tag":"Deploy","count":10},{"language":"default","tag":"Examples","count":10},{"language":"default","tag":"Input Widgets","count":9},{"language":"default","tag":"Basic Concepts","count":9},{"language":"default","tag":"Platforms","count":9}]},"assistantConfig":{},"basePath":"","hasChatPermissions":false,"hasWebMcpPermissions":false,"toggles":[{"name":"kill-isr","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":"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":"workos-onboarding","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"llms-txt-v2","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":"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":"assistant-v5","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"byok-sep-25","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":"vite-origin","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"billing-updated-9-15","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"workos-sso-scim","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":"workos-signup","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":"workos-enabled","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":"sso-setup-deadline-banner","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false}],"googleFontsInlined":false},"customCss":[],"page":{"pagePath":"integrations/message-based","slug":"/integrations/message-based","pageMetadata":{"title":"vLLM, LMStudio, HuggingFace","description":null,"href":"/integrations/message-based"},"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,Warning}=_components;if(!CodeBlock)_missingMdxReference(`CodeBlock`,true);if(!Warning)_missingMdxReference(`Warning`,true);return _jsxs(_Fragment,{children:[_jsx(_components.p,{children:`We can leverage the OpenAI instrumentation to log calls from inference servers that use messages-based API, such as vLLM, LMStudio or HuggingFace’s TGI.`}),`\n`,_jsx(Warning,{children:_jsx(_components.p,{children:`You shouldn’t configure this integration if you’re already using another integration like LangChain or LlamaIndex. Both integrations would record the same generation and create duplicate steps in the UI.`})}),`\n`,_jsxs(_components.p,{children:[`Create a new Python file named `,_jsx(_components.code,{children:`app.py`}),` in your project directory. This file will contain the main logic for your LLM application.`]}),`\n`,_jsxs(_components.p,{children:[`In `,_jsx(_components.code,{children:`app.py`}),`, import the necessary packages and define one function to handle messages incoming from the UI.`]}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`28`,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:`28`,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:` openai `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`import`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` AsyncOpenAI`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`import`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` chainlit `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`as`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` cl`})]}),`\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:`base_url`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"http://localhost:1234/v1\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_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:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"lm-studio\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`)`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#6E7781`,\"--shiki-dark\":`#6A9955`},children:`# Instrument the OpenAI client`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`cl.instrument_openai()`})}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`settings `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` {`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"model\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"gpt-3.5-turbo\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"temperature\"`}),_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`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#6E7781`,\"--shiki-dark\":`#6A9955`},children:` # ... more settings`})}),`\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:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`@cl.on_message`})}),`\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:` on_message`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`message`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: cl.Message):`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` response `}),_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:` messages`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},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:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"content\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"You are a helpful bot, you always reply in Spanish\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,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\"`})]}),`\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:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"content\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: message.content,`})]}),`\n`,_jsxs(_components.span,{className:`line`,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:`\"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:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:` **`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`settings`})]}),`\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:` await`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` cl.Message(`}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:`content`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`response.choices[`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#B5CEA8`},children:`0`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`].message.content).send()`})]}),`\n`]})})}),`\n`,_jsxs(_components.p,{children:[`Create a file named `,_jsx(_components.code,{children:`.env`}),` in the same folder as your `,_jsx(_components.code,{children:`app.py`}),` file. Add your OpenAI API key in the `,_jsx(_components.code,{children:`OPENAI_API_KEY`}),` variable.`]}),`\n`,_jsxs(_components.p,{children:[`To start your app, open a terminal and navigate to the directory containing `,_jsx(_components.code,{children:`app.py`}),`. Then run the following command:`]}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`1`,language:`shellscript`,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:`shellscript`,children:_jsxs(_components.code,{language:`shellscript`,numberOfLines:`1`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#DCDCAA`},children:`chainlit`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` run`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` app.py`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:` -w`})]}),`\n`]})})}),`\n`,_jsxs(_components.p,{children:[`The `,_jsx(_components.code,{children:`-w`}),` flag tells Chainlit to enable auto-reloading, so you don’t need to restart the server every time you make changes to your application. Your chatbot UI should now be accessible at `,_jsx(_components.a,{href:`http://localhost:8000`,children:`http://localhost:8000`}),`.`]})]})}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":"vLLM, LMStudio, HuggingFace","description":null,"href":"/integrations/message-based"}}},"mdxSourceWithNoJs":null},"mdxExtracts":{"tableOfContents":[],"codeExamples":{}},"jsLinks":[],"subdomain":"chainlit-43","siteName":"Chainlit","title":"vLLM, LMStudio, HuggingFace - Chainlit","navMaps":{"firstHrefInVersion":{},"firstHrefInLanguage":{}},"lastModified":"2026-10-23T09:16:26.032Z","originalFileLocation":"integrations/message-based.mdx"},"headHtml":"\u003cscript data-mint-head>(function(){var d=document.documentElement,p=null;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=\"Chainlit\">\u003cmeta data-mint-head name=\"generator\" content=\"Mintlify\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"192x192\" href=\"/mintlify-assets/_mintlify/favicons/chainlit-43/dEvNex89E1YeuZx8/_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/chainlit-43/dEvNex89E1YeuZx8/_generated/favicon/apple-touch-icon.png\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"16x16\" href=\"/mintlify-assets/_mintlify/favicons/chainlit-43/dEvNex89E1YeuZx8/_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/chainlit-43/dEvNex89E1YeuZx8/_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/chainlit-43/dEvNex89E1YeuZx8/_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/chainlit-43/dEvNex89E1YeuZx8/_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/chainlit-43/dEvNex89E1YeuZx8/_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/chainlit-43/dEvNex89E1YeuZx8/_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/chainlit-43/dEvNex89E1YeuZx8/_generated/favicon-dark/favicon.ico\" media=\"(prefers-color-scheme: dark)\">\u003cmeta data-mint-head property=\"og:title\" content=\"vLLM, LMStudio, HuggingFace - Chainlit\">\u003cmeta data-mint-head property=\"og:site_name\" content=\"Chainlit\">\u003cmeta data-mint-head property=\"og:url\" content=\"https://docs.chainlit.io/integrations/message-based\">\u003cmeta data-mint-head property=\"og:type\" content=\"website\">\u003cmeta data-mint-head property=\"og:image\" content=\"https://chainlit-43.mintlify.app/_mintlify/api/og/v2?division=Integrations\u0026amp;title=vLLM%2C+LMStudio%2C+HuggingFace\u0026amp;theme=526b67ea84a41d792424ad38\u0026amp;signature=5de15a155cbcf26a6472bc26a2d879a50528c87168042138a9102651bd8bfcfe\">\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=\"vLLM, LMStudio, HuggingFace - Chainlit\">\u003cmeta data-mint-head name=\"twitter:image\" content=\"https://chainlit-43.mintlify.app/_mintlify/api/og/v2?division=Integrations\u0026amp;title=vLLM%2C+LMStudio%2C+HuggingFace\u0026amp;theme=526b67ea84a41d792424ad38\u0026amp;signature=5de15a155cbcf26a6472bc26a2d879a50528c87168042138a9102651bd8bfcfe\">\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/chainlit-43/dEvNex89E1YeuZx8/_generated/favicon/browserconfig.xml\">\u003cmeta data-mint-head name=\"apple-mobile-web-app-title\" content=\"Chainlit\">\u003cmeta data-mint-head name=\"msapplication-TileColor\" content=\"#F80061\">\u003clink data-mint-head rel=\"canonical\" href=\"https://docs.chainlit.io/integrations/message-based\">\u003clink data-mint-head rel=\"alternate\" type=\"application/xml\" href=\"/sitemap.xml\">\u003clink data-mint-head rel=\"alternate\" type=\"text/markdown\" href=\"/integrations/message-based.md\">\u003cscript data-mint-head type=\"application/ld+json\">{\"@context\":\"https://schema.org\",\"@graph\":[{\"@type\":\"Organization\",\"@id\":\"https://docs.chainlit.io/#organization\",\"name\":\"Chainlit\",\"url\":\"https://docs.chainlit.io\",\"logo\":{\"@type\":\"ImageObject\",\"url\":\"https://mintcdn.com/chainlit-43/bY2N4qUEa_bGPLfY/logo/light.svg?fit=max\u0026auto=format\u0026n=bY2N4qUEa_bGPLfY\u0026q=85\u0026s=1b972cff6fb5980cf9bfb5c54d6b6821\"}},{\"@type\":\"WebSite\",\"@id\":\"https://docs.chainlit.io#website\",\"name\":\"Chainlit\",\"url\":\"https://docs.chainlit.io\",\"publisher\":{\"@id\":\"https://docs.chainlit.io/#organization\"}},{\"@type\":\"WebPage\",\"@id\":\"https://docs.chainlit.io/integrations/message-based#webpage\",\"url\":\"https://docs.chainlit.io/integrations/message-based\",\"name\":\"vLLM, LMStudio, HuggingFace\",\"dateModified\":\"2026-10-23T09:16:26.032Z\",\"isPartOf\":{\"@id\":\"https://docs.chainlit.io#website\"},\"breadcrumb\":{\"@id\":\"https://docs.chainlit.io/integrations/message-based#breadcrumb\"}},{\"@type\":\"BreadcrumbList\",\"@id\":\"https://docs.chainlit.io/integrations/message-based#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Get Started\",\"item\":\"https://docs.chainlit.io/get-started/overview\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Integrations\",\"item\":\"https://docs.chainlit.io/integrations/fastapi\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"vLLM, LMStudio, HuggingFace\",\"item\":\"https://docs.chainlit.io/integrations/message-based\"}]},{\"@type\":[\"Article\",\"TechArticle\"],\"@id\":\"https://docs.chainlit.io/integrations/message-based#article\",\"headline\":\"vLLM, LMStudio, HuggingFace\",\"name\":\"vLLM, LMStudio, HuggingFace\",\"url\":\"https://docs.chainlit.io/integrations/message-based\",\"mainEntityOfPage\":{\"@id\":\"https://docs.chainlit.io/integrations/message-based#webpage\"},\"dateModified\":\"2026-10-23T09:16:26.032Z\",\"publisher\":{\"@id\":\"https://docs.chainlit.io/#organization\"},\"isPartOf\":{\"@id\":\"https://docs.chainlit.io#website\"}}]}\u003c/script>\u003cscript data-mint-head type=\"application/ld+json\">{\"@context\":\"https://schema.org\",\"@type\":\"WebSite\",\"name\":\"Chainlit\",\"creator\":{\"@type\":\"Organization\",\"name\":\"Mintlify\",\"url\":\"https://mintlify.com\"}}\u003c/script>","siteName":"Chainlit","nav":{"global":{"anchors":[{"anchor":"Chainlit Help","icon":"comment","href":"https://help.chainlit.io"}]},"tabs":[{"tab":"Documentation","groups":[{"group":"Get Started","pages":[{"title":"Overview","href":"/get-started/overview"},{"title":"Project status","href":"/get-started/project-status"},{"title":"Installation","href":"/get-started/installation"},{"title":"In Pure Python","href":"/get-started/pure-python"},{"group":"Integrations","pages":[{"title":"FastAPI","href":"/integrations/fastapi"},{"title":"LangChain/LangGraph","href":"/integrations/langchain"},{"title":"OpenAI","href":"/integrations/openai"},{"title":"Semantic Kernel","href":"/integrations/semantic-kernel"},{"title":"Mistral AI","href":"/integrations/mistralai"},{"title":"LiteLLM","href":"/integrations/litellm"},{"title":"Llama Index","href":"/integrations/llama-index"},{"title":"Embedchain","description":null,"href":"/integrations/embedchain"},{"title":"vLLM, LMStudio, HuggingFace","href":"/integrations/message-based"}]}]},{"group":"Deploy","pages":[{"title":"Overview","description":null,"href":"/deploy/overview"},{"group":"Platforms","pages":[{"title":"Web App","href":"/deploy/webapp"},{"group":"React","pages":[{"title":"Overview","href":"/deploy/react/overview"},{"title":null,"href":"/deploy/react/installation-and-setup"},{"title":null,"href":"/deploy/react/usage"},{"title":null,"href":"/deploy/react/additional-resources"}]},{"title":"Copilot","href":"/deploy/copilot"},{"title":"Teams","href":"/deploy/teams"},{"title":"Slack","href":"/deploy/slack"},{"title":"Discord","href":"/deploy/discord"}]}]},{"group":"Basic Concepts","pages":[{"title":"Chat Life Cycle","href":"/concepts/chat-lifecycle"},{"title":"Starters","href":"/concepts/starters"},{"title":"Message","href":"/concepts/message"},{"title":"Step","href":"/concepts/step"},{"title":"User Session","href":"/concepts/user-session"},{"title":"Element","href":"/concepts/element"},{"title":"Action","href":"/concepts/action"},{"title":"Command","href":"/concepts/command"},{"title":"Modes","href":"/concepts/modes"}]},{"group":"Advanced Features","pages":[{"title":"Streaming","href":"/advanced-features/streaming"},{"title":"MCP","href":"/advanced-features/mcp"},{"title":"Ask User","href":"/advanced-features/ask-user"},{"title":"Multi-Modality","href":"/advanced-features/multi-modal"},{"title":"Chat Profiles","href":"/advanced-features/chat-profiles"},{"title":"Chat Settings","href":"/advanced-features/chat-settings"},{"title":"Testing \u0026 Debugging","href":"/advanced-features/test-debug"}]},{"group":"Data Persistence","pages":[{"title":"Overview","href":"/data-persistence/overview"},{"title":"Chat History","href":"/data-persistence/history"},{"title":"Human Feedback","href":"/data-persistence/feedback"},{"group":"Open Source Data Layers","pages":[{"title":"Overview","href":"/data-layers/overview"},{"title":"Official Data Layer","href":"/data-layers/official"},{"title":"SQLAlchemy Data Layer","href":"/data-layers/sqlalchemy"},{"title":"DynamoDB Data Layer","href":"/data-layers/dynamodb"}]},{"title":"Tags \u0026 Metadata","href":"/data-persistence/tags-metadata"}]},{"group":"Authentication","pages":[{"title":"Overview","href":"/authentication/overview"},{"title":"Password","href":"/authentication/password"},{"title":"Header","href":"/authentication/header"},{"title":"OAuth","href":"/authentication/oauth"}]},{"group":"Customisation","pages":[{"title":null,"href":"/customisation/overview"},{"title":"Translation","href":"/customisation/translation"},{"title":"Avatars","href":"/customisation/avatars"},{"title":"Logo and Favicon","href":"/customisation/custom-logo-and-favicon"},{"title":"Theme","href":"/customisation/theme"},{"title":"JS","href":"/customisation/custom-js"},{"title":"CSS","href":"/customisation/custom-css"}]},{"group":"Backend","pages":[{"group":"Config","pages":[{"title":"Overview","href":"/backend/config/overview"},{"title":"Project","href":"/backend/config/project"},{"title":"Features","href":"/backend/config/features"},{"title":"UI","href":"/backend/config/ui"}]},{"title":"Environment Variables","href":"/backend/env-variables"},{"title":"Command Line Options","href":"/backend/command-line"}]},{"group":"Guides","pages":[{"title":"Async / Sync","href":"/guides/sync-async"}]},{"group":"Migration Guides","pages":[{"title":"Migrate to Chainlit v2.9.4","href":"/guides/migration/2.9.4"},{"title":"Migrate to Chainlit v2.3.0","href":"/guides/migration/2.3.0"},{"title":"Migrate to Chainlit v2.1.0","href":"/guides/migration/2.1.0"},{"title":"Migrate to Chainlit v2.0.0","href":"/guides/migration/2.0.0"},{"title":"Migrate to Chainlit v1.1.404","href":"/guides/migration/1.1.404"},{"title":"Migrate to Chainlit v1.1.400","href":"/guides/migration/1.1.400"},{"title":"Migrate to Chainlit v1.1.300","href":"/guides/migration/1.1.300"},{"title":"Migrate to Chainlit v1.1.0","href":"/guides/migration/1.1.0"},{"title":"Migrate to Chainlit v1.0.500","href":"/guides/migration/1.0.500"}]}]},{"tab":"Examples","pages":[{"title":"Examples","href":"/examples/cookbook"}]},{"tab":"API Reference","pages":[{"title":"API Reference","href":"/api-reference/lifecycle-hooks/on-chat-start"}]}]},"basePath":"","title":"vLLM, LMStudio, HuggingFace - Chainlit","buildId":"dpl_DeHjVRGfFnhYQwHnfC2pjeXXv8h9","deploymentId":"dpl_DeHjVRGfFnhYQwHnfC2pjeXXv8h9","dynamics":["10e4515597"],"chunks":["BannerMarkdown-CX_qQQOL.js","dist-BTZUMDnx.js","lib-DuNMoZ05.js","lib-B8HbPgcC.js","clsx-xpJZXxdP.js","html-void-elements-mCSPHezU.js","katex-YMM-FMeD.js","marked.esm-CZWythHk.js"]}