How to Work with Cohere API

This guide will walk you through the essential steps: obtaining your API key, understanding the critical differences between key types (especially regarding costs and usage limits), and performing a simple initial test using the Apidog tool to ensure your key is working correctly.

Medy Evrard

16 April 2025

How to Work with Cohere API

Cohere provides developers access to sophisticated Large Language Models (LLMs) capable of understanding and generating human-like text. To interact with these models programmatically, you need an API key. This key acts as your unique identifier and password, allowing Cohere's systems to authenticate your requests and track your usage.

This guide will walk you through the essential steps: obtaining your API key, understanding the critical differences between key types (especially regarding costs and usage limits), and performing a simple initial test using the Apidog tool to ensure your key is working correctly.

Step 1: Obtaining Your Cohere API Key

Getting your key is the first and most crucial step. Cohere makes this process relatively simple through their online dashboard.

  1. Navigate to the Cohere Dashboard: Open your web browser and go to the main Cohere platform access point. You'll typically find a login or sign-up page.
  2. Access Your Account:

Locate the API Keys Section: Once you are successfully logged into the Cohere dashboard, look for a section specifically dedicated to managing API Keys. This might be under account settings, a developer section, or directly accessible via a menu item labeled "API Keys". The interface is designed to be user-friendly, so it should be relatively prominent.

Initiate Key Generation: Within the API Keys section, you will find an option to create a new key. You will likely see choices differentiating between key types, most notably "Trial Key" and potentially "Production Key". For initial testing and learning, select the option to generate a Trial Key.

Assign a Name: A prompt will ask you to name your key. Choose a descriptive name that will help you remember its purpose later, especially if you generate multiple keys for different projects. Examples include "MyFirstTestKey", "LearningProjectKey", or "ApidogTestingKey".

Generate and Secure Your Key: Click the button to confirm and generate the key (e.g., "Generate Trial Key"). Cohere will then display your newly generated API key. This is the only time the full key will be shown. It is absolutely essential that you copy this key immediately and store it in a very secure location, such as a password manager or a secure note. Treat it with the same level of security as a password. Do not share it publicly, embed it directly in client-side code, or commit it to version control systems like Git. Once you close the pop-up window or navigate away, you cannot retrieve the full key again for security reasons (though you can see the key's name and potentially its first/last few characters in the dashboard). If you lose it, you will need to generate a new one.

With your API key copied and secured, you're ready to understand what you can do with it and the associated rules.

Step 2: Understanding Key Types, Costs, and Usage Limits

Not all Cohere API keys are created equal. The type of key you have dictates how much you can use the API, how quickly, and whether it incurs costs. Understanding these differences is vital to avoid unexpected interruptions or charges.

A. Trial API Keys: Free for Evaluation

When you first sign up or generate a key without setting up billing, you typically receive a Trial Key. These are designed for exploration, learning, and small-scale testing.

Trial keys are ideal for:

If you consistently hit the monthly cap or the per-minute rate limits, it's a strong indicator that you need to upgrade to a Production key.

B. Production API Keys: For Building and Scaling

When you're ready to build applications with real users, handle more significant workloads, or move beyond the trial limitations, you'll need a Production Key. This requires setting up billing information in your Cohere account.

Production keys are necessary for:

C. Choosing the Right Key:

Okay, here is the revised Step 3 section focusing on testing the streaming chat request provided in the curl command using Apidog, presented in Markdown:

Step 3: Performing a Basic API Test Call for Streaming Chat with Apidog

Before integrating the API into complex code, especially for streaming responses, it's helpful to perform a direct test. Apidog allows you to replicate the curl command structure to verify your key and understand the basic request/response flow for streaming.

  1. Launch Apidog: Open the Apidog application on your computer.
  2. Create a New Request: Click the '+' button or equivalent to create a new API request. Name it something descriptive, like "Cohere Streaming Chat Test".
  3. Configure the Endpoint:

4. Set Up Headers:

5. Construct the Request Body (with Streaming Enabled):

{
  "stream": true,
  "model": "command-r",
  "messages": [
    {
      "role": "user",
      "content": "Hello world!"
    }
  ]
}

(Note: The curl example used "role": "user" (lowercase) and model "command-a-03-2025". I've kept "role": "USER" and model "command-r" for consistency with earlier examples, but you should adjust the model and role casing in the JSON above to precisely match the specific request you intend to test if different.)

6. Execute the Request: Click the "Send" button in Apidog.

7. Analyze the Response (Streaming Specifics):

This test helps confirm that the API accepts your streaming request and that your key is valid for this type of interaction, even if Apidog itself isn't the ideal tool for visualizing the stream's real-time nature. It verifies the fundamental request setup is correct.

Conclusion

You now have your Cohere API key and understand the crucial differences between Trial and Production keys, particularly regarding the 1,000 monthly call limit and per-minute rate limits on Trial keys versus the pay-as-you-go, token-based pricing and higher limits of Production keys. You've also performed a basic but vital test using Apidog to confirm your key works and you can structure a simple API call.

This foundation is essential for interacting effectively with the Cohere API. Remember to keep your key secure, monitor your usage against the limits (especially on a Trial key), and refer to Cohere's documentation for detailed information on specific models, advanced parameters, and SDK usage as you start building more sophisticated applications.

Explore more

How to Use RAGFlow(Open Source RAG Engine): A Complete Guide

How to Use RAGFlow(Open Source RAG Engine): A Complete Guide

Discover how to use RAGFlow to create AI-powered Q&A systems. This beginner’s guide covers setup, document parsing, and querying with tips!

18 June 2025

Testing Open Source Cluely (That help you cheat on everything with AI)

Testing Open Source Cluely (That help you cheat on everything with AI)

Discover how to install and test open-source Cluely, the AI that assists in interviews. This beginner’s guide covers setup, mock testing, and ethics!

18 June 2025

Cursor's New $200 Ultra Plan: Is It Worth It for Developers?

Cursor's New $200 Ultra Plan: Is It Worth It for Developers?

Explore Cursor’s new $200 Ultra Plan, offering 20x more usage than the Pro tier. Learn about Cursor pricing, features like Agent mode, and whether the Cursor Ultra plan suits developers. Compare with Pro, Business, and competitors to make an informed choice.

18 June 2025

Practice API Design-first in Apidog

Discover an easier way to build and use APIs