Below is the documentation for integrating Reconify with OpenAI via REST API.
Currently we support Chat and Completion actions on OpenAI via REST API. Additional actions will be supported in the future. For image actions, try our Node NPM or Python PIP modules.
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 openAI (i.e. the prompts) and the response from openAI, 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": "openai",
"type": "chat",
"version": "1.0.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": "text-davinci-003",
"prompt": "say this is a test",
"max_tokens": 7,
"temperature": 0
}
}
{
"response": {
"id": "cmpl-abcdef1234",
"object": "text_completion",
"created": 1589478378,
"model": "text-davinci-003",
"choices": [{
"text": "\n\nThis is indeed a test",
"index": 0,
"logprobs": null,
"finish_reason": "length"
}],
"usage": {
"prompt_tokens": 5,
"completion_tokens": 7,
"total_tokens": 12
}
Below is an example JSON to post to the endpoint for a Chat.
{
"reconify": {
"format": "openai",
"type": "chat",
"version": "1.0.0",
"appKey": process.env.RECONIFY_APP_KEY,
"apiKey": process.env.RECONIFY_API_KEY
},
"timestamps": {
"request": 1689703471457,
"response": 1689703474393
},
"user": {
"userId": "ABC123",
"firstName": "Jane",
"lastName": "Doe"
},
"request": {
"model": "gpt-3.5-turbo-0613",
"messages": [
{ "role" : "system", "content": "You are a stand up comic" },
{ "role" : "user", "content": "Tell a cat joke" }
]
},
"response": {
"id": "chatcmpl-abcdef",
"object": "chat.completion",
"created": 1689703472,
"model": "gpt-3.5-turbo-0613",
"choices": [{
"index": 0,
"message": {
"role" : "assistant",
"content" : "Sure, here's a cat joke for you: \n\nWhy don't cats play poker in the wild?\n\nBecause there are too many cheetahs!",
},
"finish_reason": "stop"
}],
"usage": {
"prompt_tokens": 21,
"completion_tokens": 31,
"total_tokens": 52
}
}
}
Below is an example JSON to post to the endpoint for a Completion.
{
"reconify": {
"format": "openai",
"type": "completion",
"version": "1.0.0",
"appKey": process.env.RECONIFY_APP_KEY,
"apiKey": process.env.RECONIFY_API_KEY
},
"timestamps": {
"request": 1686091778298,
"response": 1686091844345
},
"user": {
"userId": "ABC123",
"firstName": "Jane",
"lastName": "Doe"
},
"request": {
"model": "text-davinci-003",
"prompt": "say this is a test",
"max_tokens": 7,
"temperature": 0
},
"response": {
"id": "cmpl-abcdef1234",
"object": "text_completion",
"created": 1589478378,
"model": "text-davinci-003",
"choices": [{
"text": "\n\nThis is indeed a test",
"index": 0,
"logprobs": null,
"finish_reason": "length"
}],
"usage": {
"prompt_tokens": 5,
"completion_tokens": 7,
"total_tokens": 12
}
}
}