Prerequisites :
Programming language of choice (Python, JavaScript, etc.)
Valid Quantum API Bearer token
Access to the Quantum AI Agent system
Follow these steps to set up your development environment for integrating with the Quantum AI Agent.
Install required dependencies
Choose your preferred programming language and install the necessary HTTP client libraries: Python
JavaScript/Node.js
cURL
pip install requests
pip install python-dotenv # For environment variables
npm install axios
npm install dotenv # For environment variables
# cURL is usually pre-installed on most systems
curl --version
Set up environment variables
Create a .env file in your project root to store your API credentials securely: QUANTUM_API_TOKEN = your_bearer_token_here
QUANTUM_API_BASE_URL = https://www.cognivo.app/api/v1
QUANTUM_AGENT_ID = 5
QUANTUM_COMPANY_ID = 2
QUANTUM_OWNER_ID = 1
Never commit your .env file to version control. Add it to your .gitignore.
Create your first integration
Set up a basic integration to test your connection to the Quantum AI Agent: import os
import requests
from dotenv import load_dotenv
# Load environment variables
load_dotenv()
class QuantumAPIClient :
def __init__ ( self ):
self .base_url = os.getenv( 'QUANTUM_API_BASE_URL' )
self .token = os.getenv( 'QUANTUM_API_TOKEN' )
self .headers = {
'Authorization' : f 'Bearer { self .token } ' ,
'Content-Type' : 'application/json'
}
def test_connection ( self ):
"""Test API connection"""
try :
response = requests.get( f ' { self .base_url } /test' , headers = self .headers)
return response.status_code == 200
except Exception as e:
print ( f "Connection failed: { e } " )
return False
# Initialize client
client = QuantumAPIClient()
if client.test_connection():
print ( "✅ Connected to Quantum AI Agent successfully!" )
else :
print ( "❌ Failed to connect to Quantum AI Agent" )
const axios = require ( 'axios' );
require ( 'dotenv' ). config ();
class QuantumAPIClient {
constructor () {
this . baseURL = process . env . QUANTUM_API_BASE_URL ;
this . token = process . env . QUANTUM_API_TOKEN ;
this . headers = {
'Authorization' : `Bearer ${ this . token } ` ,
'Content-Type' : 'application/json'
};
}
async testConnection () {
try {
const response = await axios . get ( ` ${ this . baseURL } /test` , {
headers: this . headers
});
return response . status === 200 ;
} catch ( error ) {
console . error ( 'Connection failed:' , error . message );
return false ;
}
}
}
// Initialize client
const client = new QuantumAPIClient ();
client . testConnection (). then ( success => {
if ( success ) {
console . log ( '✅ Connected to Quantum AI Agent successfully!' );
} else {
console . log ( '❌ Failed to connect to Quantum AI Agent' );
}
});
Test document upload
Create a simple test to upload a document to the Quantum AI Agent: import base64
def upload_test_document ( client ):
# Create a simple text document
text_content = "Hello Quantum AI Agent! This is a test document."
base64_content = base64.b64encode(text_content.encode()).decode()
data = {
"owner_id" : int (os.getenv( 'QUANTUM_OWNER_ID' )),
"company_id" : int (os.getenv( 'QUANTUM_COMPANY_ID' )),
"agent_id" : int (os.getenv( 'QUANTUM_AGENT_ID' )),
"documents" : [
{
"name" : "test-document.txt" ,
"mimetype" : "text/plain" ,
"base64" : base64_content
}
]
}
response = requests.post(
f ' { client.base_url } /documents/create' ,
headers = client.headers,
json = data
)
return response.json()
# Test upload
result = upload_test_document(client)
print ( "Upload result:" , result)
async function uploadTestDocument ( client ) {
// Create a simple text document
const textContent = "Hello Quantum AI Agent! This is a test document." ;
const base64Content = Buffer . from ( textContent ). toString ( 'base64' );
const data = {
owner_id: parseInt ( process . env . QUANTUM_OWNER_ID ),
company_id: parseInt ( process . env . QUANTUM_COMPANY_ID ),
agent_id: parseInt ( process . env . QUANTUM_AGENT_ID ),
documents: [
{
name: "test-document.txt" ,
mimetype: "text/plain" ,
base64: base64Content
}
]
};
try {
const response = await axios . post (
` ${ client . baseURL } /documents/create` ,
data ,
{ headers: client . headers }
);
return response . data ;
} catch ( error ) {
console . error ( 'Upload failed:' , error . response ?. data || error . message );
return null ;
}
}
// Test upload
uploadTestDocument ( client ). then ( result => {
console . log ( 'Upload result:' , result );
});
Best Practices
Error Handling Always implement proper error handling for API calls. Check status codes and handle network failures gracefully.
Rate Limiting Respect API rate limits. Implement exponential backoff for retries when encountering rate limit errors.
Security Store API tokens securely using environment variables. Never hardcode credentials in your source code.
Logging Implement comprehensive logging to track API interactions and debug issues effectively.
Check out our GitHub repository for complete integration examples in multiple programming languages.
Use virtual environments (Python) or package managers (Node.js)
Set up proper IDE configuration with API documentation
Configure debugging tools for API interactions
Next Steps
Once you have your development environment set up:
Explore the API : Review the API Documentation
Upload Documents : Try the Documents API
Build Your Integration : Start developing your custom integration
Test Thoroughly : Ensure your integration handles all edge cases
Need help? Check our troubleshooting guide or contact support for assistance with your Quantum AI Agent integration.
We suggest using extensions on your IDE to recognize and format MDX. If you’re a VSCode user, consider the MDX VSCode extension for syntax highlighting, and Prettier for code formatting.
Troubleshooting
Error: Could not load the "sharp" module using the darwin-arm64 runtime
This may be due to an outdated version of node. Try the following:
Remove the currently-installed version of the CLI: npm remove -g mint
Upgrade to Node v19 or higher.
Reinstall the CLI: npm i -g mint
Issue: Encountering an unknown error
Solution: Go to the root of your device and delete the ~/.mintlify folder. Then run mint dev again.
Curious about what changed in the latest CLI version? Check out the CLI changelog .