Below is the documentation for integrating Reconify with Google Gemini via REST API.
Currently we support Generate with text and Chat interactions on Gemini via REST API. For Generate with text and images, please use the Node NPM module.
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 Gemini and the response from Gemini, 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": "gemini",
"type": "generate",
"version": "2.2.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": {
"contents": [
{
"parts": [
{
"text": "Tell a cat joke"
}
]
}
],
"model": "gemini-pro",
"generationConfig": {
"maxOutputTokens": 350
},
"safetySettings": []
}
}
{
"response": {
"candidates": [
{
"content": {
"parts": [
{
"text": "Why did the cat join the Red Cross?\nBecause he wanted to be a first-aid kitty!"
}
],
"role": "model"
},
"finishReason": "STOP",
"index": 0,
"safetyRatings": [
{
"category": "HARM_CATEGORY_SEXUALLY_EXPLICIT",
"probability": "NEGLIGIBLE"
},
{
"category": "HARM_CATEGORY_HATE_SPEECH",
"probability": "NEGLIGIBLE"
},
{
"category": "HARM_CATEGORY_HARASSMENT",
"probability": "NEGLIGIBLE"
},
{
"category": "HARM_CATEGORY_DANGEROUS_CONTENT",
"probability": "NEGLIGIBLE"
}
]
}
],
"promptFeedback": {
"safetyRatings": [
{
"category": "HARM_CATEGORY_SEXUALLY_EXPLICIT",
"probability": "NEGLIGIBLE"
},
{
"category": "HARM_CATEGORY_HATE_SPEECH",
"probability": "NEGLIGIBLE"
},
{
"category": "HARM_CATEGORY_HARASSMENT",
"probability": "NEGLIGIBLE"
},
{
"category": "HARM_CATEGORY_DANGEROUS_CONTENT",
"probability": "NEGLIGIBLE"
}
]
}
}
Below is an example JSON to post to the endpoint for a Generate action.
{
"reconify": {
"format": "gemini",
"type": "generate",
"version": "2.3.0",
"appKey": process.env.RECONIFY_APP_KEY,
"apiKey": process.env.RECONIFY_API_KEY
},
"timestamps": {
"request": 1703135407816,
"response": 1703135409193
},
"user": {
"userId": "ABC123",
"firstName": "Jane",
"lastName": "Doe"
},
"request": {
"contents": [
{
"parts": [
{
"text": "Tell a cat joke"
}
]
}
],
"model": "gemini-pro",
"generationConfig": {
"maxOutputTokens": 350
},
"safetySettings": []
},
"candidates": [
{
"content": {
"parts": [
{
"text": "Why did the cat join the Red Cross?\nBecause he wanted to be a first-aid kitty!"
}
],
"role": "model"
},
"finishReason": "STOP",
"index": 0,
"safetyRatings": [
{
"category": "HARM_CATEGORY_SEXUALLY_EXPLICIT",
"probability": "NEGLIGIBLE"
},
{
"category": "HARM_CATEGORY_HATE_SPEECH",
"probability": "NEGLIGIBLE"
},
{
"category": "HARM_CATEGORY_HARASSMENT",
"probability": "NEGLIGIBLE"
},
{
"category": "HARM_CATEGORY_DANGEROUS_CONTENT",
"probability": "NEGLIGIBLE"
}
]
}
],
"promptFeedback": {
"safetyRatings": [
{
"category": "HARM_CATEGORY_SEXUALLY_EXPLICIT",
"probability": "NEGLIGIBLE"
},
{
"category": "HARM_CATEGORY_HATE_SPEECH",
"probability": "NEGLIGIBLE"
},
{
"category": "HARM_CATEGORY_HARASSMENT",
"probability": "NEGLIGIBLE"
},
{
"category": "HARM_CATEGORY_DANGEROUS_CONTENT",
"probability": "NEGLIGIBLE"
}
]
}
}
Below is an example JSON to post to the endpoint for a Chat action.
{
"reconify": {
"format": "gemini",
"type": "chat",
"version": "2.3.0",
"appKey": process.env.RECONIFY_APP_KEY,
"apiKey": process.env.RECONIFY_API_KEY
},
"timestamps": {
"request": 1703135407816,
"response": 1703135409193
},
"user": {
"userId": "ABC123",
"firstName": "Jane",
"lastName": "Doe"
},
"request": {
"contents": [
{
"role" : "user",
"parts": [
{
"text": "I have a tuxedo cat and a calico cat"
}
]
},
{
"role" : "model",
"parts": [
{
"text": "How can I help?"
}
]
},
{
"role" : "user",
"parts": [
{
"text": "How many colors are my cats?"
}
]
}
],
"model": "gemini-pro",
"generationConfig": {
"maxOutputTokens": 200
},
},
"candidates": [
{
"content": {
"parts": [
{
"text": "Tuxedo cats typically have two colors: black and white. However, some tuxedo cats may also have a small amount of orange or tabby markings. Calico cats typically have three colors: black, orange, and white. However, the exact colors and patterns of a calico cat can vary widely.\n\nTuxedo Cat Colors:\n\n* Black and white\n* Black, white, and orange\n* Black, white, and tabby\n\nCalico Cat Colors:\n\n* Black, orange, and white\n* Blue, cream, and white\n* Red, cream, and white\n* Chocolate, orange, and white\n* Lilac, cream, and white\n* Cinnamon, orange, and white\n* Fawn, cream, and white\n\nIt is important to note that these are just the most common colors and patterns for tuxedo and calico cats. There is a wide variety of coat colors and patterns that can occur in both breeds."
}
],
"role": "model"
},
"finishReason": "STOP",
"index": 0,
"safetyRatings": [
{
"category": "HARM_CATEGORY_SEXUALLY_EXPLICIT",
"probability": "NEGLIGIBLE"
},
{
"category": "HARM_CATEGORY_HATE_SPEECH",
"probability": "NEGLIGIBLE"
},
{
"category": "HARM_CATEGORY_HARASSMENT",
"probability": "NEGLIGIBLE"
},
{
"category": "HARM_CATEGORY_DANGEROUS_CONTENT",
"probability": "NEGLIGIBLE"
}
]
}
],
"promptFeedback": {
"safetyRatings": [
{
"category": "HARM_CATEGORY_SEXUALLY_EXPLICIT",
"probability": "NEGLIGIBLE"
},
{
"category": "HARM_CATEGORY_HATE_SPEECH",
"probability": "NEGLIGIBLE"
},
{
"category": "HARM_CATEGORY_HARASSMENT",
"probability": "NEGLIGIBLE"
},
{
"category": "HARM_CATEGORY_DANGEROUS_CONTENT",
"probability": "NEGLIGIBLE"
}
]
}
}