In this method, Aporia acts as a proxy, forwarding your requests to OpenAI and simultaneously invoking guardrails. The returned response is either the original from OpenAI or a modified version enforced by Aporia’s policies.This integration supports real-time applications through streaming capabilities, making it particularly useful for chatbots.
If you’re just getting started and your app is based on OpenAI or Azure OpenAI, this method is highly recommended.All you need to do is replace the OpenAI Base URL and add Aporia’s API Key header.
Here is a basic example of how to configure the OpenAI client to use Aporia’s OpenAI Proxy method:
from openai import OpenAIclient = OpenAI( api_key='<your OpenAI API key>', base_url='<the copied base URL>', default_headers={'X-APORIA-API-KEY': '<your Aporia API key>'})chat_completion = client.chat.completions.create( model="gpt-3.5-turbo", messages=[ { "role": "user", "content": "Hello world", } ], user="<end-user ID>",)
import OpenAI from "openai";const openai = new OpenAI({ apiKey: "<your OpenAI API key>", baseURL: "<the copied URL>", defaultHeaders: {"X-APORIA-API-KEY": "<your Aporia API key>"},});async function chat() { const completion = await openai.chat.completions.create({ messages: [{ role: "system", content: "You are a helpful assistant." }], model: "gpt-3.5-turbo", user: "<end-user ID>", });}
import { ChatOpenAI } from "@langchain/openai";const model = new ChatOpenAI({ apiKey: "<your OpenAI API key>", configuration: { baseURL: "<the copied URL>", defaultHeaders: {"X-APORIA-API-KEY": "<your Aporia API key>"}, }, user: "<end-user ID>",});const response = await model.invoke( "What would be a good company name a company that makes colorful socks?");console.log(response);
To integrate Aporia with Azure OpenAI, use the X-AZURE-OPENAI-ENDPOINT header to specify your Azure OpenAI endpoint.
from openai import AzureOpenAIclient = AzureOpenAI( azure_endpoint="<Aporia base URL>/azure", # Note the /azure! azure_deployment="<Azure deployment>", api_version="<Azure API version>", api_key="<Azure API key>", default_headers={ "X-APORIA-API-KEY": "<your Aporia API key>", "X-AZURE-OPENAI-ENDPOINT": "<your Azure OpenAI endpoint>", })chat_completion = client.chat.completions.create( model="gpt-3.5-turbo", messages=[ { "role": "user", "content": "Hello world", } ], user="<end-user ID>",)
{"docsConfig":{"$schema":"https://mintlify.com/docs.json","theme":"mint","name":"Aporia","colors":{"primary":"#0D9373","light":"#07C983","dark":"#0D9373"},"favicon":"/favicon.svg","logo":{"light":"https://mintcdn.com/aporia/67z2pg4gk3aiMXT7/logo/light.svg?fit=max\u0026auto=format\u0026n=67z2pg4gk3aiMXT7\u0026q=85\u0026s=966825e33ef682d0fdd1826ea5b680b7","dark":"https://mintcdn.com/aporia/67z2pg4gk3aiMXT7/logo/light.svg?fit=max\u0026auto=format\u0026n=67z2pg4gk3aiMXT7\u0026q=85\u0026s=966825e33ef682d0fdd1826ea5b680b7"},"appearance":{"default":"light","strict":true},"navbar":{"links":[{"label":"contact us","href":"https://www.aporia.com/contact-us/"}],"primary":{"type":"button","label":"Book a Demo","href":"https://www.aporia.com/demo/"}},"footer":{"socials":{"website":"https://www.aporia.com","x":"https://twitter.com/AporiaAi","github":"https://github.com/aporia-ai","linkedin":"https://www.linkedin.com/company/aporiaai","youtube":"https://www.youtube.com/channel/UClImHZUPNbL-PxKSMS1E92g","instagram":"https://www.instagram.com/life.at.aporia/"}},"integrations":{"gtm":{"tagId":"GTM-NNNMX2PG"}},"navigation":{"global":{"anchors":[{"anchor":"Guardrails Dashboard","href":"https://guardrails.aporia.com/","icon":"shield"},{"anchor":"GenAI Academy","href":"https://www.aporia.com/learn/generative-ai/","icon":"graduation-cap"},{"anchor":"ML Observability Docs","href":"https://docs.aporia.com","icon":"heart-pulse"},{"anchor":"Blog","href":"https://www.aporia.com/blog/","icon":"newspaper"}]},"pages":[]}},"deployment":{"deploymentMetadataValue":{"subdomain":"aporia","hasAudioNarration":false,"actualSubdomain":"aporia","customDomains":["gr-docs.aporia.com"],"gitSource":{"type":"github","owner":"aporia-ai","repo":"docs","deployBranch":"main","contentDirectory":"","isPrivate":true,"mountPath":"","label":""},"chroma":{"liveDeploymentHistoryId":"6a21e624b8c65e77d6677922","collectionId":"c0bf3932-150f-4cc8-ad5c-70d0eae56d13","schemaVersion":"v2"},"entitlements":{"AI_CHAT":{"status":"ENABLED"},"REMOVE_BRANDING":{"status":"DISABLED"},"CONTEXTUAL_FEEDBACK":{"status":"DISABLED"},"CODE_SNIPPET_FEEDBACK":{"status":"DISABLED"},"WEB_MCP":{"status":"ENABLED"},"NARRATION":{"status":"ENABLED"}},"buildId":"6a21e624b8c65e77d6677922:success","clientVersion":"0.0.4045","searchFilterCounts":[{"language":"default","tag":"Documentation","count":58},{"language":"default","tag":"Policies","count":21},{"language":"default","tag":"Fundamentals","count":12},{"language":"default","tag":"Release Notes","count":12},{"language":"default","tag":"Enterprise","count":5},{"language":"default","tag":"Text-to-SQL Security","count":5},{"language":"default","tag":"Examples","count":4},{"language":"default","tag":"AI Gateway integration","count":4},{"language":"default","tag":"Integrate to LLM app","count":3},{"language":"default","tag":"Get Started","count":3}]},"assistantConfig":{},"basePath":"","hasChatPermissions":true,"hasWebMcpPermissions":true,"toggles":[],"googleFontsInlined":false},"customCss":[],"page":{"pagePath":"fundamentals/integration/openai-proxy","slug":"/fundamentals/integration/openai-proxy","pageMetadata":{"title":"OpenAI Proxy","description":null,"href":"/fundamentals/integration/openai-proxy"},"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`,ol:`ol`,p:`p`,pre:`pre`,span:`span`,strong:`strong`,..._provideComponents(),...props.components},{CodeBlock,CodeGroup,Heading,OptimizedImage,Tip}=_components;if(!CodeBlock)_missingMdxReference(`CodeBlock`,true);if(!CodeGroup)_missingMdxReference(`CodeGroup`,true);if(!Heading)_missingMdxReference(`Heading`,true);if(!OptimizedImage)_missingMdxReference(`OptimizedImage`,true);if(!Tip)_missingMdxReference(`Tip`,true);return _jsxs(_Fragment,{children:[_jsx(Heading,{level:`2`,id:`overview`,children:`Overview`}),`\n`,_jsx(_components.p,{children:`In this method, Aporia acts as a proxy, forwarding your requests to OpenAI and simultaneously invoking guardrails. The returned response is either the original from OpenAI or a modified version enforced by Aporia’s policies.`}),`\n`,_jsx(_components.p,{children:`This integration supports real-time applications through streaming capabilities, making it particularly useful for chatbots.`}),`\n`,_jsxs(Tip,{children:[_jsxs(_components.p,{children:[`If you’re just getting started and your app is based on OpenAI or Azure OpenAI, `,_jsx(_components.strong,{children:`this method is highly recommended`}),`.`]}),_jsx(_components.p,{children:`All you need to do is replace the OpenAI Base URL and add Aporia’s API Key header.`})]}),`\n`,_jsx(Heading,{level:`2`,id:`prerequisites`,children:`Prerequisites`}),`\n`,_jsx(_components.p,{children:`To use this integration method, ensure you have:`}),`\n`,_jsxs(_components.ol,{children:[`\n`,_jsx(_components.li,{children:_jsx(_components.a,{href:`/fundamentals/projects#creating-a-project`,children:`Created an Aporia Guardrails project.`})}),`\n`]}),`\n`,_jsx(Heading,{level:`2`,id:`integration-guide`,children:`Integration Guide`}),`\n`,_jsx(Heading,{level:`3`,id:`step-1-gather-aporia’s-base-url-and-api-key`,children:`Step 1: Gather Aporia’s Base URL and API Key`}),`\n`,_jsxs(_components.ol,{children:[`\n`,_jsxs(_components.li,{children:[`Log into the `,_jsx(_components.a,{href:`https://guardrails.aporia.com`,children:`Aporia dashboard`}),`.`]}),`\n`,_jsxs(_components.li,{children:[`Select your project and click on the `,_jsx(_components.strong,{children:`Integration`}),` tab.`]}),`\n`,_jsxs(_components.li,{children:[`Under Integration, ensure that `,_jsx(_components.strong,{children:`Host URL`}),` is active.`]}),`\n`,_jsxs(_components.li,{children:[`Copy the `,_jsx(_components.strong,{children:`Host URL`}),`.`]}),`\n`,_jsxs(_components.li,{children:[`Click on `,_jsx(_components.strong,{children:`“API Keys Table”`}),` to navigate to your keys table.`]}),`\n`,_jsxs(_components.li,{children:[`Create a new API key and `,_jsx(_components.strong,{children:`save it somewhere safe and accessible`}),`. If you lose this secret key, you’ll need to create a new one.`]}),`\n`]}),`\n`,_jsx(OptimizedImage,{src:`https://mintcdn.com/aporia/ikR99If3485QaXQB/images/integration-press-table.png?fit=max\u0026auto=format\u0026n=ikR99If3485QaXQB\u0026q=85\u0026s=2f7e09bf0cbb2bb2aee6e2ea3c2d183a`,className:`mint-block mint-rounded-md`,\"data-og-width\":`628`,width:`628`,\"data-og-height\":`549`,height:`549`,\"data-path\":`images/integration-press-table.png`,\"data-optimize\":`true`,\"data-opv\":`3`,srcset:`https://mintcdn.com/aporia/ikR99If3485QaXQB/images/integration-press-table.png?w=280\u0026fit=max\u0026auto=format\u0026n=ikR99If3485QaXQB\u0026q=85\u0026s=9d92c921990e62193907865b76ce453d 280w, https://mintcdn.com/aporia/ikR99If3485QaXQB/images/integration-press-table.png?w=560\u0026fit=max\u0026auto=format\u0026n=ikR99If3485QaXQB\u0026q=85\u0026s=09c1211253bdb9327ca7622c00180347 560w, https://mintcdn.com/aporia/ikR99If3485QaXQB/images/integration-press-table.png?w=840\u0026fit=max\u0026auto=format\u0026n=ikR99If3485QaXQB\u0026q=85\u0026s=b6935ec02bad642bbf5f30749ede1bee 840w, https://mintcdn.com/aporia/ikR99If3485QaXQB/images/integration-press-table.png?w=1100\u0026fit=max\u0026auto=format\u0026n=ikR99If3485QaXQB\u0026q=85\u0026s=8832461001e79fcb50c41bd5a16279cd 1100w, https://mintcdn.com/aporia/ikR99If3485QaXQB/images/integration-press-table.png?w=1650\u0026fit=max\u0026auto=format\u0026n=ikR99If3485QaXQB\u0026q=85\u0026s=4cf251988efa8d3786282bd0673545bf 1650w, https://mintcdn.com/aporia/ikR99If3485QaXQB/images/integration-press-table.png?w=2500\u0026fit=max\u0026auto=format\u0026n=ikR99If3485QaXQB\u0026q=85\u0026s=f7edf0b73c531d3e8871c0e66a815c95 2500w`}),`\n`,_jsx(OptimizedImage,{src:`https://mintcdn.com/aporia/ikR99If3485QaXQB/images/api-keys-table.png?fit=max\u0026auto=format\u0026n=ikR99If3485QaXQB\u0026q=85\u0026s=bf85a93475760458d3426dc02fc1b361`,className:`mint-block mint-rounded-md`,\"data-og-width\":`1703`,width:`1703`,\"data-og-height\":`539`,height:`539`,\"data-path\":`images/api-keys-table.png`,\"data-optimize\":`true`,\"data-opv\":`3`,srcset:`https://mintcdn.com/aporia/ikR99If3485QaXQB/images/api-keys-table.png?w=280\u0026fit=max\u0026auto=format\u0026n=ikR99If3485QaXQB\u0026q=85\u0026s=0ba5f943d817c5df21879c13bbc1385d 280w, https://mintcdn.com/aporia/ikR99If3485QaXQB/images/api-keys-table.png?w=560\u0026fit=max\u0026auto=format\u0026n=ikR99If3485QaXQB\u0026q=85\u0026s=1f420c4e3d0b3f7add0c252d670b7da9 560w, https://mintcdn.com/aporia/ikR99If3485QaXQB/images/api-keys-table.png?w=840\u0026fit=max\u0026auto=format\u0026n=ikR99If3485QaXQB\u0026q=85\u0026s=d9f8db8e3e1bc4e76042662a1cc03154 840w, https://mintcdn.com/aporia/ikR99If3485QaXQB/images/api-keys-table.png?w=1100\u0026fit=max\u0026auto=format\u0026n=ikR99If3485QaXQB\u0026q=85\u0026s=7efad16fe1d7ad4d2124a749668af9ba 1100w, https://mintcdn.com/aporia/ikR99If3485QaXQB/images/api-keys-table.png?w=1650\u0026fit=max\u0026auto=format\u0026n=ikR99If3485QaXQB\u0026q=85\u0026s=5a29e811fd2749d2e03b304b29572d41 1650w, https://mintcdn.com/aporia/ikR99If3485QaXQB/images/api-keys-table.png?w=2500\u0026fit=max\u0026auto=format\u0026n=ikR99If3485QaXQB\u0026q=85\u0026s=f623ccb4293b469d8ac8dbff72654174 2500w`}),`\n`,_jsx(Heading,{level:`3`,id:`step-2-integrate-into-your-code`,children:`Step 2: Integrate into Your Code`}),`\n`,_jsxs(_components.ol,{children:[`\n`,_jsx(_components.li,{children:`Locate the section in your codebase where you use the OpenAI’s API.`}),`\n`,_jsxs(_components.li,{children:[`Replace the existing `,_jsx(_components.code,{children:`base_url`}),` in your code with the URL copied from the Aporia dashboard.`]}),`\n`,_jsxs(_components.li,{children:[`Add the `,_jsx(_components.code,{children:`X-APORIA-API-KEY`}),` header to your HTTP requests using the `,_jsx(_components.code,{children:`default_headers`}),` parameter provided by OpenAI’s SDK.`]}),`\n`]}),`\n`,_jsx(Heading,{level:`2`,id:`code-example`,children:`Code Example`}),`\n`,_jsx(_components.p,{children:`Here is a basic example of how to configure the OpenAI client to use Aporia’s OpenAI Proxy method:`}),`\n`,_jsxs(CodeGroup,{children:[_jsx(CodeBlock,{filename:`Python (OpenAI)`,numberOfLines:`18`,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:`18`,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:` OpenAI`})]}),`\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:` OpenAI(`})]}),`\n`,_jsxs(_components.span,{className:`line`,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:`'\u003cyour 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:`#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:`'\u003cthe copied base URL>'`}),_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:` default_headers`}),_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:`'X-APORIA-API-KEY'`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`'\u003cyour Aporia API key>'`}),_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`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`chat_completion `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_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-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:`#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:` \"role\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"user\"`}),_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:`\"Hello world\"`}),_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`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:` user`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"\u003cend-user ID>\"`}),_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(CodeBlock,{filename:`Node.js (OpenAI)`,numberOfLines:`15`,language:`javascript`,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:`javascript`,children:_jsxs(_components.code,{language:`javascript`,numberOfLines:`15`,children:[_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\":`#9CDCFE`},children:` OpenAI`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:` from`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"openai\"`}),_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:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`const`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#4FC1FF`},children:` openai`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:` =`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:` new`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:` OpenAI`}),_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:` apiKey:`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"\u003cyour 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\":`#9CDCFE`},children:` baseURL:`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"\u003cthe copied URL>\"`}),_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:` defaultHeaders:`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` {`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"X-APORIA-API-KEY\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`:`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"\u003cyour Aporia API key>\"`}),_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`,_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:` function`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:` chat`}),_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\":`#569CD6`},children:` const`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#4FC1FF`},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\":`#9CDCFE`},children:` openai`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`chat`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`completions`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`create`}),_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:` messages:`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` [{ `}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`role:`}),_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:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`content:`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"You are a helpful assistant.\"`}),_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:` model:`}),_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:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` user:`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"\u003cend-user ID>\"`}),_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(CodeBlock,{filename:`LangChain.js`,numberOfLines:`16`,language:`javascript`,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:`javascript`,children:_jsxs(_components.code,{language:`javascript`,numberOfLines:`16`,children:[_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:` { `}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`ChatOpenAI`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` } `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`from`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"@langchain/openai\"`}),_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:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`const`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#4FC1FF`},children:` model`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:` =`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:` new`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:` ChatOpenAI`}),_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:` apiKey:`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"\u003cyour 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\":`#9CDCFE`},children:` configuration:`}),_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:` baseURL:`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"\u003cthe copied URL>\"`}),_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:` defaultHeaders:`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` {`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"X-APORIA-API-KEY\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`:`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"\u003cyour Aporia API key>\"`}),_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:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` user:`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"\u003cend-user ID>\"`}),_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`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`const`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#4FC1FF`},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\":`#9CDCFE`},children:` model`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`invoke`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"What would be a good company name a company that makes colorful socks?\"`})}),`\n`,_jsx(_components.span,{className:`line`,children:_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\":`#9CDCFE`},children:`console`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`log`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`response`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`);`})]}),`\n`]})})})]}),`\n`,_jsx(Heading,{level:`2`,id:`azure-openai`,children:`Azure OpenAI`}),`\n`,_jsxs(_components.p,{children:[`To integrate Aporia with Azure OpenAI, use the `,_jsx(_components.code,{children:`X-AZURE-OPENAI-ENDPOINT`}),` header to specify your Azure OpenAI endpoint.`]}),`\n`,_jsx(CodeGroup,{children:_jsx(CodeBlock,{filename:`Python (Azure OpenAI)`,numberOfLines:`23`,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:`23`,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:` AzureOpenAI`})]}),`\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:` AzureOpenAI(`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:` azure_endpoint`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"\u003cAporia base URL>/azure\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#6E7781`,\"--shiki-dark\":`#6A9955`},children:`# Note the /azure!`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:` azure_deployment`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"\u003cAzure deployment>\"`}),_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:` api_version`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"\u003cAzure API version>\"`}),_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:` api_key`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"\u003cAzure API key>\"`}),_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:` default_headers`}),_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:` \"X-APORIA-API-KEY\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"\u003cyour Aporia API key>\"`}),_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:` \"X-AZURE-OPENAI-ENDPOINT\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"\u003cyour Azure OpenAI endpoint>\"`}),_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`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`chat_completion `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_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-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:`#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:` \"role\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"user\"`}),_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:`\"Hello world\"`}),_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`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:` user`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"\u003cend-user ID>\"`}),_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`]})})})})]})}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":"OpenAI Proxy","description":null,"href":"/fundamentals/integration/openai-proxy"}}},"mdxSourceWithNoJs":null},"mdxExtracts":{"tableOfContents":[{"title":"Overview","slug":"overview","depth":2,"children":[]},{"title":"Prerequisites","slug":"prerequisites","depth":2,"children":[]},{"title":"Integration Guide","slug":"integration-guide","depth":2,"children":[{"title":"Step 1: Gather Aporia’s Base URL and API Key","slug":"step-1-gather-aporia’s-base-url-and-api-key","depth":3,"children":[]},{"title":"Step 2: Integrate into Your Code","slug":"step-2-integrate-into-your-code","depth":3,"children":[]}]},{"title":"Code Example","slug":"code-example","depth":2,"children":[]},{"title":"Azure OpenAI","slug":"azure-openai","depth":2,"children":[]}],"codeExamples":{}},"jsLinks":[],"dynamicCss":".mint-block {\n display: block\n}\n.mint-rounded-md {\n border-radius: 0.375rem\n}","subdomain":"aporia","siteName":"Aporia","title":"OpenAI Proxy - Aporia","navMaps":{"firstHrefInVersion":{},"firstHrefInLanguage":{}},"lastModified":"2026-01-07T01:42:05.842Z","originalFileLocation":"fundamentals/integration/openai-proxy.mdx"},"headHtml":"\u003cscript data-mint-head>(function(){var d=document.documentElement,p=\"light\";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=\"light\"}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=\"Aporia\">\u003cmeta data-mint-head name=\"generator\" content=\"Mintlify\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"192x192\" href=\"/mintlify-assets/_mintlify/favicons/aporia/H_DPHe6g25nENpoI/_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/aporia/H_DPHe6g25nENpoI/_generated/favicon/apple-touch-icon.png\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"16x16\" href=\"/mintlify-assets/_mintlify/favicons/aporia/H_DPHe6g25nENpoI/_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/aporia/H_DPHe6g25nENpoI/_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/aporia/H_DPHe6g25nENpoI/_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/aporia/H_DPHe6g25nENpoI/_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/aporia/H_DPHe6g25nENpoI/_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/aporia/H_DPHe6g25nENpoI/_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/aporia/H_DPHe6g25nENpoI/_generated/favicon-dark/favicon.ico\" media=\"(prefers-color-scheme: dark)\">\u003cmeta data-mint-head property=\"og:title\" content=\"OpenAI Proxy - Aporia\">\u003cmeta data-mint-head property=\"og:site_name\" content=\"Aporia\">\u003cmeta data-mint-head property=\"og:url\" content=\"https://gr-docs.aporia.com/fundamentals/integration/openai-proxy\">\u003cmeta data-mint-head property=\"og:type\" content=\"website\">\u003cmeta data-mint-head property=\"og:image\" content=\"https://aporia.mintlify.app/_mintlify/api/og/v2?division=Integrate+to+LLM+app\u0026amp;title=OpenAI+Proxy\u0026amp;theme=c6aa2364538a9990f23bac42\u0026amp;signature=bb31ae9bbf9cb827e64a0393c5e5fdafc4c5b9d8889036aa594cb95eaa2118df\">\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=\"OpenAI Proxy - Aporia\">\u003cmeta data-mint-head name=\"twitter:image\" content=\"https://aporia.mintlify.app/_mintlify/api/og/v2?division=Integrate+to+LLM+app\u0026amp;title=OpenAI+Proxy\u0026amp;theme=c6aa2364538a9990f23bac42\u0026amp;signature=bb31ae9bbf9cb827e64a0393c5e5fdafc4c5b9d8889036aa594cb95eaa2118df\">\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/aporia/H_DPHe6g25nENpoI/_generated/favicon/browserconfig.xml\">\u003cmeta data-mint-head name=\"apple-mobile-web-app-title\" content=\"Aporia\">\u003cmeta data-mint-head name=\"msapplication-TileColor\" content=\"#0D9373\">\u003clink data-mint-head rel=\"canonical\" href=\"https://gr-docs.aporia.com/fundamentals/integration/openai-proxy\">\u003clink data-mint-head rel=\"alternate\" type=\"application/xml\" href=\"/sitemap.xml\">\u003clink data-mint-head rel=\"alternate\" type=\"text/markdown\" href=\"/fundamentals/integration/openai-proxy.md\">\u003cscript data-mint-head type=\"application/ld+json\">{\"@context\":\"https://schema.org\",\"@graph\":[{\"@type\":\"Organization\",\"@id\":\"https://gr-docs.aporia.com/#organization\",\"name\":\"Aporia\",\"url\":\"https://gr-docs.aporia.com\",\"logo\":{\"@type\":\"ImageObject\",\"url\":\"https://mintcdn.com/aporia/67z2pg4gk3aiMXT7/logo/light.svg?fit=max\u0026auto=format\u0026n=67z2pg4gk3aiMXT7\u0026q=85\u0026s=966825e33ef682d0fdd1826ea5b680b7\"}},{\"@type\":\"WebSite\",\"@id\":\"https://gr-docs.aporia.com#website\",\"name\":\"Aporia\",\"url\":\"https://gr-docs.aporia.com\",\"publisher\":{\"@id\":\"https://gr-docs.aporia.com/#organization\"}},{\"@type\":\"WebPage\",\"@id\":\"https://gr-docs.aporia.com/fundamentals/integration/openai-proxy#webpage\",\"url\":\"https://gr-docs.aporia.com/fundamentals/integration/openai-proxy\",\"name\":\"OpenAI Proxy\",\"dateModified\":\"2026-01-07T01:42:05.842Z\",\"isPartOf\":{\"@id\":\"https://gr-docs.aporia.com#website\"},\"breadcrumb\":{\"@id\":\"https://gr-docs.aporia.com/fundamentals/integration/openai-proxy#breadcrumb\"}},{\"@type\":\"BreadcrumbList\",\"@id\":\"https://gr-docs.aporia.com/fundamentals/integration/openai-proxy#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Fundamentals\",\"item\":\"https://gr-docs.aporia.com/fundamentals/projects\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Integrate to LLM app\",\"item\":\"https://gr-docs.aporia.com/fundamentals/integration/integration-overview\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"OpenAI Proxy\",\"item\":\"https://gr-docs.aporia.com/fundamentals/integration/openai-proxy\"}]},{\"@type\":[\"Article\",\"TechArticle\"],\"@id\":\"https://gr-docs.aporia.com/fundamentals/integration/openai-proxy#article\",\"headline\":\"OpenAI Proxy\",\"name\":\"OpenAI Proxy\",\"url\":\"https://gr-docs.aporia.com/fundamentals/integration/openai-proxy\",\"mainEntityOfPage\":{\"@id\":\"https://gr-docs.aporia.com/fundamentals/integration/openai-proxy#webpage\"},\"dateModified\":\"2026-01-07T01:42:05.842Z\",\"publisher\":{\"@id\":\"https://gr-docs.aporia.com/#organization\"},\"isPartOf\":{\"@id\":\"https://gr-docs.aporia.com#website\"}}]}\u003c/script>\u003cscript data-mint-head type=\"application/ld+json\">{\"@context\":\"https://schema.org\",\"@type\":\"WebSite\",\"name\":\"Aporia\",\"creator\":{\"@type\":\"Organization\",\"name\":\"Mintlify\",\"url\":\"https://mintlify.com\"}}\u003c/script>","siteName":"Aporia","nav":{"global":{"anchors":[{"anchor":"Guardrails Dashboard","href":"https://guardrails.aporia.com/","icon":"shield"},{"anchor":"GenAI Academy","href":"https://www.aporia.com/learn/generative-ai/","icon":"graduation-cap"},{"anchor":"ML Observability Docs","href":"https://docs.aporia.com","icon":"heart-pulse"},{"anchor":"Blog","href":"https://www.aporia.com/blog/","icon":"newspaper"}]},"tabs":[{"tab":"Documentation","groups":[{"group":"Get Started","pages":[{"title":"Introduction","href":"/get-started/introduction"},{"title":"Quickstart","href":"/get-started/quickstart"},{"title":"Why Guardrails?","href":"/get-started/why-guardrails"}]},{"group":"Fundamentals","pages":[{"title":"Projects overview","href":"/fundamentals/projects"},{"title":"Extractions","href":"/fundamentals/extractions"},{"group":"Integrate to LLM app","pages":[{"title":"Overview","description":"This guide provides an overview and comparison between the different integration methods provided by Aporia Guardrails. ","href":"/fundamentals/integration/integration-overview"},{"title":"OpenAI Proxy","href":"/fundamentals/integration/openai-proxy"},{"title":"REST API","description":null,"href":"/fundamentals/integration/rest-api"}]},{"title":"Customization","href":"/fundamentals/customization"},{"title":"Streaming support","href":"/fundamentals/streaming"},{"group":"AI Gateway integration","pages":[{"title":"Overview","href":"/fundamentals/ai-gateways/overview"},{"title":"LiteLLM integration","href":"/fundamentals/ai-gateways/litellm"},{"title":"Portkey integration","href":"/fundamentals/ai-gateways/portkey"},{"title":"Cloudflare AI Gateway","href":"/fundamentals/ai-gateways/cloudflare"}]},{"title":"Team Management","href":"/fundamentals/team-management"}]},{"group":"Policies","pages":[{"title":"AGT Test","href":"/policies/agt-test"},{"title":"Toxicity","href":"/policies/toxicity"},{"title":"RAG Hallucination","href":"/policies/rag-hallucination"},{"title":"Restricted Phrases","href":"/policies/restricted-phrases"},{"title":"Prompt Injection","href":"/policies/prompt-injection"},{"title":"Allowed Topics","href":"/policies/allowed-topics"},{"title":"Restricted Topics","href":"/policies/restricted-topics"},{"group":"Text-to-SQL Security","pages":[{"title":"Overview","href":"/policies/sql-security"},{"title":"Allowed Tables","href":"/policies/sql-allowed-tables"},{"title":"Load Limit","href":"/policies/sql-load-limit"},{"title":"Read-Only Access","href":"/policies/sql-read-only-access"},{"title":"Restricted Tables","href":"/policies/sql-restricted-tables"}]},{"title":"Competition Discussion","href":"/policies/competition"},{"title":"PII","href":"/policies/pii"},{"title":"Task Adherence","href":"/policies/task-adherence"},{"title":"Custom Policy","href":"/policies/custom-policy"},{"title":"Language Mismatch","href":"/policies/language-mismatch"},{"title":"Denial of Service","href":"/policies/denial-of-service"},{"title":"Cost Harvesting","href":"/policies/cost-harvesting"},{"title":"Rag Access Control","href":"/policies/rag-access-control"},{"title":"Tool Parameter Correctness","href":"/policies/tool-parameter-correctness"}]},{"group":"Observability","pages":[{"title":"Dashboard","href":"/observability/dashboard"},{"title":"Session Explorer","href":"/observability/session-explorer"},{"title":"Dataset Upload","href":"/observability/dataset-upload"}]},{"group":"REST API","pages":[{"title":"Projects API","href":"/crud-operations/projects-and-project-policies"},{"title":"Policies API","href":"/crud-operations/policy-catalog-and-custom-policies"}]},{"group":"Enterprise","pages":[{"title":"Security \u0026 Compliance","href":"/enterprise/security-and-compliance"},{"title":"Self Hosting","href":"/enterprise/self-hosting"},{"title":"Single sign-on (SSO)","href":"/enterprise/single-sign-on"},{"title":"Multi-factor Authentication (MFA)","href":"/enterprise/multi-factor-authentication"},{"title":"Directory sync","href":"/enterprise/directory-sync"}]},{"group":"Release Notes","pages":[{"title":"December 1st 2024","href":"/release-notes/rn-28-11-2024"},{"title":"October 31st 2024","href":"/release-notes/rn-31-10-2024"},{"title":"September 19th 2024","href":"/release-notes/release-notes-19-09-2024"},{"title":"September 3rd 2024","href":"/release-notes/release-notes-03-09-2024"},{"title":"August 20th 2024","href":"/release-notes/release-notes-20-08-2024"},{"title":"August 6th 2024","href":"/release-notes/release-notes-28-07-2024"},{"title":"July 17th 2024","href":"/release-notes/rn-21-07-2024"},{"title":"June 1st 2024","href":"/release-notes/rn-01-06-2024"},{"title":"May 1st 2024","href":"/release-notes/rn-01-05-2024"},{"title":"April 1st 2024","href":"/release-notes/rn-01-04-2024"},{"title":"March 1st 2024","href":"/release-notes/rn-01-03-2024"},{"title":"February 1st 2024","href":"/release-notes/rn-01-02-2024"}]}]},{"tab":"Examples","pages":[{"title":"Examples","href":"/examples/embedchain-chainlit"}]}]},"basePath":"","title":"OpenAI Proxy - Aporia","buildId":"dpl_36EDyZCDfRuoUD9af5CH4M1bqY2h","deploymentId":"dpl_36EDyZCDfRuoUD9af5CH4M1bqY2h","dynamics":["a74be98ba7"],"chunks":["zoom-image-lightbox-eHyQ0tlO.js","lightbox-handle-r17bVUz3.js"]}