In this tutorial, we will demonstrate how to use One API to help deploy Llama3 to Bytebase SQL editor
For data security reasons, you may want to enable AI Assistant with a self-deployed LLM. Here we chose the powerful open source model Llama3. We used Ollama and One API as a relay to convert between Bytebase’s OpenAI API-compliant requests and Llama3 API requests.
Run the following command in terminal to get a Docker container running:
docker run -d -p 11434:11434 --name ollama --restart always ollama/ollama
Container starts and returns id, then enter the container with the following command:
docker exec -it ollama bash
Pull and run the Llama3 model. Due to mapping issues, the model needs to be renamed to gpt-3.5-turbo (or mapped in One-API). After renaming, the model name is gpt-3.5-turbo, but indeed it is still Llama3.
ollama pull Llama3ollama cp Llama3 gpt-3.5-turboollama run gpt-3.5-turbo
Now that the model is running, you can test if the API is working properly in a new terminal page:
curl http://localhost:11434/api/generate -d '{ "model": "gpt-3.5-turbo", "prompt":"Why is the sky blue?"}'
Seeing the results streaming out means that API is working well.
Choose a directory with read&write permissions (replace YOUR_PATH in the following command) to save data and logs. For example, you can use the pwd command in the mac terminal to view the current path and replace YOUR_PATH with it.
Seeing the Docker container start and id output means successful deployment. If you encounter any issues, refer to the solution in One API documentation.In Docker dashboard, you can see one-api container and its address as well. You can access localhost:3000 here to log in to One API dashboard.
The initial account username is root, password is 123456.
Enter channel page, select Add a new channel. Fill in model information:
Type: ollama
Name: Llama3
Group: default
Model: gpt-3.5-turbo
Key: Anything (for example SSSS|sssss|1111) with format APPID|APISecret|APIKey if ollama has not set up for key
Proxy: the IP address of the ollama container http://host.docker.internal:11434
Furthermore, we mentioned above that the model name can be mapped in One-API. This can be done in the Model redirection bar on this page using a JSON string.
In the API keys page, click Add New Token, and fill in the Name (for example Llama3) and Model scope (for example gpt-3.5-turbo).After clicking Submit, you will see the new API key in My keys list within API keys page. Click Copy to get a token starting with sk-, with witch you can repalce YOUR_TOKEN in the code below. If the code runs successfully in your terminal, it means that One API configuration is complete.
In Bytebase Workspace, go to Settings > General and scroll down to the AI Assistant section. Turn on Enable AI Assistant, then configure:
AI Provider: OpenAI.
API Key: the YOUR_TOKEN you generated in One API.
Model: Custom model, which shows the two fields below.
Model Name: gpt-3.5-turbo — the name you mapped Llama3 to in One API.
API Endpoint: http://localhost:3000/v1/chat/completions. Bytebase posts OpenAI-compatible requests to this URL as-is, so include the full /v1/chat/completions path — not just the host. Because the path doesn’t end in /responses, Bytebase uses the Chat Completions API, which is what One API implements here (see Responses or Chat Completions).
Click Update.Enter SQL Editor from the top of any page. Click the AI icon in the top right corner to start a conversation with the AI Assistant, ask questions in natural language, and get SQL results.
Was this page helpful?
{"docsConfig":{"theme":"mint","$schema":"https://mintlify.com/docs.json","name":"Bytebase Docs","colors":{"primary":"#2b66ff","light":"#4faaff","dark":"#1c49be"},"logo":{"light":"https://mintcdn.com/dbx/vw8BbfZhlW9y-cr_/images/logo/logo-full.png?fit=max\u0026auto=format\u0026n=vw8BbfZhlW9y-cr_\u0026q=85\u0026s=894c5021793b82b6bcef8b09cef3d85d","dark":"https://mintcdn.com/dbx/vw8BbfZhlW9y-cr_/images/logo/logo-full-white.png?fit=max\u0026auto=format\u0026n=vw8BbfZhlW9y-cr_\u0026q=85\u0026s=9f660755d7e64c8f3d4882e66589af29"},"favicon":"https://mintcdn.com/dbx/otHCKEZkOwO4gA2D/favicon.svg?fit=max\u0026auto=format\u0026n=otHCKEZkOwO4gA2D\u0026q=85\u0026s=a7e205f761697f5ffcec570fa5de78b0","navbar":{"links":[{"href":"https://www.bytebase.com","label":"bytebase.com"}],"primary":{"type":"button","label":"Try Cloud","href":"https://cloud.bytebase.com/"}},"footer":{"socials":{"x":"https://x.com/bytebase","github":"https://github.com/bytebase/bytebase","linkedin":"https://linkedin.com/company/bytebase"}},"seo":{"metatags":{"canonical":"https://docs.bytebase.com"}},"icons":{"library":"lucide"},"integrations":{"ga4":{"measurementId":"G-4BZ4JH7449"}},"errors":{"404":{"redirect":false}},"contextual":{"options":["copy","view","chatgpt","claude"],"display":"header"},"styling":{"latex":true},"navigation":{"global":{"anchors":[]},"pages":[]}},"deployment":{"deploymentMetadataValue":{"subdomain":"dbx","hasAudioNarration":false,"actualSubdomain":"dbx","customDomains":["docs.bytebase.com"],"gitSource":{"type":"github","owner":"bytebase","repo":"bytebase.com","deployBranch":"main","contentDirectory":"docs","isPrivate":true,"mountPath":"","label":""},"feedback":{"thumbs":true},"entitlements":{"AI_CHAT":{"status":"ENABLED"},"WEB_MCP":{"status":"ENABLED"},"NARRATION":{"status":"ENABLED"}},"buildId":"6af2f0d28b1d48fe462fdcbc","clientVersion":"0.0.4102","searchFilterCounts":[{"language":"default","tag":"Changelog","count":54},{"language":"default","tag":"Change Management","count":46},{"language":"default","tag":"Get Started","count":43},{"language":"default","tag":"Tutorials","count":41},{"language":"default","tag":"Administration","count":32},{"language":"default","tag":"GitOps Workflow","count":24},{"language":"default","tag":"Access Control","count":23},{"language":"default","tag":"Security","count":19},{"language":"default","tag":"UI-Driven Workflow","count":15},{"language":"default","tag":"Install","count":11}]},"assistantConfig":{"enableAskAiButton":true,"enableAskAiSearchBar":false,"deflection":{"enabled":true,"email":"help@bytebase.com"}},"basePath":"","hasChatPermissions":true,"hasWebMcpPermissions":true,"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":"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":"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":"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":"editor-metadata","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},{"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}],"googleFontsInlined":false},"customCss":[{"filePath":"demo-embed.css","content":".demo-embed{position:relative;display:block;margin:1.5rem 0;border:0;border-radius:0;cursor:zoom-in;text-decoration:none!important}.demo-embed img{display:block;width:100%;margin:0!important;border-radius:0!important}.demo-embed::after{content:\"Play the interactive demo\";position:absolute;left:50%;top:50%;transform:translate(-50%, -50%);padding:0.5rem 0.875rem 0.5rem 2.25rem;border:1px solid rgb(228 228 231);border-radius:9999px;background:rgb(255 255 255 / 0.96) no-repeat 0.875rem center / 1rem 1rem\n\t\turl(\"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2318181b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M8 3H5a2 2 0 0 0-2 2v3M21 8V5a2 2 0 0 0-2-2h-3M3 16v3a2 2 0 0 0 2 2h3M16 21h3a2 2 0 0 0 2-2v-3'/%3E%3C/svg%3E\");color:rgb(24 24 27);font-size:0.8125rem;font-weight:500;line-height:1.25rem;box-shadow:0 2px 8px rgb(0 0 0 / 0.12);transition:transform 0.15s ease}.demo-embed:hover::after{transform:translate(-50%, -50%) scale(1.04)}.demo-dialog{position:fixed;inset:0;margin:auto;width:min(96vw, calc((100vh - 5rem) * 792 / 480), 1352px);max-width:none;max-height:none;padding:0;border:0;background:transparent;box-shadow:none;overflow:visible}.demo-dialog::backdrop{background:rgb(255 255 255 / 0.85);backdrop-filter:blur(8px);-webkit-backdrop-filter:blur(8px)}html.dark .demo-dialog::backdrop{background:rgb(9 9 11 / 0.85)}.demo-dialog iframe{display:block;width:100%;aspect-ratio:792 / 480;border:0}.demo-dialog__close{position:fixed;top:1rem;right:1rem;display:flex;align-items:center;justify-content:center;width:2.5rem;height:2.5rem;border:1px solid rgb(228 228 231);border-radius:9999px;background:#fff;color:rgb(24 24 27);font-size:1.25rem;line-height:1;cursor:pointer}html.dark .demo-dialog__close{border-color:rgb(63 63 70);background:rgb(24 24 27);color:#fff}"}],"page":{"pagePath":"tutorials/self-host-llama","slug":"/tutorials/self-host-llama","pageMetadata":{"title":"Self-host Llama3 for Bytebase AI Assistant","author":"Ayra","tags":"Tutorial","updated_at":"2024/12/27 18:15","integrations":"General","category":"Integration","level":"Intermediate","estimated_time":"20 mins","description":"In this tutorial, we will demonstrate how to use One API to help deploy Llama3 to Bytebase SQL editor","href":"/tutorials/self-host-llama"},"description":{"compiledSource":"\"use strict\";\nconst {jsx: _jsx} = arguments[0];\nconst {useMDXComponents: _provideComponents} = arguments[0];\nfunction _createMdxContent(props) {\n const _components = {\n p: \"p\",\n ..._provideComponents(),\n ...props.components\n };\n return _jsx(_components.p, {\n children: \"In this tutorial, we will demonstrate how to use One API to help deploy Llama3 to Bytebase SQL editor\"\n });\n}\nfunction MDXContent(props = {}) {\n const {wrapper: MDXLayout} = {\n ..._provideComponents(),\n ...props.components\n };\n return MDXLayout ? _jsx(MDXLayout, {\n ...props,\n children: _jsx(_createMdxContent, {\n ...props\n })\n }) : _createMdxContent(props);\n}\nreturn {\n default: MDXContent\n};\n","frontmatter":{},"scope":{}},"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`,li:`li`,p:`p`,pre:`pre`,span:`span`,strong:`strong`,ul:`ul`,..._provideComponents(),...props.components},{CodeBlock,Heading,OptimizedImage,Tip}=_components;if(!CodeBlock)_missingMdxReference(`CodeBlock`,true);if(!Heading)_missingMdxReference(`Heading`,true);if(!OptimizedImage)_missingMdxReference(`OptimizedImage`,true);if(!Tip)_missingMdxReference(`Tip`,true);return _jsxs(_Fragment,{children:[_jsxs(_components.p,{children:[`For data security reasons, you may want to enable `,_jsx(_components.a,{href:`/ai-assistant/`,children:`AI Assistant`}),` with a self-deployed LLM. Here we chose the powerful open source model Llama3. We used `,_jsx(_components.a,{href:`https://ollama.com/`,children:`Ollama`}),` and `,_jsx(_components.a,{href:`https://github.com/songquanpeng/one-api/blob/main/README.en.md`,children:`One API`}),` as a relay to convert between Bytebase’s OpenAI API-compliant requests and Llama3 API requests.`]}),`\n`,_jsx(Heading,{level:`2`,id:`prerequisites`,children:`Prerequisites`}),`\n`,_jsx(_components.p,{children:`Before you begin, make sure you have:`}),`\n`,_jsxs(_components.ul,{children:[`\n`,_jsxs(_components.li,{children:[_jsx(_components.a,{href:`https://www.docker.com/`,children:`Docker`}),` installed`]}),`\n`,_jsxs(_components.li,{children:[_jsx(_components.a,{href:`https://www.bytebase.com/docs/get-started/step-by-step/start-bytebase/`,children:`Bytebase`}),` instance running`]}),`\n`]}),`\n`,_jsx(Heading,{level:`2`,id:`get-llama3-running-in-docker`,children:`Get Llama3 running in Docker`}),`\n`,_jsx(_components.p,{children:`Run the following command in terminal to get a Docker container running:`}),`\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:`docker`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` run`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:` -d`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:` -p`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` 11434:11434`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:` --name`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` ollama`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:` --restart`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` always`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` ollama/ollama`})]}),`\n`]})})}),`\n`,_jsx(_components.p,{children:`Container starts and returns id, then enter the container with 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:`docker`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` exec`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:` -it`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` ollama`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` bash`})]}),`\n`]})})}),`\n`,_jsxs(_components.p,{children:[`Pull and run the Llama3 model. Due to mapping issues, the model needs to be renamed to `,_jsx(_components.code,{children:`gpt-3.5-turbo`}),` (or mapped in One-API). After renaming, the model name is `,_jsx(_components.code,{children:`gpt-3.5-turbo`}),`, but indeed it is still Llama3.`]}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`3`,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:`3`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#DCDCAA`},children:`ollama`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` pull`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` Llama3`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#DCDCAA`},children:`ollama`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` cp`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` Llama3`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` gpt-3.5-turbo`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#DCDCAA`},children:`ollama`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` run`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` gpt-3.5-turbo`})]}),`\n`]})})}),`\n`,_jsx(_components.p,{children:`Now that the model is running, you can test if the API is working properly in a new terminal page:`}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`4`,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:`4`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#DCDCAA`},children:`curl`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` http://localhost:11434/api/generate`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:` -d`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` '{`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"model\": \"gpt-3.5-turbo\",`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"prompt\":\"Why is the sky blue?\"`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`}'`})}),`\n`]})})}),`\n`,_jsx(_components.p,{children:`Seeing the results streaming out means that API is working well.`}),`\n`,_jsx(Heading,{level:`2`,id:`configure-one-api`,children:`Configure One API`}),`\n`,_jsxs(_components.p,{children:[`Choose a directory with read\u0026write permissions (replace `,_jsx(_components.code,{children:`YOUR_PATH`}),` in the following command) to save data and logs. For example, you can use the `,_jsx(_components.code,{children:`pwd`}),` command in the mac terminal to view the current path and replace `,_jsx(_components.code,{children:`YOUR_PATH`}),` with it.`]}),`\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:`docker`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` run`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:` --name`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` one-api`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:` -d`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:` --restart`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` always`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:` -p`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` 3000:3000`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:` -e`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` TZ=Asia/Shanghai`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:` -v`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` YOUR_PATH/one-api:/data`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` justsong/one-api-en`})]}),`\n`]})})}),`\n`,_jsx(_components.p,{children:`Seeing the Docker container start and id output means successful deployment. If you encounter any issues, refer to the solution in One API documentation.`}),`\n`,_jsx(OptimizedImage,{src:`https://mintcdn.com/dbx/UWWiSACs47prwfdV/content/docs/tutorials/self-host-llama/one-api-docker-run.webp?fit=max\u0026auto=format\u0026n=UWWiSACs47prwfdV\u0026q=85\u0026s=73cc78d9900c94081b9d3e76373e4f56`,alt:`one-api-docker-run`,\"data-og-width\":`1280`,width:`1280`,\"data-og-height\":`182`,height:`182`,\"data-path\":`content/docs/tutorials/self-host-llama/one-api-docker-run.webp`,\"data-optimize\":`true`,\"data-opv\":`3`,srcset:`https://mintcdn.com/dbx/UWWiSACs47prwfdV/content/docs/tutorials/self-host-llama/one-api-docker-run.webp?w=280\u0026fit=max\u0026auto=format\u0026n=UWWiSACs47prwfdV\u0026q=85\u0026s=d52b3f7025dbea3a06e86d6acbec947e 280w, https://mintcdn.com/dbx/UWWiSACs47prwfdV/content/docs/tutorials/self-host-llama/one-api-docker-run.webp?w=560\u0026fit=max\u0026auto=format\u0026n=UWWiSACs47prwfdV\u0026q=85\u0026s=da93ca8cd3f8c7a229e99aa8ce6c4306 560w, https://mintcdn.com/dbx/UWWiSACs47prwfdV/content/docs/tutorials/self-host-llama/one-api-docker-run.webp?w=840\u0026fit=max\u0026auto=format\u0026n=UWWiSACs47prwfdV\u0026q=85\u0026s=e9b54c97d4f096ab123ef156cd6e6a5f 840w, https://mintcdn.com/dbx/UWWiSACs47prwfdV/content/docs/tutorials/self-host-llama/one-api-docker-run.webp?w=1100\u0026fit=max\u0026auto=format\u0026n=UWWiSACs47prwfdV\u0026q=85\u0026s=220dcea31171578c8f7868da6a952cbf 1100w, https://mintcdn.com/dbx/UWWiSACs47prwfdV/content/docs/tutorials/self-host-llama/one-api-docker-run.webp?w=1650\u0026fit=max\u0026auto=format\u0026n=UWWiSACs47prwfdV\u0026q=85\u0026s=1645a0772b82ad573f6020b82b9b6a7c 1650w, https://mintcdn.com/dbx/UWWiSACs47prwfdV/content/docs/tutorials/self-host-llama/one-api-docker-run.webp?w=2500\u0026fit=max\u0026auto=format\u0026n=UWWiSACs47prwfdV\u0026q=85\u0026s=cd16632154c4b77424ff99a47b4d22df 2500w`}),`\n`,_jsxs(_components.p,{children:[`In Docker dashboard, you can see one-api container and its address as well. You can access `,_jsx(_components.code,{children:`localhost:3000`}),` here to log in to One API dashboard.`]}),`\n`,_jsx(Tip,{children:_jsxs(_components.p,{children:[`The initial account username is `,_jsx(_components.code,{children:`root`}),`, password is `,_jsx(_components.code,{children:`123456`}),`.`]})}),`\n`,_jsx(Heading,{level:`3`,id:`configure-channel`,children:`Configure Channel`}),`\n`,_jsxs(_components.p,{children:[`Enter `,_jsx(_components.strong,{children:`channel page`}),`, select `,_jsx(_components.strong,{children:`Add a new channel`}),`. Fill in model information:`]}),`\n`,_jsxs(_components.ul,{children:[`\n`,_jsxs(_components.li,{children:[_jsx(_components.strong,{children:`Type`}),`: `,_jsx(_components.code,{children:`ollama`})]}),`\n`,_jsxs(_components.li,{children:[_jsx(_components.strong,{children:`Name`}),`: `,_jsx(_components.code,{children:`Llama3`})]}),`\n`,_jsxs(_components.li,{children:[_jsx(_components.strong,{children:`Group`}),`: `,_jsx(_components.code,{children:`default`})]}),`\n`,_jsxs(_components.li,{children:[_jsx(_components.strong,{children:`Model`}),`: `,_jsx(_components.code,{children:`gpt-3.5-turbo`})]}),`\n`,_jsxs(_components.li,{children:[_jsx(_components.strong,{children:`Key`}),`: Anything (for example `,_jsx(_components.code,{children:`SSSS|sssss|1111`}),`) with format `,_jsx(_components.code,{children:`APPID|APISecret|APIKey`}),` if ollama has not set up for key`]}),`\n`,_jsxs(_components.li,{children:[_jsx(_components.strong,{children:`Proxy`}),`: the IP address of the ollama container `,_jsx(_components.code,{children:`http://host.docker.internal:11434`})]}),`\n`]}),`\n`,_jsxs(_components.p,{children:[`Furthermore, we mentioned above that the model name can be mapped in One-API. This can be done in the `,_jsx(_components.strong,{children:`Model redirection`}),` bar on this page using a JSON string.`]}),`\n`,_jsx(Heading,{level:`3`,id:`configure-api-keys`,children:`Configure API Keys`}),`\n`,_jsxs(_components.p,{children:[`In the `,_jsx(_components.strong,{children:`API keys`}),` page, click `,_jsx(_components.strong,{children:`Add New Token`}),`, and fill in the `,_jsx(_components.strong,{children:`Name`}),` (for example `,_jsx(_components.code,{children:`Llama3`}),`) and `,_jsx(_components.strong,{children:`Model scope`}),` (for example `,_jsx(_components.code,{children:`gpt-3.5-turbo`}),`).`]}),`\n`,_jsxs(_components.p,{children:[`After clicking `,_jsx(_components.strong,{children:`Submit`}),`, you will see the new API key in `,_jsx(_components.strong,{children:`My keys`}),` list within `,_jsx(_components.strong,{children:`API keys`}),` page. Click `,_jsx(_components.strong,{children:`Copy`}),` to get a token starting with `,_jsx(_components.code,{children:`sk-`}),`, with witch you can repalce `,_jsx(_components.code,{children:`YOUR_TOKEN`}),` in the code below. If the code runs successfully in your terminal, it means that One API configuration is complete.`]}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`13`,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:`13`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#DCDCAA`},children:`curl`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` http://localhost:3000/v1/chat/completions`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D7BA7D`},children:` \\\\`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:` -H`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"Content-Type: application/json\"`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D7BA7D`},children:` \\\\`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:` -H`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"Authorization: Bearer YOUR_TOKEN\"`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D7BA7D`},children:` \\\\`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:` -d`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` '{`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"model\": \"gpt-3.5-turbo\",`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"messages\": [`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` {`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"role\": \"user\",`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"content\": \"Tell me a joke.\"`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` }`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` ],`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"temperature\": 0.7`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` }'`})}),`\n`]})})}),`\n`,_jsx(Heading,{level:`2`,id:`configure-bytebase-and-run`,children:`Configure Bytebase and run`}),`\n`,_jsxs(_components.p,{children:[`In Bytebase Workspace, go to `,_jsx(_components.strong,{children:`Settings > General`}),` and scroll down to the `,_jsx(_components.strong,{children:`AI Assistant`}),` section. Turn on `,_jsx(_components.strong,{children:`Enable AI Assistant`}),`, then configure:`]}),`\n`,_jsxs(_components.ul,{children:[`\n`,_jsxs(_components.li,{children:[_jsx(_components.strong,{children:`AI Provider`}),`: `,_jsx(_components.strong,{children:`OpenAI`}),`.`]}),`\n`,_jsxs(_components.li,{children:[_jsx(_components.strong,{children:`API Key`}),`: the `,_jsx(_components.code,{children:`YOUR_TOKEN`}),` you generated in One API.`]}),`\n`,_jsxs(_components.li,{children:[_jsx(_components.strong,{children:`Model`}),`: `,_jsx(_components.strong,{children:`Custom model`}),`, which shows the two fields below.`]}),`\n`,_jsxs(_components.li,{children:[_jsx(_components.strong,{children:`Model Name`}),`: `,_jsx(_components.code,{children:`gpt-3.5-turbo`}),` — the name you mapped Llama3 to in One API.`]}),`\n`,_jsxs(_components.li,{children:[_jsx(_components.strong,{children:`API Endpoint`}),`: `,_jsx(_components.code,{children:`http://localhost:3000/v1/chat/completions`}),`. Bytebase posts OpenAI-compatible requests to this URL as-is, so include the full `,_jsx(_components.code,{children:`/v1/chat/completions`}),` path — not just the host. Because the path doesn’t end in `,_jsx(_components.code,{children:`/responses`}),`, Bytebase uses the Chat Completions API, which is what One API implements here (see `,_jsx(_components.a,{href:`/ai-assistant#openai-and-azure-openai-responses-or-chat-completions`,children:`Responses or Chat Completions`}),`).`]}),`\n`]}),`\n`,_jsxs(_components.p,{children:[`Click `,_jsx(_components.strong,{children:`Update`}),`.`]}),`\n`,_jsxs(_components.p,{children:[`Enter `,_jsx(_components.strong,{children:`SQL Editor`}),` from the top of any page. Click the AI icon in the top right corner to start a conversation with the AI Assistant, ask questions in natural language, and get SQL results.`]}),`\n`,_jsx(OptimizedImage,{src:`https://mintcdn.com/dbx/UWWiSACs47prwfdV/content/docs/tutorials/self-host-llama/bytebase-ai-assistant-sql-editor.webp?fit=max\u0026auto=format\u0026n=UWWiSACs47prwfdV\u0026q=85\u0026s=64af3afd7dc80a6ac8d1999f9e6554fe`,alt:`bytebase-ai-assistant-sql-editor`,\"data-og-width\":`1098`,width:`1098`,\"data-og-height\":`1166`,height:`1166`,\"data-path\":`content/docs/tutorials/self-host-llama/bytebase-ai-assistant-sql-editor.webp`,\"data-optimize\":`true`,\"data-opv\":`3`,srcset:`https://mintcdn.com/dbx/UWWiSACs47prwfdV/content/docs/tutorials/self-host-llama/bytebase-ai-assistant-sql-editor.webp?w=280\u0026fit=max\u0026auto=format\u0026n=UWWiSACs47prwfdV\u0026q=85\u0026s=1fdc437ba77fc1985cbff3cc7e752dac 280w, https://mintcdn.com/dbx/UWWiSACs47prwfdV/content/docs/tutorials/self-host-llama/bytebase-ai-assistant-sql-editor.webp?w=560\u0026fit=max\u0026auto=format\u0026n=UWWiSACs47prwfdV\u0026q=85\u0026s=0950680aee9136882ec81e536d92c26e 560w, https://mintcdn.com/dbx/UWWiSACs47prwfdV/content/docs/tutorials/self-host-llama/bytebase-ai-assistant-sql-editor.webp?w=840\u0026fit=max\u0026auto=format\u0026n=UWWiSACs47prwfdV\u0026q=85\u0026s=cbd08d8523c75b3c2f08d72c859be90e 840w, https://mintcdn.com/dbx/UWWiSACs47prwfdV/content/docs/tutorials/self-host-llama/bytebase-ai-assistant-sql-editor.webp?w=1100\u0026fit=max\u0026auto=format\u0026n=UWWiSACs47prwfdV\u0026q=85\u0026s=baea52a870a33db81a4e193f93af7172 1100w, https://mintcdn.com/dbx/UWWiSACs47prwfdV/content/docs/tutorials/self-host-llama/bytebase-ai-assistant-sql-editor.webp?w=1650\u0026fit=max\u0026auto=format\u0026n=UWWiSACs47prwfdV\u0026q=85\u0026s=b14267b81861732d9ae513713c4c7672 1650w, https://mintcdn.com/dbx/UWWiSACs47prwfdV/content/docs/tutorials/self-host-llama/bytebase-ai-assistant-sql-editor.webp?w=2500\u0026fit=max\u0026auto=format\u0026n=UWWiSACs47prwfdV\u0026q=85\u0026s=08383dae0fa3447c5686fa20925f15f5 2500w`})]})}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":"Self-host Llama3 for Bytebase AI Assistant","author":"Ayra","tags":"Tutorial","updated_at":"2024/12/27 18:15","integrations":"General","category":"Integration","level":"Intermediate","estimated_time":"20 mins","description":"In this tutorial, we will demonstrate how to use One API to help deploy Llama3 to Bytebase SQL editor","href":"/tutorials/self-host-llama"}}},"mdxSourceWithNoJs":null},"mdxExtracts":{"tableOfContents":[{"title":"Prerequisites","slug":"prerequisites","depth":2,"children":[]},{"title":"Get Llama3 running in Docker","slug":"get-llama3-running-in-docker","depth":2,"children":[]},{"title":"Configure One API","slug":"configure-one-api","depth":2,"children":[{"title":"Configure Channel","slug":"configure-channel","depth":3,"children":[]},{"title":"Configure API Keys","slug":"configure-api-keys","depth":3,"children":[]}]},{"title":"Configure Bytebase and run","slug":"configure-bytebase-and-run","depth":2,"children":[]}],"codeExamples":{}},"jsLinks":["/_mintlify/custom/dbx/c3c3611938944066/demo-embed.js"],"subdomain":"dbx","siteName":"Bytebase Docs","title":"Self-host Llama3 for Bytebase AI Assistant - Bytebase Docs","navMaps":{"firstHrefInVersion":{},"firstHrefInLanguage":{}},"lastModified":"2026-11-03T14:17:06.058Z","originalFileLocation":"tutorials/self-host-llama.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=\"system\"}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=\"description\" content=\"In this tutorial, we will demonstrate how to use One API to help deploy Llama3 to Bytebase SQL editor\">\u003cmeta data-mint-head name=\"application-name\" content=\"Bytebase Docs\">\u003cmeta data-mint-head name=\"generator\" content=\"Mintlify\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"192x192\" href=\"/mintlify-assets/_mintlify/favicons/dbx/R2-p_QktkMNyxiB0/_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/dbx/R2-p_QktkMNyxiB0/_generated/favicon/apple-touch-icon.png\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"16x16\" href=\"/mintlify-assets/_mintlify/favicons/dbx/R2-p_QktkMNyxiB0/_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/dbx/R2-p_QktkMNyxiB0/_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/dbx/R2-p_QktkMNyxiB0/_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/dbx/R2-p_QktkMNyxiB0/_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/dbx/R2-p_QktkMNyxiB0/_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/dbx/R2-p_QktkMNyxiB0/_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/dbx/R2-p_QktkMNyxiB0/_generated/favicon-dark/favicon.ico\" media=\"(prefers-color-scheme: dark)\">\u003cmeta data-mint-head property=\"og:title\" content=\"Self-host Llama3 for Bytebase AI Assistant - Bytebase Docs\">\u003cmeta data-mint-head property=\"og:description\" content=\"In this tutorial, we will demonstrate how to use One API to help deploy Llama3 to Bytebase SQL editor\">\u003cmeta data-mint-head property=\"og:site_name\" content=\"Bytebase Docs\">\u003cmeta data-mint-head property=\"og:url\" content=\"https://docs.bytebase.com/tutorials/self-host-llama\">\u003cmeta data-mint-head property=\"og:type\" content=\"website\">\u003cmeta data-mint-head property=\"og:image\" content=\"https://dbx.mintlify.site/_mintlify/api/og/v2?division=Integrations\u0026amp;title=Self-host+Llama3+for+Bytebase+AI+Assistant\u0026amp;description=In+this+tutorial%2C+we+will+demonstrate+how+to+use+One+API+to+help+deploy+Llama3+to+Bytebase+SQL+editor\u0026amp;theme=2e759ed1f2242d273808a7b9\u0026amp;signature=fc4c1e2c7c87da462d59b91ec89836e90221d011e881beef4fb850123ec63ade\">\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=\"Self-host Llama3 for Bytebase AI Assistant - Bytebase Docs\">\u003cmeta data-mint-head name=\"twitter:description\" content=\"In this tutorial, we will demonstrate how to use One API to help deploy Llama3 to Bytebase SQL editor\">\u003cmeta data-mint-head name=\"twitter:image\" content=\"https://dbx.mintlify.site/_mintlify/api/og/v2?division=Integrations\u0026amp;title=Self-host+Llama3+for+Bytebase+AI+Assistant\u0026amp;description=In+this+tutorial%2C+we+will+demonstrate+how+to+use+One+API+to+help+deploy+Llama3+to+Bytebase+SQL+editor\u0026amp;theme=2e759ed1f2242d273808a7b9\u0026amp;signature=fc4c1e2c7c87da462d59b91ec89836e90221d011e881beef4fb850123ec63ade\">\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/dbx/R2-p_QktkMNyxiB0/_generated/favicon/browserconfig.xml\">\u003cmeta data-mint-head name=\"apple-mobile-web-app-title\" content=\"Bytebase Docs\">\u003cmeta data-mint-head name=\"msapplication-TileColor\" content=\"#2b66ff\">\u003clink data-mint-head rel=\"canonical\" href=\"https://docs.bytebase.com/tutorials/self-host-llama\">\u003clink data-mint-head rel=\"alternate\" type=\"application/xml\" href=\"/sitemap.xml\">\u003clink data-mint-head rel=\"alternate\" type=\"text/markdown\" href=\"/tutorials/self-host-llama.md\">\u003cscript data-mint-head type=\"application/ld+json\">{\"@context\":\"https://schema.org\",\"@graph\":[{\"@type\":\"Organization\",\"@id\":\"https://docs.bytebase.com/#organization\",\"name\":\"Bytebase Docs\",\"url\":\"https://docs.bytebase.com\",\"logo\":{\"@type\":\"ImageObject\",\"url\":\"https://mintcdn.com/dbx/vw8BbfZhlW9y-cr_/images/logo/logo-full.png?fit=max\u0026auto=format\u0026n=vw8BbfZhlW9y-cr_\u0026q=85\u0026s=894c5021793b82b6bcef8b09cef3d85d\"}},{\"@type\":\"WebSite\",\"@id\":\"https://docs.bytebase.com#website\",\"name\":\"Bytebase Docs\",\"url\":\"https://docs.bytebase.com\",\"publisher\":{\"@id\":\"https://docs.bytebase.com/#organization\"}},{\"@type\":\"WebPage\",\"@id\":\"https://docs.bytebase.com/tutorials/self-host-llama#webpage\",\"url\":\"https://docs.bytebase.com/tutorials/self-host-llama\",\"name\":\"Self-host Llama3 for Bytebase AI Assistant\",\"description\":\"In this tutorial, we will demonstrate how to use One API to help deploy Llama3 to Bytebase SQL editor\",\"dateModified\":\"2026-11-03T14:17:06.058Z\",\"isPartOf\":{\"@id\":\"https://docs.bytebase.com#website\"},\"breadcrumb\":{\"@id\":\"https://docs.bytebase.com/tutorials/self-host-llama#breadcrumb\"}},{\"@type\":\"BreadcrumbList\",\"@id\":\"https://docs.bytebase.com/tutorials/self-host-llama#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Integrations\",\"item\":\"https://docs.bytebase.com/tutorials/connect-ai-assistant-with-mcp\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Self-host Llama3 for Bytebase AI Assistant\",\"item\":\"https://docs.bytebase.com/tutorials/self-host-llama\"}]},{\"@type\":[\"Article\",\"TechArticle\"],\"@id\":\"https://docs.bytebase.com/tutorials/self-host-llama#article\",\"headline\":\"Self-host Llama3 for Bytebase AI Assistant\",\"name\":\"Self-host Llama3 for Bytebase AI Assistant\",\"description\":\"In this tutorial, we will demonstrate how to use One API to help deploy Llama3 to Bytebase SQL editor\",\"url\":\"https://docs.bytebase.com/tutorials/self-host-llama\",\"mainEntityOfPage\":{\"@id\":\"https://docs.bytebase.com/tutorials/self-host-llama#webpage\"},\"dateModified\":\"2026-11-03T14:17:06.058Z\",\"publisher\":{\"@id\":\"https://docs.bytebase.com/#organization\"},\"isPartOf\":{\"@id\":\"https://docs.bytebase.com#website\"}}]}\u003c/script>\u003cscript data-mint-head type=\"application/ld+json\">{\"@context\":\"https://schema.org\",\"@type\":\"WebSite\",\"name\":\"Bytebase Docs\",\"publisher\":{\"@type\":\"Organization\",\"name\":\"Bytebase Docs\"},\"provider\":{\"@type\":\"Organization\",\"name\":\"Mintlify\",\"url\":\"https://mintlify.com\"}}\u003c/script>","agentPointerHref":"/tutorials/self-host-llama.md","siteName":"Bytebase Docs","nav":{"global":{"anchors":[]},"tabs":[{"tab":"Get Started","pages":[{"title":"Get Started","href":"/introduction/what-is-bytebase"}]},{"tab":"Change Management","pages":[{"title":"Change Management","href":"/change-database/change-workflow"}]},{"tab":"Access Control","pages":[{"title":"Access Control","href":"/security/database-permission/overview"}]},{"tab":"Administration","pages":[{"title":"Administration","href":"/ai-assistant"}]},{"tab":"Tutorials","pages":[{"group":"Platform Setup","pages":[{"title":"Risks Best Practice","href":"/tutorials/risks-best-practice"},{"title":"Database Change with Custom Approval Flow","href":"/tutorials/database-change-management-with-risk-adjusted-approval-flow"},{"title":"Organize SQL Server Availability Groups in Bytebase","href":"/tutorials/sql-server-availability-groups"}]},{"group":"Database Change","pages":[{"title":"Deploy Schema Change with Rollout Policy","href":"/tutorials/deploy-schema-migration"},{"title":"Data Change with 1-Click Rollback","href":"/tutorials/data-rollback"},{"title":"How to Move Schema Change from Test to Prod","href":"/tutorials/how-to-move-schema-change-from-test-to-prod"},{"title":"How to Synchronize Database Schemas","href":"/tutorials/how-to-synchronize-database-schemas"},{"title":"Batch Change with Database Group","href":"/tutorials/batch-change-with-database-group"},{"title":"SQL Review with Bytebase GUI","href":"/tutorials/sql-review-gui"},{"title":"SQL Review with Bytebase API","href":"/tutorials/sql-review-api"},{"title":"Codify SQL Review Policies with Bytebase API","href":"/tutorials/api-sql-review-policy"},{"title":"Manual Database Change with Jira","href":"/tutorials/database-change-management-with-jira-manual"},{"title":"Automate Database Change with Jira","href":"/tutorials/database-change-management-with-jira-automated"},{"title":"Create Issue with Bytebase API","href":"/tutorials/api-issue"}]},{"group":"Database Access","pages":[{"title":"How to Configure Dynamic Data Masking","href":"/tutorials/data-masking"},{"title":"Data Masking with Classification Levels","href":"/tutorials/data-classification"},{"title":"How to Manage Roles","href":"/tutorials/how-to-manage-roles"},{"title":"Just-in-Time Database Access via GUI","href":"/tutorials/just-in-time-database-access-part1"},{"title":"Just-in-Time Database Access via Slack","href":"/tutorials/just-in-time-database-access-part2"},{"title":"Just-in-time Database Access to Amazon Aurora","href":"/tutorials/just-in-time-database-access-amazon-aurora"},{"title":"User and Database Permissions with Bytebase API","href":"/tutorials/api-user-database-permission"}]},{"group":"GitOps","pages":[{"title":"Database GitOps with GitHub Actions","href":"/tutorials/gitops-github-workflow"},{"title":"Database GitOps with Azure DevOps Pipeline","href":"/tutorials/gitops-azure-devops-workflow"},{"title":"Database GitOps with GitLab CI","href":"/tutorials/gitops-gitlab-workflow"},{"title":"Database GitOps with Bitbucket Pipelines","href":"/tutorials/gitops-bitbucket-workflow"},{"title":"State-based Schema Management with GitHub Actions and AI Review","href":"/tutorials/state-based-schema-management-github"},{"title":"Data Masking with GitHub Actions Part 1 - Semantic Type and Global Masking Rule","href":"/tutorials/github-action-data-masking-part1"},{"title":"Data Masking with GitHub Actions Part 2 - Column Masking and Masking Exemption","href":"/tutorials/github-action-data-masking-part2"},{"title":"Data Masking with GitHub Actions Part 3 - Data Classification","href":"/tutorials/github-action-data-masking-part3"}]},{"group":"Terraform","pages":[{"title":"Manage Environments with Terraform","href":"/tutorials/manage-environments-with-terraform"},{"title":"Manage Databases with Terraform","href":"/tutorials/manage-databases-with-terraform"},{"title":"Manage Projects with Terraform","href":"/tutorials/manage-projects-with-terraform"},{"title":"Manage General Settings with Terraform","href":"/tutorials/manage-general-settings-with-terraform"},{"title":"Manage SQL Review Rules with Terraform","href":"/tutorials/manage-sql-review-rules-with-terraform"},{"title":"Manage Users and Groups with Terraform","href":"/tutorials/manage-users-and-groups-with-terraform"},{"title":"Manage Database Access Control with Terraform","href":"/tutorials/manage-database-access-control-with-terraform"},{"title":"Manage Data Masking with Terraform","href":"/tutorials/manage-data-masking-with-terraform"}]},{"group":"Integrations","pages":[{"title":"Connect an AI Assistant to Bytebase with MCP","description":null,"href":"/tutorials/connect-ai-assistant-with-mcp"},{"title":"Self-host Llama3 for Bytebase AI Assistant","href":"/tutorials/self-host-llama"},{"title":"Embed SQL Editor in Your Internal Web Portal","description":null,"href":"/tutorials/embed-sql-editor"},{"title":"Audit Database Activities with Bytebase API","href":"/tutorials/api-audit-log"}]}]},{"tab":"API Reference","href":"https://api.bytebase.com"},{"tab":"Changelog","pages":[{"title":"Changelog","href":"/changelog/bytebase-3-24-1"}]}]},"basePath":"","title":"Self-host Llama3 for Bytebase AI Assistant - Bytebase Docs","buildId":"dpl_596ePT575z4qnAFksq1biRW97aLY","deploymentId":"dpl_596ePT575z4qnAFksq1biRW97aLY","dynamics":["a74be98ba7"],"chunks":["zoom-image-lightbox-C5F0mVLH.js","lightbox-handle-r17bVUz3.js"]}