Skip to main content

Requirements

The Autumn Python SDK requires Python 3.10 or higher.

Installation

You can install the Autumn Python SDK using your preferred Python package manager:
The SDK uses modern Python tooling and is optimized for use with uv, a fast Python package installer and resolver.

Getting Your API Key

  1. Log in to your Autumn dashboard
  2. Navigate to Settings > API Keys
  3. Create a new secret key or copy an existing one
  4. Store it securely (we recommend using environment variables)
Never commit your secret key to version control. Always use environment variables or a secure secret management system.

Basic Setup

Create a new Python file and initialize the SDK:

Environment Variables

Create a .env file in your project root:
.env
Then load it in your application:

Configuration Options

The SDK supports several configuration options:

Configuration Parameters

string
required
Your Autumn API secret key. You can also pass a callable that returns the key for dynamic authentication.
string
API version to use. Defaults to the latest stable version (2.1).
string
Override the default API server URL. Useful for testing or using a proxy.
int
Request timeout in milliseconds. Applied to all operations unless overridden per-request.
RetryConfig
Custom retry configuration for failed requests. See Retries below.
HttpClient
Custom httpx client instance for synchronous operations.
AsyncHttpClient
Custom httpx async client instance for asynchronous operations.

Retry Configuration

The SDK automatically retries failed requests with exponential backoff. You can customize this behavior:

Resource Management

The SDK implements proper resource management using Python context managers:
Always use context managers (with statement) to ensure proper cleanup of HTTP connections, especially in long-running applications.

IDE Support

The SDK includes full type hints and works great with modern IDEs:

PyCharm

For enhanced Pydantic integration in PyCharm, install the Pydantic plugin:

VS Code

VS Code provides excellent autocomplete and type checking out of the box. For the best experience:
  1. Install the Python extension
  2. Enable type checking in your settings.json:

Testing Your Installation

Verify your installation with this simple test:
test.py
Run the test:

Debugging

Enable debug logging to troubleshoot issues:

Next Steps

Usage Guide

Learn how to use the SDK for common billing and usage tracking tasks

API Reference

Explore the complete API reference