This project provides a simple RESTful API interface for interacting with the Cohere AI model using go.
- Go 1.23.2 or later
- An API key from Cohere
-
Clone the repository:
git clone https://github.com/yourusername/my-cohere-api.git cd THIS-RESPOS-NAME
-
Create a
.env
file in the root of the project directory. This file should contain your Cohere API key.Example
.env
file:# This is an example .env file. Below is the way you should place your COHERE_API_KEY # Assume your COHERE_API_KEY is "123456" COHERE_API_KEY=123456
- The project defaults to the Command R+ 08-2024 model from Cohere, which cannot be changed in the provided code.
To start the server, use:
make start
- POST
/chat
- Sends a message to the AI model and receives a response.
To test the API using Postman, follow these steps:
-
Open Postman and create a new request.
-
Set the request type to POST.
-
Enter the URL:
http://localhost:8080/chat
. -
Go to the Headers tab and set the Content-Type to
application/json
. -
In the Body tab, select the raw option and choose JSON from the dropdown menu.
-
Enter the JSON payload, for example:
{ "message": "Hello, AI!" }
-
Send the request and observe the response.
This project is licensed under the MIT License - see the LICENSE file for details.