Skip to main content

Get User Credit

Retrieves the current user's Stability AI credit balance.

Common Properties

  • Name - The custom name of the node.
  • Color - The custom color of the node.
  • Delay Before (sec) - Waits in seconds before executing the node.
  • Delay After (sec) - Waits in seconds after executing node.
  • Continue On Error - Automation will continue regardless of any error. The default value is false.
info

If the ContinueOnError property is true, no error is caught when the project is executed, even if a Catch node is used.

Inputs

  • Connection Id - The connection ID from the Connect node (optional if API Key is provided directly).

Options

  • API Key - Stability AI API key (optional if using Connection ID). You can provide the API key directly instead of using a Connect node.

Output

  • User Credit - Numeric value representing the current credit balance for the account. Credits are consumed when generating images, upscaling, or performing other API operations.

How It Works

The Get User Credit node retrieves the credit balance from Stability AI. When executed, the node:

  1. Validates the connection or creates a temporary client using provided credentials
  2. Sends a request to the Stability AI user balance endpoint
  3. Retrieves the credit balance
  4. Returns the credit amount as a numeric value

Requirements

  • Either a valid Connection Id from Connect node OR direct API Key credentials
  • Active Stability AI account with API access
  • Valid API key with appropriate permissions

Error Handling

The node will return specific errors in the following cases:

  • Invalid or missing credentials (both Connection Id and API Key are empty)
  • Connection not found (when using Connection Id)
  • API authentication errors (401) - Invalid API key
  • API authorization errors (403) - Insufficient permissions
  • API rate limit errors (429)
  • API service errors (500, 503)

Usage Notes

  • You can use this node in two ways:
    1. With Connect node: More efficient for multiple operations
    2. With direct API key: Simpler for single operations
  • Credits are consumed by image generation, upscaling, and other operations
  • Different operations consume different amounts of credits
  • Check credits before starting expensive batch operations
  • Credit balance is updated in real-time after each operation
  • Useful for cost monitoring and budget management

Credit Consumption Guidelines

Typical credit costs (may vary based on Stability AI pricing):

  • Text-to-Image: 1-10 credits per image (depends on resolution and steps)
  • Image-to-Image: 1-10 credits per image
  • Inpainting (Masking): 1-10 credits per image
  • Upscaling (ESRGAN): 0.2-1 credits per upscale
  • Upscaling (SD x4): 1-5 credits per upscale
  • Higher resolution: More credits
  • More steps: More credits

Examples

Example 1: Check Credit Balance

Inputs:

  • Connection Id: (from Connect node)

Flow:

Connect → Get User Credit → Display balance

Output Example:

250.5

Use Case: Check available credits before starting operations


Example 2: Pre-flight Credit Check

Inputs:

  • Connection Id: (from Connect node)

Flow:

Connect
→ Get User Credit
→ If credits > 100:
→ Proceed with batch generation
→ Else:
→ Send low credit alert
→ Stop flow

Use Case: Ensure sufficient credits before expensive operations


Example 3: Using Direct API Key

Options:

  • API Key: (your credential)

Flow:

Get User Credit → Check balance

Use Case: Quick credit check without setting up Connect node


Example 4: RPA Use Case - Credit Monitoring

Flow:

Scheduled trigger (hourly)
→ Connect
→ Get User Credit
→ Store credit value with timestamp
→ If credits < threshold:
→ Send alert email to admin
→ "Low credits: {credits} remaining"
→ Disconnect

Use Case: Monitor credit usage and alert when running low


Example 5: RPA Use Case - Cost Tracking

Flow:

Connect
→ Get User Credit (initial balance)
→ Store as start_credits
→ Generate 100 images (batch operation)
→ Get User Credit (final balance)
→ Calculate cost: start_credits - final_credits
→ Log operation cost to database
→ Send cost report

Use Case: Track actual costs of automation operations


Example 6: RPA Use Case - Budget-Based Generation

Flow:

Connect
→ Get User Credit
→ Calculate max_images = credits / avg_cost_per_image
→ Generate images up to max_images
→ Get User Credit (check remaining)
→ Update budget report

Use Case: Generate as many images as budget allows


Example 7: RPA Use Case - Multi-Account Load Balancing

Flow:

Read list of API keys
→ For each API key:
→ Get User Credit
→ Store {key: credits}
→ Select API key with most credits
→ Use selected key for operations

Use Case: Distribute load across multiple accounts based on credit availability


Example 8: RPA Use Case - Daily Credit Report

Flow:

Scheduled trigger (daily at midnight)
→ Connect to each account
→ Get User Credit
→ Compare with yesterday's balance
→ Calculate daily consumption
→ Generate consumption report
→ Email to finance team

Use Case: Track daily credit consumption for billing purposes


Example 9: Error Recovery with Credit Check

Flow:

Try:
→ Generate images
Catch (insufficient credits error):
→ Get User Credit
→ Log remaining credits
→ Send "Insufficient credits" alert
→ Store failed batch for retry

Use Case: Handle credit exhaustion errors gracefully


Example 10: Dynamic Batch Sizing

Flow:

Connect
→ Get User Credit
→ Calculate safe batch size:
- If credits > 1000: batch_size = 100
- If credits > 500: batch_size = 50
- If credits > 100: batch_size = 10
- Else: batch_size = 1
→ Process images in calculated batch size

Use Case: Adjust operation scale based on available credits

Best Practices

  1. Pre-flight Checks:

    • Always check credits before expensive batch operations
    • Set minimum credit thresholds for operations
    • Implement credit-based decision logic
  2. Monitoring:

    • Regularly monitor credit balance
    • Set up alerts for low credit warnings
    • Track credit consumption patterns
  3. Cost Management:

    • Calculate operation costs before execution
    • Track actual vs. estimated costs
    • Implement budget limits in automation
  4. Error Handling:

    • Handle insufficient credit errors gracefully
    • Implement retry logic when credits are replenished
    • Log credit-related errors for analysis
  5. Efficiency:

    • Cache credit balance for short periods to reduce API calls
    • Check credits at appropriate intervals, not on every operation
    • Combine with other account operations when possible
  6. Budgeting:

    • Set credit budgets for different automation tasks
    • Track spending by project or department
    • Forecast credit needs based on historical usage

Tips for RPA Developers

  • Threshold Alerts: Set up automated alerts at multiple thresholds (e.g., 25%, 10%, 5% remaining)
  • Cost Estimation: Build cost estimation tools to predict credit usage
  • Budget Control: Implement hard stops when budget limits are reached
  • Usage Analytics: Track credit consumption by operation type, time, user
  • Batch Optimization: Adjust batch sizes dynamically based on credit availability
  • Fallback Accounts: Have backup accounts ready when primary runs low
  • Credit Tracking: Log credit balance before and after operations for accounting
  • Scheduled Checks: Implement scheduled credit monitoring for proactive management

Integration Examples

Example: Complete Cost Tracking Flow

Flow:

Connect
→ Get User Account (record user)
→ Get User Credit (start balance)
→ Store start_balance, timestamp, user_email

→ Perform operations:
- TextToImages (50 images)
- Upscale (25 images)

→ Get User Credit (end balance)
→ Calculate costs:
- total_cost = start_balance - end_balance
- avg_cost_per_image = total_cost / 50

→ Store to database:
- user_email
- operation_type
- quantity
- total_cost
- timestamp

→ Generate cost report
→ Disconnect

Benefits:

  • Complete cost visibility
  • Accurate operation cost tracking
  • Audit trail for billing

Example: Credit-Aware Batch Processing

Flow:

Read 1000 product descriptions from database

Connect
→ Get User Credit
→ estimated_cost_per_image = 2
→ max_affordable = floor(credits / estimated_cost_per_image)

→ If max_affordable >= 1000:
→ Process all 1000 products
→ Else:
→ Process only max_affordable products
→ Save remaining to retry queue
→ Send "Partial completion" notification

→ Get User Credit (verify remaining)
→ Disconnect

Benefits:

  • Prevents credit exhaustion
  • Graceful partial processing
  • Clear retry mechanism

Example: Multi-Stage Credit Management

Flow:

Stage 1: Planning
→ Get User Credit
→ Calculate operation budget
→ Determine feasible scope

Stage 2: Execution
→ Execute within budget
→ Monitor credits periodically

Stage 3: Reporting
→ Get User Credit (final)
→ Calculate actual costs
→ Compare to estimates
→ Generate variance report

Common Errors and Solutions

Error: "Failed to get user credit balance" (401)

  • Solution: API key is invalid or expired - verify API key in vault
  • Solution: Generate new API key from platform.stability.ai

Error: "Failed to get user credit balance" (403)

  • Solution: API key lacks necessary permissions
  • Solution: Check account status on Stability AI platform

Error: "Connection not found"

  • Solution: Ensure Connect node ran successfully before this node
  • Solution: Verify Connection Id is being passed correctly

Credit balance shows 0 but operations succeed:

  • Solution: Account may have different billing model
  • Solution: Check account type on Stability AI platform

Unexpected credit consumption:

  • Solution: Review operation parameters (resolution, steps affect cost)
  • Solution: Check for failed operations that still consumed credits
  • Solution: Review Stability AI pricing documentation

Credit Balance Interpretation

  • Positive Balance: Credits available for operations
  • Zero or Low Balance: Operations may fail or be limited
  • High Consumption Rate: May indicate:
    • High-resolution generation
    • Many diffusion steps
    • Large batch operations
    • Inefficient parameter settings
  • Connect - Establishes connection needed for this node
  • Get User Account - Gets account details (often used together)
  • Get Engines List - Gets available engines for planning costs
  • Disconnect - Cleans up connection after use
  • TextToImages, ImageToImages, Upscale, Masking - Nodes that consume credits

Monitoring Dashboard Example

Create a monitoring dashboard that displays:

  1. Current credit balance
  2. Daily consumption rate
  3. Estimated days until credits run out
  4. Top consuming operations
  5. Credit consumption trends
  6. Alerts and warnings

This can be built using Get User Credit node with scheduled triggers and data visualization tools.