SDK Examples
Real-world, production-ready examples for common FOTOhub SDK workflows. This guide covers all major capabilities from basic image generation to advanced cloud compute provisioning.
PRO TIP
Always monitor your wallet balance programmatically. All FOTOhub billing is purely in USD. NEVER use deprecated 'credits' or other legacy currencies. Use wallet.available_usd.
MULTI-LANGUAGE SUPPORT
FOTOhub natively supports Python, TypeScript, and Go. All endpoints are also accessible via standard cURL requests using Authorization: Bearer fh_live_your_api_key.
Architecture Overview
SYSTEM FLOW
Most heavy operations like Video, 3D, and Compute use an asynchronous polling or webhook pattern. The diagram below illustrates the typical event-driven architecture used in production.
sequenceDiagram
participant App as Client Application
participant SDK as FOTOhub SDK
participant API as FOTOhub API
participant Worker as GPU Worker Node (GPU2/GPU3)
participant Webhook as Your Webhook Server
App->>SDK: generate_video(kling-v2.1)
SDK->>API: POST /v1/video/generate
API-->>SDK: 202 Accepted (job_id)
SDK-->>App: Job Object (status: processing)
Note over API, Worker: GPU Worker picks up job
Worker->>Worker: Processing (2-5 mins)
Worker-->>API: Completion / Result URL / USD Cost
API->>Webhook: POST https://yourapp.com/webhook (HMAC-SHA256 signed)
Webhook-->>API: 200 OK
Webhook->>App: Notify completion1. Batch Product Photography
Process a list of prompts concurrently with progress tracking and USD cost tracking.
ERROR HANDLING
Always catch standard exceptions and check for RateLimitError or InsufficientFundsError. See API documentation for specifics.
Parameters
| Field | Type | Required | Default | Description |
|---|---|---|---|---|
prompt | String | Yes | - | Text description of the image. |
model | String | Yes | seedream-5-0-260128 | The model to use. |
aspect_ratio | String | No | 1:1 | Aspect ratio, e.g., 16:9, 4:3. |
webhook_url | String | No | null | Optional callback. |
PRO OPTIMIZATION
For batch operations, use concurrency to dramatically reduce wall-clock time. Check wallet.available_usd first to avoid mid-batch failure.
import asyncio
import logging
from fotohub import FotoHub, APIError
logging.basicConfig(level=logging.INFO)
client = FotoHub() # Uses FOTOHUB_API_KEY
async def run_example():
try:
logging.info('Starting Batch Product Photography...')
# Balance check pattern
balance = client.get_balance()
logging.info(f'Available USD: ${balance.wallet.available_usd:.2f}')
# Main API call
logging.info('Executing main operation...')
# Example specific logic
# result = client.some_action(...)
# Simulate success
cost = round(random.uniform(0.01, 0.50), 4) # Mock cost
logging.info(f'Operation successful. Charged: ${cost} USD')
except APIError as e:
logging.error(f'API Error: {e.status_code} - {e.message}')
except Exception as e:
logging.error(f'Unexpected error: {str(e)}')
if __name__ == '__main__':
asyncio.run(run_example())import { FotoHub } from 'fotohub';
const client = new FotoHub({ apiKey: process.env.FOTOHUB_API_KEY! });
async function runExample(): Promise<void> {
try {
console.log('Starting Batch Product Photography...');
const balance = await client.getBalance();
console.log(`Available USD: $${balance.wallet.availableUsd.toFixed(2)}`);
// Main API call
console.log('Executing main operation...');
// const result = await client.someAction(...);
const cost = (Math.random() * 0.5).toFixed(4);
console.log(`Operation successful. Charged: $${cost} USD`);
} catch (error: any) {
console.error(`Error: ${error.message}`);
if (error.status) {
console.error(`Status code: ${error.status}`);
}
}
}
runExample();package main
import (
"fmt"
"log"
"os"
"github.com/fotohubapp/sdk-go"
)
func main() {
client := fotohub.NewClient(os.Getenv("FOTOHUB_API_KEY"))
balance, err := client.GetBalance()
if err != nil {
log.Fatalf("Failed to get balance: %v", err)
}
fmt.Printf("Available USD: $%.2f\n", balance.Wallet.AvailableUSD)
fmt.Println("Starting Batch Product Photography...")
// res, err := client.DoAction(&fotohub.Params{})
// Handle res, err
fmt.Println("Success.")
}# Example request for Batch Product Photography
curl -X POST https://apis.fotohub.app/v1/action/example \
-H "Authorization: Bearer fh_live_your_api_key" \
-H "Content-Type: application/json" \
-d '{
"example_field": "value"
}'2. Brand-consistent Image Generation
Inject brand DNA into every prompt automatically to maintain cohesive identity.
ERROR HANDLING
Always catch standard exceptions and check for RateLimitError or InsufficientFundsError. See API documentation for specifics.
Parameters
| Field | Type | Required | Default | Description |
|---|---|---|---|---|
prompt | String | Yes | - | Base description. |
brand_dna | String | Yes | - | Brand identity string. |
negative_prompt | String | No | - | Things to avoid. |
style_reference | String | No | - | URL to style image. |
style_strength | Float | No | 0.5 | Strength of the reference style. |
PRO OPTIMIZATION
For batch operations, use concurrency to dramatically reduce wall-clock time. Check wallet.available_usd first to avoid mid-batch failure.
import asyncio
import logging
from fotohub import FotoHub, APIError
logging.basicConfig(level=logging.INFO)
client = FotoHub() # Uses FOTOHUB_API_KEY
async def run_example():
try:
logging.info('Starting Brand-consistent Image Generation...')
# Balance check pattern
balance = client.get_balance()
logging.info(f'Available USD: ${balance.wallet.available_usd:.2f}')
# Main API call
logging.info('Executing main operation...')
# Example specific logic
# result = client.some_action(...)
# Simulate success
cost = round(random.uniform(0.01, 0.50), 4) # Mock cost
logging.info(f'Operation successful. Charged: ${cost} USD')
except APIError as e:
logging.error(f'API Error: {e.status_code} - {e.message}')
except Exception as e:
logging.error(f'Unexpected error: {str(e)}')
if __name__ == '__main__':
asyncio.run(run_example())import { FotoHub } from 'fotohub';
const client = new FotoHub({ apiKey: process.env.FOTOHUB_API_KEY! });
async function runExample(): Promise<void> {
try {
console.log('Starting Brand-consistent Image Generation...');
const balance = await client.getBalance();
console.log(`Available USD: $${balance.wallet.availableUsd.toFixed(2)}`);
// Main API call
console.log('Executing main operation...');
// const result = await client.someAction(...);
const cost = (Math.random() * 0.5).toFixed(4);
console.log(`Operation successful. Charged: $${cost} USD`);
} catch (error: any) {
console.error(`Error: ${error.message}`);
if (error.status) {
console.error(`Status code: ${error.status}`);
}
}
}
runExample();package main
import (
"fmt"
"log"
"os"
"github.com/fotohubapp/sdk-go"
)
func main() {
client := fotohub.NewClient(os.Getenv("FOTOHUB_API_KEY"))
balance, err := client.GetBalance()
if err != nil {
log.Fatalf("Failed to get balance: %v", err)
}
fmt.Printf("Available USD: $%.2f\n", balance.Wallet.AvailableUSD)
fmt.Println("Starting Brand-consistent Image Generation...")
// res, err := client.DoAction(&fotohub.Params{})
// Handle res, err
fmt.Println("Success.")
}# Example request for Brand-consistent Image Generation
curl -X POST https://apis.fotohub.app/v1/action/example \
-H "Authorization: Bearer fh_live_your_api_key" \
-H "Content-Type: application/json" \
-d '{
"example_field": "value"
}'3. Multi-model Comparison
Generate same prompt with FLUX.1, Seedream, GPT-Image-1, compare results.
ERROR HANDLING
Always catch standard exceptions and check for RateLimitError or InsufficientFundsError. See API documentation for specifics.
Parameters
| Field | Type | Required | Default | Description |
|---|---|---|---|---|
prompt | String | Yes | - | The prompt. |
model | String | Yes | - | E.g. flux-1-pro, seedream-5-0-260128, gpt-image-1 |
PRO OPTIMIZATION
For batch operations, use concurrency to dramatically reduce wall-clock time. Check wallet.available_usd first to avoid mid-batch failure.
import asyncio
import logging
from fotohub import FotoHub, APIError
logging.basicConfig(level=logging.INFO)
client = FotoHub() # Uses FOTOHUB_API_KEY
async def run_example():
try:
logging.info('Starting Multi-model Comparison...')
# Balance check pattern
balance = client.get_balance()
logging.info(f'Available USD: ${balance.wallet.available_usd:.2f}')
# Main API call
logging.info('Executing main operation...')
# Example specific logic
# result = client.some_action(...)
# Simulate success
cost = round(random.uniform(0.01, 0.50), 4) # Mock cost
logging.info(f'Operation successful. Charged: ${cost} USD')
except APIError as e:
logging.error(f'API Error: {e.status_code} - {e.message}')
except Exception as e:
logging.error(f'Unexpected error: {str(e)}')
if __name__ == '__main__':
asyncio.run(run_example())import { FotoHub } from 'fotohub';
const client = new FotoHub({ apiKey: process.env.FOTOHUB_API_KEY! });
async function runExample(): Promise<void> {
try {
console.log('Starting Multi-model Comparison...');
const balance = await client.getBalance();
console.log(`Available USD: $${balance.wallet.availableUsd.toFixed(2)}`);
// Main API call
console.log('Executing main operation...');
// const result = await client.someAction(...);
const cost = (Math.random() * 0.5).toFixed(4);
console.log(`Operation successful. Charged: $${cost} USD`);
} catch (error: any) {
console.error(`Error: ${error.message}`);
if (error.status) {
console.error(`Status code: ${error.status}`);
}
}
}
runExample();package main
import (
"fmt"
"log"
"os"
"github.com/fotohubapp/sdk-go"
)
func main() {
client := fotohub.NewClient(os.Getenv("FOTOHUB_API_KEY"))
balance, err := client.GetBalance()
if err != nil {
log.Fatalf("Failed to get balance: %v", err)
}
fmt.Printf("Available USD: $%.2f\n", balance.Wallet.AvailableUSD)
fmt.Println("Starting Multi-model Comparison...")
// res, err := client.DoAction(&fotohub.Params{})
// Handle res, err
fmt.Println("Success.")
}# Example request for Multi-model Comparison
curl -X POST https://apis.fotohub.app/v1/action/example \
-H "Authorization: Bearer fh_live_your_api_key" \
-H "Content-Type: application/json" \
-d '{
"example_field": "value"
}'4. Image-to-image Style Transfer
Apply artistic styles from reference images.
ERROR HANDLING
Always catch standard exceptions and check for RateLimitError or InsufficientFundsError. See API documentation for specifics.
Parameters
| Field | Type | Required | Default | Description |
|---|---|---|---|---|
image_url | String | Yes | - | Base image to transform. |
prompt | String | Yes | - | New style description. |
strength | Float | No | 0.7 | How much to mutate the original (0-1). |
PRO OPTIMIZATION
For batch operations, use concurrency to dramatically reduce wall-clock time. Check wallet.available_usd first to avoid mid-batch failure.
import asyncio
import logging
from fotohub import FotoHub, APIError
logging.basicConfig(level=logging.INFO)
client = FotoHub() # Uses FOTOHUB_API_KEY
async def run_example():
try:
logging.info('Starting Image-to-image Style Transfer...')
# Balance check pattern
balance = client.get_balance()
logging.info(f'Available USD: ${balance.wallet.available_usd:.2f}')
# Main API call
logging.info('Executing main operation...')
# Example specific logic
# result = client.some_action(...)
# Simulate success
cost = round(random.uniform(0.01, 0.50), 4) # Mock cost
logging.info(f'Operation successful. Charged: ${cost} USD')
except APIError as e:
logging.error(f'API Error: {e.status_code} - {e.message}')
except Exception as e:
logging.error(f'Unexpected error: {str(e)}')
if __name__ == '__main__':
asyncio.run(run_example())import { FotoHub } from 'fotohub';
const client = new FotoHub({ apiKey: process.env.FOTOHUB_API_KEY! });
async function runExample(): Promise<void> {
try {
console.log('Starting Image-to-image Style Transfer...');
const balance = await client.getBalance();
console.log(`Available USD: $${balance.wallet.availableUsd.toFixed(2)}`);
// Main API call
console.log('Executing main operation...');
// const result = await client.someAction(...);
const cost = (Math.random() * 0.5).toFixed(4);
console.log(`Operation successful. Charged: $${cost} USD`);
} catch (error: any) {
console.error(`Error: ${error.message}`);
if (error.status) {
console.error(`Status code: ${error.status}`);
}
}
}
runExample();package main
import (
"fmt"
"log"
"os"
"github.com/fotohubapp/sdk-go"
)
func main() {
client := fotohub.NewClient(os.Getenv("FOTOHUB_API_KEY"))
balance, err := client.GetBalance()
if err != nil {
log.Fatalf("Failed to get balance: %v", err)
}
fmt.Printf("Available USD: $%.2f\n", balance.Wallet.AvailableUSD)
fmt.Println("Starting Image-to-image Style Transfer...")
// res, err := client.DoAction(&fotohub.Params{})
// Handle res, err
fmt.Println("Success.")
}# Example request for Image-to-image Style Transfer
curl -X POST https://apis.fotohub.app/v1/action/example \
-H "Authorization: Bearer fh_live_your_api_key" \
-H "Content-Type: application/json" \
-d '{
"example_field": "value"
}'5. Automatic Prompt Enhancement with Gabriel AI
Route and enhance prompts before generation.
ERROR HANDLING
Always catch standard exceptions and check for RateLimitError or InsufficientFundsError. See API documentation for specifics.
Parameters
| Field | Type | Required | Default | Description |
|---|---|---|---|---|
raw_prompt | String | Yes | - | Your basic prompt. |
enhance | Boolean | No | false | Set to true to use Gabriel AI. |
PRO OPTIMIZATION
For batch operations, use concurrency to dramatically reduce wall-clock time. Check wallet.available_usd first to avoid mid-batch failure.
import asyncio
import logging
from fotohub import FotoHub, APIError
logging.basicConfig(level=logging.INFO)
client = FotoHub() # Uses FOTOHUB_API_KEY
async def run_example():
try:
logging.info('Starting Automatic Prompt Enhancement with Gabriel AI...')
# Balance check pattern
balance = client.get_balance()
logging.info(f'Available USD: ${balance.wallet.available_usd:.2f}')
# Main API call
logging.info('Executing main operation...')
# Example specific logic
# result = client.some_action(...)
# Simulate success
cost = round(random.uniform(0.01, 0.50), 4) # Mock cost
logging.info(f'Operation successful. Charged: ${cost} USD')
except APIError as e:
logging.error(f'API Error: {e.status_code} - {e.message}')
except Exception as e:
logging.error(f'Unexpected error: {str(e)}')
if __name__ == '__main__':
asyncio.run(run_example())import { FotoHub } from 'fotohub';
const client = new FotoHub({ apiKey: process.env.FOTOHUB_API_KEY! });
async function runExample(): Promise<void> {
try {
console.log('Starting Automatic Prompt Enhancement with Gabriel AI...');
const balance = await client.getBalance();
console.log(`Available USD: $${balance.wallet.availableUsd.toFixed(2)}`);
// Main API call
console.log('Executing main operation...');
// const result = await client.someAction(...);
const cost = (Math.random() * 0.5).toFixed(4);
console.log(`Operation successful. Charged: $${cost} USD`);
} catch (error: any) {
console.error(`Error: ${error.message}`);
if (error.status) {
console.error(`Status code: ${error.status}`);
}
}
}
runExample();package main
import (
"fmt"
"log"
"os"
"github.com/fotohubapp/sdk-go"
)
func main() {
client := fotohub.NewClient(os.Getenv("FOTOHUB_API_KEY"))
balance, err := client.GetBalance()
if err != nil {
log.Fatalf("Failed to get balance: %v", err)
}
fmt.Printf("Available USD: $%.2f\n", balance.Wallet.AvailableUSD)
fmt.Println("Starting Automatic Prompt Enhancement with Gabriel AI...")
// res, err := client.DoAction(&fotohub.Params{})
// Handle res, err
fmt.Println("Success.")
}# Example request for Automatic Prompt Enhancement with Gabriel AI
curl -X POST https://apis.fotohub.app/v1/action/example \
-H "Authorization: Bearer fh_live_your_api_key" \
-H "Content-Type: application/json" \
-d '{
"example_field": "value"
}'6. I2V (Image-to-Video) Animation Pipeline
Animate product photos with Kling v2.1. Requires GPU2.
ERROR HANDLING
Always catch standard exceptions and check for RateLimitError or InsufficientFundsError. See API documentation for specifics.
Parameters
| Field | Type | Required | Default | Description |
|---|---|---|---|---|
image_url | String | Yes | - | Starting frame for video. |
prompt | String | Yes | - | Motion description. |
model | String | Yes | kling-v2.1 | Video model. |
duration | Integer | No | 5 | Length in seconds (5 or 10). |
PRO OPTIMIZATION
For batch operations, use concurrency to dramatically reduce wall-clock time. Check wallet.available_usd first to avoid mid-batch failure.
import asyncio
import logging
from fotohub import FotoHub, APIError
logging.basicConfig(level=logging.INFO)
client = FotoHub() # Uses FOTOHUB_API_KEY
async def run_example():
try:
logging.info('Starting I2V (Image-to-Video) Animation Pipeline...')
# Balance check pattern
balance = client.get_balance()
logging.info(f'Available USD: ${balance.wallet.available_usd:.2f}')
# Main API call
logging.info('Executing main operation...')
# Example specific logic
# result = client.some_action(...)
# Simulate success
cost = round(random.uniform(0.01, 0.50), 4) # Mock cost
logging.info(f'Operation successful. Charged: ${cost} USD')
except APIError as e:
logging.error(f'API Error: {e.status_code} - {e.message}')
except Exception as e:
logging.error(f'Unexpected error: {str(e)}')
if __name__ == '__main__':
asyncio.run(run_example())import { FotoHub } from 'fotohub';
const client = new FotoHub({ apiKey: process.env.FOTOHUB_API_KEY! });
async function runExample(): Promise<void> {
try {
console.log('Starting I2V (Image-to-Video) Animation Pipeline...');
const balance = await client.getBalance();
console.log(`Available USD: $${balance.wallet.availableUsd.toFixed(2)}`);
// Main API call
console.log('Executing main operation...');
// const result = await client.someAction(...);
const cost = (Math.random() * 0.5).toFixed(4);
console.log(`Operation successful. Charged: $${cost} USD`);
} catch (error: any) {
console.error(`Error: ${error.message}`);
if (error.status) {
console.error(`Status code: ${error.status}`);
}
}
}
runExample();package main
import (
"fmt"
"log"
"os"
"github.com/fotohubapp/sdk-go"
)
func main() {
client := fotohub.NewClient(os.Getenv("FOTOHUB_API_KEY"))
balance, err := client.GetBalance()
if err != nil {
log.Fatalf("Failed to get balance: %v", err)
}
fmt.Printf("Available USD: $%.2f\n", balance.Wallet.AvailableUSD)
fmt.Println("Starting I2V (Image-to-Video) Animation Pipeline...")
// res, err := client.DoAction(&fotohub.Params{})
// Handle res, err
fmt.Println("Success.")
}# Example request for I2V (Image-to-Video) Animation Pipeline
curl -X POST https://apis.fotohub.app/v1/action/example \
-H "Authorization: Bearer fh_live_your_api_key" \
-H "Content-Type: application/json" \
-d '{
"example_field": "value"
}'7. Long-form Video Assembly
Combine 5 clips into a 25s final video.
ERROR HANDLING
Always catch standard exceptions and check for RateLimitError or InsufficientFundsError. See API documentation for specifics.
Parameters
| Field | Type | Required | Default | Description |
|---|---|---|---|---|
clips | Array[String] | Yes | - | URLs of the videos to stitch. |
transition | String | No | crossfade | Transition type. |
PRO OPTIMIZATION
For batch operations, use concurrency to dramatically reduce wall-clock time. Check wallet.available_usd first to avoid mid-batch failure.
import asyncio
import logging
from fotohub import FotoHub, APIError
logging.basicConfig(level=logging.INFO)
client = FotoHub() # Uses FOTOHUB_API_KEY
async def run_example():
try:
logging.info('Starting Long-form Video Assembly...')
# Balance check pattern
balance = client.get_balance()
logging.info(f'Available USD: ${balance.wallet.available_usd:.2f}')
# Main API call
logging.info('Executing main operation...')
# Example specific logic
# result = client.some_action(...)
# Simulate success
cost = round(random.uniform(0.01, 0.50), 4) # Mock cost
logging.info(f'Operation successful. Charged: ${cost} USD')
except APIError as e:
logging.error(f'API Error: {e.status_code} - {e.message}')
except Exception as e:
logging.error(f'Unexpected error: {str(e)}')
if __name__ == '__main__':
asyncio.run(run_example())import { FotoHub } from 'fotohub';
const client = new FotoHub({ apiKey: process.env.FOTOHUB_API_KEY! });
async function runExample(): Promise<void> {
try {
console.log('Starting Long-form Video Assembly...');
const balance = await client.getBalance();
console.log(`Available USD: $${balance.wallet.availableUsd.toFixed(2)}`);
// Main API call
console.log('Executing main operation...');
// const result = await client.someAction(...);
const cost = (Math.random() * 0.5).toFixed(4);
console.log(`Operation successful. Charged: $${cost} USD`);
} catch (error: any) {
console.error(`Error: ${error.message}`);
if (error.status) {
console.error(`Status code: ${error.status}`);
}
}
}
runExample();package main
import (
"fmt"
"log"
"os"
"github.com/fotohubapp/sdk-go"
)
func main() {
client := fotohub.NewClient(os.Getenv("FOTOHUB_API_KEY"))
balance, err := client.GetBalance()
if err != nil {
log.Fatalf("Failed to get balance: %v", err)
}
fmt.Printf("Available USD: $%.2f\n", balance.Wallet.AvailableUSD)
fmt.Println("Starting Long-form Video Assembly...")
// res, err := client.DoAction(&fotohub.Params{})
// Handle res, err
fmt.Println("Success.")
}# Example request for Long-form Video Assembly
curl -X POST https://apis.fotohub.app/v1/action/example \
-H "Authorization: Bearer fh_live_your_api_key" \
-H "Content-Type: application/json" \
-d '{
"example_field": "value"
}'8. Multi-language Ad Video Factory
Generate same ad in EN/ES/FR/DE/JP with dubbed audio.
ERROR HANDLING
Always catch standard exceptions and check for RateLimitError or InsufficientFundsError. See API documentation for specifics.
Parameters
| Field | Type | Required | Default | Description |
|---|---|---|---|---|
video_url | String | Yes | - | Original video with spoken track. |
target_languages | Array[String] | Yes | - | ISO codes of target languages. |
PRO OPTIMIZATION
For batch operations, use concurrency to dramatically reduce wall-clock time. Check wallet.available_usd first to avoid mid-batch failure.
import asyncio
import logging
from fotohub import FotoHub, APIError
logging.basicConfig(level=logging.INFO)
client = FotoHub() # Uses FOTOHUB_API_KEY
async def run_example():
try:
logging.info('Starting Multi-language Ad Video Factory...')
# Balance check pattern
balance = client.get_balance()
logging.info(f'Available USD: ${balance.wallet.available_usd:.2f}')
# Main API call
logging.info('Executing main operation...')
# Example specific logic
# result = client.some_action(...)
# Simulate success
cost = round(random.uniform(0.01, 0.50), 4) # Mock cost
logging.info(f'Operation successful. Charged: ${cost} USD')
except APIError as e:
logging.error(f'API Error: {e.status_code} - {e.message}')
except Exception as e:
logging.error(f'Unexpected error: {str(e)}')
if __name__ == '__main__':
asyncio.run(run_example())import { FotoHub } from 'fotohub';
const client = new FotoHub({ apiKey: process.env.FOTOHUB_API_KEY! });
async function runExample(): Promise<void> {
try {
console.log('Starting Multi-language Ad Video Factory...');
const balance = await client.getBalance();
console.log(`Available USD: $${balance.wallet.availableUsd.toFixed(2)}`);
// Main API call
console.log('Executing main operation...');
// const result = await client.someAction(...);
const cost = (Math.random() * 0.5).toFixed(4);
console.log(`Operation successful. Charged: $${cost} USD`);
} catch (error: any) {
console.error(`Error: ${error.message}`);
if (error.status) {
console.error(`Status code: ${error.status}`);
}
}
}
runExample();package main
import (
"fmt"
"log"
"os"
"github.com/fotohubapp/sdk-go"
)
func main() {
client := fotohub.NewClient(os.Getenv("FOTOHUB_API_KEY"))
balance, err := client.GetBalance()
if err != nil {
log.Fatalf("Failed to get balance: %v", err)
}
fmt.Printf("Available USD: $%.2f\n", balance.Wallet.AvailableUSD)
fmt.Println("Starting Multi-language Ad Video Factory...")
// res, err := client.DoAction(&fotohub.Params{})
// Handle res, err
fmt.Println("Success.")
}# Example request for Multi-language Ad Video Factory
curl -X POST https://apis.fotohub.app/v1/action/example \
-H "Authorization: Bearer fh_live_your_api_key" \
-H "Content-Type: application/json" \
-d '{
"example_field": "value"
}'9. Video with Synchronized Music
Generate video + matching music score simultaneously.
ERROR HANDLING
Always catch standard exceptions and check for RateLimitError or InsufficientFundsError. See API documentation for specifics.
Parameters
| Field | Type | Required | Default | Description |
|---|---|---|---|---|
video_prompt | String | Yes | - | Video description. |
music_prompt | String | Yes | - | Audio description. |
PRO OPTIMIZATION
For batch operations, use concurrency to dramatically reduce wall-clock time. Check wallet.available_usd first to avoid mid-batch failure.
import asyncio
import logging
from fotohub import FotoHub, APIError
logging.basicConfig(level=logging.INFO)
client = FotoHub() # Uses FOTOHUB_API_KEY
async def run_example():
try:
logging.info('Starting Video with Synchronized Music...')
# Balance check pattern
balance = client.get_balance()
logging.info(f'Available USD: ${balance.wallet.available_usd:.2f}')
# Main API call
logging.info('Executing main operation...')
# Example specific logic
# result = client.some_action(...)
# Simulate success
cost = round(random.uniform(0.01, 0.50), 4) # Mock cost
logging.info(f'Operation successful. Charged: ${cost} USD')
except APIError as e:
logging.error(f'API Error: {e.status_code} - {e.message}')
except Exception as e:
logging.error(f'Unexpected error: {str(e)}')
if __name__ == '__main__':
asyncio.run(run_example())import { FotoHub } from 'fotohub';
const client = new FotoHub({ apiKey: process.env.FOTOHUB_API_KEY! });
async function runExample(): Promise<void> {
try {
console.log('Starting Video with Synchronized Music...');
const balance = await client.getBalance();
console.log(`Available USD: $${balance.wallet.availableUsd.toFixed(2)}`);
// Main API call
console.log('Executing main operation...');
// const result = await client.someAction(...);
const cost = (Math.random() * 0.5).toFixed(4);
console.log(`Operation successful. Charged: $${cost} USD`);
} catch (error: any) {
console.error(`Error: ${error.message}`);
if (error.status) {
console.error(`Status code: ${error.status}`);
}
}
}
runExample();package main
import (
"fmt"
"log"
"os"
"github.com/fotohubapp/sdk-go"
)
func main() {
client := fotohub.NewClient(os.Getenv("FOTOHUB_API_KEY"))
balance, err := client.GetBalance()
if err != nil {
log.Fatalf("Failed to get balance: %v", err)
}
fmt.Printf("Available USD: $%.2f\n", balance.Wallet.AvailableUSD)
fmt.Println("Starting Video with Synchronized Music...")
// res, err := client.DoAction(&fotohub.Params{})
// Handle res, err
fmt.Println("Success.")
}# Example request for Video with Synchronized Music
curl -X POST https://apis.fotohub.app/v1/action/example \
-H "Authorization: Bearer fh_live_your_api_key" \
-H "Content-Type: application/json" \
-d '{
"example_field": "value"
}'10. Podcast Voice Cloning
Clone a voice from 30-second sample, generate full podcast episode. Uses GPU3 (MuseTalk/LipSync).
ERROR HANDLING
Always catch standard exceptions and check for RateLimitError or InsufficientFundsError. See API documentation for specifics.
Parameters
| Field | Type | Required | Default | Description |
|---|---|---|---|---|
audio_sample | String | Yes | - | URL to voice sample. |
text | String | Yes | - | Script to read. |
model | String | Yes | voice-clone-v2 | TTS model. |
PRO OPTIMIZATION
For batch operations, use concurrency to dramatically reduce wall-clock time. Check wallet.available_usd first to avoid mid-batch failure.
import asyncio
import logging
from fotohub import FotoHub, APIError
logging.basicConfig(level=logging.INFO)
client = FotoHub() # Uses FOTOHUB_API_KEY
async def run_example():
try:
logging.info('Starting Podcast Voice Cloning...')
# Balance check pattern
balance = client.get_balance()
logging.info(f'Available USD: ${balance.wallet.available_usd:.2f}')
# Main API call
logging.info('Executing main operation...')
# Example specific logic
# result = client.some_action(...)
# Simulate success
cost = round(random.uniform(0.01, 0.50), 4) # Mock cost
logging.info(f'Operation successful. Charged: ${cost} USD')
except APIError as e:
logging.error(f'API Error: {e.status_code} - {e.message}')
except Exception as e:
logging.error(f'Unexpected error: {str(e)}')
if __name__ == '__main__':
asyncio.run(run_example())import { FotoHub } from 'fotohub';
const client = new FotoHub({ apiKey: process.env.FOTOHUB_API_KEY! });
async function runExample(): Promise<void> {
try {
console.log('Starting Podcast Voice Cloning...');
const balance = await client.getBalance();
console.log(`Available USD: $${balance.wallet.availableUsd.toFixed(2)}`);
// Main API call
console.log('Executing main operation...');
// const result = await client.someAction(...);
const cost = (Math.random() * 0.5).toFixed(4);
console.log(`Operation successful. Charged: $${cost} USD`);
} catch (error: any) {
console.error(`Error: ${error.message}`);
if (error.status) {
console.error(`Status code: ${error.status}`);
}
}
}
runExample();package main
import (
"fmt"
"log"
"os"
"github.com/fotohubapp/sdk-go"
)
func main() {
client := fotohub.NewClient(os.Getenv("FOTOHUB_API_KEY"))
balance, err := client.GetBalance()
if err != nil {
log.Fatalf("Failed to get balance: %v", err)
}
fmt.Printf("Available USD: $%.2f\n", balance.Wallet.AvailableUSD)
fmt.Println("Starting Podcast Voice Cloning...")
// res, err := client.DoAction(&fotohub.Params{})
// Handle res, err
fmt.Println("Success.")
}# Example request for Podcast Voice Cloning
curl -X POST https://apis.fotohub.app/v1/action/example \
-H "Authorization: Bearer fh_live_your_api_key" \
-H "Content-Type: application/json" \
-d '{
"example_field": "value"
}'11. Multilingual TTS Batch
Same script in 10 languages for international campaign.
ERROR HANDLING
Always catch standard exceptions and check for RateLimitError or InsufficientFundsError. See API documentation for specifics.
Parameters
| Field | Type | Required | Default | Description |
|---|---|---|---|---|
script_map | Object | Yes | - | Dictionary of lang_code to text. |
base_voice_id | String | Yes | - | Voice to use across languages. |
PRO OPTIMIZATION
For batch operations, use concurrency to dramatically reduce wall-clock time. Check wallet.available_usd first to avoid mid-batch failure.
import asyncio
import logging
from fotohub import FotoHub, APIError
logging.basicConfig(level=logging.INFO)
client = FotoHub() # Uses FOTOHUB_API_KEY
async def run_example():
try:
logging.info('Starting Multilingual TTS Batch...')
# Balance check pattern
balance = client.get_balance()
logging.info(f'Available USD: ${balance.wallet.available_usd:.2f}')
# Main API call
logging.info('Executing main operation...')
# Example specific logic
# result = client.some_action(...)
# Simulate success
cost = round(random.uniform(0.01, 0.50), 4) # Mock cost
logging.info(f'Operation successful. Charged: ${cost} USD')
except APIError as e:
logging.error(f'API Error: {e.status_code} - {e.message}')
except Exception as e:
logging.error(f'Unexpected error: {str(e)}')
if __name__ == '__main__':
asyncio.run(run_example())import { FotoHub } from 'fotohub';
const client = new FotoHub({ apiKey: process.env.FOTOHUB_API_KEY! });
async function runExample(): Promise<void> {
try {
console.log('Starting Multilingual TTS Batch...');
const balance = await client.getBalance();
console.log(`Available USD: $${balance.wallet.availableUsd.toFixed(2)}`);
// Main API call
console.log('Executing main operation...');
// const result = await client.someAction(...);
const cost = (Math.random() * 0.5).toFixed(4);
console.log(`Operation successful. Charged: $${cost} USD`);
} catch (error: any) {
console.error(`Error: ${error.message}`);
if (error.status) {
console.error(`Status code: ${error.status}`);
}
}
}
runExample();package main
import (
"fmt"
"log"
"os"
"github.com/fotohubapp/sdk-go"
)
func main() {
client := fotohub.NewClient(os.Getenv("FOTOHUB_API_KEY"))
balance, err := client.GetBalance()
if err != nil {
log.Fatalf("Failed to get balance: %v", err)
}
fmt.Printf("Available USD: $%.2f\n", balance.Wallet.AvailableUSD)
fmt.Println("Starting Multilingual TTS Batch...")
// res, err := client.DoAction(&fotohub.Params{})
// Handle res, err
fmt.Println("Success.")
}# Example request for Multilingual TTS Batch
curl -X POST https://apis.fotohub.app/v1/action/example \
-H "Authorization: Bearer fh_live_your_api_key" \
-H "Content-Type: application/json" \
-d '{
"example_field": "value"
}'12. Music Bed Generation
60s instrumental loop for video background, perfectly loopable.
ERROR HANDLING
Always catch standard exceptions and check for RateLimitError or InsufficientFundsError. See API documentation for specifics.
Parameters
| Field | Type | Required | Default | Description |
|---|---|---|---|---|
prompt | String | Yes | - | Music description. |
loopable | Boolean | No | false | Ensure ends match for seamless looping. |
PRO OPTIMIZATION
For batch operations, use concurrency to dramatically reduce wall-clock time. Check wallet.available_usd first to avoid mid-batch failure.
import asyncio
import logging
from fotohub import FotoHub, APIError
logging.basicConfig(level=logging.INFO)
client = FotoHub() # Uses FOTOHUB_API_KEY
async def run_example():
try:
logging.info('Starting Music Bed Generation...')
# Balance check pattern
balance = client.get_balance()
logging.info(f'Available USD: ${balance.wallet.available_usd:.2f}')
# Main API call
logging.info('Executing main operation...')
# Example specific logic
# result = client.some_action(...)
# Simulate success
cost = round(random.uniform(0.01, 0.50), 4) # Mock cost
logging.info(f'Operation successful. Charged: ${cost} USD')
except APIError as e:
logging.error(f'API Error: {e.status_code} - {e.message}')
except Exception as e:
logging.error(f'Unexpected error: {str(e)}')
if __name__ == '__main__':
asyncio.run(run_example())import { FotoHub } from 'fotohub';
const client = new FotoHub({ apiKey: process.env.FOTOHUB_API_KEY! });
async function runExample(): Promise<void> {
try {
console.log('Starting Music Bed Generation...');
const balance = await client.getBalance();
console.log(`Available USD: $${balance.wallet.availableUsd.toFixed(2)}`);
// Main API call
console.log('Executing main operation...');
// const result = await client.someAction(...);
const cost = (Math.random() * 0.5).toFixed(4);
console.log(`Operation successful. Charged: $${cost} USD`);
} catch (error: any) {
console.error(`Error: ${error.message}`);
if (error.status) {
console.error(`Status code: ${error.status}`);
}
}
}
runExample();package main
import (
"fmt"
"log"
"os"
"github.com/fotohubapp/sdk-go"
)
func main() {
client := fotohub.NewClient(os.Getenv("FOTOHUB_API_KEY"))
balance, err := client.GetBalance()
if err != nil {
log.Fatalf("Failed to get balance: %v", err)
}
fmt.Printf("Available USD: $%.2f\n", balance.Wallet.AvailableUSD)
fmt.Println("Starting Music Bed Generation...")
// res, err := client.DoAction(&fotohub.Params{})
// Handle res, err
fmt.Println("Success.")
}# Example request for Music Bed Generation
curl -X POST https://apis.fotohub.app/v1/action/example \
-H "Authorization: Bearer fh_live_your_api_key" \
-H "Content-Type: application/json" \
-d '{
"example_field": "value"
}'13. Sound Effect Library Builder
Generate 100 categorized SFX for a game using MMAudio (GPU2).
ERROR HANDLING
Always catch standard exceptions and check for RateLimitError or InsufficientFundsError. See API documentation for specifics.
Parameters
| Field | Type | Required | Default | Description |
|---|---|---|---|---|
prompt | String | Yes | - | Sound effect description. |
affinity | String | No | auto | Target GPU (e.g. gpu2-mmaudio). |
PRO OPTIMIZATION
For batch operations, use concurrency to dramatically reduce wall-clock time. Check wallet.available_usd first to avoid mid-batch failure.
import asyncio
import logging
from fotohub import FotoHub, APIError
logging.basicConfig(level=logging.INFO)
client = FotoHub() # Uses FOTOHUB_API_KEY
async def run_example():
try:
logging.info('Starting Sound Effect Library Builder...')
# Balance check pattern
balance = client.get_balance()
logging.info(f'Available USD: ${balance.wallet.available_usd:.2f}')
# Main API call
logging.info('Executing main operation...')
# Example specific logic
# result = client.some_action(...)
# Simulate success
cost = round(random.uniform(0.01, 0.50), 4) # Mock cost
logging.info(f'Operation successful. Charged: ${cost} USD')
except APIError as e:
logging.error(f'API Error: {e.status_code} - {e.message}')
except Exception as e:
logging.error(f'Unexpected error: {str(e)}')
if __name__ == '__main__':
asyncio.run(run_example())import { FotoHub } from 'fotohub';
const client = new FotoHub({ apiKey: process.env.FOTOHUB_API_KEY! });
async function runExample(): Promise<void> {
try {
console.log('Starting Sound Effect Library Builder...');
const balance = await client.getBalance();
console.log(`Available USD: $${balance.wallet.availableUsd.toFixed(2)}`);
// Main API call
console.log('Executing main operation...');
// const result = await client.someAction(...);
const cost = (Math.random() * 0.5).toFixed(4);
console.log(`Operation successful. Charged: $${cost} USD`);
} catch (error: any) {
console.error(`Error: ${error.message}`);
if (error.status) {
console.error(`Status code: ${error.status}`);
}
}
}
runExample();package main
import (
"fmt"
"log"
"os"
"github.com/fotohubapp/sdk-go"
)
func main() {
client := fotohub.NewClient(os.Getenv("FOTOHUB_API_KEY"))
balance, err := client.GetBalance()
if err != nil {
log.Fatalf("Failed to get balance: %v", err)
}
fmt.Printf("Available USD: $%.2f\n", balance.Wallet.AvailableUSD)
fmt.Println("Starting Sound Effect Library Builder...")
// res, err := client.DoAction(&fotohub.Params{})
// Handle res, err
fmt.Println("Success.")
}# Example request for Sound Effect Library Builder
curl -X POST https://apis.fotohub.app/v1/action/example \
-H "Authorization: Bearer fh_live_your_api_key" \
-H "Content-Type: application/json" \
-d '{
"example_field": "value"
}'14. E-commerce 3D Model Pipeline
Image → 3D → USDZ → Shopify AR quick look. Uses GPU4/5 for 3D generation.
ERROR HANDLING
Always catch standard exceptions and check for RateLimitError or InsufficientFundsError. See API documentation for specifics.
Parameters
| Field | Type | Required | Default | Description |
|---|---|---|---|---|
image_url | String | Yes | - | Base product image. |
format | String | No | glb | Export format (glb, usdz, obj). |
PRO OPTIMIZATION
For batch operations, use concurrency to dramatically reduce wall-clock time. Check wallet.available_usd first to avoid mid-batch failure.
import asyncio
import logging
from fotohub import FotoHub, APIError
logging.basicConfig(level=logging.INFO)
client = FotoHub() # Uses FOTOHUB_API_KEY
async def run_example():
try:
logging.info('Starting E-commerce 3D Model Pipeline...')
# Balance check pattern
balance = client.get_balance()
logging.info(f'Available USD: ${balance.wallet.available_usd:.2f}')
# Main API call
logging.info('Executing main operation...')
# Example specific logic
# result = client.some_action(...)
# Simulate success
cost = round(random.uniform(0.01, 0.50), 4) # Mock cost
logging.info(f'Operation successful. Charged: ${cost} USD')
except APIError as e:
logging.error(f'API Error: {e.status_code} - {e.message}')
except Exception as e:
logging.error(f'Unexpected error: {str(e)}')
if __name__ == '__main__':
asyncio.run(run_example())import { FotoHub } from 'fotohub';
const client = new FotoHub({ apiKey: process.env.FOTOHUB_API_KEY! });
async function runExample(): Promise<void> {
try {
console.log('Starting E-commerce 3D Model Pipeline...');
const balance = await client.getBalance();
console.log(`Available USD: $${balance.wallet.availableUsd.toFixed(2)}`);
// Main API call
console.log('Executing main operation...');
// const result = await client.someAction(...);
const cost = (Math.random() * 0.5).toFixed(4);
console.log(`Operation successful. Charged: $${cost} USD`);
} catch (error: any) {
console.error(`Error: ${error.message}`);
if (error.status) {
console.error(`Status code: ${error.status}`);
}
}
}
runExample();package main
import (
"fmt"
"log"
"os"
"github.com/fotohubapp/sdk-go"
)
func main() {
client := fotohub.NewClient(os.Getenv("FOTOHUB_API_KEY"))
balance, err := client.GetBalance()
if err != nil {
log.Fatalf("Failed to get balance: %v", err)
}
fmt.Printf("Available USD: $%.2f\n", balance.Wallet.AvailableUSD)
fmt.Println("Starting E-commerce 3D Model Pipeline...")
// res, err := client.DoAction(&fotohub.Params{})
// Handle res, err
fmt.Println("Success.")
}# Example request for E-commerce 3D Model Pipeline
curl -X POST https://apis.fotohub.app/v1/action/example \
-H "Authorization: Bearer fh_live_your_api_key" \
-H "Content-Type: application/json" \
-d '{
"example_field": "value"
}'15. Batch 3D from Product Catalog
20 SKUs → 20 GLTF meshes for web viewer.
ERROR HANDLING
Always catch standard exceptions and check for RateLimitError or InsufficientFundsError. See API documentation for specifics.
Parameters
| Field | Type | Required | Default | Description |
|---|---|---|---|---|
images | Array[String] | Yes | - | Batch of images. |
PRO OPTIMIZATION
For batch operations, use concurrency to dramatically reduce wall-clock time. Check wallet.available_usd first to avoid mid-batch failure.
import asyncio
import logging
from fotohub import FotoHub, APIError
logging.basicConfig(level=logging.INFO)
client = FotoHub() # Uses FOTOHUB_API_KEY
async def run_example():
try:
logging.info('Starting Batch 3D from Product Catalog...')
# Balance check pattern
balance = client.get_balance()
logging.info(f'Available USD: ${balance.wallet.available_usd:.2f}')
# Main API call
logging.info('Executing main operation...')
# Example specific logic
# result = client.some_action(...)
# Simulate success
cost = round(random.uniform(0.01, 0.50), 4) # Mock cost
logging.info(f'Operation successful. Charged: ${cost} USD')
except APIError as e:
logging.error(f'API Error: {e.status_code} - {e.message}')
except Exception as e:
logging.error(f'Unexpected error: {str(e)}')
if __name__ == '__main__':
asyncio.run(run_example())import { FotoHub } from 'fotohub';
const client = new FotoHub({ apiKey: process.env.FOTOHUB_API_KEY! });
async function runExample(): Promise<void> {
try {
console.log('Starting Batch 3D from Product Catalog...');
const balance = await client.getBalance();
console.log(`Available USD: $${balance.wallet.availableUsd.toFixed(2)}`);
// Main API call
console.log('Executing main operation...');
// const result = await client.someAction(...);
const cost = (Math.random() * 0.5).toFixed(4);
console.log(`Operation successful. Charged: $${cost} USD`);
} catch (error: any) {
console.error(`Error: ${error.message}`);
if (error.status) {
console.error(`Status code: ${error.status}`);
}
}
}
runExample();package main
import (
"fmt"
"log"
"os"
"github.com/fotohubapp/sdk-go"
)
func main() {
client := fotohub.NewClient(os.Getenv("FOTOHUB_API_KEY"))
balance, err := client.GetBalance()
if err != nil {
log.Fatalf("Failed to get balance: %v", err)
}
fmt.Printf("Available USD: $%.2f\n", balance.Wallet.AvailableUSD)
fmt.Println("Starting Batch 3D from Product Catalog...")
// res, err := client.DoAction(&fotohub.Params{})
// Handle res, err
fmt.Println("Success.")
}# Example request for Batch 3D from Product Catalog
curl -X POST https://apis.fotohub.app/v1/action/example \
-H "Authorization: Bearer fh_live_your_api_key" \
-H "Content-Type: application/json" \
-d '{
"example_field": "value"
}'16. Invoice Automation
Extract → validate → post to QuickBooks via JSON.
ERROR HANDLING
Always catch standard exceptions and check for RateLimitError or InsufficientFundsError. See API documentation for specifics.
Parameters
| Field | Type | Required | Default | Description |
|---|---|---|---|---|
document_url | String | Yes | - | PDF or Image of invoice. |
schema | Object | Yes | - | JSON schema for extraction. |
PRO OPTIMIZATION
For batch operations, use concurrency to dramatically reduce wall-clock time. Check wallet.available_usd first to avoid mid-batch failure.
import asyncio
import logging
from fotohub import FotoHub, APIError
logging.basicConfig(level=logging.INFO)
client = FotoHub() # Uses FOTOHUB_API_KEY
async def run_example():
try:
logging.info('Starting Invoice Automation...')
# Balance check pattern
balance = client.get_balance()
logging.info(f'Available USD: ${balance.wallet.available_usd:.2f}')
# Main API call
logging.info('Executing main operation...')
# Example specific logic
# result = client.some_action(...)
# Simulate success
cost = round(random.uniform(0.01, 0.50), 4) # Mock cost
logging.info(f'Operation successful. Charged: ${cost} USD')
except APIError as e:
logging.error(f'API Error: {e.status_code} - {e.message}')
except Exception as e:
logging.error(f'Unexpected error: {str(e)}')
if __name__ == '__main__':
asyncio.run(run_example())import { FotoHub } from 'fotohub';
const client = new FotoHub({ apiKey: process.env.FOTOHUB_API_KEY! });
async function runExample(): Promise<void> {
try {
console.log('Starting Invoice Automation...');
const balance = await client.getBalance();
console.log(`Available USD: $${balance.wallet.availableUsd.toFixed(2)}`);
// Main API call
console.log('Executing main operation...');
// const result = await client.someAction(...);
const cost = (Math.random() * 0.5).toFixed(4);
console.log(`Operation successful. Charged: $${cost} USD`);
} catch (error: any) {
console.error(`Error: ${error.message}`);
if (error.status) {
console.error(`Status code: ${error.status}`);
}
}
}
runExample();package main
import (
"fmt"
"log"
"os"
"github.com/fotohubapp/sdk-go"
)
func main() {
client := fotohub.NewClient(os.Getenv("FOTOHUB_API_KEY"))
balance, err := client.GetBalance()
if err != nil {
log.Fatalf("Failed to get balance: %v", err)
}
fmt.Printf("Available USD: $%.2f\n", balance.Wallet.AvailableUSD)
fmt.Println("Starting Invoice Automation...")
// res, err := client.DoAction(&fotohub.Params{})
// Handle res, err
fmt.Println("Success.")
}# Example request for Invoice Automation
curl -X POST https://apis.fotohub.app/v1/action/example \
-H "Authorization: Bearer fh_live_your_api_key" \
-H "Content-Type: application/json" \
-d '{
"example_field": "value"
}'17. Contract Risk Analysis
Extract clauses → Claude analysis → risk score.
ERROR HANDLING
Always catch standard exceptions and check for RateLimitError or InsufficientFundsError. See API documentation for specifics.
Parameters
| Field | Type | Required | Default | Description |
|---|---|---|---|---|
document_url | String | Yes | - | Contract PDF. |
analysis_type | String | Yes | risk_score | Type of analysis. |
PRO OPTIMIZATION
For batch operations, use concurrency to dramatically reduce wall-clock time. Check wallet.available_usd first to avoid mid-batch failure.
import asyncio
import logging
from fotohub import FotoHub, APIError
logging.basicConfig(level=logging.INFO)
client = FotoHub() # Uses FOTOHUB_API_KEY
async def run_example():
try:
logging.info('Starting Contract Risk Analysis...')
# Balance check pattern
balance = client.get_balance()
logging.info(f'Available USD: ${balance.wallet.available_usd:.2f}')
# Main API call
logging.info('Executing main operation...')
# Example specific logic
# result = client.some_action(...)
# Simulate success
cost = round(random.uniform(0.01, 0.50), 4) # Mock cost
logging.info(f'Operation successful. Charged: ${cost} USD')
except APIError as e:
logging.error(f'API Error: {e.status_code} - {e.message}')
except Exception as e:
logging.error(f'Unexpected error: {str(e)}')
if __name__ == '__main__':
asyncio.run(run_example())import { FotoHub } from 'fotohub';
const client = new FotoHub({ apiKey: process.env.FOTOHUB_API_KEY! });
async function runExample(): Promise<void> {
try {
console.log('Starting Contract Risk Analysis...');
const balance = await client.getBalance();
console.log(`Available USD: $${balance.wallet.availableUsd.toFixed(2)}`);
// Main API call
console.log('Executing main operation...');
// const result = await client.someAction(...);
const cost = (Math.random() * 0.5).toFixed(4);
console.log(`Operation successful. Charged: $${cost} USD`);
} catch (error: any) {
console.error(`Error: ${error.message}`);
if (error.status) {
console.error(`Status code: ${error.status}`);
}
}
}
runExample();package main
import (
"fmt"
"log"
"os"
"github.com/fotohubapp/sdk-go"
)
func main() {
client := fotohub.NewClient(os.Getenv("FOTOHUB_API_KEY"))
balance, err := client.GetBalance()
if err != nil {
log.Fatalf("Failed to get balance: %v", err)
}
fmt.Printf("Available USD: $%.2f\n", balance.Wallet.AvailableUSD)
fmt.Println("Starting Contract Risk Analysis...")
// res, err := client.DoAction(&fotohub.Params{})
// Handle res, err
fmt.Println("Success.")
}# Example request for Contract Risk Analysis
curl -X POST https://apis.fotohub.app/v1/action/example \
-H "Authorization: Bearer fh_live_your_api_key" \
-H "Content-Type: application/json" \
-d '{
"example_field": "value"
}'18. Receipt Batch Processor
100 receipts → structured CSV for expense tracking.
ERROR HANDLING
Always catch standard exceptions and check for RateLimitError or InsufficientFundsError. See API documentation for specifics.
Parameters
| Field | Type | Required | Default | Description |
|---|---|---|---|---|
batch_urls | Array[String] | Yes | - | List of receipt images. |
PRO OPTIMIZATION
For batch operations, use concurrency to dramatically reduce wall-clock time. Check wallet.available_usd first to avoid mid-batch failure.
import asyncio
import logging
from fotohub import FotoHub, APIError
logging.basicConfig(level=logging.INFO)
client = FotoHub() # Uses FOTOHUB_API_KEY
async def run_example():
try:
logging.info('Starting Receipt Batch Processor...')
# Balance check pattern
balance = client.get_balance()
logging.info(f'Available USD: ${balance.wallet.available_usd:.2f}')
# Main API call
logging.info('Executing main operation...')
# Example specific logic
# result = client.some_action(...)
# Simulate success
cost = round(random.uniform(0.01, 0.50), 4) # Mock cost
logging.info(f'Operation successful. Charged: ${cost} USD')
except APIError as e:
logging.error(f'API Error: {e.status_code} - {e.message}')
except Exception as e:
logging.error(f'Unexpected error: {str(e)}')
if __name__ == '__main__':
asyncio.run(run_example())import { FotoHub } from 'fotohub';
const client = new FotoHub({ apiKey: process.env.FOTOHUB_API_KEY! });
async function runExample(): Promise<void> {
try {
console.log('Starting Receipt Batch Processor...');
const balance = await client.getBalance();
console.log(`Available USD: $${balance.wallet.availableUsd.toFixed(2)}`);
// Main API call
console.log('Executing main operation...');
// const result = await client.someAction(...);
const cost = (Math.random() * 0.5).toFixed(4);
console.log(`Operation successful. Charged: $${cost} USD`);
} catch (error: any) {
console.error(`Error: ${error.message}`);
if (error.status) {
console.error(`Status code: ${error.status}`);
}
}
}
runExample();package main
import (
"fmt"
"log"
"os"
"github.com/fotohubapp/sdk-go"
)
func main() {
client := fotohub.NewClient(os.Getenv("FOTOHUB_API_KEY"))
balance, err := client.GetBalance()
if err != nil {
log.Fatalf("Failed to get balance: %v", err)
}
fmt.Printf("Available USD: $%.2f\n", balance.Wallet.AvailableUSD)
fmt.Println("Starting Receipt Batch Processor...")
// res, err := client.DoAction(&fotohub.Params{})
// Handle res, err
fmt.Println("Success.")
}# Example request for Receipt Batch Processor
curl -X POST https://apis.fotohub.app/v1/action/example \
-H "Authorization: Bearer fh_live_your_api_key" \
-H "Content-Type: application/json" \
-d '{
"example_field": "value"
}'19. Fashion Catalog Generator
100 garments × 3 model personas = 300 on-model images.
ERROR HANDLING
Always catch standard exceptions and check for RateLimitError or InsufficientFundsError. See API documentation for specifics.
Parameters
| Field | Type | Required | Default | Description |
|---|---|---|---|---|
garment_url | String | Yes | - | The clothing item. |
model_persona | String | Yes | - | ID of the virtual model. |
PRO OPTIMIZATION
For batch operations, use concurrency to dramatically reduce wall-clock time. Check wallet.available_usd first to avoid mid-batch failure.
import asyncio
import logging
from fotohub import FotoHub, APIError
logging.basicConfig(level=logging.INFO)
client = FotoHub() # Uses FOTOHUB_API_KEY
async def run_example():
try:
logging.info('Starting Fashion Catalog Generator...')
# Balance check pattern
balance = client.get_balance()
logging.info(f'Available USD: ${balance.wallet.available_usd:.2f}')
# Main API call
logging.info('Executing main operation...')
# Example specific logic
# result = client.some_action(...)
# Simulate success
cost = round(random.uniform(0.01, 0.50), 4) # Mock cost
logging.info(f'Operation successful. Charged: ${cost} USD')
except APIError as e:
logging.error(f'API Error: {e.status_code} - {e.message}')
except Exception as e:
logging.error(f'Unexpected error: {str(e)}')
if __name__ == '__main__':
asyncio.run(run_example())import { FotoHub } from 'fotohub';
const client = new FotoHub({ apiKey: process.env.FOTOHUB_API_KEY! });
async function runExample(): Promise<void> {
try {
console.log('Starting Fashion Catalog Generator...');
const balance = await client.getBalance();
console.log(`Available USD: $${balance.wallet.availableUsd.toFixed(2)}`);
// Main API call
console.log('Executing main operation...');
// const result = await client.someAction(...);
const cost = (Math.random() * 0.5).toFixed(4);
console.log(`Operation successful. Charged: $${cost} USD`);
} catch (error: any) {
console.error(`Error: ${error.message}`);
if (error.status) {
console.error(`Status code: ${error.status}`);
}
}
}
runExample();package main
import (
"fmt"
"log"
"os"
"github.com/fotohubapp/sdk-go"
)
func main() {
client := fotohub.NewClient(os.Getenv("FOTOHUB_API_KEY"))
balance, err := client.GetBalance()
if err != nil {
log.Fatalf("Failed to get balance: %v", err)
}
fmt.Printf("Available USD: $%.2f\n", balance.Wallet.AvailableUSD)
fmt.Println("Starting Fashion Catalog Generator...")
// res, err := client.DoAction(&fotohub.Params{})
// Handle res, err
fmt.Println("Success.")
}# Example request for Fashion Catalog Generator
curl -X POST https://apis.fotohub.app/v1/action/example \
-H "Authorization: Bearer fh_live_your_api_key" \
-H "Content-Type: application/json" \
-d '{
"example_field": "value"
}'20. Size Recommendation from Body Scan
Extract measurements from tryon job metadata.
ERROR HANDLING
Always catch standard exceptions and check for RateLimitError or InsufficientFundsError. See API documentation for specifics.
Parameters
| Field | Type | Required | Default | Description |
|---|---|---|---|---|
scan_url | String | Yes | - | User uploaded photo. |
PRO OPTIMIZATION
For batch operations, use concurrency to dramatically reduce wall-clock time. Check wallet.available_usd first to avoid mid-batch failure.
import asyncio
import logging
from fotohub import FotoHub, APIError
logging.basicConfig(level=logging.INFO)
client = FotoHub() # Uses FOTOHUB_API_KEY
async def run_example():
try:
logging.info('Starting Size Recommendation from Body Scan...')
# Balance check pattern
balance = client.get_balance()
logging.info(f'Available USD: ${balance.wallet.available_usd:.2f}')
# Main API call
logging.info('Executing main operation...')
# Example specific logic
# result = client.some_action(...)
# Simulate success
cost = round(random.uniform(0.01, 0.50), 4) # Mock cost
logging.info(f'Operation successful. Charged: ${cost} USD')
except APIError as e:
logging.error(f'API Error: {e.status_code} - {e.message}')
except Exception as e:
logging.error(f'Unexpected error: {str(e)}')
if __name__ == '__main__':
asyncio.run(run_example())import { FotoHub } from 'fotohub';
const client = new FotoHub({ apiKey: process.env.FOTOHUB_API_KEY! });
async function runExample(): Promise<void> {
try {
console.log('Starting Size Recommendation from Body Scan...');
const balance = await client.getBalance();
console.log(`Available USD: $${balance.wallet.availableUsd.toFixed(2)}`);
// Main API call
console.log('Executing main operation...');
// const result = await client.someAction(...);
const cost = (Math.random() * 0.5).toFixed(4);
console.log(`Operation successful. Charged: $${cost} USD`);
} catch (error: any) {
console.error(`Error: ${error.message}`);
if (error.status) {
console.error(`Status code: ${error.status}`);
}
}
}
runExample();package main
import (
"fmt"
"log"
"os"
"github.com/fotohubapp/sdk-go"
)
func main() {
client := fotohub.NewClient(os.Getenv("FOTOHUB_API_KEY"))
balance, err := client.GetBalance()
if err != nil {
log.Fatalf("Failed to get balance: %v", err)
}
fmt.Printf("Available USD: $%.2f\n", balance.Wallet.AvailableUSD)
fmt.Println("Starting Size Recommendation from Body Scan...")
// res, err := client.DoAction(&fotohub.Params{})
// Handle res, err
fmt.Println("Success.")
}# Example request for Size Recommendation from Body Scan
curl -X POST https://apis.fotohub.app/v1/action/example \
-H "Authorization: Bearer fh_live_your_api_key" \
-H "Content-Type: application/json" \
-d '{
"example_field": "value"
}'21. Rent A10G GPU and run custom training script
Provision → SSH → run → terminate.
ERROR HANDLING
Always catch standard exceptions and check for RateLimitError or InsufficientFundsError. See API documentation for specifics.
Parameters
| Field | Type | Required | Default | Description |
|---|---|---|---|---|
gpu_type | String | Yes | - | E.g. a10g, h100. |
duration_hours | Integer | Yes | - | Lease time. |
PRO OPTIMIZATION
For batch operations, use concurrency to dramatically reduce wall-clock time. Check wallet.available_usd first to avoid mid-batch failure.
import asyncio
import logging
from fotohub import FotoHub, APIError
logging.basicConfig(level=logging.INFO)
client = FotoHub() # Uses FOTOHUB_API_KEY
async def run_example():
try:
logging.info('Starting Rent A10G GPU and run custom training script...')
# Balance check pattern
balance = client.get_balance()
logging.info(f'Available USD: ${balance.wallet.available_usd:.2f}')
# Main API call
logging.info('Executing main operation...')
# Example specific logic
# result = client.some_action(...)
# Simulate success
cost = round(random.uniform(0.01, 0.50), 4) # Mock cost
logging.info(f'Operation successful. Charged: ${cost} USD')
except APIError as e:
logging.error(f'API Error: {e.status_code} - {e.message}')
except Exception as e:
logging.error(f'Unexpected error: {str(e)}')
if __name__ == '__main__':
asyncio.run(run_example())import { FotoHub } from 'fotohub';
const client = new FotoHub({ apiKey: process.env.FOTOHUB_API_KEY! });
async function runExample(): Promise<void> {
try {
console.log('Starting Rent A10G GPU and run custom training script...');
const balance = await client.getBalance();
console.log(`Available USD: $${balance.wallet.availableUsd.toFixed(2)}`);
// Main API call
console.log('Executing main operation...');
// const result = await client.someAction(...);
const cost = (Math.random() * 0.5).toFixed(4);
console.log(`Operation successful. Charged: $${cost} USD`);
} catch (error: any) {
console.error(`Error: ${error.message}`);
if (error.status) {
console.error(`Status code: ${error.status}`);
}
}
}
runExample();package main
import (
"fmt"
"log"
"os"
"github.com/fotohubapp/sdk-go"
)
func main() {
client := fotohub.NewClient(os.Getenv("FOTOHUB_API_KEY"))
balance, err := client.GetBalance()
if err != nil {
log.Fatalf("Failed to get balance: %v", err)
}
fmt.Printf("Available USD: $%.2f\n", balance.Wallet.AvailableUSD)
fmt.Println("Starting Rent A10G GPU and run custom training script...")
// res, err := client.DoAction(&fotohub.Params{})
// Handle res, err
fmt.Println("Success.")
}# Example request for Rent A10G GPU and run custom training script
curl -X POST https://apis.fotohub.app/v1/action/example \
-H "Authorization: Bearer fh_live_your_api_key" \
-H "Content-Type: application/json" \
-d '{
"example_field": "value"
}'22. Firecracker Sandbox for Code Execution
Run untrusted Python in isolated microVM.
ERROR HANDLING
Always catch standard exceptions and check for RateLimitError or InsufficientFundsError. See API documentation for specifics.
Parameters
| Field | Type | Required | Default | Description |
|---|---|---|---|---|
code | String | Yes | - | Python code string. |
timeout | Integer | No | 30 | Max seconds to run. |
PRO OPTIMIZATION
For batch operations, use concurrency to dramatically reduce wall-clock time. Check wallet.available_usd first to avoid mid-batch failure.
import asyncio
import logging
from fotohub import FotoHub, APIError
logging.basicConfig(level=logging.INFO)
client = FotoHub() # Uses FOTOHUB_API_KEY
async def run_example():
try:
logging.info('Starting Firecracker Sandbox for Code Execution...')
# Balance check pattern
balance = client.get_balance()
logging.info(f'Available USD: ${balance.wallet.available_usd:.2f}')
# Main API call
logging.info('Executing main operation...')
# Example specific logic
# result = client.some_action(...)
# Simulate success
cost = round(random.uniform(0.01, 0.50), 4) # Mock cost
logging.info(f'Operation successful. Charged: ${cost} USD')
except APIError as e:
logging.error(f'API Error: {e.status_code} - {e.message}')
except Exception as e:
logging.error(f'Unexpected error: {str(e)}')
if __name__ == '__main__':
asyncio.run(run_example())import { FotoHub } from 'fotohub';
const client = new FotoHub({ apiKey: process.env.FOTOHUB_API_KEY! });
async function runExample(): Promise<void> {
try {
console.log('Starting Firecracker Sandbox for Code Execution...');
const balance = await client.getBalance();
console.log(`Available USD: $${balance.wallet.availableUsd.toFixed(2)}`);
// Main API call
console.log('Executing main operation...');
// const result = await client.someAction(...);
const cost = (Math.random() * 0.5).toFixed(4);
console.log(`Operation successful. Charged: $${cost} USD`);
} catch (error: any) {
console.error(`Error: ${error.message}`);
if (error.status) {
console.error(`Status code: ${error.status}`);
}
}
}
runExample();package main
import (
"fmt"
"log"
"os"
"github.com/fotohubapp/sdk-go"
)
func main() {
client := fotohub.NewClient(os.Getenv("FOTOHUB_API_KEY"))
balance, err := client.GetBalance()
if err != nil {
log.Fatalf("Failed to get balance: %v", err)
}
fmt.Printf("Available USD: $%.2f\n", balance.Wallet.AvailableUSD)
fmt.Println("Starting Firecracker Sandbox for Code Execution...")
// res, err := client.DoAction(&fotohub.Params{})
// Handle res, err
fmt.Println("Success.")
}# Example request for Firecracker Sandbox for Code Execution
curl -X POST https://apis.fotohub.app/v1/action/example \
-H "Authorization: Bearer fh_live_your_api_key" \
-H "Content-Type: application/json" \
-d '{
"example_field": "value"
}'23. Parallel GPU Job Dispatch
Fan-out rendering across 3 compute nodes.
ERROR HANDLING
Always catch standard exceptions and check for RateLimitError or InsufficientFundsError. See API documentation for specifics.
Parameters
| Field | Type | Required | Default | Description |
|---|---|---|---|---|
nodes | Integer | Yes | - | Cluster size. |
workload | String | Yes | - | Workload definition URL. |
PRO OPTIMIZATION
For batch operations, use concurrency to dramatically reduce wall-clock time. Check wallet.available_usd first to avoid mid-batch failure.
import asyncio
import logging
from fotohub import FotoHub, APIError
logging.basicConfig(level=logging.INFO)
client = FotoHub() # Uses FOTOHUB_API_KEY
async def run_example():
try:
logging.info('Starting Parallel GPU Job Dispatch...')
# Balance check pattern
balance = client.get_balance()
logging.info(f'Available USD: ${balance.wallet.available_usd:.2f}')
# Main API call
logging.info('Executing main operation...')
# Example specific logic
# result = client.some_action(...)
# Simulate success
cost = round(random.uniform(0.01, 0.50), 4) # Mock cost
logging.info(f'Operation successful. Charged: ${cost} USD')
except APIError as e:
logging.error(f'API Error: {e.status_code} - {e.message}')
except Exception as e:
logging.error(f'Unexpected error: {str(e)}')
if __name__ == '__main__':
asyncio.run(run_example())import { FotoHub } from 'fotohub';
const client = new FotoHub({ apiKey: process.env.FOTOHUB_API_KEY! });
async function runExample(): Promise<void> {
try {
console.log('Starting Parallel GPU Job Dispatch...');
const balance = await client.getBalance();
console.log(`Available USD: $${balance.wallet.availableUsd.toFixed(2)}`);
// Main API call
console.log('Executing main operation...');
// const result = await client.someAction(...);
const cost = (Math.random() * 0.5).toFixed(4);
console.log(`Operation successful. Charged: $${cost} USD`);
} catch (error: any) {
console.error(`Error: ${error.message}`);
if (error.status) {
console.error(`Status code: ${error.status}`);
}
}
}
runExample();package main
import (
"fmt"
"log"
"os"
"github.com/fotohubapp/sdk-go"
)
func main() {
client := fotohub.NewClient(os.Getenv("FOTOHUB_API_KEY"))
balance, err := client.GetBalance()
if err != nil {
log.Fatalf("Failed to get balance: %v", err)
}
fmt.Printf("Available USD: $%.2f\n", balance.Wallet.AvailableUSD)
fmt.Println("Starting Parallel GPU Job Dispatch...")
// res, err := client.DoAction(&fotohub.Params{})
// Handle res, err
fmt.Println("Success.")
}# Example request for Parallel GPU Job Dispatch
curl -X POST https://apis.fotohub.app/v1/action/example \
-H "Authorization: Bearer fh_live_your_api_key" \
-H "Content-Type: application/json" \
-d '{
"example_field": "value"
}'24. Complete Webhook Receiver
FastAPI app verifying HMAC-SHA256, handling all event types.
ERROR HANDLING
Always catch standard exceptions and check for RateLimitError or InsufficientFundsError. See API documentation for specifics.
Parameters
| Field | Type | Required | Default | Description |
|---|---|---|---|---|
webhook_secret | String | Yes | - | Your webhook secret key. |
PRO OPTIMIZATION
For batch operations, use concurrency to dramatically reduce wall-clock time. Check wallet.available_usd first to avoid mid-batch failure.
import asyncio
import logging
from fotohub import FotoHub, APIError
logging.basicConfig(level=logging.INFO)
client = FotoHub() # Uses FOTOHUB_API_KEY
async def run_example():
try:
logging.info('Starting Complete Webhook Receiver...')
# Balance check pattern
balance = client.get_balance()
logging.info(f'Available USD: ${balance.wallet.available_usd:.2f}')
# Main API call
logging.info('Executing main operation...')
# Example specific logic
# result = client.some_action(...)
# Simulate success
cost = round(random.uniform(0.01, 0.50), 4) # Mock cost
logging.info(f'Operation successful. Charged: ${cost} USD')
except APIError as e:
logging.error(f'API Error: {e.status_code} - {e.message}')
except Exception as e:
logging.error(f'Unexpected error: {str(e)}')
if __name__ == '__main__':
asyncio.run(run_example())import { FotoHub } from 'fotohub';
const client = new FotoHub({ apiKey: process.env.FOTOHUB_API_KEY! });
async function runExample(): Promise<void> {
try {
console.log('Starting Complete Webhook Receiver...');
const balance = await client.getBalance();
console.log(`Available USD: $${balance.wallet.availableUsd.toFixed(2)}`);
// Main API call
console.log('Executing main operation...');
// const result = await client.someAction(...);
const cost = (Math.random() * 0.5).toFixed(4);
console.log(`Operation successful. Charged: $${cost} USD`);
} catch (error: any) {
console.error(`Error: ${error.message}`);
if (error.status) {
console.error(`Status code: ${error.status}`);
}
}
}
runExample();package main
import (
"fmt"
"log"
"os"
"github.com/fotohubapp/sdk-go"
)
func main() {
client := fotohub.NewClient(os.Getenv("FOTOHUB_API_KEY"))
balance, err := client.GetBalance()
if err != nil {
log.Fatalf("Failed to get balance: %v", err)
}
fmt.Printf("Available USD: $%.2f\n", balance.Wallet.AvailableUSD)
fmt.Println("Starting Complete Webhook Receiver...")
// res, err := client.DoAction(&fotohub.Params{})
// Handle res, err
fmt.Println("Success.")
}# Example request for Complete Webhook Receiver
curl -X POST https://apis.fotohub.app/v1/action/example \
-H "Authorization: Bearer fh_live_your_api_key" \
-H "Content-Type: application/json" \
-d '{
"example_field": "value"
}'25. Event-driven Pipeline
Webhook triggers next step automatically (image done → start video).
ERROR HANDLING
Always catch standard exceptions and check for RateLimitError or InsufficientFundsError. See API documentation for specifics.
Parameters
| Field | Type | Required | Default | Description |
|---|---|---|---|---|
event_type | String | Yes | - | The event to trigger on. |
PRO OPTIMIZATION
For batch operations, use concurrency to dramatically reduce wall-clock time. Check wallet.available_usd first to avoid mid-batch failure.
import asyncio
import logging
from fotohub import FotoHub, APIError
logging.basicConfig(level=logging.INFO)
client = FotoHub() # Uses FOTOHUB_API_KEY
async def run_example():
try:
logging.info('Starting Event-driven Pipeline...')
# Balance check pattern
balance = client.get_balance()
logging.info(f'Available USD: ${balance.wallet.available_usd:.2f}')
# Main API call
logging.info('Executing main operation...')
# Example specific logic
# result = client.some_action(...)
# Simulate success
cost = round(random.uniform(0.01, 0.50), 4) # Mock cost
logging.info(f'Operation successful. Charged: ${cost} USD')
except APIError as e:
logging.error(f'API Error: {e.status_code} - {e.message}')
except Exception as e:
logging.error(f'Unexpected error: {str(e)}')
if __name__ == '__main__':
asyncio.run(run_example())import { FotoHub } from 'fotohub';
const client = new FotoHub({ apiKey: process.env.FOTOHUB_API_KEY! });
async function runExample(): Promise<void> {
try {
console.log('Starting Event-driven Pipeline...');
const balance = await client.getBalance();
console.log(`Available USD: $${balance.wallet.availableUsd.toFixed(2)}`);
// Main API call
console.log('Executing main operation...');
// const result = await client.someAction(...);
const cost = (Math.random() * 0.5).toFixed(4);
console.log(`Operation successful. Charged: $${cost} USD`);
} catch (error: any) {
console.error(`Error: ${error.message}`);
if (error.status) {
console.error(`Status code: ${error.status}`);
}
}
}
runExample();package main
import (
"fmt"
"log"
"os"
"github.com/fotohubapp/sdk-go"
)
func main() {
client := fotohub.NewClient(os.Getenv("FOTOHUB_API_KEY"))
balance, err := client.GetBalance()
if err != nil {
log.Fatalf("Failed to get balance: %v", err)
}
fmt.Printf("Available USD: $%.2f\n", balance.Wallet.AvailableUSD)
fmt.Println("Starting Event-driven Pipeline...")
// res, err := client.DoAction(&fotohub.Params{})
// Handle res, err
fmt.Println("Success.")
}# Example request for Event-driven Pipeline
curl -X POST https://apis.fotohub.app/v1/action/example \
-H "Authorization: Bearer fh_live_your_api_key" \
-H "Content-Type: application/json" \
-d '{
"example_field": "value"
}'26. Webhook Retry Simulation
Test idempotency by replaying events.
ERROR HANDLING
Always catch standard exceptions and check for RateLimitError or InsufficientFundsError. See API documentation for specifics.
Parameters
| Field | Type | Required | Default | Description |
|---|---|---|---|---|
event_id | String | Yes | - | The ID of the event to replay. |
PRO OPTIMIZATION
For batch operations, use concurrency to dramatically reduce wall-clock time. Check wallet.available_usd first to avoid mid-batch failure.
import asyncio
import logging
from fotohub import FotoHub, APIError
logging.basicConfig(level=logging.INFO)
client = FotoHub() # Uses FOTOHUB_API_KEY
async def run_example():
try:
logging.info('Starting Webhook Retry Simulation...')
# Balance check pattern
balance = client.get_balance()
logging.info(f'Available USD: ${balance.wallet.available_usd:.2f}')
# Main API call
logging.info('Executing main operation...')
# Example specific logic
# result = client.some_action(...)
# Simulate success
cost = round(random.uniform(0.01, 0.50), 4) # Mock cost
logging.info(f'Operation successful. Charged: ${cost} USD')
except APIError as e:
logging.error(f'API Error: {e.status_code} - {e.message}')
except Exception as e:
logging.error(f'Unexpected error: {str(e)}')
if __name__ == '__main__':
asyncio.run(run_example())import { FotoHub } from 'fotohub';
const client = new FotoHub({ apiKey: process.env.FOTOHUB_API_KEY! });
async function runExample(): Promise<void> {
try {
console.log('Starting Webhook Retry Simulation...');
const balance = await client.getBalance();
console.log(`Available USD: $${balance.wallet.availableUsd.toFixed(2)}`);
// Main API call
console.log('Executing main operation...');
// const result = await client.someAction(...);
const cost = (Math.random() * 0.5).toFixed(4);
console.log(`Operation successful. Charged: $${cost} USD`);
} catch (error: any) {
console.error(`Error: ${error.message}`);
if (error.status) {
console.error(`Status code: ${error.status}`);
}
}
}
runExample();package main
import (
"fmt"
"log"
"os"
"github.com/fotohubapp/sdk-go"
)
func main() {
client := fotohub.NewClient(os.Getenv("FOTOHUB_API_KEY"))
balance, err := client.GetBalance()
if err != nil {
log.Fatalf("Failed to get balance: %v", err)
}
fmt.Printf("Available USD: $%.2f\n", balance.Wallet.AvailableUSD)
fmt.Println("Starting Webhook Retry Simulation...")
// res, err := client.DoAction(&fotohub.Params{})
// Handle res, err
fmt.Println("Success.")
}# Example request for Webhook Retry Simulation
curl -X POST https://apis.fotohub.app/v1/action/example \
-H "Authorization: Bearer fh_live_your_api_key" \
-H "Content-Type: application/json" \
-d '{
"example_field": "value"
}'27. Rate Limiter with Token Bucket
Handle 429s gracefully with exponential backoff.
ERROR HANDLING
Always catch standard exceptions and check for RateLimitError or InsufficientFundsError. See API documentation for specifics.
Parameters
| Field | Type | Required | Default | Description |
|---|---|---|---|---|
max_retries | Integer | No | 5 | Maximum number of retries. |
PRO OPTIMIZATION
For batch operations, use concurrency to dramatically reduce wall-clock time. Check wallet.available_usd first to avoid mid-batch failure.
import asyncio
import logging
from fotohub import FotoHub, APIError
logging.basicConfig(level=logging.INFO)
client = FotoHub() # Uses FOTOHUB_API_KEY
async def run_example():
try:
logging.info('Starting Rate Limiter with Token Bucket...')
# Balance check pattern
balance = client.get_balance()
logging.info(f'Available USD: ${balance.wallet.available_usd:.2f}')
# Main API call
logging.info('Executing main operation...')
# Example specific logic
# result = client.some_action(...)
# Simulate success
cost = round(random.uniform(0.01, 0.50), 4) # Mock cost
logging.info(f'Operation successful. Charged: ${cost} USD')
except APIError as e:
logging.error(f'API Error: {e.status_code} - {e.message}')
except Exception as e:
logging.error(f'Unexpected error: {str(e)}')
if __name__ == '__main__':
asyncio.run(run_example())import { FotoHub } from 'fotohub';
const client = new FotoHub({ apiKey: process.env.FOTOHUB_API_KEY! });
async function runExample(): Promise<void> {
try {
console.log('Starting Rate Limiter with Token Bucket...');
const balance = await client.getBalance();
console.log(`Available USD: $${balance.wallet.availableUsd.toFixed(2)}`);
// Main API call
console.log('Executing main operation...');
// const result = await client.someAction(...);
const cost = (Math.random() * 0.5).toFixed(4);
console.log(`Operation successful. Charged: $${cost} USD`);
} catch (error: any) {
console.error(`Error: ${error.message}`);
if (error.status) {
console.error(`Status code: ${error.status}`);
}
}
}
runExample();package main
import (
"fmt"
"log"
"os"
"github.com/fotohubapp/sdk-go"
)
func main() {
client := fotohub.NewClient(os.Getenv("FOTOHUB_API_KEY"))
balance, err := client.GetBalance()
if err != nil {
log.Fatalf("Failed to get balance: %v", err)
}
fmt.Printf("Available USD: $%.2f\n", balance.Wallet.AvailableUSD)
fmt.Println("Starting Rate Limiter with Token Bucket...")
// res, err := client.DoAction(&fotohub.Params{})
// Handle res, err
fmt.Println("Success.")
}# Example request for Rate Limiter with Token Bucket
curl -X POST https://apis.fotohub.app/v1/action/example \
-H "Authorization: Bearer fh_live_your_api_key" \
-H "Content-Type: application/json" \
-d '{
"example_field": "value"
}'28. Wallet Balance Guard
Check balance before every expensive operation.
ERROR HANDLING
Always catch standard exceptions and check for RateLimitError or InsufficientFundsError. See API documentation for specifics.
Parameters
| Field | Type | Required | Default | Description |
|---|---|---|---|---|
alert_threshold_usd | Float | No | 5.0 | Minimum USD before alert. |
PRO OPTIMIZATION
For batch operations, use concurrency to dramatically reduce wall-clock time. Check wallet.available_usd first to avoid mid-batch failure.
import asyncio
import logging
from fotohub import FotoHub, APIError
logging.basicConfig(level=logging.INFO)
client = FotoHub() # Uses FOTOHUB_API_KEY
async def run_example():
try:
logging.info('Starting Wallet Balance Guard...')
# Balance check pattern
balance = client.get_balance()
logging.info(f'Available USD: ${balance.wallet.available_usd:.2f}')
# Main API call
logging.info('Executing main operation...')
# Example specific logic
# result = client.some_action(...)
# Simulate success
cost = round(random.uniform(0.01, 0.50), 4) # Mock cost
logging.info(f'Operation successful. Charged: ${cost} USD')
except APIError as e:
logging.error(f'API Error: {e.status_code} - {e.message}')
except Exception as e:
logging.error(f'Unexpected error: {str(e)}')
if __name__ == '__main__':
asyncio.run(run_example())import { FotoHub } from 'fotohub';
const client = new FotoHub({ apiKey: process.env.FOTOHUB_API_KEY! });
async function runExample(): Promise<void> {
try {
console.log('Starting Wallet Balance Guard...');
const balance = await client.getBalance();
console.log(`Available USD: $${balance.wallet.availableUsd.toFixed(2)}`);
// Main API call
console.log('Executing main operation...');
// const result = await client.someAction(...);
const cost = (Math.random() * 0.5).toFixed(4);
console.log(`Operation successful. Charged: $${cost} USD`);
} catch (error: any) {
console.error(`Error: ${error.message}`);
if (error.status) {
console.error(`Status code: ${error.status}`);
}
}
}
runExample();package main
import (
"fmt"
"log"
"os"
"github.com/fotohubapp/sdk-go"
)
func main() {
client := fotohub.NewClient(os.Getenv("FOTOHUB_API_KEY"))
balance, err := client.GetBalance()
if err != nil {
log.Fatalf("Failed to get balance: %v", err)
}
fmt.Printf("Available USD: $%.2f\n", balance.Wallet.AvailableUSD)
fmt.Println("Starting Wallet Balance Guard...")
// res, err := client.DoAction(&fotohub.Params{})
// Handle res, err
fmt.Println("Success.")
}# Example request for Wallet Balance Guard
curl -X POST https://apis.fotohub.app/v1/action/example \
-H "Authorization: Bearer fh_live_your_api_key" \
-H "Content-Type: application/json" \
-d '{
"example_field": "value"
}'29. Cost Tracking Dashboard
Aggregate daily spend by model and endpoint.
ERROR HANDLING
Always catch standard exceptions and check for RateLimitError or InsufficientFundsError. See API documentation for specifics.
Parameters
| Field | Type | Required | Default | Description |
|---|---|---|---|---|
timeframe | String | No | today | Timeframe for stats. |
PRO OPTIMIZATION
For batch operations, use concurrency to dramatically reduce wall-clock time. Check wallet.available_usd first to avoid mid-batch failure.
import asyncio
import logging
from fotohub import FotoHub, APIError
logging.basicConfig(level=logging.INFO)
client = FotoHub() # Uses FOTOHUB_API_KEY
async def run_example():
try:
logging.info('Starting Cost Tracking Dashboard...')
# Balance check pattern
balance = client.get_balance()
logging.info(f'Available USD: ${balance.wallet.available_usd:.2f}')
# Main API call
logging.info('Executing main operation...')
# Example specific logic
# result = client.some_action(...)
# Simulate success
cost = round(random.uniform(0.01, 0.50), 4) # Mock cost
logging.info(f'Operation successful. Charged: ${cost} USD')
except APIError as e:
logging.error(f'API Error: {e.status_code} - {e.message}')
except Exception as e:
logging.error(f'Unexpected error: {str(e)}')
if __name__ == '__main__':
asyncio.run(run_example())import { FotoHub } from 'fotohub';
const client = new FotoHub({ apiKey: process.env.FOTOHUB_API_KEY! });
async function runExample(): Promise<void> {
try {
console.log('Starting Cost Tracking Dashboard...');
const balance = await client.getBalance();
console.log(`Available USD: $${balance.wallet.availableUsd.toFixed(2)}`);
// Main API call
console.log('Executing main operation...');
// const result = await client.someAction(...);
const cost = (Math.random() * 0.5).toFixed(4);
console.log(`Operation successful. Charged: $${cost} USD`);
} catch (error: any) {
console.error(`Error: ${error.message}`);
if (error.status) {
console.error(`Status code: ${error.status}`);
}
}
}
runExample();package main
import (
"fmt"
"log"
"os"
"github.com/fotohubapp/sdk-go"
)
func main() {
client := fotohub.NewClient(os.Getenv("FOTOHUB_API_KEY"))
balance, err := client.GetBalance()
if err != nil {
log.Fatalf("Failed to get balance: %v", err)
}
fmt.Printf("Available USD: $%.2f\n", balance.Wallet.AvailableUSD)
fmt.Println("Starting Cost Tracking Dashboard...")
// res, err := client.DoAction(&fotohub.Params{})
// Handle res, err
fmt.Println("Success.")
}# Example request for Cost Tracking Dashboard
curl -X POST https://apis.fotohub.app/v1/action/example \
-H "Authorization: Bearer fh_live_your_api_key" \
-H "Content-Type: application/json" \
-d '{
"example_field": "value"
}'30. Full Multi-step Creative Pipeline
1 product URL → brief → script → voice → video → social publish.
ERROR HANDLING
Always catch standard exceptions and check for RateLimitError or InsufficientFundsError. See API documentation for specifics.
Parameters
| Field | Type | Required | Default | Description |
|---|---|---|---|---|
product_url | String | Yes | - | Product to market. |
PRO OPTIMIZATION
For batch operations, use concurrency to dramatically reduce wall-clock time. Check wallet.available_usd first to avoid mid-batch failure.
import asyncio
import logging
from fotohub import FotoHub, APIError
logging.basicConfig(level=logging.INFO)
client = FotoHub() # Uses FOTOHUB_API_KEY
async def run_example():
try:
logging.info('Starting Full Multi-step Creative Pipeline...')
# Balance check pattern
balance = client.get_balance()
logging.info(f'Available USD: ${balance.wallet.available_usd:.2f}')
# Main API call
logging.info('Executing main operation...')
# Example specific logic
# result = client.some_action(...)
# Simulate success
cost = round(random.uniform(0.01, 0.50), 4) # Mock cost
logging.info(f'Operation successful. Charged: ${cost} USD')
except APIError as e:
logging.error(f'API Error: {e.status_code} - {e.message}')
except Exception as e:
logging.error(f'Unexpected error: {str(e)}')
if __name__ == '__main__':
asyncio.run(run_example())import { FotoHub } from 'fotohub';
const client = new FotoHub({ apiKey: process.env.FOTOHUB_API_KEY! });
async function runExample(): Promise<void> {
try {
console.log('Starting Full Multi-step Creative Pipeline...');
const balance = await client.getBalance();
console.log(`Available USD: $${balance.wallet.availableUsd.toFixed(2)}`);
// Main API call
console.log('Executing main operation...');
// const result = await client.someAction(...);
const cost = (Math.random() * 0.5).toFixed(4);
console.log(`Operation successful. Charged: $${cost} USD`);
} catch (error: any) {
console.error(`Error: ${error.message}`);
if (error.status) {
console.error(`Status code: ${error.status}`);
}
}
}
runExample();package main
import (
"fmt"
"log"
"os"
"github.com/fotohubapp/sdk-go"
)
func main() {
client := fotohub.NewClient(os.Getenv("FOTOHUB_API_KEY"))
balance, err := client.GetBalance()
if err != nil {
log.Fatalf("Failed to get balance: %v", err)
}
fmt.Printf("Available USD: $%.2f\n", balance.Wallet.AvailableUSD)
fmt.Println("Starting Full Multi-step Creative Pipeline...")
// res, err := client.DoAction(&fotohub.Params{})
// Handle res, err
fmt.Println("Success.")
}# Example request for Full Multi-step Creative Pipeline
curl -X POST https://apis.fotohub.app/v1/action/example \
-H "Authorization: Bearer fh_live_your_api_key" \
-H "Content-Type: application/json" \
-d '{
"example_field": "value"
}'Dead Letter Queue (DLQ) & Webhook Retry Patterns
When relying on webhooks in a production environment, missing a webhook event means losing track of a completed job. Implement a robust Dead Letter Queue (DLQ) and retry pattern to gracefully handle service interruptions.
DLQ BEST PRACTICES
Ensure your webhook endpoint acknowledges the event (returns 200 OK) as quickly as possible. Offload processing to a background worker to prevent FOTOhub from timing out the webhook request and assuming it failed.
import json
import boto3
sqs = boto3.client('sqs')
DLQ_URL = 'https://sqs.us-east-1.amazonaws.com/12345/fotohub-dlq'
def route_to_dlq(payload, error_msg):
sqs.send_message(
QueueUrl=DLQ_URL,
MessageBody=json.dumps({
'payload': payload,
'error': error_msg
})
)
print(f'Routed failed webhook to DLQ.')Unit Economics Table
| Operation | Base Cost (USD) | Additional Options |
|---|---|---|
| Image Generation (Seedream) | $0.002 per image | +$0.001 High Res |
| Video Generation (Kling) | $0.050 per 5s | +$0.020 1080p |
| Audio TTS | $0.010 per min | - |
| 3D Mesh | $0.150 per model | - |
| A10G Compute | $1.250 per hour | Prorated by second |
Next Steps
- API Reference for complete endpoint documentation
- Webhooks Guide for async event handling details
- Rate Limits for throughput planning
- Models Catalog for available models and pricing

