Transpiler methods
Qiskit & AI transpiler methods
Benchmark AI-powered passes
Returns a task ID; use the '/benchmark/{taskId}' endpoint to get the result.
Code samples
curl -X POST \
https://cloud-transpiler.quantum.ibm.com/benchmark \
-H 'Authorization: Bearer YOUR-TOKEN' \
-H 'Accept: application/json'
import requests
response = requests.request(
"POST",
"https://cloud-transpiler.quantum.ibm.com/benchmark",
headers={
"Accept": "application/json",
"Authorization": "Bearer YOUR_API_TOKEN_HERE"
},
)
print(response.json())
Responses
{
"task_id": "example"
}
{
"properties": {
"task_id": {
"type": "string",
"title": "Task Id"
}
},
"type": "object",
"required": [
"task_id"
],
"title": "TaskIdResponse"
}
Get benchmark result
Code samples
curl -X GET \
https://cloud-transpiler.quantum.ibm.com/benchmark/{task_id} \
-H 'Authorization: Bearer YOUR-TOKEN' \
-H 'Accept: application/json'
import requests
response = requests.request(
"GET",
"https://cloud-transpiler.quantum.ibm.com/benchmark/{task_id}",
headers={
"Accept": "application/json",
"Authorization": "Bearer YOUR_API_TOKEN_HERE"
},
)
print(response.json())
Responses
{
"state": "example",
"result": null
}
{
"properties": {
"state": {
"type": "string",
"title": "State"
},
"result": {
"anyOf": [
{
"items": {
"properties": {
"algorithm_name": {
"type": "string",
"title": "Algorithm Name"
},
"algorithm_name_compact": {
"type": "string",
"title": "Algorithm Name Compact"
},
"qasm": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"title": "Qasm"
},
"success": {
"type": "boolean",
"title": "Success"
},
"metrics": {
"anyOf": [
{
"properties": {
"n_gates": {
"type": "integer",
"title": "N Gates"
},
"n_layers": {
"type": "integer",
"title": "N Layers"
},
"n_cnots": {
"type": "integer",
"title": "N Cnots"
},
"n_layers_cnots": {
"type": "integer",
"title": "N Layers Cnots"
},
"synthesize_time": {
"anyOf": [
{
"type": "number"
},
{
"type": "null"
}
],
"title": "Synthesize Time"
}
},
"type": "object",
"required": [
"n_gates",
"n_layers",
"n_cnots",
"n_layers_cnots"
],
"title": "BaseMetrics"
},
{
"type": "null"
}
]
}
},
"type": "object",
"required": [
"algorithm_name",
"algorithm_name_compact",
"success"
],
"title": "BenchmarkResult"
},
"type": "array"
},
{
"type": "null"
}
],
"title": "Result"
}
},
"type": "object",
"required": [
"state"
],
"title": "TaskBenchmarkResultResponse"
}
Transpile circuits
Transpile abstract circuits into an instruction set architecture (ISA) circuit, either using Qiskit SDK or AI-powered transpilation. Returns a task ID; use the '/transpile/{taskId}' endpoint to get the result.
Query Parameters
Name, Type | Description |
---|---|
backend string | The name of the backend to transpile the circuit to. Refer to https://docs.quantum.ibm.com/run/get-backend-information. If not specified, you must specify `backend_coupling_map` in the request body. Example: "ibm_kyoto" |
optimization_level integer | How much to optimize the circuit. Refer to https://docs.quantum.ibm.com/transpile/set-optimization Default value: 3 |
use_ai boolean | DEPRECATED: Use 'ai' parameter instead |
ai string | Whether to use Qiskit SDK transpile, the AI-powered features, or let the service to apply automatically the best procedure possible Possible values: true false auto Default value: auto |
ai_layout_mode string | Possible values: keep optimize improve Default value: optimize |
Body Parameters (application/json)
Name, Type | Description |
---|---|
qasm_circuits Required string[] | string | The OpenQASM circuit(s) to transpile. Both OpenQASM 2 and OpenQASM 3 are supported. Example: ["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];","OPENQASM 2.0;\ninclude \"qelib1.inc\";\ngate dcx q0,q1 { cx q0,q1; cx q1,q0; }\nqreg q[3];\ncz q[0],q[2];\nsdg q[1];\ndcx q[2],q[1];\nu3(3.890139082217223,3.447697582994976,1.1583481971959322) q[0];\ncrx(2.3585459177723522) q[1],q[0];\ny q[2];"] |
qiskit_transpile_options object | null | Dictionary with inputs to configure the transpile endpoint. Accepts the same inputs as Qiskit transpile() method https://docs.quantum.ibm.com/api/qiskit/compiler#transpile, except for 'circuits' and 'backend' Example: {"basis_gates":["u1","u2","u3","cx"],"seed_transpiler":0} |
backend_coupling_map integer[][] | null | A list of pairs that represents physical links between qubits.Must be specified if the query parameter `backend` is not set. Example: [[1,2],[2,1]] |
HTTP Response Status Codes
Status code | Description |
---|---|
200 | Successful Response |
422 | Validation Error |
Code samples
curl -X POST \
https://cloud-transpiler.quantum.ibm.com/transpile \
-H 'Authorization: Bearer YOUR-TOKEN' \
-H 'Accept: application/json' \
-H 'Content-Type: application/json' \
-d '{"qasm_circuits":["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];","OPENQASM 2.0;\ninclude \"qelib1.inc\";\ngate dcx q0,q1 { cx q0,q1; cx q1,q0; }\nqreg q[3];\ncz q[0],q[2];\nsdg q[1];\ndcx q[2],q[1];\nu3(3.890139082217223,3.447697582994976,1.1583481971959322) q[0];\ncrx(2.3585459177723522) q[1],q[0];\ny q[2];"]}'
import requests
response = requests.request(
"POST",
"https://cloud-transpiler.quantum.ibm.com/transpile",
headers={
"Accept": "application/json",
"Content-Type": "application/json",
"Authorization": "Bearer YOUR_API_TOKEN_HERE"
},
data="{\"qasm_circuits\":[\"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];\",\"OPENQASM 2.0;\
include \\\"qelib1.inc\\\";\
gate dcx q0,q1 { cx q0,q1; cx q1,q0; }\
qreg q[3];\
cz q[0],q[2];\
sdg q[1];\
dcx q[2],q[1];\
u3(3.890139082217223,3.447697582994976,1.1583481971959322) q[0];\
crx(2.3585459177723522) q[1],q[0];\
y q[2];\"]}"
)
print(response.json())
Responses
{
"task_id": "example"
}
{
"properties": {
"task_id": {
"type": "string",
"title": "Task Id"
}
},
"type": "object",
"required": [
"task_id"
],
"title": "TaskIdResponse"
}
Get transpilation result
Code samples
curl -X GET \
https://cloud-transpiler.quantum.ibm.com/transpile/{task_id} \
-H 'Authorization: Bearer YOUR-TOKEN' \
-H 'Accept: application/json'
import requests
response = requests.request(
"GET",
"https://cloud-transpiler.quantum.ibm.com/transpile/{task_id}",
headers={
"Accept": "application/json",
"Authorization": "Bearer YOUR_API_TOKEN_HERE"
},
)
print(response.json())
Responses
{
"state": "example",
"result": null
}
{
"properties": {
"state": {
"type": "string",
"title": "State"
},
"result": {
"anyOf": [
{
"properties": {
"qasm": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"title": "Qasm"
},
"success": {
"type": "boolean",
"title": "Success"
},
"layout": {
"anyOf": [
{
"properties": {
"initial": {
"items": {
"type": "integer"
},
"type": "array",
"title": "Initial"
},
"final": {
"items": {
"type": "integer"
},
"type": "array",
"title": "Final"
}
},
"type": "object",
"required": [
"initial",
"final"
],
"title": "LayoutResult",
"description": "Enum for layout result"
},
{
"type": "null"
}
]
},
"error": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"title": "Error"
}
},
"type": "object",
"required": [
"success"
],
"title": "RlResult",
"description": "Enum for Rl Result information"
},
{
"items": {
"properties": {
"qasm": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"title": "Qasm"
},
"success": {
"type": "boolean",
"title": "Success"
},
"layout": {
"anyOf": [
{
"properties": {
"initial": {
"items": {
"type": "integer"
},
"type": "array",
"title": "Initial"
},
"final": {
"items": {
"type": "integer"
},
"type": "array",
"title": "Final"
}
},
"type": "object",
"required": [
"initial",
"final"
],
"title": "LayoutResult",
"description": "Enum for layout result"
},
{
"type": "null"
}
]
},
"error": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"title": "Error"
}
},
"type": "object",
"required": [
"success"
],
"title": "RlResult",
"description": "Enum for Rl Result information"
},
"type": "array"
},
{
"type": "string"
},
{
"type": "null"
}
],
"title": "Result"
}
},
"type": "object",
"required": [
"state"
],
"title": "TaskResultResponse"
}