StruAI Drawing Analysis SDK - AI-powered construction drawing analysis
Project description
StruAI Python SDK
Official Python SDK for the StruAI Drawing Analysis API.
Installation
pip install struai
Quick Start
from struai import StruAI
client = StruAI(api_key="sk-xxx") # or set STRUAI_API_KEY env var
# Optional: override base URL (http://localhost:8000 or http://localhost:8000/v1)
client = StruAI(api_key="sk-xxx", base_url="http://localhost:8000")
Tier 1: Raw Detection ($0.02/page)
Fast geometric detection. Returns annotations in ~1-2 seconds.
# Analyze a PDF page
result = client.drawings.analyze("structural.pdf", page=4)
print(f"Processed in {result.processing_ms}ms")
print(f"Page size: {result.dimensions.width}x{result.dimensions.height}")
# Access detected annotations
for leader in result.annotations.leaders:
texts = [t.text for t in leader.texts_inside]
print(f"Leader at {leader.arrow_tip}: {', '.join(texts)}")
for tag in result.annotations.section_tags:
label = tag.texts_inside[0].text
print(f"Section {label}, direction: {tag.direction}")
# Retrieve/delete previous results
drawing = client.drawings.get("drw_7f8a9b2c")
client.drawings.delete("drw_7f8a9b2c")
Tier 2: Graph + Search ($0.15/page)
Full pipeline: detection → LLM enrichment → knowledge graph → semantic search.
# Create a project
project = client.projects.create(
name="Building A Structural",
description="96-page structural drawing set"
)
# Add sheets (async processing)
job = project.sheets.add("structural.pdf", page=4)
result = job.wait(timeout=120) # Blocks until complete
print(f"Created {result.entities_created} entities")
# Semantic search
results = project.search(
query="W12x26 beam connections at grid A",
limit=10,
include_graph_context=True
)
for hit in results.results:
print(f"{hit.entity.label}: {hit.score:.2f}")
if hit.graph_context:
for rel in hit.graph_context.relationships:
print(f" - {rel.type}: {rel.fact}")
# Natural language query
answer = project.query("What beams connect to column C3?")
print(answer.answer)
print(f"Confidence: {answer.confidence:.0%}")
# Browse entities
entities = project.entities.list(type="Component", limit=50)
entity = project.entities.get("ent_abc123")
Async Support
from struai import AsyncStruAI
async with AsyncStruAI(api_key="sk-xxx") as client:
# Tier 1
result = await client.drawings.analyze("structural.pdf", page=4)
# Tier 2
project = await client.projects.create(name="Building A")
job = await project.sheets.add("structural.pdf", page=4)
result = await job.wait(timeout=120)
results = await project.search("W12x26 beam connections")
Error Handling
from struai import StruAI, AuthenticationError, RateLimitError, NotFoundError
try:
result = client.drawings.analyze("plans.pdf", page=99)
except AuthenticationError:
print("Invalid API key")
except RateLimitError as e:
print(f"Rate limited. Retry after {e.retry_after}s")
except NotFoundError:
print("Resource not found")
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file struai-1.0.1.tar.gz.
File metadata
- Download URL: struai-1.0.1.tar.gz
- Upload date:
- Size: 17.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1dbb9e4b28a3760d872b006dfd927749edfe72f5e1e6fedc4f5f965f960569cc
|
|
| MD5 |
c3dec0fea9a3352663dcacfe854a1a66
|
|
| BLAKE2b-256 |
4e463e559546d6ee230bf34c446b6cbc64b93574149573c4b77a0abf584687d7
|
Provenance
The following attestation bundles were made for struai-1.0.1.tar.gz:
Publisher:
release.yml on bhoshaga/struai
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
struai-1.0.1.tar.gz -
Subject digest:
1dbb9e4b28a3760d872b006dfd927749edfe72f5e1e6fedc4f5f965f960569cc - Sigstore transparency entry: 910075491
- Sigstore integration time:
-
Permalink:
bhoshaga/struai@91e94b00f5eb6e123adb2cfae01a473ed4cd5cbd -
Branch / Tag:
refs/heads/main - Owner: https://github.com/bhoshaga
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@91e94b00f5eb6e123adb2cfae01a473ed4cd5cbd -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file struai-1.0.1-py3-none-any.whl.
File metadata
- Download URL: struai-1.0.1-py3-none-any.whl
- Upload date:
- Size: 16.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
74ff7919683d9afddf5e620a24bbf65744371d0ed9446912c9f276b67cc139cc
|
|
| MD5 |
9e070eca028a075d0a410c713e54a2eb
|
|
| BLAKE2b-256 |
6e2fbceb97a6e0db2e2a8bc204de86eadad9768b799c4063b2b2829eee036465
|
Provenance
The following attestation bundles were made for struai-1.0.1-py3-none-any.whl:
Publisher:
release.yml on bhoshaga/struai
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
struai-1.0.1-py3-none-any.whl -
Subject digest:
74ff7919683d9afddf5e620a24bbf65744371d0ed9446912c9f276b67cc139cc - Sigstore transparency entry: 910075497
- Sigstore integration time:
-
Permalink:
bhoshaga/struai@91e94b00f5eb6e123adb2cfae01a473ed4cd5cbd -
Branch / Tag:
refs/heads/main - Owner: https://github.com/bhoshaga
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@91e94b00f5eb6e123adb2cfae01a473ed4cd5cbd -
Trigger Event:
workflow_dispatch
-
Statement type: