Below is the documentation for integrating Reconify with Cohere via REST API.
Currently we support chat and generate completions on Cohere via REST API.
If you are integrating with Amazon Bedrock, refer to the Bedrock Rest documentation.
The first step is to create an account at app.reconify.com.
In the Reconify console, add an Application to your account. This will generate both an API_KEY and an APP_KEY which will be used in the code below to send data to Reconify.
Below are instructions on integrating with the REST API.
At a high level, you will send a copy of the JSON input into Cohere (i.e. the prompts) and the response from Cohere, along with your Reconify API and APP keys. There are additional optional parameters for tracking users and sessions.
Sign up for an account to get the endpoint url.
{
"reconify": {},
"timestamps": {},
"session": "",
"sessionTimeOut": null,
"user": {},
"request": {},
"response": {}
}
{
"reconify": {
"format": "cohere",
"type": "chat",
"version": "2.1.0",
"appKey": process.env.RECONIFY_APP_KEY,
"apiKey": process.env.RECONIFY_API_KEY
}
}
{
"timestamps": {
"request": 1686091778298,
"response": 1686091844345
}
}
{
"session": "ABCDEF123456",
"sessionTimeout": 10
}
{
"user: {
"userId": "ABC123",
"isAuthenticated": 1,
"firstName": "Jane",
"lastName": "Doe",
"email": "some_email",
"phone": "555-555-5555",
"gender": "female"
}
}
{
"request": {
"model": "command",
"message": "Tell me one good cat joke"
}
}
{
"response": {
"response_id": "d479aeb3-a87d-41ef-b13f-7a712094106e",
"text": "Why did the cat cross the road?\nTo get to the meow-niverse!\n\nPurr-fect joke, hahaha? \n\nWould you like to hear another one? \n\nIf you're feeling adventurous, you could even tell me a joke about cats!",
"generationId": "6e0f59a0-4469-412e-9279-d552f2b51db4",
"token_count": {
"prompt_tokens": 68,
"response_tokens": 59,
"total_tokens": 127,
"billed_tokens": 116
},
"meta": {
"api_version": {
"version": "1"
},
"billed_units": {
"input_tokens": 57,
"output_tokens": 59
}
}
}
}
Below is an example JSON to post to the endpoint for a chat completion.
{
"reconify": {
"format": "cohere",
"type": "chat",
"version": "2.1.0",
"appKey": process.env.RECONIFY_APP_KEY,
"apiKey": process.env.RECONIFY_API_KEY
},
"timestamps": {
"request": 1701460517528,
"response": 1701460522216
},
"user": {
"userId": "ABC123",
"firstName": "Jane",
"lastNam": "Doe"
},
"request": {
"model": "command",
"message": "Tell me one good cat joke"
},
"response": {
"response_id": "d479aeb3-a87d-41ef-b13f-7a712094106e",
"text": "Why did the cat cross the road?\nTo get to the meow-niverse!\n\nPurr-fect joke, hahaha? \n\nWould you like to hear another one? \n\nIf you're feeling adventurous, you could even tell me a joke about cats!",
"generationId": "6e0f59a0-4469-412e-9279-d552f2b51db4",
"token_count": {
"prompt_tokens": 68,
"response_tokens": 59,
"total_tokens": 127,
"billed_tokens": 116
},
"meta": {
"api_version": {
"version": "1"
},
"billed_units": {
"input_tokens": 57,
"output_tokens": 59
}
}
}
}
Below is an example JSON to post to the endpoint for a generate completion.
{
"reconify": {
"format": "cohere",
"type": "generate",
"version": "2.1.0",
"appKey": process.env.RECONIFY_APP_KEY,
"apiKey": process.env.RECONIFY_API_KEY
},
"timestamps": {
"request": 1701460517528,
"response": 1701460522216
},
"user": {
"userId": "ABC123",
"firstName": "Jane",
"lastNam": "Doe"
},
"request": {
"model": "command",
"message": "write a cat haiku",
"max_tokens": 300
},
"response": {
"id": "7d05abf3-688a-47d5-8d8e-18ef34ec6178",
"generations": [
{
"id": "7c3206e5-d412-4df3-8ad3-f2335a5d4f53",
"text": " Independent feline,\nQuietly plotting solitude,\nSpring rain gleams in her eyes. \n\nWould you like me to write another cat haiku? ",
"finish_reason": "COMPLETE"
}
],
"prompt": "write a cat haiku",
"meta": {
"apiVersion": {
"version": "1"
},
"billed_units": {
"input_tokens": 5,
"output_tokens": 33
}
}
}
}