Integrations¶
Sartiq integrates with external AI services for image generation, text processing, and multimodal tasks.
Overview¶
| Integration | Purpose | Primary Use |
|---|---|---|
| Anthropic | Claude API | Image captioning, vision analysis, outfit generation |
| Fal.ai | ML inference platform | Image generation, LoRA training, video |
| Google AI | Gemini + Vertex AI | Styling, captioning, image generation |
Anthropic (Claude)¶
Claude's vision and text capabilities power image analysis and structured content generation.
| Feature | Model | Use Case |
|---|---|---|
| Image Captioning | Claude Sonnet 4 | Product descriptions for ML training |
| Outfit Generation | Claude 3.5 Sonnet | Styling recommendations |
| Vision Analysis | Claude Sonnet 4 | Multi-image comparison |
Key capabilities: Vision, structured JSON output, multi-turn conversations
Fal.ai¶
Serverless GPU inference for image generation, training, and processing.
| Feature | Model/Endpoint | Use Case |
|---|---|---|
| Image Generation | Flux + Custom LoRAs | Fashion photography |
| LoRA Training | flux-lora-fast-training | Subject/style models |
| Face Detection | Moondream3 | Face bounding boxes |
| Segmentation | SAM-3 | Person/garment masks |
| Video Generation | video-gen | Motion from stills |
Key capabilities: Multiple LoRAs, custom workflows, real-time status
Google AI (Gemini + Vertex AI)¶
Google provides two integration pathways:
Gemini API (LLM)¶
Text generation and multimodal analysis via LiteLLM abstraction.
| Feature | Model | Use Case |
|---|---|---|
| Styling | gemini-2.0-flash | Outfit recommendations |
| Captioning | gemini-2.5-flash | Product descriptions |
| Visibility | gemini-flash | Product filtering |
Vertex AI (Image)¶
Native image generation and editing with Gemini models.
| Feature | Model | Use Case |
|---|---|---|
| Generation | gemini-3-pro-image | Text-to-image |
| Editing | gemini-3-pro-image | Virtual try-on |
| Vision | gemini-3-pro | Fashion analysis |
Key difference: Vertex AI supports image generation with permissive safety settings for fashion content.
Architecture¶
flowchart TB
subgraph Backend["Backend API"]
CAP[Captioning]
STYLE[Styling]
LLM[LLM Handler]
end
subgraph Compute["Compute Server"]
GEN[Generation]
EDIT[Editing]
TRAIN[Training]
end
subgraph External["External Services"]
ANTH[Anthropic Claude]
FAL[Fal.ai]
GEM[Gemini API]
VERT[Vertex AI]
end
CAP --> ANTH
STYLE --> GEM
LLM --> ANTH
LLM --> GEM
GEN --> FAL
GEN --> VERT
EDIT --> FAL
EDIT --> VERT
TRAIN --> FAL
Common Patterns¶
API Key Management¶
All keys are managed via environment variables:
# Anthropic
ANTHROPIC_API_KEY="sk-ant-..."
# Fal.ai
FAL_KEY="..."
# Google
GEMINI_API_KEY="..."
GOOGLE_API_KEY="..."
GOOGLE_CLOUD_PROJECT="..."
Error Handling¶
Standard error wrapper across integrations:
from sartiq.integrations.errors import (
ExternalServiceError,
RateLimitError,
AuthenticationError,
)
Retry Logic¶
All integrations use exponential backoff:
@retry(
stop=stop_after_attempt(3),
wait=wait_exponential(multiplier=1, min=1, max=10),
retry=retry_if_exception_type(RateLimitError)
)
async def call_external_service():
...
Provider Selection¶
| Task Type | Primary Provider | Fallback |
|---|---|---|
| Captioning | Anthropic | Gemini |
| Styling | Gemini | Anthropic |
| Image Generation | Fal.ai | Vertex AI |
| LoRA Training | Fal.ai | - |
| Vision Analysis | Anthropic | Gemini |