{"id":"openapi-python-sdk-generation","slug":"generate-python-sdk-from-openapi-spec","title":"Generate a Python SDK From the unLocked CRM OpenAPI Spec","excerpt":"Build a typed, async-ready Python client for unLocked CRM in under 10 minutes using openapi-python-client. Perfect for back-office automations, data pipelines, and AI agent toolchains.","content":"<p>Python is the lingua franca of data and AI. If you're building a back-office automation, an LLM agent, or a nightly ETL job that touches the CRM, generate a typed Python SDK from the OpenAPI spec.</p>\n\n<h2>Install the Generator</h2>\n<pre><code>pipx install openapi-python-client</code></pre>\n\n<h2>Generate the Client</h2>\n<pre><code>openapi-python-client generate --url https://unlockedcrm.ai/openapi.json</code></pre>\n<p>This produces a <code>unlocked_crm_client/</code> package with typed models (via <code>attrs</code>), an async-ready httpx client, and one function per endpoint.</p>\n\n<h2>Use It</h2>\n<pre><code>from unlocked_crm_client import AuthenticatedClient\nfrom unlocked_crm_client.api.contacts import get_contacts\n\nclient = AuthenticatedClient(\n    base_url=\"https://api.unlockedcrm.ai\",\n    token=os.environ[\"UNLOCKED_API_KEY\"],\n    prefix=\"\",\n    auth_header_name=\"x-api-key\",\n)\n\nresponse = get_contacts.sync(client=client, limit=50)\nfor contact in response.data:\n    print(contact.first_name, contact.email)</code></pre>\n\n<h2>Why a Generated Client Beats requests + dict</h2>\n<ul>\n<li><strong>Type safety</strong> — mypy/pyright catch field typos at lint time, not at runtime.</li>\n<li><strong>Auto-pagination</strong> — most generators ship cursor helpers.</li>\n<li><strong>Drift detection</strong> — re-run on every release; breaking changes fail your build instead of production.</li>\n<li><strong>LLM-friendly</strong> — Claude and ChatGPT can read the typed client and write working code without hallucinating field names.</li>\n</ul>\n\n<p>For larger workloads, swap to the async client and parallelize requests with <code>asyncio.gather()</code>.</p>","category":"Tutorials","featureLink":"/mcp-server","cluster":"mcp-api","date":"2026-11-18","lastModified":"2026-11-18","readTime":"7 min","author":"unLocked Team"}