Skip to main content
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.
1

Install required dependencies

Choose your preferred programming language and install the necessary HTTP client libraries:
pip install requests
pip install python-dotenv  # For environment variables
2

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.
3

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")
4

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)

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.

Development Tools

  • Postman: Create and test API requests with a GUI
  • Insomnia: Lightweight REST client for API testing
  • cURL: Command-line tool for making HTTP requests
  • HTTPie: User-friendly command-line HTTP client
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:
  1. Explore the API: Review the API Documentation
  2. Upload Documents: Try the Documents API
  3. Build Your Integration: Start developing your custom integration
  4. 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

This may be due to an outdated version of node. Try the following:
  1. Remove the currently-installed version of the CLI: npm remove -g mint
  2. Upgrade to Node v19 or higher.
  3. Reinstall the CLI: npm i -g mint
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.
I