Skip to content

DigitalOcean.GenAI reference

Source: packages/digitalocean/src/GenAI/Agent.ts

A DigitalOcean GenAI Platform agent: a hosted model with your instructions and optional knowledge bases behind a private chat endpoint. Call it with an AgentApiKey and the InvokeAgent binding. The model, instructions, knowledge bases and tuning update in place; projectId and region replace the agent.

const project = yield* DigitalOcean.Project("support", {});
const docs = yield* DigitalOcean.GenAI.KnowledgeBase("docs", {
projectId: project.projectId,
embeddingModel: "GTE Large EN v1.5",
sources: [{ webCrawler: { baseUrl: "https://docs.example.com" } }],
});
const agent = yield* DigitalOcean.GenAI.Agent("support", {
projectId: project.projectId,
model: "Ministral 3 14B",
instruction: "Answer questions about Example Corp. using the docs.",
knowledgeBaseIds: [docs.knowledgeBaseId],
});

Source: packages/digitalocean/src/GenAI/AgentApiKey.ts

A key that authorizes calls to one GenAI agent’s endpoint. DigitalOcean returns the secret only at create, so Alchemy keeps it in state as a Redacted value. Pass it to InvokeAgent, or to any OpenAI-compatible client as the API key.

const key = yield* DigitalOcean.GenAI.AgentApiKey("support-key", {
agentId: agent.agentId,
});

Source: packages/digitalocean/src/GenAI/CustomModel.ts

An open-weight model imported into your team, from a Hugging Face repository or a Spaces bucket, to serve with Dedicated Inference. Deploy waits until the import finishes.

From Hugging Face

const model = yield* DigitalOcean.GenAI.CustomModel("Qwen", {
source: { huggingFace: "Qwen/Qwen2.5-0.5B-Instruct" },
});

A gated model, with your Hugging Face token

const token = yield* Config.Redacted("HF_TOKEN");
const model = yield* DigitalOcean.GenAI.CustomModel("Llama", {
source: { huggingFace: "meta-llama/Llama-3.2-1B-Instruct", token },
});

From a Spaces bucket

const model = yield* DigitalOcean.GenAI.CustomModel("FineTuned", {
source: { bucket: "models", region: "nyc3", prefix: "my-model/" },
});

Source: packages/digitalocean/src/GenAI/InvokeAgent.ts

Calls a GenAI agent’s chat endpoint from a runtime. Binding it mints an AgentApiKey for the host, because DigitalOcean signs no workload identity a runtime could present instead; the key travels to the host as a secret.

export default class Api extends DigitalOcean.App<Api>()(
"Api",
{ main: import.meta.url },
Effect.gen(function* () {
const support = yield* DigitalOcean.GenAI.InvokeAgent(SupportAgent);
return {
fetch: Effect.gen(function* () {
const answer = yield* support.ask("How do I reset my password?");
return HttpServerResponse.text(answer);
}).pipe(Effect.orDie),
};
}).pipe(Effect.provide(DigitalOcean.GenAI.InvokeAgentHttp)),
) {}

Source: packages/digitalocean/src/GenAI/InvokeAgentHttp.ts Kind: Layer · Provides: DigitalOcean.GenAI.InvokeAgent

InvokeAgent over the agent’s OpenAI-compatible chat endpoint, with an AgentApiKey minted for the host.

Source: packages/digitalocean/src/GenAI/KnowledgeBase.ts

A DigitalOcean GenAI knowledge base: content from Spaces buckets or crawled websites, embedded and indexed in an OpenSearch database, that agents retrieve from. Attach it to an Agent with knowledgeBaseIds.

Without databaseId, DigitalOcean provisions an OpenSearch cluster for the knowledge base, billed while it exists; Alchemy destroys that cluster when it destroys the knowledge base.

Index a documentation site

const docs = yield* DigitalOcean.GenAI.KnowledgeBase("docs", {
projectId: project.projectId,
embeddingModel: "GTE Large EN v1.5",
sources: [
{ webCrawler: { baseUrl: "https://docs.example.com", crawlingOption: "PATH" } },
],
});

Index the files in a Spaces bucket

const files = yield* DigitalOcean.Spaces.Bucket("files", { region: "nyc3" });
const kb = yield* DigitalOcean.GenAI.KnowledgeBase("files", {
projectId: project.projectId,
embeddingModel: "GTE Large EN v1.5",
sources: [{ spaces: { bucketName: files.bucketName, region: "nyc3" } }],
});

Source: packages/digitalocean/src/GenAI/ModelRouter.ts

A model router: picks a model per request by task, with fallbacks. Every field updates in place.

yield* DigitalOcean.GenAI.ModelRouter("chat", {
description: "Chat with a cheap fallback",
fallbackModels: ["mistral-3-14B"],
});

Source: packages/digitalocean/src/GenAI/ProviderKey.ts

Your own OpenAI or Anthropic API key, registered with the GenAI Platform so agents can run on that provider’s models, billed to your provider account. DigitalOcean validates the key when it is added.

const apiKey = yield* Config.Redacted("ANTHROPIC_API_KEY");
yield* DigitalOcean.GenAI.ProviderKey("anthropic", { provider: "anthropic", apiKey });

Source: packages/digitalocean/src/GenAI/Workspace.ts

A GenAI workspace: a group of agents that share access and evaluations. Agents listed in agentIds are moved into it.

yield* DigitalOcean.GenAI.Workspace("support", {
description: "Customer support agents",
agentIds: [triage.agentId, billing.agentId],
});