> ## Documentation Index
> Fetch the complete documentation index at: https://ailabtools.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# SDKs

> Install official AILabTools SDKs or use direct HTTP to integrate AILabTools image APIs.

## Prerequisites

1. Create an API key in the [Developer Console](https://www.ailabtools.com/developer).
2. Store the key in an environment variable or secret manager.
3. Choose either an SDK integration or direct HTTP integration.

## Integration Options

| Integration                                                                    | Guidance                                                   |
| :----------------------------------------------------------------------------- | :--------------------------------------------------------- |
| [AILabTools Multi-language SDKs](https://github.com/ailabtools/ailabtools-sdk) | Use an official SDK for supported runtimes.                |
| [AILabTools PHP SDK](https://github.com/ailabtools/ailabtools-php)             | Use the Composer package for PHP applications.             |
| **Direct HTTP**                                                                | Call the API endpoints directly from your own HTTP client. |

<Info>
  SDKs wrap the same public HTTP APIs documented on this site. Direct HTTP and SDK integrations use the same API key and the same underlying endpoints.
</Info>

## Install

Select your runtime, then use the package manager already used by your project.

<Tip>
  Unversioned commands install the latest published release. Versioned snippets are pinning examples; check the linked registry before copying a fixed version into production.
</Tip>

<Tabs>
  <Tab title="Node.js">
    Requires Node.js 18 or later.

    The package is published on npm. npm, pnpm, Yarn, and Bun install the same `ailabtools` package.

    #### <Icon icon="npm" iconType="brands" /> npm: [`ailabtools`](https://www.npmjs.com/package/ailabtools)

    ```bash theme={null}
    npm install ailabtools
    ```

    #### <Icon icon="boxes-stacked" /> pnpm: [`ailabtools`](https://www.npmjs.com/package/ailabtools)

    ```bash theme={null}
    pnpm add ailabtools
    ```

    #### <Icon icon="yarn" iconType="brands" /> Yarn: [`ailabtools`](https://yarnpkg.com/package?name=ailabtools)

    ```bash theme={null}
    yarn add ailabtools
    ```

    #### <Icon icon="bolt" /> Bun: [`ailabtools`](https://www.npmjs.com/package/ailabtools)

    ```bash theme={null}
    bun add ailabtools
    ```

    <Warning>
      `bun add` only covers dependency installation. Validate your application before using Bun as the production runtime for the Node.js SDK.
    </Warning>
  </Tab>

  <Tab title="Python">
    Requires Python 3.8 or later. Install `ailabtools-sdk`, then import it as `ailabtools`.

    Use `pip` or `uv pip` for environment-level installs. Use `uv add` or `poetry add` for project dependencies.

    #### <Icon icon="python" iconType="brands" /> pip: [`ailabtools-sdk`](https://pypi.org/project/ailabtools-sdk/)

    ```bash theme={null}
    pip install ailabtools-sdk
    ```

    #### <Icon icon="terminal" /> uv environment: [`ailabtools-sdk`](https://pypi.org/project/ailabtools-sdk/)

    ```bash theme={null}
    uv pip install ailabtools-sdk
    ```

    #### <Icon icon="folder-tree" /> uv project: [`ailabtools-sdk`](https://pypi.org/project/ailabtools-sdk/)

    ```bash theme={null}
    uv add ailabtools-sdk
    ```

    #### <Icon icon="feather" /> Poetry: [`ailabtools-sdk`](https://pypi.org/project/ailabtools-sdk/)

    ```bash theme={null}
    poetry add ailabtools-sdk
    ```
  </Tab>

  <Tab title="Go">
    Use the module path shown on pkg.go.dev for the current Go package and exported type names.

    #### <Icon icon="code" /> go get: [`github.com/ailabtools/ailabtools-sdk/packages/go`](https://pkg.go.dev/github.com/ailabtools/ailabtools-sdk/packages/go)

    ```bash theme={null}
    go get github.com/ailabtools/ailabtools-sdk/packages/go
    ```
  </Tab>

  <Tab title="Dart / Flutter">
    Requires Dart SDK `>=3.0.0 <4.0.0`. This is a pure Dart package. Use `flutter pub` for Flutter apps or `dart pub` for Dart packages and CLIs.

    #### <Icon icon="mobile-screen-button" /> Flutter: [`ailabtools`](https://pub.dev/packages/ailabtools)

    ```bash theme={null}
    flutter pub add ailabtools
    ```

    #### <Icon icon="code" /> Dart: [`ailabtools`](https://pub.dev/packages/ailabtools)

    ```bash theme={null}
    dart pub add ailabtools
    ```
  </Tab>

  <Tab title="PHP">
    Requires PHP 8.1 or later and Composer.

    #### <Icon icon="php" iconType="brands" /> Composer: [`ailabtools/ailabtools`](https://packagist.org/packages/ailabtools/ailabtools)

    ```bash theme={null}
    composer require ailabtools/ailabtools
    ```

    Or add the package to `composer.json`:

    ```json theme={null}
    {
      "require": {
        "ailabtools/ailabtools": "^0.5.4"
      }
    }
    ```
  </Tab>

  <Tab title="Ruby">
    Requires Ruby 2.6 or later. Use Bundler for applications, or RubyGems for direct installation.

    #### <Icon icon="gem" /> Bundler: [`ailabtools`](https://rubygems.org/gems/ailabtools)

    ```ruby theme={null}
    gem "ailabtools", "~> 0.5.4"
    ```

    #### <Icon icon="gem" /> RubyGems: [`ailabtools`](https://rubygems.org/gems/ailabtools)

    ```bash theme={null}
    gem install ailabtools
    ```
  </Tab>

  <Tab title="Rust">
    Requires Rust 1.70 or later. Use Cargo to add the crate to your project.

    #### <Icon icon="rust" iconType="brands" /> Cargo: [`ailabtools`](https://docs.rs/crate/ailabtools/latest)

    ```bash theme={null}
    cargo add ailabtools
    ```

    Or add the crate to `Cargo.toml`:

    ```toml theme={null}
    [dependencies]
    ailabtools = "0.5.4"
    ```
  </Tab>

  <Tab title="Java">
    Requires Java 11 or later. Choose Maven or Gradle according to your build system.

    #### <Icon icon="java" iconType="brands" /> Maven: [`com.ailabtools:ailabtools-sdk`](https://central.sonatype.com/artifact/com.ailabtools/ailabtools-sdk)

    ```xml theme={null}
    <dependency>
      <groupId>com.ailabtools</groupId>
      <artifactId>ailabtools-sdk</artifactId>
      <version>0.5.4</version>
    </dependency>
    ```

    #### <Icon icon="diagram-project" /> Gradle: [`com.ailabtools:ailabtools-sdk`](https://central.sonatype.com/artifact/com.ailabtools/ailabtools-sdk)

    Groovy DSL:

    ```gradle theme={null}
    implementation "com.ailabtools:ailabtools-sdk:0.5.4"
    ```

    Kotlin DSL:

    ```kotlin theme={null}
    implementation("com.ailabtools:ailabtools-sdk:0.5.4")
    ```
  </Tab>

  <Tab title="Swift">
    Requires iOS 13.0, macOS 10.15, tvOS 13.0, or watchOS 6.0 or later. Use Swift Package Manager or CocoaPods according to your Apple platform project setup.

    #### <Icon icon="swift" iconType="brands" /> Swift Package Manager: [`ailabtools/ailabtools-sdk`](https://github.com/ailabtools/ailabtools-sdk)

    ```swift theme={null}
    .package(
      url: "https://github.com/ailabtools/ailabtools-sdk.git",
      from: "0.5.4"
    )
    ```

    #### <Icon icon="seedling" /> CocoaPods: [`AILabTools`](https://cocoapods.org/pods/AILabTools)

    ```ruby theme={null}
    pod 'AILabTools', '~> 0.5.4'
    ```
  </Tab>
</Tabs>

## Authentication

All SDKs authenticate with an AILabTools API key. SDK examples use `AILAB_API_KEY` as the environment variable name:

```bash theme={null}
export AILAB_API_KEY="your_api_key_here"
```

Pass this value to the SDK client in your application code.

<Info>
  `AILAB_API_KEY` is an SDK example convention, not an HTTP header name. Direct HTTP calls use the `ailabapi-api-key` request header shown in each API reference page.
</Info>

<Warning>
  For public browser, desktop, or mobile applications, do not ship your AILabTools API key with the client. Call AILabTools from your backend, or issue requests through a trusted service that keeps the API key private.
</Warning>

## Implementation Notes

| Topic          | Guidance                                                                                                                                                         |
| :------------- | :--------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Request fields | SDKs may expose language-native names, such as `returnForm` for the HTTP field `return_form`. Use the SDK docs for code and the API reference for field meaning. |
| File uploads   | Use SDK-supported file helpers such as file paths, bytes, buffers, streams, or language-specific file wrappers.                                                  |
| Async tasks    | If a response contains `task_id`, use the SDK polling helper where available or call [Querying Async Task Results](/docs/ai-common/async-task-results/api).      |
| Result URLs    | Result image URLs may be temporary. Download and store files promptly if your application needs long-term access.                                                |
| Errors         | Log `request_id` and `log_id` when handling API errors. These IDs help the support team locate failed requests.                                                  |

## Related Resources

* [Get API Key](/docs/get-api-key)
* [OpenAPI JSON](/docs/openapi.json)
* [Response Description](/docs/response-description)
* [File Storage Policy](/docs/file-storage-policy)
* [Billing Introduction](/docs/billing-introduction)
