How to run this route from Python with the Ouro SDK.
API access requires an API key. Create one in Settings → API Keys, then set OURO_API_KEY in your environment. Install the SDK with pip install ouro-py.
POST /generateParameters and request body schema for this route.
Chemical composition (e.g., 'PbTe' or 'Bi2Se3')
P1P-1P2P2_1C2PmPcCmCcP2/mP2_1/mC2/mP2/cP2_1/cC2/cP222P222_1P2_12_12P2_12_12_1C222C222_1F222I222I2_12_12_1Pmm2Pcc2Pma2Pca2_1Pnc2Pmn2_1Pba2Pna2_1Cmm2Ccc2Amm2Abm2Ama2Aba2PmmmPnnnPccmPbanPmmaPnnaPmnaPccaPbamPccnPbcmPnnmPmmnPbcnPbcaPnmaCmcmCmcaCmmmCccmCmmaCccaFmmmFdddImmmIbamIbcaImmaP4P4_1P4_2P4_3I4I4_1P4/mP4_2/mP4/nP4_2/nI4/mI4_1/aP422P42_12P4_122P4_12_12P4_222P4_22_12P4_322P4_32_12I422I4_122P4mmP4bmP4_2cmP4_2nmP4ccP4ncP4_2mcP4_2bcI4mmI4cmI4_1mdI4_1cdP4/mmmP4/mccP4/nbmP4/nncP4/mbmP4/mncP4/nmmP4/nccP4_2/mmcP4_2/mcmP4_2/nbcP4_2/nnmP4_2/mbcP4_2/mnmP4_2/nmcP4_2/ncmI4/mmmI4/mcmI4_1/amdI4_1/acdP3P3_1P3_2R3P-3R-3P312P321P3_112P3_121P3_212P3_221R32P3m1P31mP3c1P31cR3mR3cP-31mP-3m1P-31cP-3c1R-3mR-3cP6P6_1P6_5P6_2P6_4P6_3P6/mP6_3/mP622P6_122P6_522P6_222P6_422P6_322P6mmP6ccP6_3cmP6_3mcP6/mmmP6/mccP6_3/mcmP6_3/mmcP23F23I23P2_13I2_13Pm3Pn3Fm3Fd3Im3Pa3Ia3P432P4_232F432F4_132I432P4_332P4_132I4_132P4_3mF4_3mI4_3mP4_3nF4_3cI4_3dPm3mPn3nPm3nPn3mFm3mFm3cFd3mFd3cIm3mIa3dSpace group symbol (e.g., 'Fd3m', 'P4_2/n', etc.)
Range: 0.1 to 10
Sampling temperature. 1.0 = no change, < 1.0 = less random, > 1.0 = more random
Range: 1 to 10000
Number of tokens generated in each sample
Each run saves these to Ouro. Read them by name from action.final_data.
execute returns an action: the record of this run, with its status, response, and any assets it created.
To avoid blocking on a slow run, start it without waiting and collect the result later.
By default a failed run comes back as an action with status error. Pass raise_on_error=True to raise an exception instead.
Every run is saved as an action. List yours, or read the logs of a single run. See the Python SDK reference for everything an action carries.
import os
from ouro import Ouro
ouro = Ouro(api_key=os.environ.get("OURO_API_KEY"))
# The ID also works, and stays the same if the route is renamed: "2443b425-a2bf-4a6f-8202-3ba8b36c921f"
route = ouro.routes.retrieve("lantunes/generate-a-crystal-structure-with-crystallm")
action = route.execute(
body={
"composition": "example_string",
},
)
print(action.status) # "success" or "error"
print(action.final_data)
# Assets the run created are keyed by output name
file = action.final_data["file"]
print(file["id"])# Returns as soon as the run is accepted
action = route.execute(
body={
"composition": "example_string",
},
wait=False,
)
print(action.id, action.status)
# Later, even from another process
action = ouro.routes.poll_action(str(action.id), poll_interval=5, timeout=1800)
print(action.final_data)from ouro import ExternalServiceError, RouteExecutionError
try:
action = route.execute(
body={
"composition": "example_string",
},
raise_on_error=True,
)
except ExternalServiceError as exc:
# The API behind this route failed
print(exc.status_code, exc.retryable)
except RouteExecutionError as exc:
print(exc.action_id, exc.status, exc.response)
except TimeoutError as exc:
# Still running on Ouro; pick it up again later
action = ouro.routes.poll_action(exc.action_id, timeout=None)route = ouro.routes.retrieve("lantunes/generate-a-crystal-structure-with-crystallm")
# Your runs of this route
actions = route.read_actions()
for action in actions:
print(action.id, action.status, action.created_at)
# One run and its logs
action = ouro.routes.retrieve_action("your-action-id")
for entry in action.read_logs(chronological=True):
print(entry.level, entry.message)Generate a crystal structure with CrystaLLM
Is supplement to
Antunes, Luis M et al. · Nature Communications · 2024
Execution
Usage
738 callsView history