
{"id":21521,"date":"2026-03-04T11:08:10","date_gmt":"2026-03-04T11:08:10","guid":{"rendered":"https:\/\/carloethics.ai\/docs\/connecting-to-langchain\/"},"modified":"2026-03-04T11:14:29","modified_gmt":"2026-03-04T11:14:29","slug":"connecting-to-langchain","status":"publish","type":"docs","link":"https:\/\/carloethics.ai\/ja\/docs\/connecting-to-langchain\/","title":{"rendered":"Connecting to LangChain"},"content":{"rendered":"<p><strong>Connecting to LangChain<\/strong><\/p>\n<p>Carlo can integrate with LangChain to monitor and enforce governance policies across your AI pipelines.<\/p>\n<p>This allows you to validate prompts, responses, and model outputs before they reach the user.<\/p>\n<p>Prerequisites<\/p>\n<p>Before connecting Carlo to LangChain, ensure:<\/p>\n<p>\u2022 Carlo SDK is installed<br \/>\n\u2022 LangChain is installed<br \/>\n\u2022 You have your Carlo API key<\/p>\n<p><strong>Step 1<\/strong>: Install Dependencies<\/p>\n<p>Install both Carlo and LangChain.<\/p>\n<p>pip install carlo-ai langchain<\/p>\n<p><strong>Step 2<\/strong>: Import Libraries<\/p>\n<p>Import the required modules.<\/p>\n<p>import carlo<br \/>\nfrom langchain.llms import OpenAI<\/p>\n<p><strong>Step 3<\/strong>: Initialize Carlo Guardian<\/p>\n<p>Create a Guardian instance.<\/p>\n<p>guardian = carlo.Guardian(<br \/>\napi_key=&#8221;YOUR_API_KEY&#8221;<br \/>\n)<\/p>\n<p><strong>Step 4<\/strong>: Wrap Your LangChain Model<\/p>\n<p>Connect the LangChain model with Carlo governance.<\/p>\n<p>llm = OpenAI()<\/p>\n<p>secured_llm = guardian.wrap(llm)<\/p>\n<p><strong>Step 5<\/strong>: Send a Prompt<\/p>\n<p>Now all prompts will pass through Carlo&#8217;s policy engine.<\/p>\n<p>response = secured_llm(&#8220;Explain artificial intelligence.&#8221;)<\/p>\n<p>print(response)<\/p>\n<p><strong>What Happens Now<\/strong><\/p>\n<p>Carlo will automatically:<\/p>\n<p>\u2022 Scan prompts for unsafe input<br \/>\n\u2022 Enforce governance policies<br \/>\n\u2022 Log all requests for auditing<\/p>\n<p><strong>Next Step<\/strong><\/p>\n<p>Once LangChain is connected, you can enable logging and monitoring.<br \/>\nContinue to:<br \/>\nSetting up audit logs<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Connecting to LangChain Carlo can integrate with LangChain to monitor and enforce governance policies across y&#8230;<\/p>\n","protected":false},"author":2,"featured_media":0,"parent":0,"menu_order":6,"comment_status":"open","ping_status":"closed","template":"","doc_tag":[],"class_list":["post-21521","docs","type-docs","status-publish","hentry","no-post-thumbnail"],"acf":[],"_links":{"self":[{"href":"https:\/\/carloethics.ai\/ja\/wp-json\/wp\/v2\/docs\/21521","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/carloethics.ai\/ja\/wp-json\/wp\/v2\/docs"}],"about":[{"href":"https:\/\/carloethics.ai\/ja\/wp-json\/wp\/v2\/types\/docs"}],"author":[{"embeddable":true,"href":"https:\/\/carloethics.ai\/ja\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/carloethics.ai\/ja\/wp-json\/wp\/v2\/comments?post=21521"}],"version-history":[{"count":0,"href":"https:\/\/carloethics.ai\/ja\/wp-json\/wp\/v2\/docs\/21521\/revisions"}],"wp:attachment":[{"href":"https:\/\/carloethics.ai\/ja\/wp-json\/wp\/v2\/media?parent=21521"}],"wp:term":[{"taxonomy":"doc_tag","embeddable":true,"href":"https:\/\/carloethics.ai\/ja\/wp-json\/wp\/v2\/doc_tag?post=21521"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}