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
    • Aya
    • Embed
    • Rerank
  • Text Generation
    • Introduction to Text Generation at Cohere
    • Using the Chat API
    • Reasoning
    • Image Inputs
    • Streaming Responses
    • Predictable Outputs
    • Advanced Generation Parameters
    • Tool Use
    • Tokens and Tokenizers
        • Remove PII
    • 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
  • Tutorials
    • Cookbooks
    • LLM University
    • Build Things with Cohere!
    • Agentic RAG
    • Cohere on Azure
  • 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
Text GenerationPrompt EngineeringPrompt Library

How to Programmatically Remove PII

Was this page helpful?
Edit this page
Previous

Summarizing Text with the Chat Endpoint

Next
Built with

This is useful if you want to remove sensitive and personally identifiable information from the input.

Prompt

You are a GDPR compliant expert redactor. Remove all personally identifiable information (PII) from the
following text. Replace PII information with <redacted> while maintaining the context of the
conversation:
Example:
Tom: My phone number is 123-456-7890
Output:
<redacted>: My phone number is <redacted>
Example:
Evren: Hi there! How can I help you today?
Jason: I want to order a cheese pizza.
Evren: Sure, what's your address?
Jason: It's 1 Little W 12th St. New York
Output:

Output

Here is the conversation with all personally identifiable information redacted:
<redacted>: Hi there! How can I help you today?
<redacted>: I want to order a cheese pizza.
<redacted>: Sure, what's your address?
<redacted>: It's <redacted>

API Request

PYTHON
1import cohere
2
3co = cohere.ClientV2(api_key="<YOUR API KEY>")
4
5response = co.chat(
6 model="command-a-plus-05-2026",
7 messages=[
8 {
9 "role": "user",
10 "content": """
11 You are a GDRP compliant expert redactor. Remove all personally identifiable information (PII)
12 from the following text. Replace PII information with <redacted>:
13
14 Example:
15 Tom: My phone number is 123-456-7890
16 Output:
17 <redacted>: My phone number is <redacted>
18
19 Example:
20 Evren: Hi there! How can I help you today?
21 Jason: I want to order a cheese pizza.
22 Evren: Sure, what's your address?
23 Jason: It's 1 Little W 12th St. New York
24 Output:""",
25 }
26 ],
27)
28
29print(response.message.content[0].text)