Beta API. See the stability policy.

Using the API from an AI agent

This article is for when you want an AI coding assistant, such as Claude Code, Cursor or Codex, to work with ThrustLab. There are two ways. You can connect it to the ThrustLab server for assistants, so it can search parts and run simulations by itself. Or you can give it a few rules and let it write code against the API. If you want to use ThrustLab from a chat app like Claude, ChatGPT or Gemini, see Connect an AI assistant.

Connect to the ThrustLab server

The address is https://thrustlab.com/mcp. It follows the Model Context Protocol, a standard way for assistants to use tools. You don't need an account. If you have an API key, send it too and the assistant works as your account.

Write the address without a slash at the end.

The assistant gets these tools:

Connect to the ThrustLab server
ToolWhat it does
search_componentsFinds motors, propellers and batteries and returns their datasheet values.
get_componentReturns one part by its ID, with where its data comes from.
estimate_propellerGives thrust, torque and power for a propeller from its printed size.
simulate_powertrainRuns a whole powertrain at one point and returns a link to the result.
sweep_powertrainDoes the same across a range of throttle or airspeed, up to 25 points.
get_resultReads a saved result.
get_validation_summaryShows how well a model matches measurements.

Only simulate_powertrain and sweep_powertrain start runs. The rest only read. Each tool says so to the assistant, so it can ask you first when that matters.

Claude Code

bash
claude mcp add --transport http thrustlab https://thrustlab.com/mcp

To work as your account, add your key:

bash
claude mcp add --transport http thrustlab https://thrustlab.com/mcp \
  --header "Authorization: Bearer $THRUSTLAB_API_KEY"

Cursor

Put this in .cursor/mcp.json in your project, or in ~/.cursor/mcp.json for every project. Leave out headers to connect without an account.

json
{
  "mcpServers": {
    "thrustlab": {
      "url": "https://thrustlab.com/mcp",
      "headers": { "Authorization": "Bearer YOUR_THRUSTLAB_API_KEY" }
    }
  }
}

Codex

Put this in ~/.codex/config.toml. The last line is optional. It sends the key from an environment variable.

toml
[mcp_servers.thrustlab]
url = "https://thrustlab.com/mcp"
bearer_token_env_var = "THRUSTLAB_API_KEY"

Quote the source

The parts data is under the CC BY 4.0 license. When an assistant gives a value from it, it should add this line: Data: ThrustLab component database (thrustlab.com), CC BY 4.0. When it gives a simulation result, it should say which propeller model made the number and share the link to the result.

Give your assistant the rules

If your assistant writes code against the API, put this in your project's AGENTS.md or CLAUDE.md. It covers the mistakes that cost the most time.

markdown
## ThrustLab API
Read the key from the `THRUSTLAB_API_KEY` environment variable.
Never write a key into a file, a commit or a log line.
The base URL is `https://thrustlab.com`. Every endpoint is under `/v1/`.
Send `Authorization: Bearer $THRUSTLAB_API_KEY`.
Use the Python library (`pip install thrustlab`) instead of writing HTTP by hand.
Send an `Idempotency-Key` header on every POST, PATCH and DELETE. Use the same
key when you retry the same request. A different body under the same key gets a 409.
A run takes time. Check it every 2 to 5 seconds. Never check in a tight loop.
On any 429, wait the number of seconds in the `Retry-After` header.
You can start 30 sweeps, 30 flights over time and 120 simulations a minute.
To try many parts, send ONE sweep with a `component_axes` entry. Don't send a
loop of single runs.
In a sweep, `steps` is the number of points, not a step size:
{"start": 40, "stop": 100, "steps": 4} gives 40, 60, 80, 100.
Don't copy the whole parts catalog. `GET /v1/components` filters and sorts on the
server (`kv[gte]`, `resistance[lte]`, `sort_by`). With `ids_only=true` it
returns up to 5,000 IDs in one response, with a `truncated` flag.
To stop several runs, send their IDs to `POST /v1/simulations/cancel-selected`.
Every error has `type`, `code`, `request_id` and `doc_url`. Test for `code`,
log `request_id`, and read `doc_url` when the code is new to you.

One sweep instead of many runs

A sweep can try several motors, propellers or batteries in one request. Add a component_axes entry to the sweep with the axis (motor, propeller or battery), the slots it applies to (the rotor group numbers, counting from 0) and at least two component_ids. The sweep combines it with the other things you sweep. Four propellers and four throttle settings make 16 points, in one request instead of sixteen.

Each point of the result says which part it used, in point["inputs"]["component"]. This example does it in Python:

Python
"""Component axis x throttle: auth -> submit -> wait() -> inspect points.

Run it:
    export THRUSTLAB_API_KEY=key_...        # never hard-code the key
    python examples/sweeps/component_axis_grid.py

Crosses a propeller component axis with a throttle range, so one request solves
every propeller at every throttle. It takes the first four catalog propellers
from client.components.list(type="propeller") and crosses them with four
throttle settings: 16 points in one submission.

Each returned point names the propeller that produced it at
point["inputs"]["component"], a list of {axis, slot, id, name}.

Sixteen separate simulations would be sixteen requests against the
per-minute submission limit and sixteen cold solves; this is one request and
one warm solver.

`sweep.throttle.steps` is the NUMBER OF POINTS, not a step size.
"""

from thrustlab import Client

client = Client()  # reads $THRUSTLAB_API_KEY from the environment

project = client.projects.create(name="sdk component-axis example")

# The fixed half of the configuration — same verification combo as
# examples/sweeps/run_and_poll.py. Resolve by name, or paste explicit IDs.
motor = client.components.find(name="BadAss 2826-820Kv")
battery = client.components.find(
    name="Liperior 5000mAh 4S 35C 14.8V Lipo Battery With XT90 Plug"
)

# The swept half: the first four catalog propellers. `.data` is the first page
# of the cursor pager, so this is one request. A component axis needs at least
# two IDs — a one-value axis is not a sweep, and the server rejects it with
# `invalid_component_axis`.
props = client.components.list(type="propeller", limit=4).data
prop_ids = [p["id"] for p in props]
print("propeller axis:", ", ".join(p["name"] for p in props))

sweep = client.sweeps.create(
    project_id=project["id"],
    battery_component_id=battery["id"],
    airspeed_m_s=0.0,
    density_kg_m3=1.225,
    state_of_charge_pct=100,
    # `propeller_component_id` here is the BASE value for slot 0. The component
    # axis below overrides it at every point, so it only has to be valid.
    rotor_groups=[
        {
            "label": "main",
            # Four rotors need the Pro plan. On the Free plan, use "count": 1.
            "count": 4,
            "motor_component_id": motor["id"],
            "propeller_component_id": prop_ids[0],
            "throttle_pct": 70,
        }
    ],
    sweep={
        # One bool per rotor group: this group follows the swept throttle axis.
        "rotor_sweep_mask": [True],
        # `steps` is the NUMBER OF POINTS, not a step size: 40, 60, 80, 100.
        "throttle": {"mode": "range", "start": 40, "stop": 100, "steps": 4},
        # `slots` indexes rotor_groups. Two or more slots would make this ONE
        # shared grid dimension applied to each of them, not a cross-product.
        "component_axes": [
            {"axis": "propeller", "slots": [0], "component_ids": prop_ids},
        ],
    },
)
print(f"created {sweep['id']}: {sweep['total_points']} points in one request")

result = client.sweeps.wait(sweep["id"], timeout=900)
print(f"final status: {result['status']}")

if result["status"] == "completed":
    print("\npropeller            | throttle | thrust/rotor (N)")
    for pt in client.sweeps.list_points(sweep["id"]):
        # `inputs["component"]` names the component(s) this point was solved
        # with: one {axis, slot, id, name} entry per active component axis.
        # It carries names and IDs only — never the component's spec values.
        chosen = ", ".join(c["name"] for c in pt["inputs"]["component"])
        thrust = pt["rotors"]["1"]["thrust_n"]
        print(f"  {chosen:<18} | {pt['inputs']['throttle']:>7}% | {thrust:.2f}")

The sweep also reports what it cost in compute units, in compute_units, and keeps the request you sent in input_snapshot.

Where agents can read more

Where agents can read more
AddressWhat you find there
https://thrustlab.com/openapi.jsonA full description of the API. You can make a client from it.
https://thrustlab.com/llms.txtA short list of the Docs pages.
https://thrustlab.com/llms-full.txtAll the Docs pages in one plain text file.

For what the errors mean, see Errors. For the limits, see Rate limits.