BeginnerUpdated Dec 10, 2025
Python SDK Setup
Install the Abstrakt Python package and configure authentication for seamless AI model access.
AR
Alex Rivera
Senior Engineer
3 min read
Installation
Install the Abstrakt Python SDK using pip:
pip install abstrakt-sdk
Or with Poetry:
poetry add abstrakt-sdk
Authentication
There are several ways to authenticate with the SDK:
Environment Variable (Recommended)
export ABSTRAKT_API_KEY="your_api_key_here"
python
from abstrakt import AbstraktClient # Automatically uses ABSTRAKT_API_KEY env variable client = AbstraktClient()
Direct Initialization
python
from abstrakt import AbstraktClient client = AbstraktClient(api_key="your_api_key_here")
Using a Config File
Create ~/.abstrakt/config.json:
json
{
"api_key": "your_api_key_here",
"default_model": "fal-ai/flux/schnell"
}Basic Usage
python
from abstrakt import AbstraktClient
client = AbstraktClient()
# Generate an image
result = client.run(
model="fal-ai/flux/schnell",
input={
"prompt": "A beautiful sunset over mountains",
"image_size": {"width": 1024, "height": 1024}
}
)
print(result.images[0].url)Async Support
The SDK fully supports async/await:
python
import asyncio
from abstrakt import AsyncAbstraktClient
async def main():
client = AsyncAbstraktClient()
result = await client.run(
model="fal-ai/flux/schnell",
input={"prompt": "A cosmic nebula in deep space"}
)
print(result.images[0].url)
asyncio.run(main())Error Handling
python
from abstrakt import AbstraktClient, AbstraktError, RateLimitError
client = AbstraktClient()
try:
result = client.run(model="fal-ai/flux/schnell", input={...})
except RateLimitError as e:
print(f"Rate limited. Retry after {e.retry_after} seconds")
except AbstraktError as e:
print(f"API Error: {e.message}")Next Steps
- Learn about async patterns
- Explore available models
- Set up webhooks for long tasks
#python#sdk#setup