"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.cohereDocs = void 0;
exports.cohereDocs = [
{
id: "cohere-chat",
title: "Cohere Chat API",
category: "chat",
provider: "cohere",
keywords: ["cohere", "chat", "chatbot", "conversation"],
content: `# Cohere Chat API
## Endpoint
POST https://api.cohere.ai/v2/chat
## Headers
- Authorization: Bearer YOUR_API_KEY
- Content-Type: application/json
## Request Body
\`\`\`json
{
"model": "command-r-plus" | "command-r" | "command" | "command-light" | "command-r7b-2025",
"messages": [
{
"role": "system" | "user" | "assistant" | "tool",
"content": "string" | [
{"type": "text", "text": "string"},
{"type": "image", "image": {"url": "string"}}
]
}
],
"temperature": number (0-5, default 0.3),
"p": number (0-1, top_p),
"k": number (0-500, top_k),
"max_tokens": number,
"stop_sequences": string[],
"stream": boolean,
"tools": [
{
"name": "string",
"description": "string",
"parameter_definitions": {
"param_name": {
"description": "string",
"type": "string" | "number" | "boolean",
"required": boolean,
"value": "default value"
}
}
}
],
"tool_results": [
{
"call": {
"name": "string",
"parameters": {"param": "value"}
},
"outputs": [{"text": "result"}]
}
],
"documents": [
{
"id": "string",
"data": {"text": "content"},
"title": "string",
"url": "string"
}
],
"search_queries_only": boolean,
"prompt_truncation": "AUTO" | "OFF"
}
\`\`\`
## Response
\`\`\`json
{
"id": "xxx",
"message": {
"role": "assistant",
"content": [
{"type": "text", "text": "Hello!"},
{
"type": "tool_call",
"tool_call": {
"name": "get_weather",
"parameters": {"location": "London"}
}
}
],
"tool_calls": [...]
},
"finish_reason": "COMPLETE" | "MAX_TOKENS" | "ERROR",
"usage": {
"billed_tokens": 0,
"input_tokens": 0,
"output_tokens": 0
},
"citations": [...],
"search_results": [...]
}
\`\`\`
## Available Models
- command-r-plus: Most capable, 128K context
- command-r: Balanced, 128K context
- command: Standard, 4K context
- command-light: Fast, 4K context
- command-r7b-2025: New 7B model
## Python SDK Example
\`\`\`python
import cohere
co = cohere.Client("YOUR_API_KEY")
response = co.chat(
model="command-r-plus",
message="Hello!",
temperature=0.3,
max_tokens=1024
)
print(response.message.content[0].text)
\`\`\`
## Node.js Example
\`\`\`javascript
import { CohereClient } from "cohere-ai";
const cohere = new CohereClient({ token: "YOUR_API_KEY" });
const response = await cohere.chat({
model: "command-r-plus",
message: "Hello!",
maxTokens: 1024
});
console.log(response.message.content[0].text);
\`\`\`
## cURL Example
\`\`\`bash
curl https://api.cohere.ai/v2/chat \\
-H "Authorization: Bearer $COHERE_API_KEY" \\
-H "Content-Type: application/json" \\
-d '{
"model": "command-r-plus",
"messages": [{"role": "user", "content": "Hello!"}],
"max_tokens": 1024
}'
\`\`\``
},
{
id: "cohere-embed",
title: "Cohere Embed API",
category: "embeddings",
provider: "cohere",
keywords: ["cohere", "embed", "embeddings", "vector"],
content: `# Cohere Embed API
## Endpoint
POST https://api.cohere.ai/v1/embed
## Request
\`\`\`json
{
"model": "embed-english-v3.0" | "embed-multilingual-v3.0" | "embed-english-light-v3.0" | "embed-multilingual-light-v3.0",
"texts": ["text1", "text2"],
"input_type": "search_document" | "search_query" | "classification" | "clustering",
"truncate": "NONE" | "LEFT" | "RIGHT",
"embedding_types": ["float"] | ["int8"] | ["uint8"] | ["binary"] | ["ubinary"]
}
\`\`\`
## Response
\`\`\`json
{
"id": "xxx",
"texts": ["text1", "text2"],
"embeddings": [[0.1, 0.2, ...], [0.3, 0.4, ...]],
"response_type": "embeddings_by_type",
"meta": {
"billed_units": {"input_tokens": 10}
}
}
\`\`\`
## Model Details
- embed-english-v3.0: 1024 dimensions, best quality
- embed-multilingual-v3.0: 1024 dimensions, 100+ languages
- embed-english-light-v3.0: 384 dimensions, faster
- embed-multilingual-light-v3.0: 384 dimensions, multilingual fast
## Input Types
- search_document: For embedding documents to store
- search_query: For embedding search queries
- classification: For classification tasks
- clustering: For clustering tasks
## Python Example
\`\`\`python
import cohere
co = cohere.Client("YOUR_API_KEY")
response = co.embed(
model="embed-english-v3.0",
texts=["Hello world"],
input_type="search_document"
)
embeddings = response.embeddings
\`\`\``
},
{
id: "cohere-rerank",
title: "Cohere Rerank API",
category: "rerank",
provider: "cohere",
keywords: ["cohere", "rerank", "ranking", "search", "relevance"],
content: `# Cohere Rerank API
## Endpoint
POST https://api.cohere.ai/v1/rerank
## Request
\`\`\`json
{
"model": "rerank-v3.5" | "rerank-english-v3.0" | "rerank-multilingual-v3.0",
"query": "What is Python?",
"documents": [
"Python is a programming language",
"Python is a snake",
"Python was created by Guido van Rossum"
],
"top_n": 3,
"return_documents": true,
"max_chunks_per_doc": 10
}
\`\`\`
## Response
\`\`\`json
{
"id": "xxx",
"results": [
{
"index": 2,
"relevance_score": 0.95,
"document": {"text": "Python was created by Guido van Rossum"}
},
{
"index": 0,
"relevance_score": 0.85,
"document": {"text": "Python is a programming language"}
}
],
"meta": {"billed_units": {"search_units": 1}}
}
\`\`\`
## Model Details
- rerank-v3.5: Latest, best quality
- rerank-english-v3.0: English optimized
- rerank-multilingual-v3.0: Multilingual
## Python Example
\`\`\`python
import cohere
co = cohere.Client("YOUR_API_KEY")
response = co.rerank(
model="rerank-v3.5",
query="What is Python?",
documents=[
"Python is a programming language",
"Python is a snake",
"Python was created by Guido van Rossum"
],
top_n=2
)
for result in response.results:
print(f"Index {result.index}: {result.relevance_score}")
\`\`\`
## Use in RAG Pipeline
1. Retrieve documents with embeddings (fast, approximate)
2. Rerank with Cohere Rerank (precise ordering)
3. Pass top N to LLM for generation`
},
{
id: "cohere-generate",
title: "Cohere Generate (Text Completion)",
category: "completion",
provider: "cohere",
keywords: ["cohere", "generate", "completion", "text"],
content: `# Cohere Generate API
## Endpoint
POST https://api.cohere.ai/v1/generate
## Request
\`\`\`json
{
"model": "command" | "command-light",
"prompt": "Once upon a time",
"max_tokens": 1024,
"temperature": 0.7,
"p": 0.75,
"k": 0,
"stop_sequences": ["\\n\\n"],
"num_generations": 1,
"return_likelihoods": "NONE" | "GENERATION" | "ALL"
}
\`\`\`
## Response
\`\`\`json
{
"id": "xxx",
"generations": [
{
"id": "xxx",
"text": "there was a...",
"finish_reason": "COMPLETE",
"likelihood": -12.34
}
],
"prompt": "Once upon a time",
"meta": {"billed_units": {"input_tokens": 4, "output_tokens": 50}}
}
\`\`\`
## Note
The Generate API is legacy. Use Chat API (v2) for new applications.`
},
{
id: "cohere-rate-limits",
title: "Cohere Rate Limits & Pricing",
category: "limits",
provider: "cohere",
keywords: ["cohere", "rate limit", "pricing", "cost"],
content: `# Cohere Rate Limits & Pricing
## Rate Limits
- Free tier: 5-10 RPM (varies by endpoint)
- Paid tier: Higher limits based on plan
## Pricing (per 1M tokens)
### Chat
- command-r-plus: Input $2.50, Output $10.00
- command-r: Input $0.50, Output $1.50
- command: Input $1.00, Output $2.00
- command-light: Input $0.30, Output $0.60
### Embed
- embed-english-v3.0: $0.10
- embed-multilingual-v3.0: $0.10
- embed-english-light-v3.0: $0.10
### Rerank
- rerank-v3.5: $2.00 per 1K documents
- rerank-english-v3.0: $2.00 per 1K documents
## Context Windows
- command-r-plus: 128K tokens
- command-r: 128K tokens
- command: 4K tokens
- command-light: 4K tokens
## Error Codes
- 400: Bad Request
- 401: Unauthorized
- 403: Forbidden
- 429: Rate limit exceeded
- 500: Internal error`
}
];
//# sourceMappingURL=cohere.js.map