Skip to main contentIBM Quantum Documentation
Qiskit Transpiler Service is experimental and only available for IBM Quantum Premium Plan members.

Qiskit Transpiler Service REST API

The Qiskit Transpiler Service lets you transpile circuits in the cloud by using the latest Qiskit SDK version and AI-powered transpiler passes.


Authentication

You must provide an API token with every call as an HTTP header. You can copy your API token from the upper-right corner of the Dashboard.

Submit your API token on every request within an Authorization header with this format:

Authorization: Bearer YOUR_API_TOKEN_HERE

Example request:

curl -X 'GET' \
  'https://cloud-transpiler.quantum.ibm.com/routing/backends' \
  -H 'accept: application/json' \
  -H 'Authorization: Bearer YOUR_API_TOKEN_HERE'

Transpile quantum circuits

Example request for transpiling a circuit without AI capabilities:

curl -X 'POST' \
  'https://cloud-transpiler.quantum.ibm.com/transpile?backend=ibm_sherbrooke&optimization_level=3&ai=false' \
  -H 'accept: application/json' \
  -H 'Content-Type: application/json' \
  -H 'Authorization: Bearer YOUR_API_TOKEN_HERE' \
  -d '{
  "qasm_circuits": [
    "OPENQASM 2.0;\ninclude \"qelib1.inc\";\nqreg q[3];\nh q[0];\nu3(1.9137014941898343,4.961641954901619,5.909596335243553) q[1];\nsxdg q[2];\ncswap q[2],q[0],q[1];\nh q[2];\nu1(0.5104143323055003) q[0];\nid q[1];",
    "OPENQASM 3; include \"stdgates.inc\"; bit[2] meas; qubit[2] q; h q[0]; cx q[0], q[1]; barrier q[0], q[1]; meas[0] = measure q[0]; meas[1] = measure q[1];"
  ]
}'
import requests
 
    reqUrl = "https://cloud-transpiler.quantum.ibm.com/transpile"
 
    headersList = {
      "Accept": "application/json",
      "Authorization": "Bearer YOUR_API_TOKEN_HERE"
    }
 
    params = {
        "backend": "ibm_sherbrooke",
        "optimization_level": 1,
        "ai": "false",
    }
 
    payload = {
          "qasm_circuits": [
            "OPENQASM 2.0;\ninclude \"qelib1.inc\";\nqreg q[3];\nh q[0];\nu3(1.9137014941898343,4.961641954901619,5.909596335243553) q[1];\nsxdg q[2];\ncswap q[2],q[0],q[1];\nh q[2];\nu1(0.5104143323055003) q[0];\nid q[1];",
            "OPENQASM 3; include \"stdgates.inc\"; bit[2] meas; qubit[2] q; h q[0]; cx q[0], q[1]; barrier q[0], q[1]; meas[0] = measure q[0]; meas[1] = measure q[1];"
          ],
      }
 
    response = requests.request("GET", reqUrl, json=payload, params=params, headers=headersList)
 
    print(response.json())

Example request for transpiling a circuit using the AI capabilities:

curl -X 'POST' \
  'https://cloud-transpiler.quantum.ibm.com/transpile?backend=ibm_sherbrooke&optimization_level=3&ai=true&ai_layout_mode=OPTIMIZE' \
  -H 'accept: application/json' \
  -H 'Content-Type: application/json' \
  -H 'Authorization: Bearer YOUR_API_TOKEN_HERE' \
  -d '{
  "qasm_circuits": [
    "OPENQASM 2.0;\ninclude \"qelib1.inc\";\nqreg q[3];\nh q[0];\nu3(1.9137014941898343,4.961641954901619,5.909596335243553) q[1];\nsxdg q[2];\ncswap q[2],q[0],q[1];\nh q[2];\nu1(0.5104143323055003) q[0];\nid q[1];",
    "OPENQASM 3; include \"stdgates.inc\"; bit[2] meas; qubit[2] q; h q[0]; cx q[0], q[1]; barrier q[0], q[1]; meas[0] = measure q[0]; meas[1] = measure q[1];"
  ]
}'
import requests
 
    reqUrl = "https://cloud-transpiler.quantum.ibm.com/transpile"
 
    headersList = {
      "Accept": "application/json",
      "Authorization": "Bearer YOUR_API_TOKEN_HERE"
    }
 
    params = {
        "backend": "ibm_sherbrooke",
        "optimization_level": 1,
        "ai": "true",
        ai_layout_mode: "OPTIMIZE",
    }
 
    payload = {
          "qasm_circuits": [
            "OPENQASM 2.0;\ninclude \"qelib1.inc\";\nqreg q[3];\nh q[0];\nu3(1.9137014941898343,4.961641954901619,5.909596335243553) q[1];\nsxdg q[2];\ncswap q[2],q[0],q[1];\nh q[2];\nu1(0.5104143323055003) q[0];\nid q[1];",
            "OPENQASM 3; include \"stdgates.inc\"; bit[2] meas; qubit[2] q; h q[0]; cx q[0], q[1]; barrier q[0], q[1]; meas[0] = measure q[0]; meas[1] = measure q[1];"
          ],
      }
 
    response = requests.request("GET", reqUrl, json=payload, params=params, headers=headersList)
 
    print(response.json())

All of the previous requests return a response like this, where task_id is the ID of the task running your transpilation process:

{
  "task_id": "string"
}

Request the transpilation result as follows:

curl -X 'GET' \
  'https://cloud-transpiler.quantum.ibm.com/transpile/<task_id>' \
  -H 'accept: application/json' \
  -H 'Authorization: Bearer YOUR_API_TOKEN_HERE'

The response follows this structure:

{
  "state": "string",
  "result": {
    "qasm": "string",
    "success": true,
    "layout": {
      "initial": [
        0
      ],
      "final": [
        0
      ]
    }
  }
}

Example:

{
  "state": "SUCCESS",
  "result": [
    {
      "qasm": "OPENQASM 2.0; include \"qelib1.inc\"; gate rzx(param0) q0,q1 { h q1; cx q0,q1; rz(param0) q1; cx q0,q1; h q1; } gate ecr q0,q1 { rzx(pi/4) q0,q1; x q0; rzx(-pi/4) q0,q1; } qreg q[127]; rz(-pi) q[92]; sx q[92]; rz(-pi/2) q[92]; rz(-0.3735889719360337) q[102]; sx q[102]; rz(-1.227891159399963) q[102]; sx q[102]; rz(0.7089591292161597) q[102]; rz(pi/2) q[103]; sx q[103]; ecr q[102],q[103]; rz(-2.6818864988905657) q[102]; sx q[102]; rz(-pi/4) q[102]; sx q[102]; ecr q[92],q[102]; rz(-0.8499322410428638) q[92]; sx q[92]; rz(-pi/2) q[92]; rz(-pi/4) q[102]; sx q[102]; sx q[103]; rz(pi/4) q[103]; sx q[103]; rz(-pi/2) q[103]; ecr q[102],q[103]; rz(pi/2) q[102]; sx q[102]; rz(3*pi/4) q[102]; ecr q[92],q[102]; sx q[92]; rz(pi/2) q[92]; sx q[102]; rz(-pi/2) q[102]; ecr q[92],q[102]; rz(pi/2) q[92]; sx q[92]; rz(-pi/4) q[92]; sx q[92]; rz(pi/2) q[92]; rz(2.205208228295711) q[102]; sx q[102]; rz(-pi/2) q[102]; rz(-pi/2) q[103]; sx q[103]; rz(-2.6608412204380834) q[103]; sx q[103]; ecr q[102],q[103]; rz(pi/2) q[102]; sx q[102]; rz(pi/2) q[103]; sx q[103]; rz(-pi/2) q[103]; ecr q[102],q[103]; rz(-pi/2) q[102]; sx q[102]; rz(-pi) q[102]; rz(3*pi/4) q[103]; sx q[103]; rz(-pi) q[103]; ecr q[102],q[103]; rz(-1.090044893643186) q[102]; sx q[102]; rz(-0.5104143323055013) q[102]; sx q[102]; ecr q[92],q[102]; rz(pi/2) q[92]; rz(-pi) q[102]; sx q[102]; rz(-2.2697423059411275) q[103]; sx q[103]; rz(pi/2) q[103];",
      "success": true,
      "layout": {
        "initial": [
          103,
          102,
          92,
          108,
          59,
          72,
          100,
          99,
          82,
          9,
          0,
          16,
          116,
          74,
          61,
          126,
          20,
          106,
          17,
          22,
          36,
          47,
          19,
          21,
          71,
          58,
          125,
          119,
          38,
          11,
          29,
          75,
          121,
          94,
          45,
          52,
          90,
          13,
          46,
          87,
          57,
          6,
          80,
          91,
          10,
          115,
          32,
          51,
          55,
          122,
          77,
          120,
          67,
          88,
          112,
          86,
          30,
          37,
          118,
          85,
          76,
          97,
          98,
          95,
          26,
          50,
          8,
          113,
          62,
          42,
          12,
          15,
          41,
          23,
          105,
          81,
          53,
          1,
          43,
          5,
          107,
          64,
          123,
          31,
          68,
          35,
          44,
          114,
          28,
          70,
          48,
          69,
          109,
          124,
          83,
          33,
          14,
          73,
          27,
          66,
          40,
          54,
          104,
          25,
          79,
          3,
          117,
          60,
          84,
          7,
          110,
          63,
          101,
          56,
          2,
          93,
          4,
          24,
          18,
          78,
          89,
          34,
          96,
          65,
          111,
          49,
          39
        ],
        "final": [
          58,
          79,
          7
        ]
      }
    },
    {
      "qasm": "OPENQASM 3.0; include \"stdgates.inc\"; gate rzx_139749147951056(_gate_p_0) _gate_q_0, _gate_q_1 {   h _gate_q_1;   cx _gate_q_0, _gate_q_1;   rz(pi/4) _gate_q_1;   cx _gate_q_0, _gate_q_1;   h _gate_q_1; } gate rzx_139749059469584(_gate_p_0) _gate_q_0, _gate_q_1 {   h _gate_q_1;   cx _gate_q_0, _gate_q_1;   rz(-pi/4) _gate_q_1;   cx _gate_q_0, _gate_q_1;   h _gate_q_1; } gate ecr _gate_q_0, _gate_q_1 {   rzx_139749147951056(pi/4) _gate_q_0, _gate_q_1;   x _gate_q_0;   rzx_139749059469584(-pi/4) _gate_q_0, _gate_q_1; } bit[2] meas; rz(-pi/2) $0; sx $0; rz(-0.20788316431931975) $0; sx $0; rz(-pi/2) $0; rz(-pi/2) $1; sx $1; rz(-1.9819380704886775) $1; ecr $1, $0; rz(pi/2) $0; sx $0; rz(-0.20788316431932063) $0; rz(-0.4111417436937801) $1; sx $1; rz(pi/2) $1; barrier $0, $1; meas[0] = measure $0; meas[1] = measure $1;",
      "success": true,
      "layout": {
        "initial": [
          0,
          1,
          2,
          3,
          4,
          5,
          6,
          7,
          8,
          9,
          10,
          11,
          12,
          13,
          14,
          15,
          16,
          17,
          18,
          19,
          20,
          21,
          22,
          23,
          24,
          25,
          26,
          27,
          28,
          29,
          30,
          31,
          32,
          33,
          34,
          35,
          36,
          37,
          38,
          39,
          40,
          41,
          42,
          43,
          44,
          45,
          46,
          47,
          48,
          49,
          50,
          51,
          52,
          53,
          54,
          55,
          56,
          57,
          58,
          59,
          60,
          61,
          62,
          63,
          64,
          65,
          66,
          67,
          68,
          69,
          70,
          71,
          72,
          73,
          74,
          75,
          76,
          77,
          78,
          79,
          80,
          81,
          82,
          83,
          84,
          85,
          86,
          87,
          88,
          89,
          90,
          91,
          92,
          93,
          94,
          95,
          96,
          97,
          98,
          99,
          100,
          101,
          102,
          103,
          104,
          105,
          106,
          107,
          108,
          109,
          110,
          111,
          112,
          113,
          114,
          115,
          116,
          117,
          118,
          119,
          120,
          121,
          122,
          123,
          124,
          125,
          126
        ],
        "final": [
          0,
          1
        ]
      }
    }
  ]
}
Was this page helpful?
Report a bug or request content on GitHub.