SDK Generation
Generate Python SDKs from OpenAPI specs
Generate typed Python SDK clients from OpenAPI specifications with automatic authentication via integrations.
Overview
Section titled “Overview”Bifrost can generate Python SDKs from OpenAPI specs that:
- Include typed data models from the spec
- Handle authentication automatically via integrations
- Provide retry logic with exponential backoff
- Support dot-notation for response access
Generate an SDK
Section titled “Generate an SDK”-
Open your integration in Settings > Integrations
-
Click Generate SDK
-
Enter the OpenAPI Spec URL (JSON or YAML)
-
Select Authentication Type:
- OAuth (uses integration OAuth tokens)
- API Key (uses config value)
- Basic Auth (uses config values)
- Bearer Token (uses config value)
-
Click Generate
-
SDK is created in your workspace at
modules/{name}.py
Using Generated SDKs
Section titled “Using Generated SDKs”Generated SDKs auto-authenticate using your integration:
from modules import example_api
@workflowasync def fetch_data(): # No auth setup needed - uses integration automatically resources = await example_api.list_resources() return {"count": len(resources)}Authentication Types
Section titled “Authentication Types”Uses OAuth tokens from the integration:
# Generated SDK fetches token from integration.oauth.access_tokenresult = await api.get_users()API Key
Section titled “API Key”Uses api_key from integration config:
# Generated SDK adds header: X-API-Key: {config.api_key}result = await api.get_users()Bearer Token
Section titled “Bearer Token”Uses token from integration config:
# Generated SDK adds header: Authorization: Bearer {config.token}result = await api.get_users()Basic Auth
Section titled “Basic Auth”Uses username and password from integration config:
# Generated SDK uses HTTP Basic authresult = await api.get_users()Response Access
Section titled “Response Access”Generated SDKs support dot-notation for responses:
# Instead of result["data"]["user"]["name"]print(result.data.user.name)
# Also works as dictprint(result["data"]["user"]["name"])Retry Logic
Section titled “Retry Logic”Generated SDKs include automatic retry:
- Retries on 429 (rate limit) and 5xx errors
- Exponential backoff with jitter
- Respects
Retry-Afterheaders - Configurable max retries
Generated Code Structure
Section titled “Generated Code Structure”# Data models from OpenAPI schemasclass User: id: str name: str email: str
@classmethod def from_dict(cls, data: dict) -> "User": ...
# Internal HTTP clientclass _ExampleApiClient: def __init__(self, base_url: str, session: httpx.AsyncClient): ...
async def list_users(self) -> list[User]: ...
# Lazy client that auto-initializes from integration_lazy_client = _LazyClient()
# Module-level functionsasync def list_users() -> list[User]: return await _lazy_client.list_users()Requirements
Section titled “Requirements”The OpenAPI spec should include:
servers[0].url- Base URL (or configured in integration)paths- Endpoint definitionscomponents.schemas- Data models (optional)security- Authentication requirements (optional)
Regenerating SDKs
Section titled “Regenerating SDKs”To update an SDK after spec changes:
- Open the integration
- Click Regenerate SDK
- The module file is overwritten with new code
Example: HaloPSA
Section titled “Example: HaloPSA”from modules import halopsa
@workflowasync def sync_tickets(): # Auto-authenticated via HaloPSA integration tickets = await halopsa.list_tickets()
for ticket in tickets: print(f"{ticket.id}: {ticket.summary}")
return {"synced": len(tickets)}Next Steps
Section titled “Next Steps”- Creating Integrations - Setup guide
- Integrations Module - SDK reference