Find an API

Search public APIs with auth details & Postman guides

← All APIs

Cohere API

api.cohere.com · AI

AI Bearer Token Free Tier AI NLP Embeddings

Enterprise-focused NLP API — text generation, semantic search with embeddings, classification, summarisation, and reranking. Strong for RAG applications. Free trial tier: 1,000 calls/month.

Authentication

Bearer Token Free trial API key at dashboard.cohere.com. Pass as Authorization: Bearer YOUR_KEY.

Sample Requests

POST Chat

Chat with Cohere's Command R+ model.

https://api.cohere.com/v2/chat

Hover any highlighted part to learn what it does

Headers — extra info sent with the request
Content-Type application/json
Authorization Bearer YOUR_KEY
Request Body — data you're sending
{
  "model": "command-r-plus",
  "messages": [
    {
      "role": "user",
      "content": "Explain embeddings in one sentence."
    }
  ]
}
curl -X POST "https://api.cohere.com/v2/chat" \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"model":"command-r-plus","messages":[{"role":"user","content":"Explain embeddings in one sentence."}]}'
import requests
headers = {
    "Content-Type": "application/json",
    "Authorization": "Bearer YOUR_ACCESS_TOKEN"
}
data = {
    "model": "command-r-plus",
    "messages": [
        {
            "role": "user",
            "content": "Explain embeddings in one sentence."
        }
    ]
}
response = requests.post(
    "https://api.cohere.com/v2/chat",
    headers=headers,
    json=data,
)
print(response.json())
const url = 'https://api.cohere.com/v2/chat';

const response = await fetch(url, {
  method: 'POST',
  headers: {
    'Content-Type': 'application/json',
    'Authorization': 'Bearer YOUR_ACCESS_TOKEN'
  },
  headers: { 'Content-Type': 'application/json' },
  body: JSON.stringify({
  "model": "command-r-plus",
  "messages": [
    {
      "role": "user",
      "content": "Explain embeddings in one sentence."
    }
  ]
}),
}); 
const data = await response.json();
console.log(data);
package main

import (
	"fmt"
	"io"
	"net/http"
	"bytes"
	"encoding/json"
)

func main() {
	targetURL := "https://api.cohere.com/v2/chat"
	jsonData, _ := json.Marshal({"model":"command-r-plus","messages":[{"role":"user","content":"Explain embeddings in one sentence."}]})
	req, _ := http.NewRequest("POST", targetURL, bytes.NewBuffer(jsonData))
	req.Header.Set("Content-Type", "application/json")
	req.Header.Set("Authorization", "Bearer YOUR_ACCESS_TOKEN")
	req.Header.Set("Content-Type", "application/json")

	client := &http.Client{}
	resp, _ := client.Do(req)
	defer resp.Body.Close()
	body, _ := io.ReadAll(resp.Body)
	fmt.Println(string(body))
}
require "net/http"
require "json"

uri = URI("https://api.cohere.com/v2/chat")

http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = uri.scheme == "https"

req = Net::HTTP::Post.new(uri)
req["Content-Type"] = "application/json"
req["Authorization"] = "Bearer YOUR_ACCESS_TOKEN"
req["Content-Type"] = "application/json"
req.body = "{\"model\":\"command-r-plus\",\"messages\":[{\"role\":\"user\",\"content\":\"Explain embeddings in one sentence.\"}]}"

res = http.request(req)
puts JSON.parse(res.body)
<?php
$url = "https://api.cohere.com/v2/chat";
$opts = ["http" => [
    "method" => "POST",
    "header" => implode("\r\n", [
        "Content-Type: application/json",
        "Authorization: Bearer YOUR_ACCESS_TOKEN",
        "Content-Type: application/json"
    ]),
    "content" => json_encode({"model":"command-r-plus","messages":[{"role":"user","content":"Explain embeddings in one sentence."}]}),
]];
$ctx = stream_context_create($opts);
$res = file_get_contents($url, false, $ctx);
print_r(json_decode($res, true));
POST Generate embeddings

Generate semantic embeddings for text.

https://api.cohere.com/v2/embed

Hover any highlighted part to learn what it does

Headers — extra info sent with the request
Content-Type application/json
Authorization Bearer YOUR_KEY
Request Body — data you're sending
{
  "model": "embed-english-v3.0",
  "texts": [
    "Hello world",
    "Goodbye world"
  ],
  "input_type": "search_document"
}
curl -X POST "https://api.cohere.com/v2/embed" \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"model":"embed-english-v3.0","texts":["Hello world","Goodbye world"],"input_type":"search_document"}'
import requests
headers = {
    "Content-Type": "application/json",
    "Authorization": "Bearer YOUR_ACCESS_TOKEN"
}
data = {
    "model": "embed-english-v3.0",
    "texts": [
        "Hello world",
        "Goodbye world"
    ],
    "input_type": "search_document"
}
response = requests.post(
    "https://api.cohere.com/v2/embed",
    headers=headers,
    json=data,
)
print(response.json())
const url = 'https://api.cohere.com/v2/embed';

const response = await fetch(url, {
  method: 'POST',
  headers: {
    'Content-Type': 'application/json',
    'Authorization': 'Bearer YOUR_ACCESS_TOKEN'
  },
  headers: { 'Content-Type': 'application/json' },
  body: JSON.stringify({
  "model": "embed-english-v3.0",
  "texts": [
    "Hello world",
    "Goodbye world"
  ],
  "input_type": "search_document"
}),
}); 
const data = await response.json();
console.log(data);
package main

import (
	"fmt"
	"io"
	"net/http"
	"bytes"
	"encoding/json"
)

func main() {
	targetURL := "https://api.cohere.com/v2/embed"
	jsonData, _ := json.Marshal({"model":"embed-english-v3.0","texts":["Hello world","Goodbye world"],"input_type":"search_document"})
	req, _ := http.NewRequest("POST", targetURL, bytes.NewBuffer(jsonData))
	req.Header.Set("Content-Type", "application/json")
	req.Header.Set("Authorization", "Bearer YOUR_ACCESS_TOKEN")
	req.Header.Set("Content-Type", "application/json")

	client := &http.Client{}
	resp, _ := client.Do(req)
	defer resp.Body.Close()
	body, _ := io.ReadAll(resp.Body)
	fmt.Println(string(body))
}
require "net/http"
require "json"

uri = URI("https://api.cohere.com/v2/embed")

http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = uri.scheme == "https"

req = Net::HTTP::Post.new(uri)
req["Content-Type"] = "application/json"
req["Authorization"] = "Bearer YOUR_ACCESS_TOKEN"
req["Content-Type"] = "application/json"
req.body = "{\"model\":\"embed-english-v3.0\",\"texts\":[\"Hello world\",\"Goodbye world\"],\"input_type\":\"search_document\"}"

res = http.request(req)
puts JSON.parse(res.body)
<?php
$url = "https://api.cohere.com/v2/embed";
$opts = ["http" => [
    "method" => "POST",
    "header" => implode("\r\n", [
        "Content-Type: application/json",
        "Authorization: Bearer YOUR_ACCESS_TOKEN",
        "Content-Type: application/json"
    ]),
    "content" => json_encode({"model":"embed-english-v3.0","texts":["Hello world","Goodbye world"],"input_type":"search_document"}),
]];
$ctx = stream_context_create($opts);
$res = file_get_contents($url, false, $ctx);
print_r(json_decode($res, true));

Postman Setup Guide

Get Postman ↗
  1. Get a free API key at dashboard.cohere.com
  2. Set Authorization: Bearer YOUR_KEY header
  3. Chat: POST /v2/chat with model and messages
  4. Embeddings: POST /v2/embed — great for semantic search and RAG
  5. Rerank: POST /v2/rerank to reorder search results by relevance

Open documentation ↗