digitalocean/dots
TypeScript
Captured source
source ↗digitalocean/dots
Description: Official DigitalOcean Typescript Client based on the DO OpenAPIv3 specification
Language: TypeScript
License: Apache-2.0
Stars: 6
Forks: 1
Open issues: 13
Created: 2025-04-07T18:26:24Z
Pushed: 2026-06-08T18:23:37Z
Default branch: main
Fork: no
Archived: no
README:
DoTs
DoTs is the official DigitalOcean Typescript Client based on the DO OpenAPIv3 specification.
> New in v1.11.0 — DoTs now ships first-class support for DigitalOcean Serverless Inference: streaming chat completions, image generation, and model listing. Jump to [AI & Inference](#ai--inference) for usage, or browse runnable scripts in [examples/inference/](./examples/inference).
Getting Started
Prerequisites
- NodeJS 20.10 or above
- TypeScript 5 or above
- A DigitalOcean account with an active subscription. Along with a DigitalOcean token with proper permissions to manage DigitalOcean resources.
"type": "module"in your package.json (for ES module support)
Installation
> The package is published on npmjs.com.
npm i @digitalocean/dots
Documentation
> Note: Comprehensive documentation quality is currently lacking and under development. The documentation is actively being improved and will be updated once fixed.
https://digitaloceandots.readthedocs.io/en/latest/
Basic Usage
> A quick guide to getting started with client
Authenticating
dots must be initialized with createDigitalOceanClient(). A DigitalOcean token is required. This token can be passed in via DigitalOceanApiKeyAuthenticationProvider(), an example below:
const authProvider = new DigitalOceanApiKeyAuthenticationProvider(token!); // Create request adapter using the fetch-based implementation const adapter = new FetchRequestAdapter(authProvider); // Create the API client const client = createDigitalOceanClient(adapter);
Managing DigitalOcean Resources
Find below a working example of creating a DigitalOcean volume via dots:
import { createDigitalOceanClient, DigitalOceanApiKeyAuthenticationProvider,
FetchRequestAdapter, Volumes_ext4 } from "@digitalocean/dots";
const token = process.env.DIGITALOCEAN_TOKEN;
if (!token) {
throw new Error("DIGITALOCEAN_TOKEN not set");
}
const authProvider = new DigitalOceanApiKeyAuthenticationProvider(token!);
// Create request adapter using the fetch-based implementation
const adapter = new FetchRequestAdapter(authProvider);
// Create the API client
const client = createDigitalOceanClient(adapter);
async function main(): Promise {
try {
const volumeReq: Volumes_ext4 = {
sizeGigabytes: 10,
name: `test-volume`,
description: "Block storage testing",
region: "nyc3",
filesystemType: "ext4",
};
const resp = await client.v2.volumes.post(volumeReq);
if (resp && resp.volume) {
const volume = resp.volume;
console.log(`Created volume ${volume.name} `);
} else {
throw new Error("Failed to create volume or volume is undefined");
}
console.log("Done!");
} catch (err) {
console.error(err);
}
}
main();Running the above code snippet with tsc && node index.js would output the following:
Created volume test-volume Done!
More working examples can be found in dots/examples.
AI & Inference
> Added in v1.11.0. Talk to DigitalOcean Serverless Inference directly from DoTs — streaming chat, image generation, model listing, and more.
Authentication
Inference APIs are gated by a separate credential from the v2 control-plane token. You must use one of the following:
- A DigitalOcean Personal Access Token (PAT) with _full access_ scope — read/write across all resources, including GenAI/Inference. Tokens scoped only to specific resource types will be rejected.
- A Model Access Key issued from the DigitalOcean Cloud console under *GenAI Platform → Model Access Keys*. These are the recommended credential for production workloads since they're scoped only to inference.
The credential is passed as apiKey to InferenceClient. The same DIGITALOCEAN_TOKEN env var used elsewhere in this README works here only if that PAT has full-access scope; otherwise use a Model Access Key.
import { InferenceClient } from "@digitalocean/dots";
const client = new InferenceClient({
apiKey: process.env.DIGITALOCEAN_TOKEN!, // full-access PAT or Model Access Key
});Streaming chat completions
import { InferenceClient } from "@digitalocean/dots";
const client = new InferenceClient({ apiKey: process.env.DIGITALOCEAN_TOKEN! });
const stream = await client.chat.completions.create({
model: "llama3.3-70b-instruct",
messages: [{ role: "user", content: "Write two short lines about DigitalOcean." }],
stream: true,
});
for await (const chunk of stream) {
process.stdout.write(chunk.choices?.[0]?.delta?.content ?? "");
}
process.stdout.write("\n");Callback-style streaming is also supported:
await client.chat.completions.create(
{ model: "llama3.3-70b-instruct", messages, stream: true },
{
onData: (chunk) => process.stdout.write(chunk.choices?.[0]?.delta?.content ?? ""),
onComplete: () => console.log("\n[done]"),
onError: (err) => console.error(err),
},
);Image generation
import { InferenceClient } from "@digitalocean/dots";
const client = new InferenceClient({ apiKey: process.env.DIGITALOCEAN_TOKEN! });
const result = await client.images.generate({
model: "stable-diffusion-3.5-large", // any image model from `client.models.list()`
prompt: "An isometric illustration of a serverless data center, soft pastel colors",
n: 1,
size: "1024x1024",
});
const img = result.data?.[0];
if (img?.url) {
console.log(img.url);
} else if (img?.b64_json) {
// Stable Diffusion returns base64 — decode and save to disk.
const fs = await import("node:fs");
fs.writeFileSync("generated-image.png", Buffer.from(img.b64_json, "base64"));
console.log("Saved generated-image.png");
}Listing available models
import { InferenceClient } from "@digitalocean/dots";
const client = new InferenceClient({ apiKey: process.env.DIGITALOCEAN_TOKEN! });
const models = await client.models.list();
for (const m of models.data ?? []) {
console.log(`${m.id}\t${m.owned_by ?? ""}`);
}Minimal, runnable versions of all three snippets live under [examples/inference/](./examples/inference):
-…
Excerpt shown — open the source for the full document.
Notability
notability 1.0/10Low-star repo, minimal traction.