How to Add Custom AI Providers to AutoGPT Platform: A Complete SDK Guide

You add custom AI providers to AutoGPT Platform by registering the provider name in the ProviderName enum, creating a _config.py file in your block directory, and using the ProviderBuilder SDK to declare credentials, cost types, and client logic.

The AutoGPT Platform supports custom AI providers through a flexible Provider-Builder SDK that allows developers to integrate any external LLM, image generation, or voice service without modifying core platform code. Whether you need to connect a proprietary model or a niche third-party API, the platform's architecture enables seamless registration of new providers using a declarative configuration pattern. This guide walks you through the exact steps to add custom AI providers to AutoGPT Platform using the official SDK components.

Understanding the Provider-Builder SDK Architecture

The integration relies on three core components that work together to register and manage custom AI providers across the AutoGPT Platform.

ProviderName Enum

The ProviderName enum in autogpt_platform/backend/backend/integrations/providers.py serves as the single source of truth for every supported provider. Adding your custom provider here makes the name discoverable throughout the backend, frontend UI dropdowns, and API validation layers.

ProviderBuilder Class

Located in autogpt_platform/backend/backend/sdk/builder.py, the ProviderBuilder class provides a fluent API for registering providers with the global AutoRegistry. It handles credential fields, optional OAuth flows, error handling, cost-type categorization, and custom client factory injection.

Block-Level Configuration

Each block that consumes a custom AI provider creates a _config.py file in its directory. This file instantiates the ProviderBuilder, configures provider-specific settings, and exports a typed configuration object that the block implementation imports and uses at runtime.

Step-by-Step Guide to Adding a Custom AI Provider

Follow these exact steps to integrate a new AI service into the AutoGPT Platform.

Step 1: Register the Provider Name in the Global Enum

First, add your provider identifier to the central enum so the platform recognizes it.


# File: autogpt_platform/backend/backend/integrations/providers.py

from enum import StrEnum, auto

class ProviderName(StrEnum):
    # Existing providers

    OPENAI = auto()
    ANTHROPIC = auto()
    # Add your custom provider below

    MY_PROVIDER = "my_provider"

Step 2: Create the Block Configuration File

Create a new block directory and add a _config.py file to hold the provider configuration.

mkdir -p autogpt_platform/backend/backend/blocks/my_provider
touch autogpt_platform/backend/backend/blocks/my_provider/_config.py

Step 3: Configure Credentials and Cost Settings

Use the ProviderBuilder SDK to declare required credentials and metadata.


# File: autogpt_platform/backend/backend/blocks/my_provider/_config.py

from backend.sdk import BlockCostType, ProviderBuilder

# Configure the provider using the fluent builder API

my_provider = (
    ProviderBuilder("my_provider")
        .with_api_key(env_var_name="MY_PROVIDER_API_KEY", title="My Provider API Key")
        .with_cost_type(BlockCostType.LLM)  # Categorizes billing behavior

        .build()
)

Step 4: Implement the Block Logic

Import the configured provider object into your block implementation and use its client.


# File: autogpt_platform/backend/backend/blocks/my_provider/block.py

from ._config import my_provider

async def generate_completion(prompt: str) -> str:
    # Access the configured client or credentials

    client = my_provider.client
    
    # Call the provider's API

    response = await client.completions.create(
        prompt=prompt,
        max_tokens=512
    )
    
    return response.choices[0].text.strip()

Step 5: Test Your Integration

Run the platform's test suite to verify the provider registration and block functionality.

cd autogpt_platform/backend
poetry run test

Advanced Configuration Options for Custom AI Providers

The ProviderBuilder SDK supports advanced authentication patterns and custom client implementations for complex integrations.

Adding OAuth Authentication

For providers requiring OAuth 2.0 flows, chain the .with_oauth() method before building.

my_provider = (
    ProviderBuilder("my_provider")
        .with_oauth(
            client_id_env="MY_PROVIDER_CLIENT_ID",
            client_secret_env="MY_PROVIDER_CLIENT_SECRET",
            authorize_url="https://myprovider.com/oauth/authorize",
            token_url="https://myprovider.com/oauth/token",
            scopes=["read", "write"],
        )
        .build()
)

This configuration automatically renders the OAuth flow UI in the frontend and securely stores refresh tokens.

Implementing Custom Client Factories

When you need to use a provider's native SDK instead of generic HTTP calls, provide a custom factory function.

def my_client_factory(settings):
    import myprovider_sdk
    return myprovider_sdk.Client(api_key=settings.api_key)

my_provider = (
    ProviderBuilder("my_provider")
        .with_api_client(factory=my_client_factory)
        .build()
)

The factory receives the provider's settings (including resolved credentials) and returns an initialized client that the block can access via my_provider.client.

Key Files and Their Roles in AutoGPT Platform Provider Integration

Understanding the file structure helps navigate the codebase when adding custom AI providers to AutoGPT Platform.

Path Purpose
autogpt_platform/backend/backend/integrations/providers.py Central ProviderName enum – the single source of truth for all providers.
autogpt_platform/backend/backend/sdk/builder.py ProviderBuilder class – fluent API to register credentials, OAuth, cost type, and client factories.
autogpt_platform/backend/backend/sdk/__init__.py Exports ProviderBuilder and BlockCostType for block-level imports.
autogpt_platform/backend/backend/blocks/<your-block>/_config.py Block-specific provider configuration using the SDK.
autogpt_platform/backend/backend/blocks/<your-block>/block.py Block implementation that imports and uses the configured provider.
docs/platform/block-sdk-guide.md Official documentation for the ProviderBuilder SDK pattern.
docs/platform/new_blocks.md Overview of block creation and provider integration patterns.

Summary

  • Register the provider name in autogpt_platform/backend/backend/integrations/providers.py by adding an entry to the ProviderName enum.
  • Create a _config.py file in your block directory and use ProviderBuilder from backend.sdk to declare credentials, cost types, and optional OAuth or custom clients.
  • Import the configured provider in your block implementation to access the typed client or credentials at runtime.
  • Test the integration using poetry run test to ensure the provider is correctly registered and the block functions properly.

Frequently Asked Questions

Do I need to modify core platform code to add a custom AI provider?

No. The Provider-Builder SDK is designed for extension without core modifications. You only add your provider name to the ProviderName enum in providers.py, then configure it within your specific block directory using _config.py. The platform's AutoRegistry automatically discovers and loads your configuration at runtime.

Can I use OAuth 2.0 authentication instead of API keys for my custom provider?

Yes. The ProviderBuilder supports OAuth flows through the .with_oauth() method. You provide the authorization URL, token URL, required scopes, and environment variable names for the client ID and secret. The AutoGPT Platform frontend automatically renders the OAuth UI and securely manages token refresh.

How does the platform handle billing and cost tracking for custom providers?

You specify the cost behavior using .with_cost_type() when building the provider. The BlockCostType enum includes categories like LLM, IMAGE, and VOICE that inform the platform's billing system how to calculate and track usage costs for your custom AI provider.

What if my AI provider requires a native SDK instead of REST API calls?

Use the .with_api_client() method to provide a custom factory function. This factory receives the provider settings (including resolved credentials) and returns an initialized client instance. Your block can then access this client via my_provider.client to use the native SDK methods directly.

Have a question about this repo?

These articles cover the highlights, but your codebase questions are specific. Give your agent direct access to the source. Share this with your agent to get started:

Share the following with your agent to get started:
curl -s "https://instagit.com/install.md"

Works with
Claude Codex Cursor VS Code OpenClaw Any MCP Client

Maintain an open-source project? Get it listed too →