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 as strongly typed methods, eliminating the need to manually implement HTTP, SSE, task polling, error handling, and retry backoff.

This chapter is organized in the order of an actual integration: first obtain an API Token from the console, then choose a language and read the corresponding section, and finally explore advanced usage of 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 (token-free on-chain payment) ✅ ✅ ❌ (planned)

The Go SDK's multimedia resources and task polling are currently in the alpha stage (pseudo-version v0.0.0-20260505072132-4a3d921f9bb4), while chat.completions is stable. 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 HTTP-only environments Native HTTP (each service's Quick Start)
Pay USDC on-chain per call without creating an API Token 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

Sign in to the application list and open Universal Application. If this is your first time using it, click Initialize Universal Application first. Copy the value to the right of API KEY, represented below as {token}. The SDK automatically adds the HTTP authentication header, so provide only the raw Key in the environment variable or constructor parameter.

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

Shared 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 parameters 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 these three SDKs themselves recognize only ACEDATACLOUD_API_TOKEN. If your environment contains only 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 an ordinary 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"] rather than 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 chains: 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 check elapsed time and usage. The content field is the model's actual output, and the fixed identifier ADC_*_OK is used to demonstrate that the response has not been altered by the SDK.

  1. TypeScript SDK Integration Guide — The first piece of code you can run after npm install.
  2. Python SDK Integration Guide — Three usage modes: 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 Quota

Through the Ace Data Cloud Console - Application List, you can check your account's remaining quota.

Through the Ace Data Cloud Console - Usage History, you can view all usage history and billing details.

Learn More