Skip to main content

Code Examples

Complete, production-ready code examples for SoftQCOS SDK.

Quick Navigationโ€‹

ExampleDescriptionDifficulty
Hello QuantumYour first quantum circuit๐ŸŸข Beginner
Bell StateQuantum entanglement basics๐ŸŸข Beginner
GHZ StateMulti-qubit entanglement๐ŸŸก Intermediate
Quantum TeleportationTransfer quantum state๐ŸŸก Intermediate
VQE ChemistryMolecular energy calculation๐Ÿ”ด Advanced
QAOA OptimizationCombinatorial optimization๐Ÿ”ด Advanced
Batch ProcessingProcess multiple circuits๐ŸŸก Intermediate
Azure QuantumRun on real QPUs๐ŸŸก Intermediate
Error HandlingProduction patterns๐ŸŸข Beginner
Async OperationsHigh-throughput processing๐ŸŸก Intermediate

Prerequisitesโ€‹

# Install SoftQCOS SDK
pip install softqcos-sdk

# Optional: Qiskit for circuit construction
pip install qiskit

# Optional: Visualization
pip install softqcos-sdk[visualization]

Configurationโ€‹

import os
from softqcos_sdk import QCOSClient

# Option 1: Direct API key
client = QCOSClient(api_key="your-api-key")

# Option 2: Environment variable (recommended)
os.environ["SOFTQCOS_API_KEY"] = "your-api-key"
client = QCOSClient() # Auto-loads from env

# Option 3: Config file (~/.softqcos/config.json)
client = QCOSClient() # Auto-loads from config

Running Examplesโ€‹

All examples can be run directly:

# Clone examples repository
git clone https://github.com/softquantus/softqcos-examples.git
cd softqcos-examples

# Set your API key
export SOFTQCOS_API_KEY=your-api-key

# Run any example
python examples/bell_state.py

Complete Example Indexโ€‹

Beginner Examplesโ€‹

These examples introduce the fundamental concepts of quantum computing with SoftQCOS.

  • Hello Quantum - Execute your first quantum circuit
  • Bell State - Create quantum entanglement between two qubits
  • Error Handling - Handle API errors gracefully

Intermediate Examplesโ€‹

Build on the basics with more complex circuits and features.

  • GHZ State - Scale entanglement to many qubits
  • Quantum Teleportation - Transfer quantum information
  • Batch Processing - Process hundreds of circuits efficiently
  • Azure Quantum - Execute on real quantum hardware

Advanced Examplesโ€‹

Production-grade applications of quantum computing.

  • VQE Chemistry - Calculate molecular ground state energies
  • QAOA Optimization - Solve combinatorial optimization problems
  • Quantum Machine Learning - Variational quantum classifiers