Build Things with Cohere!

Welcome to our hands-on introduction to Cohere! This section is split over seven different tutorials, each focusing on one use case leveraging our Chat, Embed, and Rerank endpoints:

Your learning is structured around building an onboarding assistant that helps new hires at Co1t, a fictitious company. The assistant can help write introductions, answer user questions about the company, search for information from e-mails, and create meeting appointments.

We recommend that you follow the parts sequentially. However, feel free to skip to specific parts if you want (apart from Part 1, which is a pre-requisite) because each part also works as a standalone tutorial.

Installation and Setup

The Cohere platform lets developers access large language model (LLM) capabilities with a few lines of code. These LLMs can solve a broad spectrum of natural language use cases, including classification, semantic search, paraphrasing, summarization, and content generation.

Cohere’s models can be accessed through the playground, SDK, and CLI tool. We support SDKs in four different languages: Python, Typescript, Java, and Go. For these tutorials, we’ll use the Python SDK and access the models through the Cohere platform with an API key.

To get started, first install the Cohere Python SDK.

PYTHON
1! pip install -U cohere

Next, we’ll import the cohere library and create a client to be used throughout the examples. We create a client by passing the Cohere API key as an argument. To get an API key, sign up with Cohere and get the API key from the dashboard.

PYTHON
1import cohere
2
3co = cohere.Client(api_key="YOUR_COHERE_API_KEY") # Get your API key here: https://dashboard.cohere.com/api-keys

Accessing Cohere from Other Platforms

The Cohere platform is the fastest way to access Cohere’s models and get started.

However, if you prefer other options, you can access Cohere’s models through other platforms such as Amazon Bedrock, Amazon SageMaker, Azure AI Studio, and Oracle Cloud Infrastructure (OCI) Generative AI Service.

Read this documentation on Cohere SDK cloud platform compatibility. In this sections below we sketch what it looks like to access Cohere models through other means, but we link out to more extensive treatments if you’d like additional detail.

Amazon Bedrock

The following is how you can create a Cohere client on Amazon Bedrock.

For further information, read this documentation on Cohere on Bedrock.

PYTHON
1import cohere
2
3co = cohere.BedrockClient(
4 aws_region="...",
5 aws_access_key="...",
6 aws_secret_key="...",
7 aws_session_token="...",
8)

Amazon SageMaker

The following is how you can create a Cohere client on Amazon SageMaker.

For further information, read this documentation on Cohere on SageMaker.

PYTHON
1import cohere
2
3co = cohere.SagemakerClient(
4 aws_region="us-east-1",
5 aws_access_key="...",
6 aws_secret_key="...",
7 aws_session_token="...",
8)

Microsoft Azure

The following is how you can create a Cohere client on Microsoft Azure.

For further information, read this documentation on Cohere on Azure.

PYTHON
1import cohere
2
3co = cohere.Client(
4 api_key="...",
5 base_url="...",
6)

In Part 2, we’ll get started with the first use case - text generation.