Quick Start
Adding Cohere to your web app
    1.
    Visit the Cohere dashboard to retrieve your API key. If you haven't previously connected a session, you should see it in the main screen. Otherwise, you can find it in the settings page.
    2.
    Add Cohere to your web application via NPM/Yarn or a script tag. Cohere.init should be called on the web browser, not the server.
NPM/Yarn
Script Tag
Install the cohere-js package via NPM:
1
npm install cohere-js # or, yarn add cohere-js
Copied!
Then, import Cohere and call Cohere.init like so:
1
import Cohere from "cohere-js";
2
Cohere.init("INSERT_API_KEY_HERE");
Copied!
Paste your Cohere snippet into the <head> tag of your site:
1
<script>!function(){var e=window.Cohere=window.Cohere||[];if(e.invoked)console.error("Tried to load Cohere twice");else{e.invoked=!0,e.snippet="0.2",e.methods=["init","identify","stop","showCode","getSessionUrl","makeCall","addCallStatusListener","removeCallStatusListener","widget","addSessionUrlListener","removeSessionUrlListener",],e.methods.forEach(function(o){e[o]=function(){var t=Array.prototype.slice.call(arguments);t.unshift(o),e.push(t)}});var o=document.createElement("script");o.type="text/javascript",o.async=!0,o.src="https://static.cohere.so/main.js",o.crossOrigin="anonymous";var t=document.getElementsByTagName("script")[0];t.parentNode.insertBefore(o,t)}}();</script>
2
<script>window.Cohere.init("INSERT_API_KEY_HERE");</script>
Copied!
If you're working with platforms like Bubble or Shopify, head to the Platform Integrations section on the left sidebar.
After adding the script, you should see your session in the Cohere dashboard! If you're still having trouble, check out the troubleshooting section.
You can now identify your users (highly recommended) and exclude sensitive elements.
Last modified 2mo ago
Copy link