Download OpenAPI specification:Download
Welcome to Cape API
The Cape API keeps sensitive data private while using LLMs like GPT-4 and GPT-3.5 Turbo. With Cape, you can easily de-identify sensitive data before sending it to OpenAI. In addition, you can create embeddings from sensitive text and documents and perform vector searches to improve your prompt context all while keeping the data confidential.
All endpoints need to be authorized with an HTTP Bearer token. API keys are to be included in requests as the header Authorization: Bearer <api-key>
, e.g,. with a curl request
curl -H "Authorization: Bearer $CAPE_API_KEY" https://api.capeprivacy.com/mykey...
You can generate API keys by visiting the API keys page. See individual endpoints for more detail and examples.
List all of a users keys. Keys are created whenever you upload a document.
Successful Response
Not found
Validation Error
{- "keys": [
- {
- "id": "string",
- "document_count": 0,
- "created_at": "string"
}
]
}
Get a list of documents that exist under a key
.
Successful Response
Validation Error
{- "documents": [
- {
- "id": "df481aff-93b1-4c09-a030-9dc7d2bb72c9",
- "filename": "file.txt",
- "tokens": 31
}
], - "total_count": 1
}
Get an upload by key & id.
You can see your keys with the /keys
endpoint, and all uploads under a key with /keys/{key}/uploads
.
When requesting an upload, you can use the format
query parameter
to return the document in either plaintext
or redacted
form.
Successful Response
Validation Error
{- "id": "df481aff-93b1-4c09-a030-9dc7d2bb72c9",
- "filename": "myfile.txt",
- "content": "Wayne Gretzky was a great hockey player!",
- "tokens": 11
}
Successful Response
Validation Error
{- "filename": "myfile.txt",
- "content": "hello, world!"
}
{- "message": "string",
- "document": {
- "id": "string",
- "filename": "string",
- "tokens": 0
}
}
Upload a file for future use in vector search.
The following type of documents are supported:
Successful Response
Validation Error
{- "message": "string",
- "document": {
- "id": "string",
- "filename": "string",
- "tokens": 0
}
}
Get the de-identified text from a document.
This removes all the personal identifiable information (PII) from the input text. You can optionally specify which entity types should be removed or allowed.
Successful Response
Validation Error
Redact existing PII entities
{- "content": "Hello, Bob!",
- "entity_detection": {
- "accuracy": "high",
- "entity_types": [
- {
- "type": "DISABLE",
- "value": [
- "NAME",
- "LOCATION",
- "LANGUAGE",
- "LOCATION_COUNTRY",
- "DATE_INTERVAL",
- "DATE",
- "EVENT"
]
}
], - "return_entity": true
}
}
{- "content": "Hello, [NAME_GIVEN_1]!",
- "entities": [
- {
- "processed_text": "NAME_GIVEN_1",
- "text": "Bob",
- "best_label": "NAME_GIVEN"
}
]
}
Get the de-identified text from a file.
This removes all the personal identifiable information (PII) from the input file. You can optionally specify which entity types should be removed or allowed.
Successful Response
Validation Error
{- "content": "Hello, [NAME_GIVEN_1]!",
- "entities": [
- {
- "processed_text": "NAME_GIVEN_1",
- "text": "Bob",
- "best_label": "NAME_GIVEN"
}
]
}
Get the re-identified text from a document.
This repopulates fields of personal identifiable information (PII) that were removed. The fields that are populated are passed in as part of the request.
Successful Response
Validation Error
{- "content": "Hello, [NAME_GIVEN_1]!",
- "entities": [
- {
- "processed_text": "NAME_GIVEN_1",
- "text": "John",
- "best_label": "NAME_GIVEN"
}
]
}
{- "content": "Hello, Johnny!"
}
Get the re-identified text from a file.
This repopulates fields of personal identifiable information (PII) that were removed. The fields that are populated are passed in as part of the request.
Successful Response
Validation Error
{- "content": "Hello, Johnny!"
}
Perform a search under a key using either similarity search or max marginal relevance search.
Similarity search: Returns documents most similar to the query.
Max marginal relevance search: Optimizes for similarity to the query and diversity among selected documents. Ensures that returned documents are not only relevant but also provide diverse information.
When searching, you can use the format
query parameter
to return the document in either plaintext
or redacted
form.
This endpoint is similar to the search
resolver and can be useful for prototyping or debugging
search resolvers.
Successful Response
Validation Error
{- "chunks": [
- "This is a matched chunk",
- "This is another matched chunk"
], - "count": 2
}
Calls Anthropic's completions endpoint.
To enable auto-redaction pass the format
parameter with the value redacted
.
To pass additional anthropic parameters use the extra_anthropic
field. For example:
{
"model": "claude-2",
"prompt": "\n\nHuman: Hello, my name is Bob\n\nAssistant:",
"format": "redacted",
"stream": True,
"max_tokens_to_sample": 500,
"extra_anthropic": {
"temperature": 0.5,
},
}
See Anthropic's API Reference for additional information about the extra parameters that can be passed.
The current supported models are claude-1
, claude-2
, claude-instant-1
.
model | string (AnthropicModels) Default: "claude-2" An enumeration. |
prompt required | string (Prompt) |
max_tokens_to_sample required | integer (Max Tokens To Sample) |
format | string (FormatType) Default: "plaintext" Whether or not to deidentify the request before sending it to anthropic. Deidentified requests will be reidentified before being returned to the caller. Currently, only streamed requests can be deidentified. |
mask_format | string (Mask Format) Default: "[MASK]"
|
return_entities | boolean (Return Entities) Default: false Return the entities that were found and redacted when using
|
verbose | boolean (Verbose) Default: false |
stream | boolean (Stream) Default: false |
extra_anthropic | object (Extra Anthropic) Extra parameters that can be passed to the underlying model. See Anthropic's API Reference for more details |
return_usage | boolean (Return Usage) Default: false When set to true, returns the number of tokens used for prompt, completions and total tokens(prompt + completions) used for the request
|
object (Policy) |
If stream, a stream of json objects otherwise a single json object
Validation Error
{- "model": "claude-2",
- "prompt": "\n\nHuman: Hello, my name is Bob\n\nAssistant:",
- "format": "redacted",
- "stream": true,
- "max_tokens_to_sample": 500,
- "extra_anthropic": {
- "temperature": 1
}
}
null
Submit a chat completions request to Azure OpenAI. Currently only supports the model gpt-4, gpt-4-32k, gpt-35-turbo, gpt-35-turbo-16k.
Uses the same format as the latest version of the OpenAI API's ChatCompletions endpoint, which is documented at https://platform.openai.com/docs/api-reference/chat/create.
model required | string (Model) |
required | Array of objects (Messages) |
functions | Array of objects (Functions) |
format | string (FormatType) Default: "plaintext" An enumeration. |
mask_format | string (Mask Format) Default: "[MASK]"
|
return_entities | boolean (Return Entities) Default: false Return the entities that were found and redacted when using |
verbose | boolean (Verbose) Default: false |
stream | boolean (Stream) Default: false |
return_usage | boolean (Return Usage) Default: false When set to true, returns the number of tokens used for prompt, completions and total tokens(prompt + completions) used for the request |
extra_openai | object (Extra Openai) Extra parameters that can be passed to the underlying model. See Azure OpenAI's API Reference for more details. |
object (Policy) |
If stream, a stream of json objects otherwise a single json object
Validation Error
{- "model": "gpt-4-32k",
- "messages": [
- {
- "role": "system",
- "content": "You are a happy, helpful assistant."
}, - {
- "role": "user",
- "content": "Tell me a joke."
}
], - "format": "redacted",
- "extra_openai": {
- "temperature": 1
}
}
null
Submit a chat completions request to OpenAI.
Uses the same format as the latest version of the OpenAI API's ChatCompletions endpoint, which is documented at https://platform.openai.com/docs/api-reference/chat/create.
model required | string (Model) |
required | Array of objects (Messages) |
functions | Array of objects (Functions) |
format | string (FormatType) Default: "plaintext" An enumeration. |
mask_format | string (Mask Format) Default: "[MASK]"
|
return_entities | boolean (Return Entities) Default: false Return the entities that were found and redacted when using |
verbose | boolean (Verbose) Default: false |
stream | boolean (Stream) Default: false |
return_usage | boolean (Return Usage) Default: false When set to true, returns the number of tokens used for prompt, completions and total tokens(prompt + completions) used for the request |
extra_openai | object (Extra Openai) Extra parameters that can be passed to the underlying model. See OpenAI's API Reference for more details |
object (Policy) |
If stream, a stream of json objects otherwise a single json object
Validation Error
{- "model": "gpt-4",
- "messages": [
- {
- "role": "system",
- "content": "You are a happy, helpful assistant."
}, - {
- "role": "user",
- "content": "Tell me a joke."
}
], - "format": "redacted",
- "extra_openai": {
- "temperature": 1
}
}
null
If stream, a stream of json objects otherwise a single json object
Validation Error
{- "message": "Some of the data may be redacted. Please respond with the placeholders as they are, without modification, as they are sufficient for a response. Please do not try to redact information yourself. Please do not change the placeholder format whatsoever. Bob is a software engineer who works at the company Cape Privacy! What company does Bob work for?",
- "format": "redacted",
- "stream": true,
- "extra_cohere": {
- "temperature": 1
}
}
null
This route calls a language model hosted by Cape in a secure enclave preserving the confidentiality of the prompt and the output returned by the model.
The current supported model is llama2-7b-chat
.
For more information about the llama2 prompt format check out this blog post https://huggingface.co/blog/llama2#how-to-prompt-llama-2.
Returns: A completion generated by the specified language model based on the input prompt and other parameters provided in cape_llm_request.
Successful Response
Validation Error
Generate text given a prompt
{- "model": "llama2-7b-chat",
- "prompt": "<|im_start|>system\nYou are a helpful Assistant.<|im_end|>\n<|im_start|>user\nWhat is the Capital of France?<|im_end|>\n<|im_start|>assistant",
- "max_tokens": 50,
- "temperature": 0.8,
- "stream": false
}
null
Submits a PDF for confidential OCR (Optical Character Recognition).
The file submitted is sent to a enclave for secure processing. No one can view the input data or the outputted response.
Successful Response
Validation Error
{- "ocr_records": {
- "pages": [
- {
- "page_idx": 0,
- "dimensions": [
- 0
], - "orientation": {
- "value": "string",
- "confidence": 0
}, - "language": {
- "value": "string",
- "confidence": 0
}, - "blocks": [
- {
- "geometry": [
- [
- null
]
], - "lines": [
- {
- "geometry": [ ],
- "words": [ ]
}
], - "artefacts": [
- null
]
}
]
}
]
}, - "ocr_transcript": "string"
}
Submit a confidential reader request. Which extracts text from many different kinds of documents.
The following type of documents are supported:
When the data is cape encrypted it must be in the following JSON format:
{
"data": "<base64 encoded data to be read>",
"mimetype": "<the mimetype such as application/pdf>",
"filename": "<a file name such as test.pdf>"
}
Otherwise it can just be one of the supported filetypes above.
Successful Response
Validation Error
{- "text": "string"
}
Successful Response
Validation Error
{- "name": "my-bot",
- "base_model": "gpt-4",
- "format": "plaintext",
- "system_prompt": "respond like super mario",
- "description": "Super Mario in your computer!"
}
{- "id": "string",
- "user_id": "string",
- "name": "string",
- "avatar_url": "string",
- "base_model": "string",
- "system_prompt": "string",
- "format": "string",
- "data_sources": [ ],
- "description": "string",
- "temperature": 0,
- "created_at": "2019-08-24T14:15:22Z",
- "updated_at": "2019-08-24T14:15:22Z"
}
Successful Response
Validation Error
{- "name": "my-bot",
- "base_model": "gpt-4",
- "format": "plaintext",
- "system_prompt": "respond like super mario"
}
null
Successful Response
Validation Error
{- "function_id": "fn-7nF8YmLKJB4bHJE2QisNV4",
- "function_name": "get_sql_data",
- "name": "get my friends",
- "description": "function to list my friends",
- "arguments": "{\"query\": \"select * from friends\"}"
}
null
Calls the requested function with the specified arguments if it exists and the user has a valid connector.
Successful Response
Not found
Validation Error
{- "arguments": { }
}
null
Successful Response
Validation Error
{- "integration_type": "gmail",
- "auth_type": "token",
- "token": "<API TOKEN>",
- "ask_confirmation": true
}
null