For AI agents: a documentation index is available at the root level at /llms.txt and /llms-full.txt. Append /llms.txt to any URL for a page-level index, or .md for the markdown version of any page.
DASHBOARDPLAYGROUNDDOCSCOMMUNITYLOG IN
Guides and conceptsAPI ReferenceRelease NotesLLMUCookbooks
Guides and conceptsAPI ReferenceRelease NotesLLMUCookbooks
  • Get Started
    • Introduction
    • Installation
    • Creating a client
    • Playground
    • FAQs
  • Models
    • An Overview of Cohere's Models
    • Embed
    • Rerank
    • Aya
  • Text Generation
    • Introduction to Text Generation at Cohere
    • Using the Chat API
    • Streaming Responses
    • Structured Outputs
    • Predictable Outputs
    • Advanced Generation Parameters
    • Retrieval Augmented Generation (RAG)
    • Tool Use
    • Tokens and Tokenizers
    • Migrating from the Generate API to the Chat API
    • Summarizing Text
    • Safety Modes
  • Embeddings (Vectors, Search, Retrieval)
    • Introduction to Embeddings at Cohere
    • Semantic Search with Embeddings
    • Multimodal Embeddings
    • Batch Embedding Jobs
  • Going to Production
    • API Keys and Rate Limits
    • Going Live
    • Deprecations
    • How Does Cohere's Pricing Work?
  • Integrations
    • Integrating Embedding Models with Other Tools
    • Cohere and LangChain
    • LlamaIndex and Cohere
  • Deployment Options
    • Overview
    • SDK Compatibility
      • Cohere on AWS
        • Amazon Bedrock
        • Amazon SageMaker
      • Cohere on Azure
      • Cohere on Oracle Cloud Infrastructure (OCI)
  • Tutorials
    • Cookbooks
    • LLM University
    • Build Things with Cohere!
  • Responsible Use
    • Security
    • Usage Policy
    • Command A Technical Report
    • Command R and Command R+ Model Card
  • Cohere Labs
    • Cohere Labs Acceptable Use Policy
  • More Resources
    • Cohere Toolkit
    • Datasets
    • Improve Cohere Docs
LogoLogodocs
DASHBOARDPLAYGROUNDDOCSCOMMUNITYLOG IN
On this page
  • Prerequisites
  • Embeddings
  • Text Generation
  • Rerank
Deployment OptionsCloud AI ServicesCohere on AWS

Cohere Models on Amazon Bedrock

Was this page helpful?
Edit this page
Previous

An Amazon SageMaker Setup Guide

Next
Built with

In this guide, you’ll learn how to use Amazon Bedrock to deploy the Cohere Command, Embed, and Rerank models on the AWS cloud computing platform. The following models are available on Bedrock:

  • Command R
  • Command R+
  • Command Light
  • Command
  • Embed - English
  • Embed - Multilingual
  • Rerank v3.5

Note that the code snippets below are in Python, but you can find the equivalent code for other languages (if they’re supported) here.

Prerequisites

THese are the steps you’ll need to get set up in advance of running Cohere models on Amazon Bedrock.

  • Subscribe to Cohere’s models on Amazon Bedrock. For more details, see here.
  • You’ll also have to configure your authentication credentials for AWS. This document has more information.

Embeddings

You can use this code to invoke Cohere’s Embed English v3 model (cohere.embed-english-v3) or Embed Multilingual v3 model (cohere.embed-multilingual-v3) on Amazon Bedrock:

PYTHON
1import cohere
2
3co = cohere.BedrockClient(
4 aws_region="us-east-1",
5 aws_access_key="...",
6 aws_secret_key="...",
7 aws_session_token="...",
8)
9
10# Input parameters for embed. In this example we are embedding hacker news post titles.
11texts = [
12 "Interesting (Non software) books?",
13 "Non-tech books that have helped you grow professionally?",
14 "I sold my company last month for $5m. What do I do with the money?",
15 "How are you getting through (and back from) burning out?",
16 "I made $24k over the last month. Now what?",
17 "What kind of personal financial investment do you do?",
18 "Should I quit the field of software development?",
19]
20input_type = "clustering"
21truncate = "NONE" # optional
22model_id = (
23 "cohere.embed-english-v3" # or "cohere.embed-multilingual-v3"
24)
25
26# Invoke the model and print the response
27result = co.embed(
28 model=model_id,
29 input_type=input_type,
30 texts=texts,
31 truncate=truncate,
32) # aws_client.invoke_model(**params)
33
34print(result)

Note that we’ve released multimodal embeddings models that are able to handle images in addition to text. Find more information here.

Text Generation

You can use this code to invoke either Command R (cohere.command-r-v1:0), Command R+ (cohere.command-r-plus-v1:0), Command (cohere.command-text-v14), or Command light (cohere.command-light-text-v14) on Amazon Bedrock:

PYTHON
1import cohere
2
3co = cohere.BedrockClient(
4 aws_region="us-east-1",
5 aws_access_key="...",
6 aws_secret_key="...",
7 aws_session_token="...",
8)
9
10result = co.chat(
11 message="Write a LinkedIn post about starting a career in tech:",
12 model="cohere.command-r-plus-v1:0", # or 'cohere.command-r-v1:0'
13)
14
15print(result)

Rerank

You can use this code to invoke our latest Rerank models on Bedrock

PYTHON
1import cohere
2
3co = cohere.BedrockClientV2(
4 aws_region="us-west-2", # pick a region where the model is available
5 aws_access_key="...",
6 aws_secret_key="...",
7 aws_session_token="...",
8)
9
10docs = [
11 "Carson City is the capital city of the American state of Nevada.",
12 "The Commonwealth of the Northern Mariana Islands is a group of islands in the Pacific Ocean. Its capital is Saipan.",
13 "Capitalization or capitalisation in English grammar is the use of a capital letter at the start of a word. English usage varies from capitalization in other languages.",
14 "Washington, D.C. (also known as simply Washington or D.C., and officially as the District of Columbia) is the capital of the United States. It is a federal district.",
15 "Capital punishment has existed in the United States since beforethe United States was a country. As of 2017, capital punishment is legal in 30 of the 50 states.",
16]
17
18response = co.rerank(
19 model="cohere.rerank-v3-5:0",
20 query="What is the capital of the United States?",
21 documents=docs,
22 top_n=3,
23)
24
25print(response)