Ace Data Cloud SDK Overview

Ace Data Cloud provides official client SDKs for TypeScript / Python / Go, wrapping capabilities such as chat completions, images, video, music, search, and x402 on api.acedata.cloud into strongly typed methods, saving you the work of writing HTTP, SSE, task polling, error handling, and retry backoff by hand.

This chapter follows the actual integration sequence: first obtain an API Token in the console, then select a language and read the corresponding section, and finally explore advanced usage for task polling, streaming responses, and X402 on-chain payments.

Repositories and Packages

Three-Language Capability Matrix

Capability TypeScript Python Go
chat.completions.create (non-streaming) ✅ ✅ ✅
chat.completions.create (SSE streaming) ✅ ✅ ✅
images.generate (Midjourney / Flux / NanoBanana / Seedream) ✅ ✅ 🚧 (alpha)
videos.generate (Sora / Veo / Luma / Kling / Hailuo / Wan) ✅ ✅ 🚧 (alpha)
audios.generate (Suno / Producer / Fish) ✅ ✅ 🚧 (alpha)
search.google (Serp) ✅ ✅ 🚧 (alpha)
TaskHandle asynchronous polling ✅ (milliseconds) ✅ (seconds) 🚧
Asynchronous client ✅ (Promise) ✅ (AsyncAceDataCloud) ✅ (context.Context)
Automatic retries + exponential backoff ✅ ✅ ✅
Typed exceptions (AuthenticationError / RateLimitError …) ✅ ✅ ✅
X402 paymentHandler hook (on-chain payment without a token) ✅ ✅ ❌ (planned)

The Go SDK's multimedia resources and task polling are currently in alpha (pseudo-version v0.0.0-20260505072132-4a3d921f9bb4), and chat.completions is the stable capability. For multimedia scenarios, prefer TypeScript or Python.

When to Use SDK / MCP / Native HTTP / X402

Scenario Recommended Approach
Backend services, CLIs, automation scripts, Agent frameworks SDK (this chapter)
Calls from MCP clients such as Claude Desktop / Cursor / Cline MCP Servers
One-time curl verification, debugging, embedded environments that only support HTTP Native HTTP (each service's Quick Start)
Avoiding API Token creation and paying USDC on-chain per call X402 Integration Guide

SDK and X402 are not mutually exclusive: the SDK supports both the “token path” and the “paymentHandler path.” See SDK + X402 Payment Hook for details.

Obtain an API Token

Log in to the application list, open the General Application, and click the copy button to the right of API KEY. The copied value is represented as {token} below. The SDK automatically adds the HTTP authentication header; enter only the raw Key in the environment variable or constructor parameter.

When you need to set API scope, limits, or an expiration date by project, see Create API Credentials.

Unified Environment Variable

The SDKs for all three languages automatically read the same environment variable, ACEDATACLOUD_API_TOKEN. We recommend using export in your shell so the SDK can pick it up automatically:

export ACEDATACLOUD_API_TOKEN={token}
# 可选:默认 https://api.acedata.cloud
# export ACEDATACLOUD_BASE_URL=https://api.acedata.cloud

You can also pass it explicitly when constructing the client. The corresponding parameter names for the three languages are:

  • TypeScript: new AceDataCloud({ apiToken: '{token}' })
  • Python: AceDataCloud(api_token="{token}")
  • Go: adc.NewClient(adc.WithAPIToken("{token}"))

Note: The convention in the AceDataCloud project repository is ACEDATACLOUD_API_KEY (in .env / CI), but the three SDKs themselves only recognize ACEDATACLOUD_API_TOKEN. If your environment only has ACEDATACLOUD_API_KEY, pass it explicitly during construction.

Three 30-Second Getting Started Examples

The following three code snippets do the same thing: call gpt-4o-mini and have it reply with only ADC_*_OK. Each includes actual run results, which you can reproduce with your own token.

TypeScript

import { AceDataCloud } from '@acedatacloud/sdk';

const client = new AceDataCloud();

const t0 = Date.now();
const res = await client.openai.chat.completions.create({
  model: 'gpt-4o-mini',
  messages: [{ role: 'user', content: 'Reply with exactly: ADC_TS_SDK_OK' }],
  max_tokens: 20,
  temperature: 0
});
console.log('elapsed_ms', Date.now() - t0);
console.log('id', res.id);
console.log('model', res.model);
console.log('content', res.choices[0].message.content);
console.log('usage', JSON.stringify(res.usage));

The SDK currently declares the response as Record<string, unknown>. At runtime, it is a plain JSON object whose fields can be accessed directly. If you encounter type errors in a strict TS project, you can temporarily use as any, or refer to SDK Task Polling and Streaming Responses to create a custom typed wrapper.

Program output:

elapsed_ms 2543
id chatcmpl-DldCcLvkTFaioST8e6SjOl0wJScQA
model gpt-4o-mini
content ADC_TS_SDK_OK
usage {"prompt_tokens":16,"completion_tokens":6,"total_tokens":22}

Python

import time, json
from acedatacloud import AceDataCloud

client = AceDataCloud()

t0 = time.time()
res = client.openai.chat.completions.create(
    model="gpt-4o-mini",
    messages=[{"role": "user", "content": "Reply with exactly: ADC_PY_SDK_OK"}],
    max_tokens=20,
    temperature=0,
)
print("elapsed_ms", int((time.time() - t0) * 1000))
print("id", res["id"])
print("model", res["model"])
print("content", res["choices"][0]["message"]["content"])
print("usage", json.dumps({k: v for k, v in res["usage"].items()
                            if k in ("prompt_tokens","completion_tokens","total_tokens")}))

The Python SDK currently returns a dict, so use res["id"] instead of res.id. This differs from openai-python and requires attention when migrating.

Program output:

elapsed_ms 2963
id chatcmpl-DldFdnIlhSUXINpupgsUmZL78MnBu
model gpt-4o-mini
content ADC_PY_SDK_OK
usage {"prompt_tokens": 17, "completion_tokens": 7, "total_tokens": 24}

Go

package main

import (
    "context"
    "fmt"
    "time"

    adc "github.com/AceDataCloud/SDK/go"
)

func main() {
    client, err := adc.NewClient()
    if err != nil {
        panic(err)
    }
    ctx, cancel := context.WithTimeout(context.Background(), 60*time.Second)
    defer cancel()

    t0 := time.Now()
    res, err := client.OpenAI().Chat().Completions().Create(ctx, adc.ChatCompletionRequest{
        Model:     "gpt-4o-mini",
        Messages:  []map[string]any{{"role": "user", "content": "Reply with exactly: ADC_GO_SDK_OK"}},
        MaxTokens: 20,
    })
    if err != nil {
        panic(err)
    }
    fmt.Println("elapsed_ms", time.Since(t0).Milliseconds())
    fmt.Println("id", res["id"])
    fmt.Println("model", res["model"])
    choices := res["choices"].([]any)
    msg := choices[0].(map[string]any)["message"].(map[string]any)
    fmt.Println("content", msg["content"])
    usage := res["usage"].(map[string]any)
    fmt.Printf("usage prompt=%v completion=%v total=%v\n",
        usage["prompt_tokens"], usage["completion_tokens"], usage["total_tokens"])
}

Go SDK responses are uniformly map[string]any, with no strongly typed structs, so you need to perform type assertions yourself. All resource accessors use method chaining: client.OpenAI().Chat().Completions().Create(...).

Program output:

elapsed_ms 6436
id chatcmpl-89DHExvFvBc4ciIPfolZYUOy7ivxv
model gpt-4o-mini
content ADC_GO_SDK_OK
usage prompt=16 completion=5 total=21

The responses in all three languages include id, elapsed_ms, and usage, which can be used to identify requests and view elapsed time and usage. The content field is the model's actual output; the fixed identifier ADC_*_OK is used to prove that the response has not been tampered with by the SDK.

  1. TypeScript SDK Integration Guide — The first piece of runnable code after npm install.
  2. Python SDK Integration Guide — Three usage patterns: synchronous, asynchronous, and streaming.
  3. Go SDK Integration Guide — Go-style context.Context and channel streaming.
  4. SDK Task Polling and Streaming Responses — TaskHandle unit differences, SSE implementation details, and retry backoff.
  5. SDK + X402 Payment Hooks — No token, with on-chain settlement per call.

How to Check Your Remaining Balance

You can check the remaining balance of your current account through the Ace Data Cloud Console - Application List.

You can view all usage history and charge details through the Ace Data Cloud Console - Usage History.

Learn More