> ## Documentation Index
> Fetch the complete documentation index at: https://docs.getbluejay.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Run Simulations

> Queue a simulation, read the results, and attach agent traces.

Run an existing simulation from Python or Node.js and use its run ID to read the results. The SDK can queue tests from a script or CI. It can also attach traces from the agent under test to the simulation result.

## Queue a run

[Connect your agent](https://docs.getbluejay.ai/integrations/overview.md) and [create a simulation](https://docs.getbluejay.ai/test/simulations/create.md) in Bluejay. Copy the simulation ID from the simulation page.

```python Python icon="https://mintcdn.com/bluejay/73RDPPJpgHtl6PiO/logo/python.svg?fit=max&auto=format&n=73RDPPJpgHtl6PiO&q=85&s=ce56f186813559443f877804e7aef209" theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
from bluejay import BluejayClient

client = BluejayClient()
run = client.simulations.run(simulation_id="YOUR_SIMULATION_ID")
print(run.simulation_run_id)
print(run.run_url)
```

```typescript TypeScript icon="https://mintcdn.com/bluejay/73RDPPJpgHtl6PiO/logo/typescript.svg?fit=max&auto=format&n=73RDPPJpgHtl6PiO&q=85&s=d4b45d3e44d76cf40cfb09b3d24831f5" theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
import { BluejayClient } from "@getbluejay/sdk";

const client = new BluejayClient();
const run = await client.simulations.run({ simulation_id: "YOUR_SIMULATION_ID" });
console.log(run.simulation_run_id, run.run_url);
```

The API returns when the run is queued. The simulation's configured Digital Humans are used unless you pass `digital_human_ids`. See the [queue API](https://docs.getbluejay.ai/api-reference/endpoint/queue-simulation-run-v2.md) for run overrides and SMS requirements.

## Read results

Fetch the results using the run ID. The run can still be `RUNNING`. For automation, poll until `COMPLETED` or until your job times out.

```python Python icon="https://mintcdn.com/bluejay/73RDPPJpgHtl6PiO/logo/python.svg?fit=max&auto=format&n=73RDPPJpgHtl6PiO&q=85&s=ce56f186813559443f877804e7aef209" theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
results = client.simulation_results.list(run.simulation_run_id, limit=20)
print(results.simulation_run.status)
print(results.simulation_run.success_rate)
```

```typescript TypeScript icon="https://mintcdn.com/bluejay/73RDPPJpgHtl6PiO/logo/typescript.svg?fit=max&auto=format&n=73RDPPJpgHtl6PiO&q=85&s=d4b45d3e44d76cf40cfb09b3d24831f5" theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
const results = await client.simulationResults.list({
  simulation_run_id: run.simulation_run_id,
  limit: 20,
});
console.log(results.simulation_run.status);
console.log(results.simulation_run.success_rate);
```

The response includes the run summary and a page of conversations. Increment `offset` by `limit` to read more. For pull request or pipeline reporting, see [CI/CD](https://docs.getbluejay.ai/native-integrations/overview.md). [Results API](https://docs.getbluejay.ai/api-reference/endpoint/retrieve-simulation-results-v2.md)

## Attach traces from the agent under test

Enable [observability](https://docs.getbluejay.ai/sdk/observability.md) in the agent process. Use the **simulation result ID for that specific conversation**, not the run ID printed above.

* **LiveKit** reads the result ID from the `X-Simulation-Result-Id` participant attribute. Node.js also checks job metadata. To supply the ID yourself, pass `simulation_result_id` in Python or `simulationResultId` in Node.js. See [Connect LiveKit](https://docs.getbluejay.ai/integrations/livekit.md).
* **Pipecat** reads it from the start request body in your application. Pass that value as `simulation_result_id` in Python when you create the [tap](https://docs.getbluejay.ai/sdk/pipecat.md).
* **Custom code** passes the simulation result ID when creating the session and calls `conversation.end()` when the test conversation finishes.

Open the completed conversation in the simulation run and inspect its [trace](https://docs.getbluejay.ai/test/traces.md).


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.