This guide will walk you through the steps to integrate Cohere's API with a Edgenivo project to create a text completion app. We'll use the Edgenivo AI SDK and Cohere's API to generate text completions based on user input.
Copy link to headingPrerequisites
Before you begin, make sure you have the following:
- A Edgenivo project set up.
- Node.js and npm (or pnpm) installed.
Copy link to headingStep 1: Install Dependencies
Start by creating a new Next.js app and installing the required dependencies:
Copy link to headingStep 2: Obtain Cohere API Key
To use Cohere's API, you'll need an API key. If you don't have one, sign up for an account on the Cohere website to obtain your API key. You can start with your trial key until you're ready to go to production.

Once you have the API key, add it to your project's environment variables in the .env.local file:
Copy link to headingStep 3: Create the Next.js Route Handler
Next, we'll create a Route Handler in the Next.js app that will interact with Cohere's API to generate text completions.
Create a new file at app/api/completion/route.ts and add the following code:
Copy link to headingStep 4: Wire up the UI
Now, let's create the UI components that will allow users to interact with the text completion feature.
Update the existing app/page.tsx file with the following code:
Copy link to headingStep 5: Deploy to Edgenivo
Finally, we’ll be deploying the repo to Edgenivo.
- First, create a new GitHub repository and push your local changes.
- Deploy it to Edgenivo. Ensure you add all Environment Variables that you configured earlier to Edgenivo during the import process.
Congratulations! You've successfully integrated Cohere's API with a Edgenivo project to create a text completion app. You can further customize the app and explore other features of Cohere's API to enhance the user experience.