

Die vorliegende Übersetzung wurde maschinell erstellt. Im Falle eines Konflikts oder eines Widerspruchs zwischen dieser übersetzten Fassung und der englischen Fassung (einschließlich infolge von Verzögerungen bei der Übersetzung) ist die englische Fassung maßgeblich.

# Schalten Sie den Amazon Braket Boto3-Client ein
<a name="braket-using-boto3-client"></a>

Um Boto3 mit Amazon Braket zu verwenden, müssen Sie Boto3 importieren und dann einen Client definieren, den Sie für die Verbindung mit Amazon Braket verwenden. API Im folgenden Beispiel wird der Boto3-Client benannt. `braket`

```
import boto3
import botocore

braket = boto3.client("braket")
```

**Anmerkung**  
[Braket unterstützt](https://docs.aws.amazon.com/vpc/latest/userguide/aws-ipv6-support.html). IPv6 [Wenn Sie ein IPv6 reines Netzwerk verwenden oder sicherstellen möchten, dass Ihr Workload IPv6 Datenverkehr verwendet, verwenden Sie die Dual-Stack-Endpunkte, wie im Leitfaden Dual-Stack- und FIPS-Endpoints beschrieben.](https://docs.aws.amazon.com/sdkref/latest/guide/feature-endpoints.html)

Jetzt, da Sie einen `braket` Kunden eingerichtet haben, können Sie Anfragen stellen und Antworten über den Amazon Braket-Service bearbeiten. Weitere Informationen zu Anfrage- und Antwortdaten finden Sie in der [API-Referenz.](https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/braket.html)

**Topics**
+ [Suchen Sie nach Geräten](#braket-using-boto3-example-search-devices)
+ [Rufen Sie ein Gerät ab](#braket-using-boto3-example-retrieve-devices)
+ [Erstellen Sie eine Quantenaufgabe](#braket-using-boto3-example-create-task)
+ [Rufen Sie eine Quantenaufgabe ab](#braket-using-boto3-example-retrieve-task)
+ [Suchen Sie nach Quantenaufgaben](#braket-using-boto3-example-search-tasks)
+ [Quantenaufgabe abbrechen](#braket-using-boto3-example-cancel-task)

## Suchen Sie nach Geräten
<a name="braket-using-boto3-example-search-devices"></a>
+  `search_devices(**kwargs)` 

Sucht nach Geräten, die die angegebenen Filter verwenden.

```
# Pass search filters and optional parameters when sending the
# request and capture the response
response = braket.search_devices(filters=[{
    'name': 'deviceArn',
    'values': ['arn:aws:braket:::device/quantum-simulator/amazon/sv1']
}], maxResults=10)

print(f"Found {len(response['devices'])} devices")

for i in range(len(response['devices'])):
    device = response['devices'][i]
    print(device['deviceArn'])
```

## Rufen Sie ein Gerät ab
<a name="braket-using-boto3-example-retrieve-devices"></a>
+  `get_device(deviceArn)` 

Rufen Sie die in Amazon Braket verfügbaren Geräte ab.

```
# Pass the device ARN when sending the request and capture the repsonse
response = braket.get_device(deviceArn='arn:aws:braket:::device/quantum-simulator/amazon/sv1')

print(f"Device {response['deviceName']} is {response['deviceStatus']}")
```

## Erstellen Sie eine Quantenaufgabe
<a name="braket-using-boto3-example-create-task"></a>
+  `create_quantum_task(**kwargs)` 

Erstellen Sie eine Quantenaufgabe.

```
# Create parameters to pass into create_quantum_task()
kwargs = {
    # Create a Bell pair
    'action': '{"braketSchemaHeader": {"name": "braket.ir.jaqcd.program", "version": "1"}, "results": [], "basis_rotation_instructions": [], "instructions": [{"type": "h", "target": 0}, {"type": "cnot", "control": 0, "target": 1}]}',
    # Specify the SV1 Device ARN
    'deviceArn': 'arn:aws:braket:::device/quantum-simulator/amazon/sv1',
    # Specify 2 qubits for the Bell pair
    'deviceParameters': '{"braketSchemaHeader": {"name": "braket.device_schema.simulators.gate_model_simulator_device_parameters", "version": "1"}, "paradigmParameters": {"braketSchemaHeader": {"name": "braket.device_schema.gate_model_parameters", "version": "1"}, "qubitCount": 2}}',
    # Specify where results should be placed when the quantum task completes.
    # You must ensure the S3 Bucket exists before calling create_quantum_task()
    'outputS3Bucket': 'amazon-braket-examples',
    'outputS3KeyPrefix': 'boto-examples',
    # Specify number of shots for the quantum task
    'shots': 100
}

# Send the request and capture the response
response = braket.create_quantum_task(**kwargs)

print(f"Quantum task {response['quantumTaskArn']} created")
```

## Rufen Sie eine Quantenaufgabe ab
<a name="braket-using-boto3-example-retrieve-task"></a>
+  `get_quantum_task(quantumTaskArn)` 

Ruft die angegebene Quantenaufgabe ab.

```
# Pass the quantum task ARN when sending the request and capture the response
response = braket.get_quantum_task(quantumTaskArn='arn:aws:braket:us-west-1:123456789012:quantum-task/ce78c429-cef5-45f2-88da-123456789012')

print(response['status'])
```

## Suchen Sie nach Quantenaufgaben
<a name="braket-using-boto3-example-search-tasks"></a>
+  `search_quantum_tasks(**kwargs)` 

Sucht nach Quantenaufgaben, die den angegebenen Filterwerten entsprechen.

```
# Pass search filters and optional parameters when sending the
# request and capture the response
response = braket.search_quantum_tasks(filters=[{
    'name': 'deviceArn',
    'operator': 'EQUAL',
    'values': ['arn:aws:braket:::device/quantum-simulator/amazon/sv1']
}], maxResults=25)

print(f"Found {len(response['quantumTasks'])} quantum tasks")

for n in range(len(response['quantumTasks'])):
    task = response['quantumTasks'][n]
    print(f"Quantum task {task['quantumTaskArn']} for {task['deviceArn']} is {task['status']}")
```

## Quantenaufgabe abbrechen
<a name="braket-using-boto3-example-cancel-task"></a>
+  `cancel_quantum_task(quantumTaskArn)` 

Storniert die angegebene Quantenaufgabe.

```
# Pass the quantum task ARN when sending the request and capture the response
response = braket.cancel_quantum_task(quantumTaskArn='arn:aws:braket:us-west-1:123456789012:quantum-task/ce78c429-cef5-45f2-88da-123456789012')

print(f"Quantum task {response['quantumTaskArn']} is {response['cancellationStatus']}")
```