About cookies on this site Our websites require some cookies to function properly (required). In addition, other cookies may be used with your consent to analyze site usage, improve the user experience and for advertising. For more information, please review your options. By visiting our website, you agree to our processing of information as described in IBM’sprivacy statement. To provide a smooth navigation, your cookie preferences will be shared across the IBM web domains listed here.
AI Routing methods
Get available backends
Gets the list of backends the user can work with
Code samples
GET
/routing/backendscurl -X GET \
https://cloud-transpiler.quantum.ibm.com/routing/backends \
-H 'Authorization: Bearer YOUR-TOKEN' \
-H 'Accept: application/json'
import requests
response = requests.request(
"GET",
"https://cloud-transpiler.quantum.ibm.com/routing/backends",
headers={
"Accept": "application/json",
"Authorization": "Bearer YOUR_API_TOKEN_HERE"
},
)
print(response.json())
Responses
[
"example"
]
{
"type": "array",
"items": {
"type": "string"
},
"title": "Response Backends Routing Backends Get"
}
Route circuit to coupling map
Returns a task ID; use the '/routing/routing/{taskId}' endpoint to get the result.
Query Parameters
Name, Type | Description |
---|---|
check_result boolean | If true, the reinforcement learning (RL) model checks the result before returning a response. Default value: false |
optimization_level integer | How much to optimize the circuit. Refer to /guides/ai-transpiler-passes#ai-routing-pass Default value: 2 |
layout_mode string | Specifies how to handle the layout selection Possible values: keep optimize improve Default value: keep |
Body Parameters (application/json)
Name, Type | Description |
---|---|
qasm string | null | The OpenQASM circuit to route. 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];" Example: "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];" |
qpy string | null | The QPY circuit to route. QPY circuits must be encoded in Base64. Example: "UUlTS0lUDAECBAAAAAAAAAABZXEAEWYACAAAAAIAAAACAAAAAAAAAAIAAAACAAAAAAAAAAUAAAAAY2lyY3VpdC0xNzgtNTAxNTcAAAAAAAAAAHt9cQEAAAACAAEBcQAAAAAAAAAAAAAAAAAAAAFjAQAAAAIABAFtZWFzAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAUAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAASEdhdGVxAAAAAAAGAAAAAAAAAAIAAAAAAAAAAAAAAAAAAAAAAAABAAAAAUNYR2F0ZXEAAAAAcQAAAAEABwAAAAAAAAACAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABCYXJyaWVycQAAAABxAAAAAQAHAAAAAAAAAAEAAAABAAAAAAAAAAAAAAAAAAAAAAAAAE1lYXN1cmVxAAAAAGMAAAAAAAcAAAAAAAAAAQAAAAEAAAAAAAAAAAAAAAAAAAAAAAAATWVhc3VyZXEAAAABYwAAAAEAAAD///////////////8AAAAAAAAAAA==" |
coupling_map Required integer[][] | string | Example: [[0,1],[1,2],[2,3],[3,4],[4,5],[5,6],[6,7]] Example: "ibm_sherbrooke" |
optimization_preferences string | string[] | null | Describe your preferences with a value or a list of values when prioritizing optimization. Allowed options: noise, n_cnots, n_gates, cnot_layers, layers. Example: ["noise","n_gates"] Example: "n_cnots" |
HTTP Response Status Codes
Status code | Description |
---|---|
200 | Successful Response |
422 | Validation Error |
Code samples
POST
/routing/routingcurl -X POST \
https://cloud-transpiler.quantum.ibm.com/routing/routing \
-H 'Authorization: Bearer YOUR-TOKEN' \
-H 'Accept: application/json' \
-H 'Content-Type: application/json' \
-d '{"coupling_map":[[0,1],[1,2],[2,3],[3,4],[4,5],[5,6],[6,7]]}'
import requests
response = requests.request(
"POST",
"https://cloud-transpiler.quantum.ibm.com/routing/routing",
headers={
"Accept": "application/json",
"Content-Type": "application/json",
"Authorization": "Bearer YOUR_API_TOKEN_HERE"
},
data="{\"coupling_map\":[[0,1],[1,2],[2,3],[3,4],[4,5],[5,6],[6,7]]}"
)
print(response.json())
Responses
{
"task_id": "example"
}
{
"properties": {
"task_id": {
"type": "string",
"title": "Task Id"
}
},
"type": "object",
"required": [
"task_id"
],
"title": "TaskIdResponse"
}
Get routing result
Gets a task routing result. The Task ID needed for this endpoint is returned by /routing/routing
Code samples
GET
/routing/routing/{task_id}curl -X GET \
https://cloud-transpiler.quantum.ibm.com/routing/routing/{task_id} \
-H 'Authorization: Bearer YOUR-TOKEN' \
-H 'Accept: application/json'
import requests
response = requests.request(
"GET",
"https://cloud-transpiler.quantum.ibm.com/routing/routing/{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"
},
"qpy": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"title": "Qpy"
},
"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": "UnCompressedRlResult"
},
{
"items": {
"properties": {
"qasm": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"title": "Qasm"
},
"qpy": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"title": "Qpy"
},
"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": "UnCompressedRlResult"
},
"type": "array"
},
{
"type": "string"
},
{
"type": "null"
}
],
"title": "Result"
}
},
"type": "object",
"required": [
"state"
],
"title": "TaskResultResponse"
}
Was this page helpful?
Report a bug or request content on GitHub.