Elle Neal
7 min readFeb 8, 2023

--

3 Easy No-Code Steps to Build Your AI Integrated App using Retool and Cohere API

Introduction

Have you ever wanted to build your own application without having to write a single line of code? Look no further, as Retool and Cohere API are here to revolutionize the way you build and launch your apps.

Retool is a no-code development platform that enables developers to build and launch applications in a matter of minutes with its drag-and-drop building blocks, while Cohere provides access to large language models that can be used to generate or analyse text. In this blog post, we’ll show you how to build a simple app with Retool and Cohere API in just 3 easy steps. Whether you’re a developer, business owner, IT manager, student, or hobbyist, this post is for you. So let’s get started and bring your ideas to life!

Let’s build our own Playground to explore prompts!

Cohere-Prompts | Retool

Getting Started with Retool

Retool is a no-code development platform that allows developers to build and launch applications in a matter of minutes. The app builder includes drag-and-drop building blocks (e.g. components for tables, buttons, forms, charts) so you can assemble an app in minutes. With Retool, you can design, build, and test your application without writing any code. You can create custom interfaces, forms, and data tables and link them to external APIs to add functionalities to your app.

Create a login for the tutorial: Sign up here to get a free account Retool | Build internal tools, remarkably fast.

Retool | Build internal tools, remarkably fast.
Pricing (retool.com)

Getting Started with the Cohere API

Cohere provide access to large language models that can be used to generate or analyse text to do things like write copy, moderate content, classify data and extract information, all at a massive scale. Cohere offer a generous free developer tier, meaning you can build and test your ideas quickly and with no cost.

Join the Discord channel here https://discord.gg/co-mmunity to join a supportive and innovative community of AI developers and be the first to know about exciting product developments.

The mission with Cohere is to really just give technology language. The goal is to put these large language models into more hands. Two of the reasons are there’s a huge compute barrier and only a tiny fraction of developers know how to use them.

AIDAN GOMEZ [CEO Cohere]

Create a login for the tutorial: Sign up here to get a free account Register | Cohere

Register | Cohere
Pricing — Custom Models, Affordable Pricing | Cohere

Let’s Start Building!

3 Steps to Build a Simple App with Retool and Cohere API

After creating a Retool and Cohere account for free, follow this 3 step process to build your free, no code, AI integrated application.

  • Build a user interface in retool
  • Create an API query to call the Cohere API and generate a response
  • Connect API to User Interface

1. Build a User Interface in Retool

If you haven’t already done so, create your free account with retool here.

First, we are going to create a new app in Retool and add our drag and drop components.

  • Locate the Apps page and select create a new app, click on Create New > App and give it a name.
Top right corner of dashboard
Create New > App
  • You will now see the main canvas where you will build your interface
  • Drag 2 x Text Area components and 1 x button component to the middle of the canvas

Watch the video to see how to do this.

  • Select the first label box and rename it to ‘prompt’

Watch the video to see how to do this.

Nice work! We now have a UI where we can enter a prompt, select a button to send an API query and see the generated response from the Cohere API.

2. Create an API query to call the Cohere API and generate a response

If you haven’t already done so, create your free account with Cohere here.

This is where we are create an API query in Retool to call Co.Generate from Cohere’s API.

This endpoint generates realistic text conditioned on a given input. You can test this output and parameters using the Cohere Playground | Generate.

Stick with me guys, this bit is super easy! No previous knowledge of API’s needed.

  • Click on the retool icon on the top left side of the page and select Query Library > New this will open up a new tab in your browser.
  • Rename the query to cohere_api
  • add the API parameters exactly as you see them below, use the screenshot to compare.

Resource: REST

Action Type: POST | https://api.cohere.ai/generate

Headers

  • Authorisation: Bearer {add your specific Trial API Key} | (exclude the braces) API Keys | Cohere
  • Content-Type: application/json
  • Cohere-Version: 2021–11–08

Body: JSON

Your completed query should look like this

Testing

Now lets test the query works, you’ve got this!

  • Remove the {{prompt.value}} and replace it with the words ‘Test’
  • Click the play button on the top left hand side of the page.
  • You should see a result like this, if you do not then go back and check the parameters carefully
  • Add the words {{prompt.value}} back into the prompt parameter
  • Click save and share, your API is ready! Return back to the tab with your Retool canvas.

3. Connect API to User Interface

Finally, we are going to connect the Prompt component to the API query and return the API response to the Generated Response component within your Retool canvas.

Adding the new Cohere API query to the app.

  • Open the bottom panel by selecting the middle icon at the top of the page
  • To add our query, on the bottom left click the + and select Import from Query Library. If there are any other queries listed here, delete them from the list.
  • Select the dropdown to ‘Run query only when manually triggered’
  • Select query: cohere_api
  • Add the {{prompt.value}}
  • Click Save and Run, you should see this message

Watch the video to see how to do this.

Returning the generated response to the user

Ok, this is the exciting bit! We get to see our app in action and return a generated response from Cohere.

  • select the Generated Response component called textArea2
  • enter {{query1.data.generations[0].text}} into the default value for the textArea2 component
  • Select the button component, within Interaction select + Add. This will connect to our query
  • add a prompt and click the button to generate a response | Examples | Cohere

Try this prompt: Write a LinkedIn post about how to start a career in tech:

Watch the video to see how to do this.

Here is an example app that builds on these foundations, I have added example presets and parameters for the user to choose from and there are 5 reponses provided in a table. We are just scratching the surface here, there are so many possibilities!

Cohere Prompt Explorer App

Next Steps

With Retool and Cohere API, creating your own AI infused application has never been easier. Whether you’re a developer, business owner, IT manager, student, or hobbyist, you can create powerful and efficient applications in a matter of minutes without having to write any code.

Now you have the basics, anything is possible. Check out the Retool and Cohere documentation and get building!

I can’t wait to see what you build, join Cohere’s Discord channel and share your apps with the community.

Elle Neal | LinkedIn — connect with me on LinkedIn

--

--

Elle Neal

AI & Data Science enthusiast, passionate STEM Ambassador teaching Lego robotics and coding to children and building AI apps for neurodiverse learners.