github.com/AceDataCloud/SDK/go is the official Go SDK for Ace Data Cloud, encapsulating chat completions / images / video / music / search on api.acedata.cloud into a method chain style of client.OpenAI().Chat().Completions().Create(...), featuring SSE streaming (based on channels), automatic retry backoff, and typed errors.
The style aligns with context.Context + functional options, suitable for integration into any Go backend service or CLI.
Source code and documentation:
- SDK repository: https://github.com/AceDataCloud/SDK
- Go module: https://pkg.go.dev/github.com/AceDataCloud/SDK/go
Installation
- Currently, there is no semver tag, and
go getpulls the commit pseudo-versionv0.0.0-<timestamp>-<sha>; this version will be locked ingo.sum, allowing team members to pull the same code and get completely consistent dependencies. - The Go SDK currently focuses on
chat.completions(synchronous + streaming) as the main stable path, while multimedia resources (images/video/audio) andTaskHandlepolling are in the alpha stage. For scenarios requiring these capabilities, please prioritize the TypeScript SDK or Python SDK.
Prepare API Token
Refer to SDK Overview - Apply for API Token to obtain the token, thenexport it in the shell:
WithAPIToken(...) option; the Go SDK will not automatically read environment variables, requiring the business code to use os.Getenv, making it more controllable in multi-account or self-testing scenarios.
Example 1: chat.completions (non-streaming)
idis the OpenAI compatible response ID, which can be found in the console usage history.content ADC_GO_SDK_OKis the actual output from the model, proving that the SDK did not alter the response.- Most of the 6.4 seconds were spent on the initial TLS handshake + model generation; after reusing the client instance, the latency is consistent with TS / Python (about 2~3 seconds).
- The response is uniformly
map[string]any, requiring manual type assertions; this is a design trade-off of the current Go SDK—avoiding the introduction of generic structs to prevent strong dependencies on a single response schema for multi-model routing.
Example 2: chat.completions (SSE streaming)
CreateStream returns two channels: <-chan map[string]any is the parsed SSE chunk frame by frame, and <-chan error will only have readable elements after the stream ends (either normally or with an error).
- The first frame took 1633 ms, and it took 1816 ms for all 13 chunks to arrive—only 183 ms for the remaining 12 frames.
range chunkswill naturally exit the loop when the stream ends; theerrschannel will yield at most one element, and usingokchecks allows for error handling.- The advantage of this channel style is that it can be directly used with
selectin conjunction withcontext.Contextfor timeout/cancellation without additional wrapping.
Example 3: Typed Error Handling
adc.APIError covers 401 / 403 / 404 / 422 / 429 / 5xx, and business code can use errors.As to access structured fields. The HTTP status code, server code, and message are kept as is. Network layer errors (DNS failures, connection refusals, etc.) will follow standard Go errors like context.DeadlineExceeded, net.OpError, etc., and will not be swallowed.
Configuration Options (functional options)
NewClient returns (*Client, error): when the token is empty and WithPaymentHandler (X402) is not provided, it will immediately report an error, making it easier to identify configuration issues during service startup.
Advanced: Reusing Client
The Go SDK internally uses a*http.Client + http.Transport, which comes with a connection pool and HTTP/2 reuse. It is recommended to create only one *adc.Client during the process lifecycle and then share it across goroutines— all methods are concurrency safe.
Limitations and Roadmap
Currently stable / recommended for production use:- ✅
client.OpenAI().Chat().Completions().Createsynchronous non-streaming - ✅
client.OpenAI().Chat().Completions().CreateStreamSSE streaming - ✅
errors.As+APIErrorerror handling - ✅ Automatic retries + exponential backoff
- 🚧
client.Images()/client.Video()/client.Audio()— interfaces are evolving, it is recommended to use HTTP directly for now - 🚧
TaskHandleasynchronous polling — not yet exposed to the Go SDK surface - 🚧
WithPaymentHandler(X402 on-chain payment) — planned, currently X402 only supports TypeScript and Python

